Salome HOME
1ddd00d485eb40852266fe8f81815df46af84d62
[modules/shaper.git] / src / ParametersPlugin / ParametersPlugin_WidgetParamsMgr.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
2
3 // File:        ParametersPlugin_WidgetParamsMgr.h
4 // Created:     11 Apr 2016
5 // Author:      Vitaly SMETANNIKOV
6
7 #ifndef ParametersPlugin_WidgetParamsMgr_H_
8 #define ParametersPlugin_WidgetParamsMgr_H_
9
10 #include <ModuleBase_ModelWidget.h>
11 #include <QModelIndex>
12 #include <QAbstractItemDelegate>
13
14 class QTreeWidget;
15 class QTreeWidgetItem;
16 class ParametersPlugin_ItemDelegate;
17 class QPushButton;
18 class QToolButton;
19
20 /*!
21  * \ingroup GUI
22  * Represent a content of the property panel to show/modify parameters of some feature.
23  */
24 class ParametersPlugin_WidgetParamsMgr : public ModuleBase_ModelWidget
25 {
26  Q_OBJECT
27 public:
28   /// Constructs a model widget
29   ParametersPlugin_WidgetParamsMgr(QWidget* theParent, const Config_WidgetAPI* theData);
30
31   /// Destructs the model widget
32   virtual ~ParametersPlugin_WidgetParamsMgr() {}
33
34   /// Returns list of widget controls
35   /// \return a control list
36   virtual QList<QWidget*> getControls() const;
37
38 protected:
39   /// Saves the internal parameters to the given feature
40   /// \return True in success
41   virtual bool storeValueCustom();
42
43   /// Restore value from attribute data to the widget's control
44   virtual bool restoreValueCustom();
45
46   /// The method called when widget is activated
47   virtual void activateCustom();
48
49 private slots:
50   /// Slot for reaction on double click in the table (start editing)
51   /// \param theIndex the clicked index
52   void onDoubleClick(const QModelIndex& theIndex);
53
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);
58
59   /// Slot for reaction on add parameter
60   void onAdd();
61
62   /// Slot for reaction on insert parameter
63   void onInsert();
64
65   /// Slot for reaction on remove parameter
66   void onRemove();
67
68   /// Slot for reaction on shift up
69   void onUp();
70
71   /// Slot for reaction on shift down
72   void onDown();
73
74   void sendWarning();
75
76   void onSelectionChanged();
77
78 private:
79   FeaturePtr createParameter() const;
80   QTreeWidgetItem* createNewItem() const;
81   QTreeWidgetItem* selectedItem() const;
82   void selectItemScroll(QTreeWidgetItem* aItem);
83
84   void updateFeaturesPart();
85
86   bool hasName(const QString& theName) const;
87
88   QTreeWidget* myTable;
89   QTreeWidgetItem* myFeatures;
90   QTreeWidgetItem* myParameters;
91   ParametersPlugin_ItemDelegate* myDelegate;
92   QModelIndex myEditingIndex;
93
94   QList<FeaturePtr> myParametersList;
95
96   QString myMessage;
97
98   QPushButton* myAddBtn;
99   QPushButton* myInsertBtn;
100   QPushButton* myRemoveBtn;
101   QToolButton* myUpBtn;
102   QToolButton* myDownBtn;
103 };
104
105
106 #endif