Przeglądaj źródła

ctkWorkflowWidget - Use Q_PROPERTY and Q_INVOKABLE to expose method to python

Jean-Christophe Fillion-Robin 14 lat temu
rodzic
commit
f2b4062265
2 zmienionych plików z 15 dodań i 12 usunięć
  1. 11 8
      Libs/Core/ctkWorkflow.h
  2. 4 4
      Libs/Widgets/ctkWorkflowWidget.h

+ 11 - 8
Libs/Core/ctkWorkflow.h

@@ -38,6 +38,8 @@ class QAbstractState;
 class CTK_CORE_EXPORT ctkWorkflow : public QObject
 {
   Q_OBJECT
+  Q_ENUMS(TransitionDirectionality)
+  Q_PROPERTY(bool isRunning READ isRunning DESIGNABLE false)
 
 public:
 
@@ -82,10 +84,10 @@ public:
   /// To add a single step, \a destination can be set to 0.
   ///
   /// Returns true/false indicating whether the method was successful.
-  virtual bool addTransition(ctkWorkflowStep* origin, ctkWorkflowStep* destination,
-                             const QString& branchId = QString(),
-                             const ctkWorkflow::TransitionDirectionality directionality
-                               = ctkWorkflow::Bidirectional);
+  Q_INVOKABLE virtual bool addTransition(ctkWorkflowStep* origin, ctkWorkflowStep* destination,
+                                         const QString& branchId = QString(),
+                                         const ctkWorkflow::TransitionDirectionality directionality
+                                         = ctkWorkflow::Bidirectional);
 
   /// \brief Determine whether a transition has already been added
   /// <ul>
@@ -96,9 +98,10 @@ public:
   /// previously added with the same origin and branch id (for forward transitions) or
   /// with the same destination and branch id (for backward transitions)</li>
   /// </ul>
-  bool hasTransition(ctkWorkflowStep* origin, ctkWorkflowStep* destination,
-                     const QString& branchId = QString(),
-                     const ctkWorkflow::TransitionDirectionality directionality = ctkWorkflow::Bidirectional);
+  Q_INVOKABLE bool hasTransition(ctkWorkflowStep* origin, ctkWorkflowStep* destination,
+                                 const QString& branchId = QString(),
+                                 const ctkWorkflow::TransitionDirectionality directionality
+                                 = ctkWorkflow::Bidirectional);
 
   /// \brief Set/get the initial step.
   ///
@@ -114,7 +117,7 @@ public:
   ctkWorkflowStep* currentStep()const;
 
   /// Check to see if there is a step with a given id in the workflow.
-  bool hasStep(const QString& id)const;
+  Q_INVOKABLE bool hasStep(const QString& id)const;
 
   /// Returns whether or not we can go forward: i.e. there exists a step that directly follows the
   /// given step.

+ 4 - 4
Libs/Widgets/ctkWorkflowWidget.h

@@ -43,7 +43,7 @@ class ctkWorkflowWidgetPrivate;
 class CTK_WIDGETS_EXPORT ctkWorkflowWidget : public QWidget
 {
   Q_OBJECT
-
+  Q_PROPERTY(bool showButtonBoxWidget READ showButtonBoxWidget WRITE setShowButtonBoxWidget)
 public:
 
   typedef QWidget Superclass;
@@ -51,8 +51,8 @@ public:
   virtual ~ctkWorkflowWidget();
 
   /// Set/get the workflow associated with this widget.
-  virtual ctkWorkflow* workflow()const;
-  virtual void setWorkflow(ctkWorkflow* newWorkflow);
+  Q_INVOKABLE virtual ctkWorkflow* workflow()const;
+  Q_INVOKABLE virtual void setWorkflow(ctkWorkflow* newWorkflow);
 
   /// Get the widget constaining the title, subtitle, pre-text, post-text, error-text and client area
   /// layout.
@@ -63,7 +63,7 @@ public:
   void setShowButtonBoxWidget(bool newShowButtonBoxWidget);
 
   /// Get the widget with the 'next', 'back' and 'goTo' buttons
-  ctkWorkflowButtonBoxWidget* buttonBoxWidget()const;
+  Q_INVOKABLE ctkWorkflowButtonBoxWidget* buttonBoxWidget()const;
 
 public slots:
   /// Triggers updates of the the workflowGroupBox and the buttonBoxWidget when the current workflow