1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
3 #ifndef XGUI_ContextMenuMgr_H
4 #define XGUI_ContextMenuMgr_H
13 class QContextMenuEvent;
18 * A claas wihich provides manement of context menu
20 class XGUI_EXPORT XGUI_ContextMenuMgr : public QObject
25 /// \param theParent a parent object
26 XGUI_ContextMenuMgr(XGUI_Workshop* theParent);
27 virtual ~XGUI_ContextMenuMgr();
29 /// Create all actions for context menus. It is called on creation of application
32 /// Returns action according to the given ID
33 /// \param theId an id of an action
34 QAction* action(const QString& theId) const;
36 /// Returns action object by its Id (name)
37 /// \param theName is an Id of the action
38 QAction* actionByName(const QString& theName) const;
40 /// Returns list of registered actions Ids
41 QStringList actionIds() const;
43 /// update state of internal commands
44 void updateCommandsStatus();
46 /// Connect to object browser from workshop. Has to called at creation of viewer.
47 void connectObjectBrowser();
49 /// Connect to viewer from workshop. Has to called at creation of viewer.
52 QMenu* objBrowserMenu() const;
53 QMenu* viewerMenu() const;
55 /// Returns a list of object group names of the action
56 /// \param theName a name of the action
57 /// \return a list of group names
58 QStringList actionObjectGroups(const QString& theName);
61 /// Signal aabout triggered action
62 /// \param theId an id of triggered action
63 /// \param isChecked is checked flag
64 void actionTriggered(const QString& theId, bool isChecked);
66 /// A signal which is sent before context menu show
67 void beforeContextMenu();
69 /// A signal which is sent after context menu show
70 void afterContextMenu();
73 /// Process action event
74 /// \param isChecked a checked action flag
75 void onAction(bool isChecked);
77 /// Process context menu event
78 /// \param theEvent a context menu event
79 void onContextMenuRequest(QContextMenuEvent* theEvent);
84 * \param theId - string ID of the item
85 * \param theAction - action to add
87 void addAction(const QString& theId, QAction* theAction);
89 /// Updates menu for object browser
90 void updateObjectBrowserMenu();
92 /// Updates menu for viewer
93 void updateViewerMenu();
95 /// Creates menu for object browser
96 void buildObjBrowserMenu();
98 /// Creates menu for viewer
99 void buildViewerMenu();
101 /// Map of created actions [id : Action]
102 QMap<QString, QAction*> myActions;
104 /// Reference to workshop
105 XGUI_Workshop* myWorkshop;
107 typedef QList<QAction*> QActionsList;
108 QMap<std::string, QActionsList> myObjBrowserMenus;
109 QMap<std::string, QActionsList> myViewerMenu;
111 QAction* mySeparator;