1 // Copyright (C) 2014-2017 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or
18 // email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
21 #ifndef XGUI_ContextMenuMgr_H
22 #define XGUI_ContextMenuMgr_H
31 class QContextMenuEvent;
37 * A claas wihich provides manement of context menu
39 class XGUI_EXPORT XGUI_ContextMenuMgr : public QObject
44 /// \param theParent a parent object
45 XGUI_ContextMenuMgr(XGUI_Workshop* theParent);
46 virtual ~XGUI_ContextMenuMgr();
48 /// Create all actions for context menus. It is called on creation of application
51 /// Returns action according to the given ID
52 /// \param theId an id of an action
53 QAction* action(const QString& theId) const;
55 /// Returns action object by its Id (name)
56 /// \param theName is an Id of the action
57 QAction* actionByName(const QString& theName) const;
59 /// Returns list of registered actions Ids
60 QStringList actionIds() const;
62 /// update state of internal commands
63 void updateCommandsStatus();
65 /// Connect to object browser from workshop. Has to called at creation of viewer.
66 void connectObjectBrowser();
68 /// Connect to viewer from workshop. Has to called at creation of viewer.
71 /// Add menu items for Object browser pop-up
72 void addObjBrowserMenu(QMenu*) const;
74 /// Add menu items for Viewer pop-up
75 void addViewerMenu(QMenu*) const;
77 /// Returns a list of object group names of the action
78 /// \param theName a name of the action
79 /// \return a list of group names
80 QStringList actionObjectGroups(const QString& theName);
82 /// Updates menu for object browser
83 void updateObjectBrowserMenu();
85 /// Updates menu for viewer
86 void updateViewerMenu();
89 /// Signal aabout triggered action
90 /// \param theId an id of triggered action
91 /// \param isChecked is checked flag
92 void actionTriggered(const QString& theId, bool isChecked);
94 /// A signal which is sent before context menu show
95 void beforeContextMenu();
97 /// A signal which is sent after context menu show
98 void afterContextMenu();
101 /// Process action event
102 /// \param isChecked a checked action flag
103 void onAction(bool isChecked);
105 /// Process context menu event
106 /// \param theEvent a context menu event
107 void onContextMenuRequest(QContextMenuEvent* theEvent);
111 /// Slot called on Result selection menu press
112 void onResultSelection(bool theChecked);
114 /// Slot called on any shape selection menu press
115 void onShapeSelection(bool theChecked);
120 * \param theId - string ID of the item
121 * \param theAction - action to add
123 void addAction(const QString& theId, QAction* theAction);
125 void addFeatures(QMenu* theMenu) const;
127 /// Creates menu for object browser
128 void buildObjBrowserMenu();
130 /// Creates menu for viewer
131 void buildViewerMenu();
133 /// Map of created actions [id : Action]
134 QMap<QString, QAction*> myActions;
136 /// Reference to workshop
137 XGUI_Workshop* myWorkshop;
139 typedef QList<QAction*> QActionsList;
140 QMap<std::string, QActionsList> myObjBrowserMenus;
141 QMap<std::string, QActionsList> myViewerMenu;
143 //QActionGroup* mySelectActions;
145 QAction* mySeparator;