dRonin  adbada4
dRonin GCS
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Groups Pages
actioncontainer_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 ACTIONCONTAINER_P_H
29 #define ACTIONCONTAINER_P_H
30 
31 #include "actionmanager_p.h"
32 
35 
36 namespace Core {
37 namespace Internal {
38 
40  {
41  public:
42  ActionContainerPrivate(int id);
44 
45  void setEmptyAction(EmptyAction ea);
46  bool hasEmptyAction(EmptyAction ea) const;
47 
48  QAction *insertLocation(const QString &group) const;
49  void appendGroup(const QString &group);
50  void addAction(Command *action, const QString &group = QString());
51  void addMenu(ActionContainer *menu, const QString &group = QString());
52 
53  int id() const;
54 
55  QMenu *menu() const;
56  QMenuBar *menuBar() const;
57 
58  virtual void insertAction(QAction *before, QAction *action) = 0;
59  virtual void insertMenu(QAction *before, QMenu *menu) = 0;
60 
61  QList<Command *> commands() const { return m_commands; }
62  QList<ActionContainer *> subContainers() const { return m_subContainers; }
63  protected:
64  bool canAddAction(Command *action) const;
65  bool canAddMenu(ActionContainer *menu) const;
66  virtual bool canBeAddedToMenu() const = 0;
67 
68  void addAction(Command *action, int pos, bool setpos);
69  void addMenu(ActionContainer *menu, int pos, bool setpos);
70 
71  private:
72  QAction *beforeAction(int pos, int *prevKey) const;
73  int calcPosition(int pos, int prevKey) const;
74 
75  QList<int> m_groups;
76  int m_data;
77  int m_id;
78  QMap<int, int> m_posmap;
79  QList<ActionContainer *> m_subContainers;
80  QList<Command *> m_commands;
81  };
82 
84  {
85  public:
86  MenuActionContainer(int id);
87 
88  void setMenu(QMenu *menu);
89  QMenu *menu() const;
90 
92  CommandLocation location() const;
93 
94  void insertAction(QAction *before, QAction *action);
95  void insertMenu(QAction *before, QMenu *menu);
96  bool update();
97 
98  protected:
99  bool canBeAddedToMenu() const;
100 
101  private:
102  QMenu *m_menu;
103  CommandLocation m_location;
104  };
105 
107  {
108  public:
109  MenuBarActionContainer(int id);
110 
111  void setMenuBar(QMenuBar *menuBar);
112  QMenuBar *menuBar() const;
113 
114  void insertAction(QAction *before, QAction *action);
115  void insertMenu(QAction *before, QMenu *menu);
116  bool update();
117 
118  protected:
119  bool canBeAddedToMenu() const;
120 
121  private:
122  QMenuBar *m_menuBar;
123  };
124 
125 } // namespace Internal
126 } // namespace Core
127 
128 #endif // ACTIONCONTAINER_P_H
virtual void insertAction(QAction *before, QAction *action)=0
virtual bool canBeAddedToMenu() const =0
void insertMenu(QAction *before, QMenu *menu)
void insertAction(QAction *before, QAction *action)
void setLocation(const CommandLocation &location)
QAction * insertLocation(const QString &group) const
QList< Command * > commands() const
void addAction(Command *action, const QString &group=QString())
void addMenu(ActionContainer *menu, const QString &group=QString())
void insertAction(QAction *before, QAction *action)
QList< ActionContainer * > subContainers() const
virtual void insertMenu(QAction *before, QMenu *menu)=0
void appendGroup(const QString &group)
bool canAddAction(Command *action) const
bool canAddMenu(ActionContainer *menu) const
void insertMenu(QAction *before, QMenu *menu)
Definition: icore.h:39
bool hasEmptyAction(EmptyAction ea) 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