ctkWorkflowAbstractWidgetStep.h 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. /*=========================================================================
  2. Library: CTK
  3. Copyright (c) Kitware Inc.
  4. Licensed under the Apache License, Version 2.0 (the "License");
  5. you may not use this file except in compliance with the License.
  6. You may obtain a copy of the License at
  7. http://www.commontk.org/LICENSE
  8. Unless required by applicable law or agreed to in writing, software
  9. distributed under the License is distributed on an "AS IS" BASIS,
  10. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  11. See the License for the specific language governing permissions and
  12. limitations under the License.
  13. =========================================================================*/
  14. #ifndef __ctkWorkflowAbstractWidgetStep_h
  15. #define __ctkWorkflowAbstractWidgetStep_h
  16. // QT includes
  17. class QObject;
  18. class QWidget;
  19. class QIcon;
  20. #include <QBoxLayout>
  21. #include <QFlags>
  22. // CTK includes
  23. #include "ctkPimpl.h"
  24. #include "ctkWidgetsExport.h"
  25. #include "ctkWorkflowStep.h"
  26. #include "ctkWorkflowTransitions.h"
  27. //class ctkWorkflowButtonBoxWidget;
  28. class ctkWorkflowGroupBox;
  29. class ctkWorkflowAbstractWidgetStepPrivate;
  30. ///
  31. /// \brief ctkWorkflowAbstractWidgetStep is a convienience class to quickly
  32. /// construct a ctkWorkflowStep with a user interface.
  33. ///
  34. /// It embeds a QWidget* stepArea, onto which step-specific widgets can be placed.
  35. /// The showUserInterface() and hideUserInterface() commands of ctkWorkflowStep are
  36. /// written for you, and, if you desire, the step's "Next" and/or "Back" buttons are
  37. /// added with the appropriate signals and slots.
  38. /// To create a custom step, you can derive from this class and
  39. /// implement only two functions:
  40. /// 1) ctkWorkflowAbstractWidgetStep::populateStepWidgetsList(), to define the
  41. /// step-specific widgets;
  42. /// 2) ctkWorkflowAbstractWidgetStep::validate(const QString&), to validate the processing
  43. /// state associated with this step.
  44. /// For additional customization, you can reimplement
  45. /// showUserInterface() and hideUserInterface() in derived classes.
  46. /// \sa showUserInterface() hideUserInterface()
  47. class CTK_WIDGETS_EXPORT ctkWorkflowAbstractWidgetStep : public ctkWorkflowStep
  48. {
  49. public:
  50. enum ButtonBoxHint {
  51. NoHints = 0x0,
  52. BackButtonHidden = 0x1,
  53. BackButtonDisabled = 0x2,
  54. NextButtonHidden = 0x4,
  55. NextButtonDisabled = 0x8,
  56. ButtonBoxHidden = 0x10
  57. };
  58. Q_DECLARE_FLAGS(ButtonBoxHints, ButtonBoxHint)
  59. typedef ctkWorkflowStep Superclass;
  60. explicit ctkWorkflowAbstractWidgetStep(ctkWorkflow* newWorkflow, const QString& newId);
  61. virtual ~ctkWorkflowAbstractWidgetStep();
  62. /// \brief Override the back button text of any ctkWorkflowButtonBox when this step
  63. /// is the current step
  64. virtual QString backButtonText()const;
  65. virtual void setBackButtonText(const QString& name);
  66. /// \brief Override the next button text of any ctkWorkflowButtonBox when this step
  67. /// is the current step
  68. virtual QString nextButtonText()const;
  69. virtual void setNextButtonText(const QString& name);
  70. /// \brief Override the button visibility of any ctkWorkflowButtonBox when this step is the
  71. /// current step
  72. void setButtonBoxHints(ButtonBoxHints buttonBoxHints);
  73. ButtonBoxHints buttonBoxHints()const;
  74. /// \brief Associate an icon with this step (ex. used by ctkWorkflowButtonBox to display an icon
  75. /// on 'goTo' buttons).
  76. QIcon icon()const;
  77. void setIcon(const QIcon& newIcon);
  78. /// Get the QObject associated with this step, to connect signals/slots
  79. QObject* ctkWorkflowAbstractWidgetStepQObject();
  80. /// Returns the QWidget onto which this step's user interface elements are placed.
  81. virtual QWidget* stepArea() = 0;
  82. /// Set/get whether a showUserInterfaceCommand has been provided in
  83. /// a separate QObject (see method 2 described for
  84. /// showUserInterface())
  85. virtual int hasShowUserInterfaceCommand()const;
  86. virtual void setHasShowUserInterfaceCommand(int flag);
  87. /// Set/get whether a createUserInterfaceCommand has been provided in
  88. /// a separate QObject (see method 2 described for
  89. /// createUserInterface())
  90. virtual int hasCreateUserInterfaceCommand()const;
  91. virtual void setHasCreateUserInterfaceCommand(int flag);
  92. protected:
  93. /// Creates the user interface associated with this step.
  94. virtual void createUserInterface() = 0;
  95. /// Prepares the step to be shown.
  96. virtual void showUserInterface();
  97. /// \brief Signal (emitted by the private implementation) indicating that the step's
  98. /// createUserInterface() method should be called.
  99. /// \sa createUserInterface()
  100. void invokeCreateUserInterfaceCommand()const;
  101. /// \brief Signal (emitted by the private implementation) indicating that the step's
  102. /// createUserInterface() method has completed.
  103. /// \sa createUserInterface()
  104. void createUserInterfaceComplete()const;
  105. /// \brief Signal (emitted by the private implementation) indicating that the step's
  106. /// 'showUserInterface() method should be called.
  107. /// \sa showUserInterface()
  108. void invokeShowUserInterfaceCommand()const;
  109. /// \brief Signal (emitted by the private implementation) indicating that the step's
  110. /// showUserInterface() method has completed.
  111. /// \sa showUserInterface()
  112. void showUserInterfaceComplete()const;
  113. protected:
  114. QScopedPointer<ctkWorkflowAbstractWidgetStepPrivate> d_ptr;
  115. private:
  116. Q_DECLARE_PRIVATE(ctkWorkflowAbstractWidgetStep);
  117. Q_DISABLE_COPY(ctkWorkflowAbstractWidgetStep);
  118. friend class ctkWorkflowGroupBox; // For access to showUserInterface()
  119. };
  120. Q_DECLARE_OPERATORS_FOR_FLAGS(ctkWorkflowAbstractWidgetStep::ButtonBoxHints)
  121. #endif