Salome HOME
Error management -- Introduce ErrorMgr
[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 Enable/Disable state of Cancel button
81   /// \param theEnabled Enable/Disable state of Cancel button
82   virtual void setCancelEnabled(bool theEnabled);
83
84   /// \return Enable/Disable state of Cancel button
85   virtual bool isCancelEnabled() const;
86
87   /// Editing mode depends on mode of current operation. This value is defined by it.
88   /// \param isEditing state of editing mode flag
89   virtual void setEditingMode(bool isEditing);
90
91   //! Allows to set predefined actions for the property panel fetched from the ActionsMgr
92   void setupActions(XGUI_ActionsMgr* theMgr);
93
94   /// Returns widget processed by preselection
95   virtual ModuleBase_ModelWidget* preselectionWidget() const;
96
97   /// Sets widget processed by preselection
98   virtual void setPreselectionWidget(ModuleBase_ModelWidget* theWidget);
99
100  public slots:
101
102    /// \brief Update all widgets in property panel with values from the given feature
103    /// \param theFeature a Feature to update values in widgets
104   void updateContentWidget(FeaturePtr theFeature);
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   */
112   virtual void activateWidget(ModuleBase_ModelWidget* theWidget);
113
114  protected:
115   QWidget* myHeaderWidget;
116
117  private:
118   ModuleBase_PageWidget* myPanelPage;
119   QList<ModuleBase_ModelWidget*> myWidgets;
120
121   /// Currently active widget
122   ModuleBase_ModelWidget* myActiveWidget;
123   /// Currently widget processed by preselection
124   ModuleBase_ModelWidget* myPreselectionWidget;
125 };
126
127 #endif /* XGUI_PROPERTYPANEL_H_ */