1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
6 * Created on: Apr 29, 2014
10 #ifndef XGUI_PROPERTYPANEL_H_
11 #define XGUI_PROPERTYPANEL_H_
15 #include <ModuleBase_ModelWidget.h>
16 #include <ModuleBase_IPropertyPanel.h>
20 class XGUI_ActionsMgr;
24 class ModuleBase_PageBase;
25 class ModuleBase_PageWidget;
26 class XGUI_OperationMgr;
28 /// Internal name of property panel widget
29 const static char* PROP_PANEL = "property_panel_dock";
31 /// Internal name of Ok button
32 const static char* PROP_PANEL_OK = "property_panel_ok";
34 /// Internal name of Cancel button
35 const static char* PROP_PANEL_CANCEL = "property_panel_cancel";
37 /// Internal name of Help button
38 const static char* PROP_PANEL_HELP = "property_panel_help";
40 /// Internal name of Preview button
41 const static char* PROP_PANEL_PREVIEW = "property_panel_preview";
45 * Realization of Property panel object.
47 class XGUI_EXPORT XGUI_PropertyPanel : public ModuleBase_IPropertyPanel
53 /// \param theParent is a parent of the property panel
54 /// \param theMgr operation manager
55 XGUI_PropertyPanel(QWidget* theParent, XGUI_OperationMgr* theMgr);
57 virtual ~XGUI_PropertyPanel();
59 /// Returns header widget
60 virtual QWidget* headerWidget() const { return myHeaderWidget; }
62 /// Returns main widget of the property panel, which children will be created
63 /// by WidgetFactory using the XML definition
64 ModuleBase_PageBase* contentWidget();
66 /// Brings back all widget created by widget factory for signal/slot
67 /// connections and further processing
68 void setModelWidgets(const QList<ModuleBase_ModelWidget*>& theWidgets);
70 /// Returns all property panel's widget created by WidgetFactory
71 virtual const QList<ModuleBase_ModelWidget*>& modelWidgets() const;
73 /// Removes all widgets in the widget area of the property panel
74 virtual void cleanContent();
76 /// Returns currently active widget
77 virtual ModuleBase_ModelWidget* activeWidget() const { return myActiveWidget; }
79 /// Activate the next widget in the property panel
80 /// \param theWidget a widget. The next widget should be activated
81 virtual void activateNextWidget(ModuleBase_ModelWidget* theWidget);
83 /// Activate the next from current widget in the property panel
84 virtual void activateNextWidget();
86 /// Set focus on the Ok button
87 virtual void setFocusOnOkButton();
89 /// Set Enable/Disable state of Cancel button
90 /// \param theEnabled Enable/Disable state of Cancel button
91 virtual void setCancelEnabled(bool theEnabled);
93 /// \return Enable/Disable state of Cancel button
94 virtual bool isCancelEnabled() const;
96 /// Editing mode depends on mode of current operation. This value is defined by it.
97 /// \param isEditing state of editing mode flag
98 virtual void setEditingMode(bool isEditing);
100 //! Allows to set predefined actions for the property panel fetched from the ActionsMgr
101 void setupActions(XGUI_ActionsMgr* theMgr);
103 /// Returns widget processed by preselection
104 virtual ModuleBase_ModelWidget* preselectionWidget() const;
106 /// Sets widget processed by preselection
107 virtual void setPreselectionWidget(ModuleBase_ModelWidget* theWidget);
109 /// Returns operation manager
110 XGUI_OperationMgr* operationMgr() const { return myOperationMgr; }
112 /// Find under the panel a child button with the parameter name
113 /// \param theInternalName a button object name
114 /// \return button instance or NULL
115 QToolButton* findButton(const char* theInternalName) const;
118 /// \brief Update all widgets in property panel with values from the given feature
119 /// \param theFeature a Feature to update values in widgets
120 void updateContentWidget(FeaturePtr theFeature);
122 /// \brief If the XML definition of the feature contains information about specific
123 /// content of the property panel, it creates the panel and allow filling it by the given feature
124 /// \param theFeature a Feature to fill property panel
125 void createContentPanel(FeaturePtr theFeature);
128 * Makes the given widget active, highlights it and removes
129 * highlighting from the previous active widget
130 * emits widgetActivated(theWidget) signal
131 * \param theWidget which has to be activated
132 * \param theEmitSignal a flag to prohibit signal emit
134 virtual void activateWidget(ModuleBase_ModelWidget* theWidget, const bool theEmitSignal = true);
136 /// Activates the parameter widget if it can accept focus
137 /// \param theWidget a widget where focus in event happened
138 void onFocusInWidget(ModuleBase_ModelWidget* theWidget);
141 /// Activate next widget
142 /// \param theWidget the current widget
143 void onActivateNextWidget(ModuleBase_ModelWidget* theWidget);
146 /// The signal is emitted if the enter is clicked in the control of the widget
147 /// \param theObject a sender of the event
148 void enterClicked(QObject* theObject);
151 /// Makes the widget active, deactivate the previous, activate and hightlight the given one
152 /// \param theWidget a widget
153 bool setActiveWidget(ModuleBase_ModelWidget* theWidget);
155 /// The parent method that processes the "Tab"/"SHIF + Tab" keyboard events
156 /// Emits a signal about focus change
157 /// If theIsNext is true, this function searches forward, if next is false, it searches backward.
158 virtual bool focusNextPrevChild(bool theIsNext);
160 /// Activate the next widget in the property panel
161 /// \param theWidget a widget. The next widget should be activated
162 /// \param isCheckVisibility flag whether the next widget visibility is checked
163 void activateNextWidget(ModuleBase_ModelWidget* theWidget,
164 const bool isCheckVisibility);
167 /// A method called on the property panel closed
168 /// \param theEvent a close event
169 void closeEvent(QCloseEvent* theEvent);
172 QWidget* myHeaderWidget; ///< A header widget
174 ModuleBase_PageWidget* myPanelPage;
175 QList<ModuleBase_ModelWidget*> myWidgets;
177 /// Currently active widget
178 ModuleBase_ModelWidget* myActiveWidget;
179 /// Currently widget processed by preselection
180 ModuleBase_ModelWidget* myPreselectionWidget;
182 XGUI_OperationMgr* myOperationMgr;
185 #endif /* XGUI_PROPERTYPANEL_H_ */