]> SALOME platform Git repositories - modules/shaper.git/blob - src/ModuleBase/ModuleBase_IPropertyPanel.h
Salome HOME
Merge branch 'master' of salome:modules/shaper
[modules/shaper.git] / src / ModuleBase / ModuleBase_IPropertyPanel.h
1 // Copyright (C) 2014-2017  CEA/DEN, EDF R&D
2 //
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.
7 //
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.
12 //
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
16 //
17 // See http://www.salome-platform.org/ or
18 // email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
19 //
20
21 #ifndef ModuleBase_PROPERTYPANEL_H_
22 #define ModuleBase_PROPERTYPANEL_H_
23
24 #include "ModuleBase.h"
25
26 #include <QDockWidget>
27 #include <QKeyEvent>
28
29 class ModuleBase_ModelWidget;
30
31 /**
32 * \ingroup GUI
33 * A class for Property panel object definition
34 */
35 class MODULEBASE_EXPORT ModuleBase_IPropertyPanel : public QDockWidget
36 {
37 Q_OBJECT
38 public:
39   /// Constructor
40   /// \param theParent is a parent of the property panel
41   ModuleBase_IPropertyPanel(QWidget* theParent);
42
43   /// Returns header widget
44   virtual QWidget* headerWidget() const = 0;
45
46   /// Returns currently active widget
47   virtual ModuleBase_ModelWidget* activeWidget() const = 0;
48
49   /// Returns all property panel's widget created by WidgetFactory
50   virtual const QList<ModuleBase_ModelWidget*>& modelWidgets() const = 0;
51
52   /// Returns widget, that has the given attribute index
53   /// \param theAttributeId an attribute from XML
54   virtual ModuleBase_ModelWidget* modelWidget(const std::string& theAttributeId) const;
55
56   /// Removes all widgets in the widget area of the property panel
57   virtual void cleanContent() = 0;
58
59   /// Editing mode depends on mode of current operation. This value is defined by it.
60   /// \param isEditing state of editing mode flag
61   virtual void setEditingMode(bool isEditing) { myIsEditing = isEditing; }
62
63   /// \return State of editing mode flag
64   bool isEditingMode() const { return myIsEditing; }
65
66   /// Set focus on the Ok button
67   virtual void setFocusOnOkButton() = 0;
68
69   /// Set Enable/Disable state of Cancel button
70   /// \param theEnabled Enable/Disable state of Cancel button
71   virtual void setCancelEnabled(bool theEnabled) = 0;
72
73   /// \return Enable/Disable state of Cancel button
74   virtual bool isCancelEnabled() const = 0;
75
76   /// Returns widget processed by preselection
77   virtual ModuleBase_ModelWidget* preselectionWidget() const = 0;
78
79   /// Sets widget processed by preselection
80   virtual void setPreselectionWidget(ModuleBase_ModelWidget* theWidget) = 0;
81
82   /// Returns the first widget, where canAcceptFocus returns true
83   /// \return a widget or null
84   ModuleBase_ModelWidget* findFirstAcceptingValueWidget();
85
86   /// The method is called on accepting of operation
87   virtual void onAcceptData() = 0;
88
89   /// Returns the first widget, where canAcceptFocus returns true
90   /// \return a widget or null
91   static ModuleBase_ModelWidget* findFirstAcceptingValueWidget(
92                           const QList<ModuleBase_ModelWidget*>& theWidgets);
93
94 signals:
95   /// The signal about key release on the control, that corresponds to the attribute
96   /// \param theObject a sender of the event
97   /// \param theEvent key release event
98   void keyReleased(QObject* theObject, QKeyEvent* theEvent);
99
100   /// The signal about the widget activation
101   /// \param theWidget the activated widget
102   void beforeWidgetActivated(ModuleBase_ModelWidget* theWidget);
103
104   /// The signal about the widget activation
105   /// \param theWidget the activated widget
106   //void widgetActivated(ModuleBase_ModelWidget* theWidget);
107
108   /// Emited when there is no next widget
109   /// \param thePreviousAttributeID an attribute key of the previous active widget
110   void noMoreWidgets(const std::string& thePreviousAttributeID);
111
112 public slots:
113   /// Activate the next widget in the property panel
114   /// \param theWidget a widget. The next widget should be activated
115   virtual void activateNextWidget(ModuleBase_ModelWidget* theWidget) = 0;
116
117   /// Activate the next from current widget in the property panel
118   virtual void activateNextWidget() = 0;
119
120   /**
121   * Makes the given widget active, highlights it and removes
122   * highlighting from the previous active widget
123   * \param theWidget which has to be activated
124   * \param theEmitSignal a flag to prohibit signal emit
125   */
126   virtual void activateWidget(ModuleBase_ModelWidget* theWidget,
127                               const bool theEmitSignal = true) = 0;
128
129 protected:
130
131   /// Flag which shows that current operation is in editing mode
132   bool myIsEditing;
133 };
134
135 #endif