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 object browser
65 void updateObjectBrowserMenu();
67 /// Updates menu for viewer
68 void updateViewerMenu();
71 /// Signal aabout triggered action
72 /// \param theId an id of triggered action
73 /// \param isChecked is checked flag
74 void actionTriggered(const QString& theId, bool isChecked);
76 /// A signal which is sent before context menu show
77 void beforeContextMenu();
79 /// A signal which is sent after context menu show
80 void afterContextMenu();
83 /// Process action event
84 /// \param isChecked a checked action flag
85 void onAction(bool isChecked);
87 /// Process context menu event
88 /// \param theEvent a context menu event
89 void onContextMenuRequest(QContextMenuEvent* theEvent);
93 /// Slot called on Result selection menu press
94 void onResultSelection(bool theChecked);
96 /// Slot called on any shape selection menu press
97 void onShapeSelection(bool theChecked);
102 * \param theId - string ID of the item
103 * \param theAction - action to add
105 void addAction(const QString& theId, QAction* theAction);
107 void addFeatures(QMenu* theMenu) const;
109 /// Creates menu for object browser
110 void buildObjBrowserMenu();
112 /// Creates menu for viewer
113 void buildViewerMenu();
115 /// Map of created actions [id : Action]
116 QMap<QString, QAction*> myActions;
118 /// Reference to workshop
119 XGUI_Workshop* myWorkshop;
121 typedef QList<QAction*> QActionsList;
122 QMap<std::string, QActionsList> myObjBrowserMenus;
123 QMap<std::string, QActionsList> myViewerMenu;
125 //QActionGroup* mySelectActions;
127 QAction* mySeparator;