Salome HOME
Issue #979: Manage parameters
[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
18 /*!
19  * \ingroup GUI
20  * Represent a content of the property panel to show/modify parameters of some feature.
21  */
22 class ParametersPlugin_WidgetParamsMgr : public ModuleBase_ModelWidget
23 {
24  Q_OBJECT
25 public:
26   /// Constructs a model widget
27   ParametersPlugin_WidgetParamsMgr(QWidget* theParent, const Config_WidgetAPI* theData);
28
29   /// Destructs the model widget
30   virtual ~ParametersPlugin_WidgetParamsMgr() {}
31
32   /// Returns list of widget controls
33   /// \return a control list
34   virtual QList<QWidget*> getControls() const;
35
36 protected:
37   /// Saves the internal parameters to the given feature
38   /// \return True in success
39   virtual bool storeValueCustom();
40
41   /// Restore value from attribute data to the widget's control
42   virtual bool restoreValueCustom();
43
44   /// The method called when widget is activated
45   virtual void activateCustom();
46
47 private slots:
48   /// Slot for reaction on double click in the table (start editing)
49   /// \param theIndex the clicked index
50   void onDoubleClick(const QModelIndex& theIndex);
51
52   /// Slot for reaction on end of cell editing
53   /// \param theEditor the editor widget
54   /// \param theHint end of edit type
55   void onCloseEditor(QWidget* theEditor, QAbstractItemDelegate::EndEditHint theHint);
56
57   /// Slot for reaction on add parameter
58   void onAdd();
59
60   /// Slot for reaction on insert parameter
61   void onInsert();
62
63   /// Slot for reaction on remove parameter
64   void onRemove();
65
66   /// Slot for reaction on shift up
67   void onUp();
68
69   /// Slot for reaction on shift down
70   void onDown();
71
72   void sendWarning();
73
74 private:
75   void updateFeaturesPart();
76
77   bool hasName(const QString& theName) const;
78
79   QTreeWidget* myTable;
80   QTreeWidgetItem* myFeatures;
81   QTreeWidgetItem* myParameters;
82   ParametersPlugin_ItemDelegate* myDelegate;
83   QModelIndex myEditingIndex;
84
85   QList<FeaturePtr> myParametersList;
86
87   QString myMessage;
88 };
89
90
91 #endif