Merged in f5soh/librepilot/update_credits (pull request #529)
[librepilot.git] / ground / gcs / src / plugins / coreplugin / actionmanager / actioncontainer_p.h
blobcb906269ea64e2eae1f1df6034cf1c89c2f638fc
1 /**
2 ******************************************************************************
4 * @file actioncontainer_p.h
5 * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
6 * Parts by Nokia Corporation (qt-info@nokia.com) Copyright (C) 2009.
7 * @addtogroup GCSPlugins GCS Plugins
8 * @{
9 * @addtogroup CorePlugin Core Plugin
10 * @{
11 * @brief The Core GCS plugin
12 *****************************************************************************/
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.
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.
24 * You should have received a copy of the GNU General Public License along
25 * with this program; if not, write to the Free Software Foundation, Inc.,
26 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
29 #ifndef ACTIONCONTAINER_P_H
30 #define ACTIONCONTAINER_P_H
32 #include "actionmanager_p.h"
34 #include <coreplugin/actionmanager/actioncontainer.h>
35 #include <coreplugin/actionmanager/command.h>
37 namespace Core {
38 namespace Internal {
39 class ActionContainerPrivate : public Core::ActionContainer {
40 public:
41 ActionContainerPrivate(int id);
42 virtual ~ActionContainerPrivate() {}
44 void setEmptyAction(EmptyAction ea);
45 bool hasEmptyAction(EmptyAction ea) const;
47 QAction *insertLocation(const QString &group) const;
48 void appendGroup(const QString &group);
49 void addAction(Command *action, const QString &group = QString());
50 void addMenu(ActionContainer *menu, const QString &group = QString());
52 int id() const;
54 QMenu *menu() const;
55 QMenuBar *menuBar() const;
57 virtual void insertAction(QAction *before, QAction *action) = 0;
58 virtual void insertMenu(QAction *before, QMenu *menu) = 0;
60 QList<Command *> commands() const
62 return m_commands;
64 QList<ActionContainer *> subContainers() const
66 return m_subContainers;
68 protected:
69 bool canAddAction(Command *action) const;
70 bool canAddMenu(ActionContainer *menu) const;
71 virtual bool canBeAddedToMenu() const = 0;
73 void addAction(Command *action, int pos, bool setpos);
74 void addMenu(ActionContainer *menu, int pos, bool setpos);
76 private:
77 QAction *beforeAction(int pos, int *prevKey) const;
78 int calcPosition(int pos, int prevKey) const;
80 QList<int> m_groups;
81 int m_data;
82 int m_id;
83 QMap<int, int> m_posmap;
84 QList<ActionContainer *> m_subContainers;
85 QList<Command *> m_commands;
88 class MenuActionContainer : public ActionContainerPrivate {
89 public:
90 MenuActionContainer(int id);
92 void setMenu(QMenu *menu);
93 QMenu *menu() const;
95 void setLocation(const CommandLocation &location);
96 CommandLocation location() const;
98 void insertAction(QAction *before, QAction *action);
99 void insertMenu(QAction *before, QMenu *menu);
100 bool update();
102 protected:
103 bool canBeAddedToMenu() const;
104 private:
105 QMenu *m_menu;
106 CommandLocation m_location;
109 class MenuBarActionContainer : public ActionContainerPrivate {
110 public:
111 MenuBarActionContainer(int id);
113 void setMenuBar(QMenuBar *menuBar);
114 QMenuBar *menuBar() const;
116 void insertAction(QAction *before, QAction *action);
117 void insertMenu(QAction *before, QMenu *menu);
118 bool update();
120 protected:
121 bool canBeAddedToMenu() const;
122 private:
123 QMenuBar *m_menuBar;
125 } // namespace Internal
126 } // namespace Core
128 #endif // ACTIONCONTAINER_P_H