Salome HOME
Issue #1114: Provide selection of origin and axis of trihedron with reference to...
[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   /// Slot to show message on closing of editor
75   void sendWarning();
76
77   /// Slot for reaction on selection in the table
78   void onSelectionChanged();
79
80 private:
81   /// Creates a new parameter feature
82   FeaturePtr createParameter() const;
83
84   /// Creates a new item
85   QTreeWidgetItem* createNewItem() const;
86
87   /// Returns currently selected item
88   QTreeWidgetItem* selectedItem() const;
89
90   /// Select the given Item and scroll the table to make it visible
91   void selectItemScroll(QTreeWidgetItem* theItem);
92
93   /// Update values in features part
94   void updateItem(QTreeWidgetItem* theItem, const QList<QStringList>& theFeaturesList);
95
96   void updateFeaturesPart();
97
98   void updateParametersPart();
99
100   /// Returns true if parameter with the given name already exists
101   bool hasName(const QString& theName) const;
102
103   QList<QStringList> featuresItems(const QList<FeaturePtr>& theFeatures) const;
104   QList<QStringList> parametersItems(const QList<FeaturePtr>& theFeatures) const;
105
106   void updateParametersFeatures();
107
108   QTreeWidget* myTable;
109   QTreeWidgetItem* myFeatures;
110   QTreeWidgetItem* myParameters;
111   ParametersPlugin_ItemDelegate* myDelegate;
112
113   QList<FeaturePtr> myParametersList;
114
115   QString myMessage;
116
117   QPushButton* myAddBtn;
118   QPushButton* myInsertBtn;
119   QPushButton* myRemoveBtn;
120   QToolButton* myUpBtn;
121   QToolButton* myDownBtn;
122 };
123
124
125 #endif