Salome HOME
Merge branch 'master' of newgeom:newgeom.git
[modules/shaper.git] / src / XGUI / XGUI_ActionsMgr.h
1 /*
2  * XGUI_ActionsMgr.h
3  */
4
5 #ifndef XGUI_ACTIONSMGR_H_
6 #define XGUI_ACTIONSMGR_H_
7
8 #include "XGUI.h"
9
10 #include <QObject>
11 #include <QMap>
12 #include <QStringList>
13
14 class XGUI_Command;
15 class XGUI_Workshop;
16 class XGUI_OperationMgr;
17 class QAction;
18
19 class XGUI_EXPORT XGUI_ActionsMgr: public QObject
20 {
21   Q_OBJECT
22
23 public:
24   XGUI_ActionsMgr(XGUI_Workshop* theWorkshop);
25   virtual ~XGUI_ActionsMgr();
26
27   //! Add a command in the manager.
28   //! Please note that nested commands in the Salome mode (No XGUI_Command, pure QActions)
29   //! won't be extracted and should be added manually using the addNestedCommands method.
30   void addCommand(QAction* theCmd);
31   //! Sets relation between the command (with given Id) and it's nested actions.
32   void addNestedCommands(const QString& theId, const QStringList& theCommands);
33
34   QStringList nestedCommands(const QString& theId) const;
35
36   bool isNested(const QString& theId) const;
37
38 public slots:
39   //! Update workbench actions according to OperationMgr state:
40   //! No active operations: all actions but nested are available
41   //! There is active operation: current operation + it's nested
42   //! are enabled, all the rest is disabled. All active commands is checked.
43   void update();
44   //! Sets all commands checked if it's operation is active.
45   void updateCheckState();
46
47 protected:
48   //! Sets all actions to isEnabled state.
49   void setAllEnabled(bool isEnabled);
50   //! Sets all nested actions to isEnabled state for the command with given ID.
51   //! If ID is empty - all nested actions will be affected.
52   void setNestedCommandsEnabled(bool isEnabled, const QString& theParent = QString());
53   //! Sets the action with theId to theChecked state.
54   void setActionChecked(const QString& theId, const bool theChecked);
55   //! Sets the action with theId to theEnabled state.
56   void setActionEnabled(const QString& theId, const bool theEnabled);
57
58 private:
59   QMap<QString, QAction*> myActions;
60   QMap<QString, QStringList> myNestedActions;
61
62   XGUI_OperationMgr* myOperationMgr;
63 };
64
65 #endif /* XGUI_ACTIONSMGR_H_ */
66