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.
8 * @see The GNU Public License (GPL) Version 3
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 SAVED_ACTION_H
30 #define SAVED_ACTION_H
32 #include "utils_global.h"
34 #include <QtCore/QString>
35 #include <QtCore/QVariant>
36 #include <QtCore/QList>
45 enum ApplyMode
{ ImmediateApply
, DeferedApply
};
47 class QTCREATOR_UTILS_EXPORT SavedAction
: public QAction
{
51 SavedAction(QObject
*parent
= 0);
53 virtual QVariant
value() const;
54 Q_SLOT
virtual void setValue(const QVariant
&value
, bool doemit
= true);
56 virtual QVariant
defaultValue() const;
57 Q_SLOT
virtual void setDefaultValue(const QVariant
&value
);
59 virtual QAction
*updatedAction(const QString
&newText
);
60 Q_SLOT
virtual void trigger(const QVariant
&data
);
62 // used for persistency
63 virtual QString
settingsKey() const;
64 Q_SLOT
virtual void setSettingsKey(const QString
&key
);
65 Q_SLOT
virtual void setSettingsKey(const QString
&group
, const QString
&key
);
67 virtual QString
settingsGroup() const;
68 Q_SLOT
virtual void setSettingsGroup(const QString
&group
);
70 virtual void readSettings(QSettings
*settings
);
71 Q_SLOT
virtual void writeSettings(QSettings
*settings
);
73 virtual void connectWidget(QWidget
*widget
, ApplyMode applyMode
= DeferedApply
);
74 virtual void disconnectWidget();
75 Q_SLOT
virtual void apply(QSettings
*settings
);
77 virtual QString
textPattern() const;
78 Q_SLOT
virtual void setTextPattern(const QString
&value
);
80 QString
toString() const;
83 void valueChanged(const QVariant
&newValue
);
86 Q_SLOT
void uncheckableButtonClicked();
87 Q_SLOT
void checkableButtonClicked(bool);
88 Q_SLOT
void lineEditEditingFinished();
89 Q_SLOT
void pathChooserEditingFinished();
90 Q_SLOT
void actionTriggered(bool);
91 Q_SLOT
void spinBoxValueChanged(int);
92 Q_SLOT
void spinBoxValueChanged(QString
);
93 Q_SLOT
void doubleSpinBoxValueChanged(double);
94 Q_SLOT
void doubleSpinBoxValueChanged(QString
);
97 QVariant m_defaultValue
;
98 QString m_settingsKey
;
99 QString m_settingsGroup
;
100 QString m_textPattern
;
103 ApplyMode m_applyMode
;
106 class QTCREATOR_UTILS_EXPORT SavedActionSet
{
111 void insert(SavedAction
*action
, QWidget
*widget
);
112 void apply(QSettings
*settings
);
120 QList
<SavedAction
*> m_list
;
124 #endif // SAVED_ACTION_H