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>
15 class QTreeWidgetItem;
16 class ParametersPlugin_ItemDelegate;
22 * Represent a content of the property panel to show/modify parameters of some feature.
24 class ParametersPlugin_WidgetParamsMgr : public ModuleBase_ModelWidget
28 /// Constructs a model widget
29 ParametersPlugin_WidgetParamsMgr(QWidget* theParent, const Config_WidgetAPI* theData);
31 /// Destructs the model widget
32 virtual ~ParametersPlugin_WidgetParamsMgr() {}
34 /// Returns list of widget controls
35 /// \return a control list
36 virtual QList<QWidget*> getControls() const;
39 /// Saves the internal parameters to the given feature
40 /// \return True in success
41 virtual bool storeValueCustom();
43 /// Restore value from attribute data to the widget's control
44 virtual bool restoreValueCustom();
46 /// The method called when widget is activated
47 virtual void activateCustom();
50 /// Slot for reaction on double click in the table (start editing)
51 /// \param theIndex the clicked index
52 void onDoubleClick(const QModelIndex& theIndex);
54 /// Slot for reaction on end of cell editing
55 /// \param theEditor the editor widget
56 /// \param theHint end of edit type
57 void onCloseEditor(QWidget* theEditor, QAbstractItemDelegate::EndEditHint theHint);
59 /// Slot for reaction on add parameter
62 /// Slot for reaction on insert parameter
65 /// Slot for reaction on remove parameter
68 /// Slot for reaction on shift up
71 /// Slot for reaction on shift down
74 /// Slot to show message on closing of editor
77 /// Slot for reaction on selection in the table
78 void onSelectionChanged();
81 /// Creates a new parameter feature
82 FeaturePtr createParameter() const;
84 /// Creates a new item
85 QTreeWidgetItem* createNewItem() const;
87 /// Returns currently selected item
88 QTreeWidgetItem* selectedItem() const;
90 /// Select the given Item and scroll the table to make it visible
91 void selectItemScroll(QTreeWidgetItem* theItem);
93 /// Update values in features part
94 void updateItem(QTreeWidgetItem* theItem, const QList<QStringList>& theFeaturesList);
96 void updateFeaturesPart();
98 void updateParametersPart();
100 /// Returns true if parameter with the given name already exists
101 bool hasName(const QString& theName) const;
103 QList<QStringList> featuresItems(const QList<FeaturePtr>& theFeatures) const;
104 QList<QStringList> parametersItems(const QList<FeaturePtr>& theFeatures) const;
106 void updateParametersFeatures();
108 QTreeWidget* myTable;
109 QTreeWidgetItem* myFeatures;
110 QTreeWidgetItem* myParameters;
111 ParametersPlugin_ItemDelegate* myDelegate;
113 QList<FeaturePtr> myParametersList;
117 QPushButton* myAddBtn;
118 QPushButton* myInsertBtn;
119 QPushButton* myRemoveBtn;
120 QToolButton* myUpBtn;
121 QToolButton* myDownBtn;