Salome HOME
Merge branch 'Dev_0.7.1' of newgeom:newgeom.git into Dev_0.7.1
[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 QKeyEvent;
21 class QVBoxLayout;
22
23 /// Internal name of property panel widget
24 const static char* PROP_PANEL = "property_panel_dock";
25
26 /// Internal name of Ok button
27 const static char* PROP_PANEL_OK = "property_panel_ok";
28
29 /// Internal name of Cancel button
30 const static char* PROP_PANEL_CANCEL = "property_panel_cancel";
31
32 /**
33 * \ingroup GUI
34 * Realization of Property panel object.
35 */
36 class XGUI_EXPORT XGUI_PropertyPanel : public ModuleBase_IPropertyPanel
37 {
38 Q_OBJECT
39  public:
40
41   /// Constructor
42   /// \param theParent is a parent of the property panel
43   XGUI_PropertyPanel(QWidget* theParent);
44
45   virtual ~XGUI_PropertyPanel();
46
47   /// Returns main widget of the property panel, which children will be created
48   /// by WidgetFactory using the XML definition
49   QWidget* contentWidget();
50
51   /// Brings back all widget created by widget factory for signal/slot
52   /// connections and further processing
53   void setModelWidgets(const QList<ModuleBase_ModelWidget*>& theWidgets);
54
55   /// Returns all property panel's widget created by WidgetFactory
56   virtual const QList<ModuleBase_ModelWidget*>& modelWidgets() const;
57
58   /// Removes all widgets in the widget area of the property panel
59   void cleanContent();
60
61   /// Returns currently active widget
62   virtual ModuleBase_ModelWidget* activeWidget() const { return myActiveWidget; }
63
64   /// Activate the next widget in the property panel
65   /// \param theWidget a widget. The next widget should be activated
66   virtual void activateNextWidget(ModuleBase_ModelWidget* theWidget);
67
68   /// Activate the next from current widget in the property panel
69   virtual void activateNextWidget();
70
71   /// \brief Enable/Disable stretch area in the panel
72   void setStretchEnabled(bool isEnabled);
73
74   /// Set Enable/Disable state of Cancel button
75   /// \param theEnabled Enable/Disable state of Cancel button
76   virtual void setCancelEnabled(bool theEnabled);
77
78   /// \return Enable/Disable state of Cancel button
79   virtual bool isCancelEnabled() const;
80
81   /// Editing mode depends on mode of current operation. This value is defined by it.
82   /// \param isEditing state of editing mode flag
83   virtual void setEditingMode(bool isEditing);
84
85  public slots:
86
87    /// \brief Update all widgets in property panel with values from the given feature
88    /// \param theFeature a Feature to update values in widgets
89   void updateContentWidget(FeaturePtr theFeature);
90
91   /// Enables / disables "ok" ("accept") button
92   /// \param toEnable enable/disable state of button
93   void setAcceptEnabled(bool toEnable);
94
95   /**
96   * Makes the given widget active, highlights it and removes
97   * highlighting from the previous active widget
98   * emits widgetActivated(theWidget) signal
99   * \param theWidget which has to be activated
100   */
101   virtual void activateWidget(ModuleBase_ModelWidget* theWidget);
102
103  private:
104   QWidget* myCustomWidget;
105   QList<ModuleBase_ModelWidget*> myWidgets;
106   QVBoxLayout* myMainLayout;
107
108   /// Currently active widget
109   ModuleBase_ModelWidget* myActiveWidget;
110 };
111
112 #endif /* XGUI_PROPERTYPANEL_H_ */