]> SALOME platform Git repositories - modules/shaper.git/blob - src/ModuleBase/ModuleBase_ModelWidget.h
Salome HOME
refs #46 - define line segment using dialog fileds
[modules/shaper.git] / src / ModuleBase / ModuleBase_ModelWidget.h
1 // File:        ModuleBase_ModelWidget.h
2 // Created:     25 Apr 2014
3 // Author:      Natalia ERMOLAEVA
4
5 #ifndef ModuleBase_ModelWidget_H
6 #define ModuleBase_ModelWidget_H
7
8 #include <ModuleBase.h>
9
10 #include <QObject>
11
12 #include <boost/shared_ptr.hpp>
13
14 class ModelAPI_Feature;
15 class QKeyEvent;
16
17 /**\class ModuleBase_ModelWidget
18  * \brief An abstract custom widget class. This class realization is assumed to create some controls.
19  * The controls values modification should send signal about values change.
20  *
21  * Common interface for widgets in the property panel.
22  * Every widget are able to save/restore data from the model and/or to contain other widgets.
23  *
24  */
25 class MODULEBASE_EXPORT ModuleBase_ModelWidget : public QObject
26 {
27   Q_OBJECT
28 public:
29   /// Constructor
30   /// \theParent the parent object
31   ModuleBase_ModelWidget(QObject* theParent) :QObject(theParent) {};
32   /// Destructor
33   virtual ~ModuleBase_ModelWidget() {};
34
35   /// Saves the internal parameters to the given feature
36   /// \param theFeature a model feature to be changed
37   virtual bool storeValue(boost::shared_ptr<ModelAPI_Feature> theFeature) = 0;
38
39   virtual bool restoreValue(boost::shared_ptr<ModelAPI_Feature> theFeature) = 0;
40
41   /// Returns whether the widget can accept focus, or if it corresponds to the given attribute
42   /// \param theAttribute name
43   virtual bool canFocusTo(const std::string& theAttributeName) = 0;
44
45   /// Set focus to the current widget if it corresponds to the given attribute
46   virtual void focusTo() = 0;
47
48   /// Returns list of widget controls
49   /// \return a control list
50   virtual QList<QWidget*> getControls() const = 0;
51
52 signals:
53   /// The signal about widget values changed
54   void valuesChanged();
55   /// The signal about key release on the control, that corresponds to the attribute
56   /// \param theAttributeName a name of the attribute
57   /// \param theEvent key release event
58   void keyReleased(const std::string& theAttributeName, QKeyEvent* theEvent);
59 };
60
61 #endif