]> SALOME platform Git repositories - modules/shaper.git/blob - src/XGUI/XGUI_ContextMenuMgr.h
Salome HOME
Update code documentation
[modules/shaper.git] / src / XGUI / XGUI_ContextMenuMgr.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
2
3 #ifndef XGUI_ContextMenuMgr_H
4 #define XGUI_ContextMenuMgr_H
5
6 #include "XGUI.h"
7
8 #include <QObject>
9 #include <QMap>
10
11 class XGUI_Workshop;
12 class QAction;
13 class QContextMenuEvent;
14 class QMenu;
15
16 /**
17  * A claas wihich provides manement of context menu
18  */
19 class XGUI_EXPORT XGUI_ContextMenuMgr : public QObject
20 {
21 Q_OBJECT
22  public:
23    /// Constructor
24    /// \param theParent a parent object
25   XGUI_ContextMenuMgr(XGUI_Workshop* theParent);
26   virtual ~XGUI_ContextMenuMgr();
27
28   /// Create all actions for context menus. It is called on creation of application
29   void createActions();
30
31   /// Returns action according to the given ID
32   /// \param theId an id of an action
33   QAction* action(const QString& theId) const;
34
35   /// Returns list of registered actions Ids
36   QStringList actionIds() const;
37
38   /// update state of internal commands
39   void updateCommandsStatus();
40
41   /// Connect to object browser from workshop. Has to called at creation of viewer.
42   void connectObjectBrowser() const;
43
44   /// Connect to viewer from workshop. Has to called at creation of viewer.
45   void connectViewer() const;
46
47   /// Add menu atems for viewer into the given menu (used in SALOME mode)
48   /// \param theMenu a menu instance
49   void addViewerItems(QMenu* theMenu) const;
50
51 signals:
52   /// Signal aabout triggered action
53   /// \param theId an id of triggered action
54   /// \param isChecked is checked flag
55   void actionTriggered(const QString& theId, bool isChecked);
56
57  private slots:
58    /// Process action event
59    /// \param isChecked a checked action flag
60   void onAction(bool isChecked);
61
62   /// Process context menu event
63   /// \param theEvent a context menu event
64   void onContextMenuRequest(QContextMenuEvent* theEvent);
65
66  private:
67   /** 
68    * Add action
69    * \param theId - string ID of the item
70    * \param theAction - action to add
71    */
72   void addAction(const QString& theId, QAction* theAction);
73
74   /// Creates menu for object browser
75   QMenu* objectBrowserMenu() const;
76
77   /// Creates menu for viewer
78   QMenu* viewerMenu() const;
79
80   /// Map of created actions [id : Action]
81   QMap<QString, QAction*> myActions;
82
83   /// Reference to workshop
84   XGUI_Workshop* myWorkshop;
85 };
86
87 #endif