Salome HOME
Merge branch 'Dev_0.7.1' of newgeom:newgeom.git into Dev_0.7.1
[modules/shaper.git] / src / ModuleBase / ModuleBase_WidgetChoice.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:        ModuleBase_WidgetChoice.h
4 // Created:     03 Sept 2014
5 // Author:      Vitaly Smetannikov
6
7 #ifndef ModuleBase_WidgetChoice_H
8 #define ModuleBase_WidgetChoice_H
9
10 #include "ModuleBase.h"
11 #include "ModuleBase_ModelWidget.h"
12
13 class QWidget;
14 class QLabel;
15 class QComboBox;
16
17 /**
18 * Implementation of model widget for choice widget definition (combo box)
19 * It can be defined as following:
20 * \code
21 *   <choice id="bool_type" 
22 *     label="Type" 
23 *     tooltip="Type of boolean operation"
24 *     string_list="Cut Fuse Common"
25 *   />
26 * \endcode
27 */
28 class MODULEBASE_EXPORT ModuleBase_WidgetChoice : public ModuleBase_ModelWidget
29 {
30 Q_OBJECT
31  public:
32   /// Constructor
33   /// \param theParent the parent object
34   /// \param theData the widget configuation. The attribute of the model widget is obtained from
35   /// \param theParentId is Id of a parent of the current attribute
36   ModuleBase_WidgetChoice(QWidget* theParent, const Config_WidgetAPI* theData, 
37                           const std::string& theParentId);
38
39   virtual ~ModuleBase_WidgetChoice();
40   
41   virtual bool storeValue() const;
42
43   virtual bool restoreValue();
44
45   virtual bool focusTo();
46
47   /// Returns the internal parent wiget control, that can be shown anywhere
48   /// \returns the widget
49   QWidget* getControl() const
50   {
51     return myContainer;
52   }
53
54   /// Returns list of widget controls
55   /// \return a controls list
56   virtual QList<QWidget*> getControls() const;
57
58 private slots:
59   /// Slot called on combo box index change
60   void onCurrentIndexChanged(int theIndex);
61
62 private:
63   /// Container widget
64   QWidget* myContainer;
65
66   /// The label
67   QLabel* myLabel;
68
69   /// The control
70   QComboBox* myCombo;
71 };
72
73 #endif