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
9 * @addtogroup CorePlugin Core Plugin
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
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>
39 class ActionContainerPrivate
: public Core::ActionContainer
{
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());
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
64 QList
<ActionContainer
*> subContainers() const
66 return m_subContainers
;
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
);
77 QAction
*beforeAction(int pos
, int *prevKey
) const;
78 int calcPosition(int pos
, int prevKey
) const;
83 QMap
<int, int> m_posmap
;
84 QList
<ActionContainer
*> m_subContainers
;
85 QList
<Command
*> m_commands
;
88 class MenuActionContainer
: public ActionContainerPrivate
{
90 MenuActionContainer(int id
);
92 void setMenu(QMenu
*menu
);
95 void setLocation(const CommandLocation
&location
);
96 CommandLocation
location() const;
98 void insertAction(QAction
*before
, QAction
*action
);
99 void insertMenu(QAction
*before
, QMenu
*menu
);
103 bool canBeAddedToMenu() const;
106 CommandLocation m_location
;
109 class MenuBarActionContainer
: public ActionContainerPrivate
{
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
);
121 bool canBeAddedToMenu() const;
125 } // namespace Internal
128 #endif // ACTIONCONTAINER_P_H