Salome HOME
f86f9bd3235a16ec4f2e62e4b26578576cee4e61
[modules/shaper.git] / src / SHAPERGUI / SHAPERGUI_ToolbarsMgr.h
1 // Copyright (C) 2014-2017  CEA/DEN, EDF R&D
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or
18 // email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
19 //
20
21 #ifndef SHAPERGUI_ToolbarsMgr_H
22 #define SHAPERGUI_ToolbarsMgr_H
23
24 #include "SHAPER_SHAPERGUI.h"
25
26 #include <Qtx.h>
27
28 #include <QDialog>
29 #include <QString>
30 #include <QStringList>
31 #include <QMap>
32
33 class QListWidget;
34 class SHAPERGUI;
35 class QLabel;
36
37 /**
38 * \ingroup Salome
39 * A dialog box for editing of toolbar items
40 */
41 class SHAPERGUI_ToolbarItemsDlg : public QDialog
42 {
43   Q_OBJECT
44 public:
45   /// Constructor
46   /// \param theParent a parent for the dialog
47   /// \param theModule a module with toolbars
48   /// \param theToolbar a name of the toolbar for editing
49   /// \param theFreeItems a list of commands out of toolbars
50   /// \param theItemsList a list of command in the toolbar
51   SHAPERGUI_ToolbarItemsDlg(QWidget* theParent,
52     SHAPERGUI* theModule,
53     const QString& theToolbar,
54     const QIntList& theFreeItems,
55     const QIntList& theItemsList);
56
57   /// Returns list of free commands
58   QIntList freeItems() const;
59
60   /// Returns list of commands in the toolbar
61   QIntList toolbarItems() const;
62
63 protected:
64   /// An redifinition of a virtual function
65   /// \param theObj an object
66   /// \param theEvent an event
67   virtual bool eventFilter(QObject* theObj, QEvent* theEvent);
68
69 private slots:
70   /// A slot for button to add an item to toolbar commands
71   void onAddItem();
72
73   /// A slot for button to remove an item from toolbar commands
74   void onDelItem();
75
76   /// A slot to move a current item up in list of toolbar command
77   void onUp();
78
79   /// A slot to move a current item down in list of toolbar command
80   void onDown();
81
82   /// A slot on help call
83   void onHelp();
84
85 private:
86   QIntList getItems(QListWidget* theWidget, int theStart) const;
87
88   SHAPERGUI* myModule;
89
90   QListWidget* myCommandsList;
91   QListWidget* myItemsList;
92 };
93
94
95 /**
96 * \ingroup Salome
97 * A dialog box for toolbars management
98 */
99 class SHAPERGUI_ToolbarsDlg : public QDialog
100 {
101   Q_OBJECT
102 public:
103   /// Constructor
104   /// \param theModule a SHAPER module
105   SHAPERGUI_ToolbarsDlg(SHAPERGUI* theModule);
106
107   /// Returns result of editing
108   QMap<QString, QIntList> result() const { return myResult; }
109
110   /// Returns a flag of resetted toolbars structure
111   bool isReset() const {
112     return myIsReset;
113   }
114
115 private slots:
116   /// A slot to add a new toolbar
117   void onAdd();
118
119   /// A slot to edit a current toolbar
120   void onEdit();
121
122   /// A slot to delete a current toolbar
123   void onDelete();
124
125   /// A slot to reset toolbars
126   void onReset();
127
128   /// A slot on help call
129   void onHelp();
130
131   /// A slot called on double click on item in list
132   void onDoubleClick(const QModelIndex& theIdx);
133
134 private:
135   /// Update content of toolbars list
136   void updateToolbarsList();
137
138   /// Update number of free items
139   void updateNumber();
140
141 private:
142   SHAPERGUI* myModule;
143   QMap<QString, QIntList> myResult;
144   QIntList myFreeCommands;
145
146   QLabel* myFreeNbLbl;
147   QListWidget* myToolbarsList;
148
149   bool myIsReset;
150 };
151
152
153 #endif