1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
3 // File: ParametersPlugin_WidgetParamsMgr.h
4 // Created: 11 Apr 2016
5 // Author: Vitaly SMETANNIKOV
7 #ifndef ParametersPlugin_WidgetParamsMgr_H_
8 #define ParametersPlugin_WidgetParamsMgr_H_
10 #include <ModuleBase_ModelDialogWidget.h>
11 #include <QModelIndex>
12 #include <QAbstractItemDelegate>
13 #include <QTreeWidget>
15 class QTreeWidgetItem;
16 class ParametersPlugin_ItemDelegate;
23 * Redefinition of QTreeWidget for processing of closeEditor event
25 class ParametersPlugin_TreeWidget: public QTreeWidget
30 /// \param theParent a parent widget
31 ParametersPlugin_TreeWidget(QWidget* theParent = 0) : QTreeWidget(theParent) {}
34 /// Redefinition of virtual method
35 /// \param theEditor a editor widget
36 /// \param theHint end of editing hint
37 virtual void closeEditor(QWidget* theEditor, QAbstractItemDelegate::EndEditHint theHint);
44 * Represent a content of the property panel to show/modify parameters of some feature.
46 class ParametersPlugin_WidgetParamsMgr : public ModuleBase_ModelDialogWidget
50 /// Constructs a model widget
51 ParametersPlugin_WidgetParamsMgr(QWidget* theParent, const Config_WidgetAPI* theData);
53 /// Destructs the model widget
54 virtual ~ParametersPlugin_WidgetParamsMgr() {}
56 /// Returns list of widget controls
57 /// \return a control list
58 virtual QList<QWidget*> getControls() const;
61 /// Saves the internal parameters to the given feature
62 /// \return True in success
63 virtual bool storeValueCustom();
65 /// Restore value from attribute data to the widget's control
66 virtual bool restoreValueCustom();
68 /// The method called when widget is activated
69 virtual void activateCustom();
72 /// Slot for reaction on double click in the table (start editing)
73 /// \param theIndex the clicked index
74 void onDoubleClick(const QModelIndex& theIndex);
76 /// Slot for reaction on end of cell editing
77 /// \param theEditor the editor widget
78 /// \param theHint end of edit type
79 void onCloseEditor(QWidget* theEditor, QAbstractItemDelegate::EndEditHint theHint);
81 /// Slot for reaction on add parameter
84 /// Slot for reaction on insert parameter
87 /// Slot for reaction on remove parameter
90 /// Slot for reaction on shift up
93 /// Slot for reaction on shift down
96 /// Slot to show message on closing of editor
99 /// Slot for reaction on selection in the table
100 void onSelectionChanged();
103 /// Creates a new parameter feature
104 FeaturePtr createParameter() const;
106 /// Creates a new item
107 QTreeWidgetItem* createNewItem(QTreeWidgetItem* theParent) const;
109 /// Returns currently selected item
110 QTreeWidgetItem* selectedItem() const;
112 /// Select the given Item and scroll the table to make it visible
113 void selectItemScroll(QTreeWidgetItem* theItem);
115 /// Update values in features part
116 void updateItem(QTreeWidgetItem* theItem, const QList<QStringList>& theFeaturesList);
118 void updateFeaturesPart();
120 void updateParametersPart();
122 /// Returns true if values in the widget are valid
125 /// Returns true if parameter with the given name already exists
126 bool hasName(const QString& theName) const;
128 /// Enable or disable buttons for parameters managemnt
129 void enableButtons(bool theEnable);
131 QList<QStringList> featuresItems(const QList<FeaturePtr>& theFeatures,
132 QList<FeaturePtr>& theFeatureList) const;
133 QList<QStringList> parametersItems(const QList<FeaturePtr>& theFeatures) const;
135 void updateParametersFeatures();
137 ParametersPlugin_TreeWidget* myTable;
138 QTreeWidgetItem* myFeatures;
139 QTreeWidgetItem* myParameters;
140 ParametersPlugin_ItemDelegate* myDelegate;
142 QList<FeaturePtr> myParametersList;
146 QPushButton* myAddBtn;
147 QPushButton* myInsertBtn;
148 QPushButton* myRemoveBtn;
149 QToolButton* myUpBtn;
150 QToolButton* myDownBtn;