Salome HOME
Issue #1860: fix end lines with spaces
[modules/shaper.git] / src / XGUI / XGUI_MenuMgr.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
2
3 // File:        XGUI_MenuMgr.hxx
4 // Created:     13 Apr 2016
5 // Author:      Natalia ERMOLAEVA
6
7 #ifndef XGUI_MENUMGR_H_
8 #define XGUI_MENUMGR_H_
9
10 #include "XGUI.h"
11
12 #include <Events_Listener.h>
13
14 #include <string>
15 #include <list>
16 #include <memory>
17
18 class XGUI_MenuWorkbench;
19 class XGUI_Workshop;
20 class Config_FeatureMessage;
21
22 class QAction;
23
24 /**
25 * \ingroup GUI
26 * A class for management of menu actions (features). The actions should be arranged like they are
27 * in XML file. It listens the read feature of XML and fills internal structure of menu workbenches
28 * and groups of feature. After, it creates menues and tools in the module.
29 */
30 class XGUI_MenuMgr : public Events_Listener
31 {
32  public:
33   /// Constructor
34   /// \param theWorkshop the current workshop
35   XGUI_EXPORT XGUI_MenuMgr(XGUI_Workshop* theWorkshop);
36   XGUI_EXPORT virtual ~XGUI_MenuMgr() {}
37
38   /// Creates feature actions
39   XGUI_EXPORT void createFeatureActions();
40
41   /// Redefinition of Events_Listener method
42   /// \param theMessage a message
43   XGUI_EXPORT virtual void processEvent(const std::shared_ptr<Events_Message>& theMessage);
44
45 protected:
46   /// Process event "Add a feature"
47   void addFeature(const std::shared_ptr<Config_FeatureMessage>& theMessage);
48
49   /// Finds or creates a workbench for the given name
50   /// \param theWorkbenchName a name defined in XML
51   /// \return an instance of workbench
52   std::shared_ptr<XGUI_MenuWorkbench> findWorkbench(const std::string& theWorkbenchName);
53
54   /// Creates a new action by the message
55   /// \param theMessage an XML information of the feature
56   /// \param theWchName a workbench name, will be used as menu/tool bar name
57   /// \param aUseSeparator boolean value if a separator should be added after the action
58   /// \return an action
59   QAction* buildAction(const std::shared_ptr<Config_FeatureMessage>& theMessage,
60                        const std::string& theWchName, const bool aUseSeparator) const;
61
62 private:
63   XGUI_Workshop* myWorkshop; ///< the current workshop
64
65   /// container of existing workbenchs
66   std::list< std::shared_ptr<XGUI_MenuWorkbench> > myWorkbenches;
67 };
68
69 #endif /* XGUI_MENUMGR_H_ */