dRonin  adbada4
dRonin GCS
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Groups Pages
actionmanager_p.h
Go to the documentation of this file.
1 
13 /*
14  * This program is free software; you can redistribute it and/or modify
15  * it under the terms of the GNU General Public License as published by
16  * the Free Software Foundation; either version 3 of the License, or
17  * (at your option) any later version.
18  *
19  * This program is distributed in the hope that it will be useful, but
20  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
21  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  * for more details.
23  *
24  * You should have received a copy of the GNU General Public License along
25  * with this program; if not, see <http://www.gnu.org/licenses/>
26  */
27 
28 #ifndef ACTIONMANAGERPRIVATE_H
29 #define ACTIONMANAGERPRIVATE_H
30 
32 
33 #include <QtCore/QMap>
34 #include <QtCore/QHash>
35 #include <QtCore/QMultiHash>
36 
37 QT_BEGIN_NAMESPACE
38 class QSettings;
39 QT_END_NAMESPACE
40 
42 {
45 };
46 
47 namespace Core {
48 
49 class UniqueIDManager;
50 
51 namespace Internal {
52 
53  class ActionContainerPrivate;
54  class MainWindow;
55  class CommandPrivate;
56 
58  {
59  Q_OBJECT
60 
61  public:
62  explicit ActionManagerPrivate(MainWindow *mainWnd);
64 
65  void setContext(const QList<int> &context);
67 
68  void saveSettings(QSettings *settings);
69  QList<int> defaultGroups() const;
70 
73 
74  bool hasContext(int context) const;
75 
76  Command *command(int uid) const;
77  ActionContainer *actionContainer(int uid) const;
78 
79  void readSettings(QSettings *settings);
80 
81  // ActionManager Interface
82  ActionContainer *createMenu(const QString &id);
83  ActionContainer *createMenuBar(const QString &id);
84 
85  Command *registerAction(QAction *action, const QString &id, const QList<int> &context);
86  Command *registerShortcut(QShortcut *shortcut, const QString &id,
87  const QList<int> &context);
88 
89  Core::Command *command(const QString &id) const;
90  Core::ActionContainer *actionContainer(const QString &id) const;
91 
92  private:
93  bool hasContext(QList<int> context) const;
94  Command *registerOverridableAction(QAction *action, const QString &id, bool checkUnique);
95 
96  static ActionManagerPrivate *m_instance;
97  QList<int> m_defaultGroups;
98 
99  typedef QHash<int, CommandPrivate *> IdCmdMap;
100  IdCmdMap m_idCmdMap;
101 
102  typedef QHash<int, ActionContainerPrivate *> IdContainerMap;
103  IdContainerMap m_idContainerMap;
104 
105  // typedef QMap<int, int> GlobalGroupMap;
106  // GlobalGroupMap m_globalgroups;
107  //
108  QList<int> m_context;
109 
110  MainWindow *m_mainWnd;
111  };
112 
113 } // namespace Internal
114 } // namespace Core
115 
116 #endif // ACTIONMANAGERPRIVATE_H
Command * registerShortcut(QShortcut *shortcut, const QString &id, const QList< int > &context)
Makes a shortcut known to the system under the specified string id.
ActionContainer * createMenuBar(const QString &id)
Creates a new menu bar with the given string id.
bool hasContext(int context) const
Command * command(int uid) const
void readSettings(QSettings *settings)
static ActionManagerPrivate * instance()
QList< ActionContainerPrivate * > containers() const
void saveSettings(QSettings *settings)
Command * registerAction(QAction *action, const QString &id, const QList< int > &context)
Makes an action known to the system under the specified string id.
void setContext(const QList< int > &context)
ActionContainer * createMenu(const QString &id)
Creates a new menu with the given string id.
The action manager is responsible for registration of menus and menu items and keyboard shortcuts...
Definition: actionmanager.h:47
ActionContainer * actionContainer(int uid) const
ActionManagerPrivate(MainWindow *mainWnd)
QList< CommandPrivate * > commands() const
The class Command represents an action like a menu item, tool button, or shortcut. You don't create Command objects directly, instead use {ActionManager::registerAction()} to register an action and retrieve a Command. The Command object represents the user visible action and its properties. If multiple actions are registered with the same ID (but different contexts) the returned Command is the shared one between these actions.
Definition: command.h:43