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_ModelWidget.h>
11 #include <QModelIndex>
12 #include <QAbstractItemDelegate>
13 #include <QTreeWidget>
15 class QTreeWidgetItem;
16 class ParametersPlugin_ItemDelegate;
21 class ParametersPlugin_TreeWidget: public QTreeWidget
25 ParametersPlugin_TreeWidget(QWidget* theParent = 0) : QTreeWidget(theParent) {}
28 virtual void closeEditor(QWidget* theEditor, QAbstractItemDelegate::EndEditHint theHint);
35 * Represent a content of the property panel to show/modify parameters of some feature.
37 class ParametersPlugin_WidgetParamsMgr : public ModuleBase_ModelWidget
41 /// Constructs a model widget
42 ParametersPlugin_WidgetParamsMgr(QWidget* theParent, const Config_WidgetAPI* theData);
44 /// Destructs the model widget
45 virtual ~ParametersPlugin_WidgetParamsMgr() {}
47 /// Returns list of widget controls
48 /// \return a control list
49 virtual QList<QWidget*> getControls() const;
52 /// Saves the internal parameters to the given feature
53 /// \return True in success
54 virtual bool storeValueCustom();
56 /// Restore value from attribute data to the widget's control
57 virtual bool restoreValueCustom();
59 /// The method called when widget is activated
60 virtual void activateCustom();
63 /// Slot for reaction on double click in the table (start editing)
64 /// \param theIndex the clicked index
65 void onDoubleClick(const QModelIndex& theIndex);
67 /// Slot for reaction on end of cell editing
68 /// \param theEditor the editor widget
69 /// \param theHint end of edit type
70 void onCloseEditor(QWidget* theEditor, QAbstractItemDelegate::EndEditHint theHint);
72 /// Slot for reaction on add parameter
75 /// Slot for reaction on insert parameter
78 /// Slot for reaction on remove parameter
81 /// Slot for reaction on shift up
84 /// Slot for reaction on shift down
87 /// Slot to show message on closing of editor
90 /// Slot for reaction on selection in the table
91 void onSelectionChanged();
94 /// Creates a new parameter feature
95 FeaturePtr createParameter() const;
97 /// Creates a new item
98 QTreeWidgetItem* createNewItem() const;
100 /// Returns currently selected item
101 QTreeWidgetItem* selectedItem() const;
103 /// Select the given Item and scroll the table to make it visible
104 void selectItemScroll(QTreeWidgetItem* theItem);
106 /// Update values in features part
107 void updateItem(QTreeWidgetItem* theItem, const QList<QStringList>& theFeaturesList);
109 void updateFeaturesPart();
111 void updateParametersPart();
113 /// Returns true if parameter with the given name already exists
114 bool hasName(const QString& theName) const;
116 QList<QStringList> featuresItems(const QList<FeaturePtr>& theFeatures) const;
117 QList<QStringList> parametersItems(const QList<FeaturePtr>& theFeatures) const;
119 void updateParametersFeatures();
121 ParametersPlugin_TreeWidget* myTable;
122 QTreeWidgetItem* myFeatures;
123 QTreeWidgetItem* myParameters;
124 ParametersPlugin_ItemDelegate* myDelegate;
126 QList<FeaturePtr> myParametersList;
130 QPushButton* myAddBtn;
131 QPushButton* myInsertBtn;
132 QPushButton* myRemoveBtn;
133 QToolButton* myUpBtn;
134 QToolButton* myDownBtn;