1 // Copyright (c) 2016 The SigViewer Development Team 2 // Licensed under the GNU General Public License (GPL) 3 // https://www.gnu.org/licenses/gpl 4 5 6 #ifndef GUI_ACTION_FACTORY_H 7 #define GUI_ACTION_FACTORY_H 8 9 #include "gui_action_command.h" 10 11 #include <QSharedPointer> 12 #include <QString> 13 #include <QMap> 14 #include <QMenu> 15 #include <QContextMenuEvent> 16 17 namespace sigviewer 18 { 19 20 class GuiActionFactory 21 { 22 public: 23 static GuiActionFactory* getInstance (); 24 25 //------------------------------------------------------------------------- 26 void registerCommand (QString const& name, 27 QSharedPointer<GuiActionCommand> command); 28 29 //------------------------------------------------------------------------- 30 /// the caller must not delete 31 QList<QAction*> getQActions (QString const& command_name = "") const; 32 33 //------------------------------------------------------------------------- 34 /// the caller must not delete 35 QAction* getQAction (QString const& action_id) const; 36 37 //------------------------------------------------------------------------- 38 void initAllCommands (); 39 private: 40 static GuiActionFactory* instance_; 41 typedef QMap<QString, QSharedPointer<GuiActionCommand> > CommandMap; 42 CommandMap command_map_; 43 CommandMap action_to_command_map_; 44 }; 45 46 } 47 48 #endif // GUI_ACTION_FACTORY_H 49