Salome HOME
Update Apply button for a point widget, do not activate the same widget(regression).
[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   XGUI_PropertyPanel(QWidget* theParent, XGUI_OperationMgr* theMgr);
51
52   virtual ~XGUI_PropertyPanel();
53
54   /// Returns header widget
55   virtual QWidget* headerWidget() const { return myHeaderWidget; }
56
57   /// Returns main widget of the property panel, which children will be created
58   /// by WidgetFactory using the XML definition
59   ModuleBase_PageBase* contentWidget();
60
61   /// Brings back all widget created by widget factory for signal/slot
62   /// connections and further processing
63   void setModelWidgets(const QList<ModuleBase_ModelWidget*>& theWidgets);
64
65   /// Returns all property panel's widget created by WidgetFactory
66   virtual const QList<ModuleBase_ModelWidget*>& modelWidgets() const;
67
68   /// Removes all widgets in the widget area of the property panel
69   virtual void cleanContent();
70
71   /// Returns currently active widget
72   virtual ModuleBase_ModelWidget* activeWidget() const { return myActiveWidget; }
73
74   /// Activate the next widget in the property panel
75   /// \param theWidget a widget. The next widget should be activated
76   virtual void activateNextWidget(ModuleBase_ModelWidget* theWidget);
77
78   /// Activate the next from current widget in the property panel
79   virtual void activateNextWidget();
80
81   /// Set focus on the Ok button
82   virtual void setFocusOnOkButton();
83
84   /// Set Enable/Disable state of Cancel button
85   /// \param theEnabled Enable/Disable state of Cancel button
86   virtual void setCancelEnabled(bool theEnabled);
87
88   /// \return Enable/Disable state of Cancel button
89   virtual bool isCancelEnabled() const;
90
91   /// Editing mode depends on mode of current operation. This value is defined by it.
92   /// \param isEditing state of editing mode flag
93   virtual void setEditingMode(bool isEditing);
94
95   //! Allows to set predefined actions for the property panel fetched from the ActionsMgr
96   void setupActions(XGUI_ActionsMgr* theMgr);
97
98   /// Returns widget processed by preselection
99   virtual ModuleBase_ModelWidget* preselectionWidget() const;
100
101   /// Sets widget processed by preselection
102   virtual void setPreselectionWidget(ModuleBase_ModelWidget* theWidget);
103
104   /// Returns operation manager
105   XGUI_OperationMgr* operationMgr() const { return myOperationMgr; }
106
107 public slots:
108
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   /**
114   * Makes the given widget active, highlights it and removes
115   * highlighting from the previous active widget
116   * emits widgetActivated(theWidget) signal
117   * \param theWidget which has to be activated
118   */
119   virtual void activateWidget(ModuleBase_ModelWidget* theWidget);
120
121   void onFocusNextPrev();
122
123 protected:
124   /// Makes the widget active, deactivate the previous, activate and hightlight the given one
125   /// \param theWidget a widget
126   bool setActiveWidget(ModuleBase_ModelWidget* theWidget);
127
128   /// The parent method that processes the "Tab"/"SHIF + Tab" keyboard events
129   /// Emits a signal about focus change
130   /// If theIsNext is true, this function searches forward, if next is false, it searches backward.
131   virtual bool focusNextPrevChild(bool theIsNext);
132
133  protected:
134    /// A method called on the property panel closed
135    /// \param theEvent a close event
136    void closeEvent(QCloseEvent* theEvent);
137
138   /// A header widget
139   QWidget* myHeaderWidget;
140
141  private:
142   ModuleBase_PageWidget* myPanelPage;
143   QList<ModuleBase_ModelWidget*> myWidgets;
144
145   /// Currently active widget
146   ModuleBase_ModelWidget* myActiveWidget;
147   /// Currently widget processed by preselection
148   ModuleBase_ModelWidget* myPreselectionWidget;
149
150   XGUI_OperationMgr* myOperationMgr;
151 };
152
153 #endif /* XGUI_PROPERTYPANEL_H_ */