1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
3 #ifndef XGUI_ContextMenuMgr_H
4 #define XGUI_ContextMenuMgr_H
13 class QContextMenuEvent;
19 * A claas wihich provides manement of context menu
21 class XGUI_EXPORT XGUI_ContextMenuMgr : public QObject
26 /// \param theParent a parent object
27 XGUI_ContextMenuMgr(XGUI_Workshop* theParent);
28 virtual ~XGUI_ContextMenuMgr();
30 /// Create all actions for context menus. It is called on creation of application
33 /// Returns action according to the given ID
34 /// \param theId an id of an action
35 QAction* action(const QString& theId) const;
37 /// Returns action object by its Id (name)
38 /// \param theName is an Id of the action
39 QAction* actionByName(const QString& theName) const;
41 /// Returns list of registered actions Ids
42 QStringList actionIds() const;
44 /// update state of internal commands
45 void updateCommandsStatus();
47 /// Connect to object browser from workshop. Has to called at creation of viewer.
48 void connectObjectBrowser();
50 /// Connect to viewer from workshop. Has to called at creation of viewer.
53 /// Add menu items for Object browser pop-up
54 void addObjBrowserMenu(QMenu*) const;
56 /// Add menu items for Viewer pop-up
57 void addViewerMenu(QMenu*) const;
59 /// Returns a list of object group names of the action
60 /// \param theName a name of the action
61 /// \return a list of group names
62 QStringList actionObjectGroups(const QString& theName);
64 /// Updates menu for viewer
65 void updateViewerMenu();
68 /// Signal aabout triggered action
69 /// \param theId an id of triggered action
70 /// \param isChecked is checked flag
71 void actionTriggered(const QString& theId, bool isChecked);
73 /// A signal which is sent before context menu show
74 void beforeContextMenu();
76 /// A signal which is sent after context menu show
77 void afterContextMenu();
80 /// Process action event
81 /// \param isChecked a checked action flag
82 void onAction(bool isChecked);
84 /// Process context menu event
85 /// \param theEvent a context menu event
86 void onContextMenuRequest(QContextMenuEvent* theEvent);
93 * \param theId - string ID of the item
94 * \param theAction - action to add
96 void addAction(const QString& theId, QAction* theAction);
98 void addFeatures(QMenu* theMenu) const;
100 /// Updates menu for object browser
101 void updateObjectBrowserMenu();
103 /// Creates menu for object browser
104 void buildObjBrowserMenu();
106 /// Creates menu for viewer
107 void buildViewerMenu();
109 /// Map of created actions [id : Action]
110 QMap<QString, QAction*> myActions;
112 /// Reference to workshop
113 XGUI_Workshop* myWorkshop;
115 typedef QList<QAction*> QActionsList;
116 QMap<std::string, QActionsList> myObjBrowserMenus;
117 QMap<std::string, QActionsList> myViewerMenu;
119 QActionGroup* mySelectActions;
121 QAction* mySeparator;