1 // Copyright (C) 2014-2019 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #ifndef XGUI_PROPERTYPANEL_H_
21 #define XGUI_PROPERTYPANEL_H_
25 #include <ModuleBase_ModelWidget.h>
26 #include <ModuleBase_IPropertyPanel.h>
30 class XGUI_ActionsMgr;
34 class ModuleBase_PageBase;
35 class ModuleBase_PageWidget;
36 class XGUI_OperationMgr;
38 /// Internal name of property panel widget
39 const static char* PROP_PANEL = "property_panel_dock";
41 /// Internal name of Ok button
42 const static char* PROP_PANEL_OK = "property_panel_ok";
44 /// Internal name of Ok button
45 const static char* PROP_PANEL_OK_PLUS = "property_panel_ok_plus";
47 /// Internal name of Cancel button
48 const static char* PROP_PANEL_CANCEL = "property_panel_cancel";
50 /// Internal name of Help button
51 const static char* PROP_PANEL_HELP = "property_panel_help";
53 /// Internal name of Preview button
54 const static char* PROP_PANEL_PREVIEW = "property_panel_preview";
58 * Realization of Property panel object.
60 class XGUI_EXPORT XGUI_PropertyPanel : public ModuleBase_IPropertyPanel
66 /// \param theParent is a parent of the property panel
67 /// \param theMgr operation manager
68 XGUI_PropertyPanel(QWidget* theParent, XGUI_OperationMgr* theMgr);
70 virtual ~XGUI_PropertyPanel();
72 /// Returns header widget
73 virtual QWidget* headerWidget() const { return myHeaderWidget; }
75 /// Returns main widget of the property panel, which children will be created
76 /// by WidgetFactory using the XML definition
77 ModuleBase_PageBase* contentWidget();
79 /// Brings back all widget created by widget factory for signal/slot
80 /// connections and further processing
81 void setModelWidgets(const QList<ModuleBase_ModelWidget*>& theWidgets);
83 /// Returns all property panel's widget created by WidgetFactory
84 virtual const QList<ModuleBase_ModelWidget*>& modelWidgets() const;
86 /// Removes all widgets in the widget area of the property panel
87 virtual void cleanContent();
89 /// Returns currently active widget. This is a widget from internal container of widgets
90 /// (myWidgets) activated/deactivated by focus in property panel. If parameter is true,
91 /// the method finds firstly the custom widget, after the direct active widget.
92 /// \param isUseCustomWidget boolean state if the custom widget might be a result
93 virtual ModuleBase_ModelWidget* activeWidget(const bool isUseCustomWidget = false) const;
95 /// Activate the next widget in the property panel
96 /// \param theWidget a widget. The next widget should be activated
97 virtual void activateNextWidget(ModuleBase_ModelWidget* theWidget);
99 /// Activate the next from current widget in the property panel
100 virtual void activateNextWidget();
102 /// Set focus on the Ok button
103 virtual void setFocusOnOkButton();
105 /// Set Enable/Disable state of Cancel button
106 /// \param theEnabled Enable/Disable state of Cancel button
107 virtual void setCancelEnabled(bool theEnabled);
109 /// \return Enable/Disable state of Cancel button
110 virtual bool isCancelEnabled() const;
112 /// Editing mode depends on mode of current operation. This value is defined by it.
113 /// \param isEditing state of editing mode flag
114 virtual void setEditingMode(bool isEditing);
116 //! Allows to set predefined actions for the property panel fetched from the ActionsMgr
117 void setupActions(XGUI_ActionsMgr* theMgr);
119 /// Returns widget processed by preselection
120 virtual ModuleBase_ModelWidget* preselectionWidget() const;
122 /// Sets widget processed by preselection
123 virtual void setPreselectionWidget(ModuleBase_ModelWidget* theWidget);
125 /// Returns operation manager
126 XGUI_OperationMgr* operationMgr() const { return myOperationMgr; }
128 /// Find under the panel a child button with the parameter name
129 /// \param theInternalName a button object name
130 /// \return button instance or NULL
131 QToolButton* findButton(const char* theInternalName) const;
133 /// Possibility to process focus by method, for example when Tab or SHIF+Tab is pressed
134 /// but property panel is not active widget
135 /// \param theIsNext true, if Tab(to the next widget) or false(moving to the previous)
136 bool setFocusNextPrevChild(bool theIsNext);
138 /// The method is called on accepting of operation
139 virtual void onAcceptData();
141 /// Set internal active widget, that can be returned as active widget and participate in active
142 /// selection filters/modes in application. It emits signal about property panel activation or
143 /// deactivation and updates selection filters/modes accordingly.
144 /// \param theWidget a widget control to store as internal active widget
145 void setInternalActiveWidget(ModuleBase_ModelWidget* theWidget);
147 void updateApplyPlusButton(FeaturePtr theFeature);
150 /// \brief Update all widgets in property panel with values from the given feature
151 /// \param theFeature a Feature to update values in widgets
152 void updateContentWidget(FeaturePtr theFeature);
154 /// \brief If the XML definition of the feature contains information about specific
155 /// content of the property panel, it creates the panel and allow filling it by the given feature
156 /// \param theFeature a Feature to fill property panel
157 void createContentPanel(FeaturePtr theFeature);
160 * Makes the given widget active, highlights it and removes
161 * highlighting from the previous active widget
162 * \param theWidget which has to be activated
163 * \param theEmitSignal a flag to prohibit signal emit
165 virtual void activateWidget(ModuleBase_ModelWidget* theWidget, const bool theEmitSignal = true);
167 /// Activates the parameter widget if it can accept focus
168 /// \param theWidget a widget where focus in event happened
169 void onFocusInWidget(ModuleBase_ModelWidget* theWidget);
172 /// Activate next widget
173 /// \param theWidget the current widget
174 void onActivateNextWidget(ModuleBase_ModelWidget* theWidget);
177 /// The signal is emitted if the enter is clicked in the control of the widget
178 /// \param theObject a sender of the event
179 void enterClicked(QObject* theObject);
181 /// Emits on deactivating property panel (e.g. by clearContent)
182 void propertyPanelDeactivated();
183 /// Emits on widget activating
184 void propertyPanelActivated();
187 /// Makes the widget active, deactivate the previous, activate and hightlight the given one
188 /// \param theWidget a widget
189 /// \param isEmitSignal flag whether panel signals should be emitted
190 bool setActiveWidget(ModuleBase_ModelWidget* theWidget, const bool isEmitSignal);
191 /// The parent method that processes the "Tab"/"SHIF + Tab" keyboard events
192 /// Emits a signal about focus change
193 /// If theIsNext is true, this function searches forward, if next is false, it searches backward.
194 virtual bool focusNextPrevChild(bool theIsNext);
195 /// Activate the next widget in the property panel
196 /// \param theWidget a widget. The next widget should be activated
197 /// \param isCheckVisibility flag whether the next widget visibility is checked
198 void activateNextWidget(ModuleBase_ModelWidget* theWidget,
199 const bool isCheckVisibility);
202 /// A method called on the property panel closed
203 /// \param theEvent a close event
204 void closeEvent(QCloseEvent* theEvent);
207 QWidget* myHeaderWidget; ///< A header widget
209 ModuleBase_PageWidget* myPanelPage;
210 QList<ModuleBase_ModelWidget*> myWidgets;
212 /// Currently active widget
213 ModuleBase_ModelWidget* myActiveWidget;
214 /// Currently widget processed by preselection
215 ModuleBase_ModelWidget* myPreselectionWidget;
216 /// Some custom widget set from outside
217 ModuleBase_ModelWidget* myInternalActiveWidget;
219 XGUI_OperationMgr* myOperationMgr;
222 #endif /* XGUI_PROPERTYPANEL_H_ */