Salome HOME
Merge branch 'Dev_0.7.1' of newgeom:newgeom 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 * \ingroup GUI
19 * Implementation of model widget for choice widget definition (combo box)
20 * It can be defined as following:
21 * \code
22 *   <choice id="bool_type" 
23 *     label="Type" 
24 *     tooltip="Type of boolean operation"
25 *     string_list="Cut Fuse Common"
26 *   />
27 * \endcode
28 */
29 class MODULEBASE_EXPORT ModuleBase_WidgetChoice : public ModuleBase_ModelWidget
30 {
31 Q_OBJECT
32  public:
33   /// Constructor
34   /// \param theParent the parent object
35   /// \param theData the widget configuation. The attribute of the model widget is obtained from
36   /// \param theParentId is Id of a parent of the current attribute
37   ModuleBase_WidgetChoice(QWidget* theParent, const Config_WidgetAPI* theData, 
38                           const std::string& theParentId);
39
40   virtual ~ModuleBase_WidgetChoice();
41   
42   virtual bool storeValue() const;
43
44   virtual bool restoreValue();
45
46   virtual bool focusTo();
47
48   /// Returns the internal parent wiget control, that can be shown anywhere
49   /// \returns the widget
50   QWidget* getControl() const
51   {
52     return myContainer;
53   }
54
55   /// Returns list of widget controls
56   /// \return a controls list
57   virtual QList<QWidget*> getControls() const;
58
59 private slots:
60   /// Slot called on combo box index change
61   void onCurrentIndexChanged(int theIndex);
62
63 private:
64   /// Container widget
65   QWidget* myContainer;
66
67   /// The label
68   QLabel* myLabel;
69
70   /// The control
71   QComboBox* myCombo;
72 };
73
74 #endif