Salome HOME
Merge branch 'master' of newgeom:newgeom
[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 public slots:
35   //! Update workbench actions according to OperationMgr state:
36   //! No active operations: all actions but nested are available
37   //! There is active operation: current operation + it's nested
38   //! are enabled, all the rest is disabled. All active commands is checked.
39   void update();
40   //! Sets all commands checked if it's operation is active.
41   void updateCheckState();
42
43 protected:
44   //! Sets all actions to isEnabled state.
45   void setAllEnabled(bool isEnabled);
46   //! Sets all nested actions to isEnabled state for the command with given ID.
47   //! If ID is empty - all nested actions will be affected.
48   void setNestedCommandsEnabled(bool isEnabled, const QString& theParent = QString());
49   //! Sets the action with theId to theChecked state.
50   void setActionChecked(const QString& theId, const bool theChecked);
51   //! Sets the action with theId to theEnabled state.
52   void setActionEnabled(const QString& theId, const bool theEnabled);
53
54 private:
55   QMap<QString, QAction*> myActions;
56   QMap<QString, QStringList> myNestedActions;
57
58   XGUI_OperationMgr* myOperationMgr;
59 };
60
61 #endif /* XGUI_ACTIONSMGR_H_ */
62