]> SALOME platform Git repositories - modules/shaper.git/blob - src/ModuleBase/ModuleBase_WidgetSwitch.h
Salome HOME
1f10c2eead1072a7116d95eeaf2e156248d7a4d8
[modules/shaper.git] / src / ModuleBase / ModuleBase_WidgetSwitch.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 /*
4  * ModuleBase_WidgetSwitch.h
5  *
6  *  Created on: Apr 16, 2014
7  *      Author: sbh
8  */
9
10 #ifndef ModuleBase_WidgetSwitch_H_
11 #define ModuleBase_WidgetSwitch_H_
12
13 #include <ModuleBase.h>
14 #include <ModuleBase_ModelWidget.h>
15
16 class QComboBox;
17 class QVBoxLayout;
18
19 /**
20 * \ingroup GUI
21 * Implements a model widget for swithch as a container widget. It can be defined in XML with "switch" keyword
22 */
23 class MODULEBASE_EXPORT ModuleBase_WidgetSwitch : public ModuleBase_ModelWidget
24 {
25   Q_OBJECT
26  public:
27    /// Constructor
28    /// \param parent a parent widget
29   ModuleBase_WidgetSwitch(QWidget* theParent,
30                           const Config_WidgetAPI* theData,
31                           const std::string& theParentId);
32   virtual ~ModuleBase_WidgetSwitch();
33
34   virtual bool restoreValue() {
35     return false;
36   }
37
38   virtual QList<QWidget*> getControls() const;
39
40   virtual bool focusTo() {
41     return false;
42   }
43
44   /// Add a page to the widget
45   /// \param theWidget a page widget
46   /// \param theName a name of page
47   int addPage(QWidget* theWidget, const QString & theName);
48
49   /// Returns count of pages
50   int count() const;
51
52   /// Returns index of current page
53   int currentIndex() const;
54
55   /// Returns current widget (page)
56   QWidget * currentWidget() const;
57
58   /// Returns index of widget (page)
59   /// \param theWidget a widget page
60   int indexOf(QWidget * theWidget) const;
61
62   /// Insert page
63   /// \param index an index (position) to insert 
64   /// \param theWidget a page widget
65   /// \param theName a name of the page
66   int insertPage(int index, QWidget * theWidget, const QString & theName);
67
68   /// Returns True if a page by given index is enabled
69   /// \param index index of the page
70   bool isPageEnabled(int index) const;
71
72   /// Returns text of the page by its id
73   /// \param index index of the page
74   QString pageText(int index) const;
75
76   /// Returns tooltip of the page by its id
77   /// \param index index of the page
78   QString pageToolTip(int index) const;
79
80   /// Remove page by its id
81   /// \param index index of the page
82   void removePage(int index);
83
84   /// Enale/disable a page by its Id
85   /// \param index index of the page
86   /// \param enabled an enable flag
87   void setPageEnabled(int index, bool enabled);
88
89   /// Set page name
90   /// \param index index of the page
91   /// \param text a name of the page
92   void setPageName(int index, const QString & text);
93
94   /// Set page tooltip
95   /// \param index index of the page
96   /// \param toolTip a tooltip of the page
97   void setPageToolTip(int index, const QString & toolTip);
98
99  public slots:
100    /// Set current page by index
101   /// \param index index of the page
102   void setCurrentIndex(int index);
103
104 signals:
105   /// Emitted on current page change
106   void currentPageChanged(int);
107
108  protected:
109   virtual bool storeValueCustom() const {
110     return false;
111   }
112   /// Update widget
113   void refresh();
114
115  private:
116    /// Layout
117   QVBoxLayout* myMainLay;
118
119   /// Combo box
120   QComboBox* myCombo;
121
122   /// List of pages
123   QWidgetList myCases;
124 };
125
126 #endif /* ModuleBase_WidgetSwitch_H_ */