Salome HOME
Issue#1059: Consider operation state in selection validator
[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
26 /// Internal name of property panel widget
27 const static char* PROP_PANEL = "property_panel_dock";
28
29 /// Internal name of Ok button
30 const static char* PROP_PANEL_OK = "property_panel_ok";
31
32 /// Internal name of Cancel button
33 const static char* PROP_PANEL_CANCEL = "property_panel_cancel";
34
35 /// Internal name of Help button
36 const static char* PROP_PANEL_HELP = "property_panel_help";
37
38 /**
39 * \ingroup GUI
40 * Realization of Property panel object.
41 */
42 class XGUI_EXPORT XGUI_PropertyPanel : public ModuleBase_IPropertyPanel
43 {
44 Q_OBJECT
45  public:
46
47   /// Constructor
48   /// \param theParent is a parent of the property panel
49   XGUI_PropertyPanel(QWidget* theParent);
50
51   virtual ~XGUI_PropertyPanel();
52
53   /// Returns header widget
54   virtual QWidget* headerWidget() const { return myHeaderWidget; }
55
56   /// Returns main widget of the property panel, which children will be created
57   /// by WidgetFactory using the XML definition
58   ModuleBase_PageBase* contentWidget();
59
60   /// Brings back all widget created by widget factory for signal/slot
61   /// connections and further processing
62   void setModelWidgets(const QList<ModuleBase_ModelWidget*>& theWidgets);
63
64   /// Returns all property panel's widget created by WidgetFactory
65   virtual const QList<ModuleBase_ModelWidget*>& modelWidgets() const;
66
67   /// Removes all widgets in the widget area of the property panel
68   virtual void cleanContent();
69
70   /// Returns currently active widget
71   virtual ModuleBase_ModelWidget* activeWidget() const { return myActiveWidget; }
72
73   /// Activate the next widget in the property panel
74   /// \param theWidget a widget. The next widget should be activated
75   virtual void activateNextWidget(ModuleBase_ModelWidget* theWidget);
76
77   /// Activate the next from current widget in the property panel
78   virtual void activateNextWidget();
79
80   /// Set focus on the Ok button
81   virtual void setFocusOnOkButton();
82
83   /// Set Enable/Disable state of Cancel button
84   /// \param theEnabled Enable/Disable state of Cancel button
85   virtual void setCancelEnabled(bool theEnabled);
86
87   /// \return Enable/Disable state of Cancel button
88   virtual bool isCancelEnabled() const;
89
90   /// Editing mode depends on mode of current operation. This value is defined by it.
91   /// \param isEditing state of editing mode flag
92   virtual void setEditingMode(bool isEditing);
93
94   //! Allows to set predefined actions for the property panel fetched from the ActionsMgr
95   void setupActions(XGUI_ActionsMgr* theMgr);
96
97   /// Returns widget processed by preselection
98   virtual ModuleBase_ModelWidget* preselectionWidget() const;
99
100   /// Sets widget processed by preselection
101   virtual void setPreselectionWidget(ModuleBase_ModelWidget* theWidget);
102
103  public slots:
104
105    /// \brief Update all widgets in property panel with values from the given feature
106    /// \param theFeature a Feature to update values in widgets
107   void updateContentWidget(FeaturePtr theFeature);
108
109   /**
110   * Makes the given widget active, highlights it and removes
111   * highlighting from the previous active widget
112   * emits widgetActivated(theWidget) signal
113   * \param theWidget which has to be activated
114   */
115   virtual void activateWidget(ModuleBase_ModelWidget* theWidget);
116
117  protected:
118   /// A header widget
119   QWidget* myHeaderWidget;
120
121  private:
122   ModuleBase_PageWidget* myPanelPage;
123   QList<ModuleBase_ModelWidget*> myWidgets;
124
125   /// Currently active widget
126   ModuleBase_ModelWidget* myActiveWidget;
127   /// Currently widget processed by preselection
128   ModuleBase_ModelWidget* myPreselectionWidget;
129 };
130
131 #endif /* XGUI_PROPERTYPANEL_H_ */