Salome HOME
a1ee29db6e288ab15696f24960bc555b48631f13
[modules/shaper.git] / src / XGUI / XGUI_PropertyPanel.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
2
3 /*
4  * XGUI_PropertyPanel.h
5  *
6  *  Created on: Apr 29, 2014
7  *      Author: sbh
8  */
9
10 #ifndef XGUI_PROPERTYPANEL_H_
11 #define XGUI_PROPERTYPANEL_H_
12
13 #include "XGUI.h"
14
15 #include <ModuleBase_ModelWidget.h>
16 #include <ModuleBase_IPropertyPanel.h>
17
18 #include <QList>
19
20 class XGUI_ActionsMgr;
21 class QKeyEvent;
22 class QGridLayout;
23 class ModuleBase_PageBase;
24 class ModuleBase_PageWidget;
25 class XGUI_OperationMgr;
26
27 /// Internal name of property panel widget
28 const static char* PROP_PANEL = "property_panel_dock";
29
30 /// Internal name of Ok button
31 const static char* PROP_PANEL_OK = "property_panel_ok";
32
33 /// Internal name of Cancel button
34 const static char* PROP_PANEL_CANCEL = "property_panel_cancel";
35
36 /// Internal name of Help button
37 const static char* PROP_PANEL_HELP = "property_panel_help";
38
39 /**
40 * \ingroup GUI
41 * Realization of Property panel object.
42 */
43 class XGUI_EXPORT XGUI_PropertyPanel : public ModuleBase_IPropertyPanel
44 {
45 Q_OBJECT
46  public:
47
48   /// Constructor
49   /// \param theParent is a parent of the property panel
50   /// \param theMgr operation manager
51   XGUI_PropertyPanel(QWidget* theParent, XGUI_OperationMgr* theMgr);
52
53   virtual ~XGUI_PropertyPanel();
54
55   /// Returns header widget
56   virtual QWidget* headerWidget() const { return myHeaderWidget; }
57
58   /// Returns main widget of the property panel, which children will be created
59   /// by WidgetFactory using the XML definition
60   ModuleBase_PageBase* contentWidget();
61
62   /// Brings back all widget created by widget factory for signal/slot
63   /// connections and further processing
64   void setModelWidgets(const QList<ModuleBase_ModelWidget*>& theWidgets);
65
66   /// Returns all property panel's widget created by WidgetFactory
67   virtual const QList<ModuleBase_ModelWidget*>& modelWidgets() const;
68
69   /// Removes all widgets in the widget area of the property panel
70   virtual void cleanContent();
71
72   /// Returns currently active widget
73   virtual ModuleBase_ModelWidget* activeWidget() const { return myActiveWidget; }
74
75   /// Activate the next widget in the property panel
76   /// \param theWidget a widget. The next widget should be activated
77   virtual void activateNextWidget(ModuleBase_ModelWidget* theWidget);
78
79   /// Activate the next from current widget in the property panel
80   virtual void activateNextWidget();
81
82   /// Set focus on the Ok button
83   virtual void setFocusOnOkButton();
84
85   /// Set Enable/Disable state of Cancel button
86   /// \param theEnabled Enable/Disable state of Cancel button
87   virtual void setCancelEnabled(bool theEnabled);
88
89   /// \return Enable/Disable state of Cancel button
90   virtual bool isCancelEnabled() const;
91
92   /// Editing mode depends on mode of current operation. This value is defined by it.
93   /// \param isEditing state of editing mode flag
94   virtual void setEditingMode(bool isEditing);
95
96   //! Allows to set predefined actions for the property panel fetched from the ActionsMgr
97   void setupActions(XGUI_ActionsMgr* theMgr);
98
99   /// Returns widget processed by preselection
100   virtual ModuleBase_ModelWidget* preselectionWidget() const;
101
102   /// Sets widget processed by preselection
103   virtual void setPreselectionWidget(ModuleBase_ModelWidget* theWidget);
104
105   /// Returns operation manager
106   XGUI_OperationMgr* operationMgr() const { return myOperationMgr; }
107
108 public slots:
109   /// \brief Update all widgets in property panel with values from the given feature
110   /// \param theFeature a Feature to update values in widgets
111   void updateContentWidget(FeaturePtr theFeature);
112
113   /// \brief If the XML definition of the feature contains information about specific
114   /// content of the property panel, it creates the panel and allow filling it by the given feature
115   /// \param theFeature a Feature to fill property panel
116   void createContentPanel(FeaturePtr theFeature);
117
118   /**
119   * Makes the given widget active, highlights it and removes
120   * highlighting from the previous active widget
121   * emits widgetActivated(theWidget) signal
122   * \param theWidget which has to be activated
123   * \param theEmitSignal a flag to prohibit signal emit
124   */
125   virtual void activateWidget(ModuleBase_ModelWidget* theWidget, const bool theEmitSignal = true);
126
127    /// Activates the parameter widget if it can accept focus
128    /// \param theWidget a widget where focus in event happened
129   void onFocusInWidget(ModuleBase_ModelWidget* theWidget);
130
131   void onActivateNextWidget(ModuleBase_ModelWidget* theWidget);
132
133 signals:
134   /// The signal is emitted if the enter is clicked in the control of the widget
135   /// \param theObject a sender of the event
136   void enterClicked(QObject* theObject);
137
138 protected:
139   /// Makes the widget active, deactivate the previous, activate and hightlight the given one
140   /// \param theWidget a widget
141   bool setActiveWidget(ModuleBase_ModelWidget* theWidget);
142
143   /// The parent method that processes the "Tab"/"SHIF + Tab" keyboard events
144   /// Emits a signal about focus change
145   /// If theIsNext is true, this function searches forward, if next is false, it searches backward.
146   virtual bool focusNextPrevChild(bool theIsNext);
147
148   /// Activate the next widget in the property panel
149   /// \param theWidget a widget. The next widget should be activated
150   /// \param isCheckVisibility flag whether the next widget visibility is checked
151   void activateNextWidget(ModuleBase_ModelWidget* theWidget,
152                           const bool isCheckVisibility);
153
154  protected:
155    /// A method called on the property panel closed
156    /// \param theEvent a close event
157    void closeEvent(QCloseEvent* theEvent);
158
159   /// A header widget
160   QWidget* myHeaderWidget;
161
162  private:
163   ModuleBase_PageWidget* myPanelPage;
164   QList<ModuleBase_ModelWidget*> myWidgets;
165
166   /// Currently active widget
167   ModuleBase_ModelWidget* myActiveWidget;
168   /// Currently widget processed by preselection
169   ModuleBase_ModelWidget* myPreselectionWidget;
170
171   XGUI_OperationMgr* myOperationMgr;
172 };
173
174 #endif /* XGUI_PROPERTYPANEL_H_ */