Salome HOME
Merge branch 'master' into cgt/devCEA
[modules/shaper.git] / src / ModuleBase / ModuleBase_IPropertyPanel.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 /*
4  * ModuleBase_IPropertyPanel.h
5  *
6  *  Created on: Oct 01, 2014
7  *      Author: vsv
8  */
9
10 #ifndef ModuleBase_PROPERTYPANEL_H_
11 #define ModuleBase_PROPERTYPANEL_H_
12
13 #include "ModuleBase.h"
14
15 #include <QDockWidget>
16 #include <QKeyEvent>
17
18 class ModuleBase_ModelWidget;
19
20 /**
21 * \ingroup GUI
22 * A class for Property panel object definition
23 */
24 class MODULEBASE_EXPORT ModuleBase_IPropertyPanel : public QDockWidget
25 {
26 Q_OBJECT
27 public:
28   /// Constructor
29   /// \param theParent is a parent of the property panel
30   ModuleBase_IPropertyPanel(QWidget* theParent);
31
32   /// Returns header widget
33   virtual QWidget* headerWidget() const = 0;
34
35   /// Returns currently active widget
36   virtual ModuleBase_ModelWidget* activeWidget() const = 0;
37
38   /// Returns all property panel's widget created by WidgetFactory
39   virtual const QList<ModuleBase_ModelWidget*>& modelWidgets() const = 0;
40
41   /// Returns widget, that has the given attribute index
42   /// \param theAttributeId an attribute from XML
43   virtual ModuleBase_ModelWidget* modelWidget(const std::string& theAttributeId) const;
44
45   /// Removes all widgets in the widget area of the property panel
46   virtual void cleanContent() = 0;
47
48   /// Editing mode depends on mode of current operation. This value is defined by it.
49   /// \param isEditing state of editing mode flag
50   virtual void setEditingMode(bool isEditing) { myIsEditing = isEditing; }
51
52   /// \return State of editing mode flag
53   bool isEditingMode() const { return myIsEditing; }
54
55   /// Set focus on the Ok button
56   virtual void setFocusOnOkButton() = 0;
57
58   /// Set Enable/Disable state of Cancel button
59   /// \param theEnabled Enable/Disable state of Cancel button
60   virtual void setCancelEnabled(bool theEnabled) = 0;
61
62   /// \return Enable/Disable state of Cancel button
63   virtual bool isCancelEnabled() const = 0;
64
65   /// Returns widget processed by preselection
66   virtual ModuleBase_ModelWidget* preselectionWidget() const = 0;
67
68   /// Sets widget processed by preselection
69   virtual void setPreselectionWidget(ModuleBase_ModelWidget* theWidget) = 0;
70
71   /// Returns the first widget, where canAcceptFocus returns true
72   /// \return a widget or null
73   ModuleBase_ModelWidget* findFirstAcceptingValueWidget();
74
75   /// Returns the first widget, where canAcceptFocus returns true
76   /// \return a widget or null
77   static ModuleBase_ModelWidget* findFirstAcceptingValueWidget(
78                           const QList<ModuleBase_ModelWidget*>& theWidgets);
79
80 signals:
81   /// The signal about key release on the control, that corresponds to the attribute
82   /// \param theObject a sender of the event
83   /// \param theEvent key release event
84   void keyReleased(QObject* theObject, QKeyEvent* theEvent);
85
86   /// The signal about the widget activation
87   /// \param theWidget the activated widget
88   void beforeWidgetActivated(ModuleBase_ModelWidget* theWidget);
89
90   /// The signal about the widget activation
91   /// \param theWidget the activated widget
92   void widgetActivated(ModuleBase_ModelWidget* theWidget);
93
94   /// Emited when there is no next widget
95   /// \param thePreviousAttributeID an attribute key of the previous active widget
96   void noMoreWidgets(const std::string& thePreviousAttributeID);
97
98 public slots:
99   /// Activate the next widget in the property panel
100   /// \param theWidget a widget. The next widget should be activated
101   virtual void activateNextWidget(ModuleBase_ModelWidget* theWidget) = 0;
102
103   /// Activate the next from current widget in the property panel
104   virtual void activateNextWidget() = 0;
105
106   /**
107   * Makes the given widget active, highlights it and removes
108   * highlighting from the previous active widget
109   * emits widgetActivated(theWidget) signal
110   * \param theWidget which has to be activated
111   * \param theEmitSignal a flag to prohibit signal emit
112   */
113   virtual void activateWidget(ModuleBase_ModelWidget* theWidget,
114                               const bool theEmitSignal = true) = 0;
115
116 protected:
117
118   /// Flag which shows that current operation is in editing mode
119   bool myIsEditing;
120 };
121
122 #endif