1 // Copyright (C) 2014-2017 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<mailto:webmaster.salome@opencascade.com>
20 #ifndef ParametersPlugin_WidgetParamsMgr_H_
21 #define ParametersPlugin_WidgetParamsMgr_H_
23 #include <ModuleBase_ModelDialogWidget.h>
24 #include <QModelIndex>
25 #include <QAbstractItemDelegate>
26 #include <QTreeWidget>
28 class QTreeWidgetItem;
29 class ParametersPlugin_ItemDelegate;
36 * Redefinition of QTreeWidget for processing of closeEditor event
38 class ParametersPlugin_TreeWidget: public QTreeWidget
43 /// \param theParent a parent widget
44 ParametersPlugin_TreeWidget(QWidget* theParent = 0) : QTreeWidget(theParent) {}
47 /// Redefinition of virtual method
48 /// \param theEditor a editor widget
49 /// \param theHint end of editing hint
50 virtual void closeEditor(QWidget* theEditor, QAbstractItemDelegate::EndEditHint theHint);
57 * Represent a content of the property panel to show/modify parameters of some feature.
59 class ParametersPlugin_WidgetParamsMgr : public ModuleBase_ModelDialogWidget
63 /// Constructs a model widget
64 ParametersPlugin_WidgetParamsMgr(QWidget* theParent, const Config_WidgetAPI* theData);
66 /// Destructs the model widget
67 virtual ~ParametersPlugin_WidgetParamsMgr() {}
69 /// Returns list of widget controls
70 /// \return a control list
71 virtual QList<QWidget*> getControls() const;
74 /// Saves the internal parameters to the given feature
75 /// \return True in success
76 virtual bool storeValueCustom();
78 /// Restore value from attribute data to the widget's control
79 virtual bool restoreValueCustom();
81 /// The method called when widget is activated
82 virtual void activateCustom();
85 /// Slot for reaction on double click in the table (start editing)
86 /// \param theIndex the clicked index
87 void onDoubleClick(const QModelIndex& theIndex);
89 /// Slot for reaction on end of cell editing
90 /// \param theEditor the editor widget
91 /// \param theHint end of edit type
92 void onCloseEditor(QWidget* theEditor, QAbstractItemDelegate::EndEditHint theHint);
94 /// Slot for reaction on add parameter
97 /// Slot for reaction on insert parameter
100 /// Slot for reaction on remove parameter
103 /// Slot for reaction on shift up
106 /// Slot for reaction on shift down
109 /// Slot to show message on closing of editor
112 /// Slot for reaction on selection in the table
113 void onSelectionChanged();
116 /// Creates a new parameter feature
117 FeaturePtr createParameter() const;
119 /// Creates a new item
120 QTreeWidgetItem* createNewItem(QTreeWidgetItem* theParent) const;
122 /// Returns currently selected item
123 QTreeWidgetItem* selectedItem() const;
125 /// Select the given Item and scroll the table to make it visible
126 void selectItemScroll(QTreeWidgetItem* theItem);
128 /// Update values in features part
129 void updateItem(QTreeWidgetItem* theItem, const QList<QStringList>& theFeaturesList);
131 void updateFeaturesPart();
133 void updateParametersPart();
135 /// Returns true if values in the widget are valid
138 /// Returns true if parameter with the given name already exists
139 bool hasName(const QString& theName) const;
141 /// Enable or disable buttons for parameters managemnt
142 void enableButtons(bool theEnable);
144 QList<QStringList> featuresItems(const QList<FeaturePtr>& theFeatures,
145 QList<FeaturePtr>& theFeatureList) const;
146 QList<QStringList> parametersItems(const QList<FeaturePtr>& theFeatures) const;
148 void updateParametersFeatures();
150 ParametersPlugin_TreeWidget* myTable;
151 QTreeWidgetItem* myFeatures;
152 QTreeWidgetItem* myParameters;
153 ParametersPlugin_ItemDelegate* myDelegate;
155 QList<FeaturePtr> myParametersList;
159 QPushButton* myAddBtn;
160 QPushButton* myInsertBtn;
161 QPushButton* myRemoveBtn;
162 QToolButton* myUpBtn;
163 QToolButton* myDownBtn;