ctkWorkflowWidget.h 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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.apache.org/licenses/LICENSE-2.0.txt
  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 __ctkWorkflowWidget_h
  15. #define __ctkWorkflowWidget_h
  16. // Qt includes
  17. #include <QWidget>
  18. class QPushButton;
  19. class QGroupBox;
  20. #include <QBoxLayout>
  21. // CTK includes
  22. #include "ctkPimpl.h"
  23. #include "ctkWidgetsExport.h"
  24. class ctkWorkflow;
  25. class ctkWorkflowStep;
  26. class ctkWorkflowButtonBoxWidget;
  27. class ctkWorkflowGroupBox;
  28. class ctkWorkflowWidgetPrivate;
  29. /// \brief ctkWorkflowWidget is the basis for a workflow with a user interface. It groups together
  30. /// and manages a ctkWorkflowGroupBox (to display the step) and a ctkWorkflowButtonBoxWidget
  31. /// (providing buttons for traversing the workflow).
  32. class CTK_WIDGETS_EXPORT ctkWorkflowWidget : public QWidget
  33. {
  34. Q_OBJECT
  35. Q_PROPERTY(bool showButtonBoxWidget READ showButtonBoxWidget WRITE setShowButtonBoxWidget)
  36. public:
  37. typedef QWidget Superclass;
  38. explicit ctkWorkflowWidget(QWidget* parent = 0);
  39. virtual ~ctkWorkflowWidget();
  40. /// Set/get the workflow associated with this widget.
  41. Q_INVOKABLE virtual ctkWorkflow* workflow()const;
  42. Q_INVOKABLE virtual void setWorkflow(ctkWorkflow* newWorkflow);
  43. /// Get the widget constaining the title, subtitle, pre-text, post-text, error-text and client area
  44. /// layout.
  45. virtual ctkWorkflowGroupBox* workflowGroupBox()const;
  46. /// Set/get whether or not to associate a buttonBoxWidget with this step (default true)
  47. bool showButtonBoxWidget()const;
  48. void setShowButtonBoxWidget(bool newShowButtonBoxWidget);
  49. /// Get the widget with the 'next', 'back' and 'goTo' buttons
  50. Q_INVOKABLE ctkWorkflowButtonBoxWidget* buttonBoxWidget()const;
  51. public slots:
  52. /// Triggers updates of the the workflowGroupBox and the buttonBoxWidget when the current workflow
  53. /// step has changed.
  54. virtual void onCurrentStepChanged(ctkWorkflowStep* currentStep);
  55. protected:
  56. // Triggers updates of the workflowGroupBox when the current workflow step has changed.
  57. virtual void updateStepUI(ctkWorkflowStep* currentStep);
  58. // Triggers updates of the buttonBoxWidget when the current workflow step has changed.
  59. void updateButtonBoxUI(ctkWorkflowStep* currentStep);
  60. protected:
  61. QScopedPointer<ctkWorkflowWidgetPrivate> d_ptr;
  62. private:
  63. Q_DECLARE_PRIVATE(ctkWorkflowWidget);
  64. Q_DISABLE_COPY(ctkWorkflowWidget);
  65. };
  66. #endif