2 ******************************************************************************
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
33 #include "actionmanager_p.h"
35 #include <QtCore/QList>
36 #include <QtCore/QMultiMap>
37 #include <QtCore/QPointer>
38 #include <QKeySequence>
42 class CommandPrivate
: public Core::Command
{
45 CommandPrivate(int id
);
46 virtual ~CommandPrivate() {}
48 virtual QString
name() const = 0;
50 void setDefaultKeySequence(const QKeySequence
&key
);
51 QKeySequence
defaultKeySequence() const;
53 void setDefaultText(const QString
&text
);
54 QString
defaultText() const;
58 QAction
*action() const;
59 QShortcut
*shortcut() const;
61 void setAttribute(CommandAttribute attr
);
62 void removeAttribute(CommandAttribute attr
);
63 bool hasAttribute(CommandAttribute attr
) const;
65 virtual bool setCurrentContext(const QList
<int> &context
) = 0;
67 QString
stringWithAppendedShortcut(const QString
&str
) const;
73 QKeySequence m_defaultKey
;
74 QString m_defaultText
;
77 class Shortcut
: public CommandPrivate
{
84 void setDefaultKeySequence(const QKeySequence
&key
);
85 void setKeySequence(const QKeySequence
&key
);
86 QKeySequence
keySequence() const;
88 virtual void setDefaultText(const QString
&key
);
89 virtual QString
defaultText() const;
91 void setShortcut(QShortcut
*shortcut
);
92 QShortcut
*shortcut() const;
94 void setContext(const QList
<int> &context
);
95 QList
<int> context() const;
96 bool setCurrentContext(const QList
<int> &context
);
98 bool isActive() const;
100 QList
<int> m_context
;
101 QShortcut
*m_shortcut
;
102 QString m_defaultText
;
105 class Action
: public CommandPrivate
{
110 QString
name() const;
112 void setDefaultKeySequence(const QKeySequence
&key
);
113 void setKeySequence(const QKeySequence
&key
);
114 QKeySequence
keySequence() const;
116 virtual void setAction(QAction
*action
);
117 QAction
*action() const;
119 void setLocations(const QList
<CommandLocation
> &locations
);
120 QList
<CommandLocation
> locations() const;
123 void updateToolTipWithKeySequence();
126 QList
<CommandLocation
> m_locations
;
130 class OverrideableAction
: public Action
{
134 OverrideableAction(int id
);
136 void setAction(QAction
*action
);
137 bool setCurrentContext(const QList
<int> &context
);
138 void addOverrideAction(QAction
*action
, const QList
<int> &context
);
139 bool isActive() const;
142 void actionChanged();
145 QPointer
<QAction
> m_currentAction
;
146 QList
<int> m_context
;
147 QMap
<int, QPointer
<QAction
> > m_contextActionMap
;
149 bool m_contextInitialized
;
151 } // namespace Internal
154 #endif // COMMAND_P_H