LP-311 Remove basic/advanced stabilization tab auto-switch (autotune/txpid lock issues)
[librepilot.git] / ground / gcs / src / libs / utils / savedaction.h
blob9f8721bde228467e025dec091910ae155cc9445e
1 /**
2 ******************************************************************************
4 * @file savedaction.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 * @brief
8 * @see The GNU Public License (GPL) Version 3
9 * @defgroup
10 * @{
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 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>
38 #include <QAction>
40 QT_BEGIN_NAMESPACE
41 class QSettings;
42 QT_END_NAMESPACE
44 namespace Utils {
45 enum ApplyMode { ImmediateApply, DeferedApply };
47 class QTCREATOR_UTILS_EXPORT SavedAction : public QAction {
48 Q_OBJECT
50 public:
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;
82 signals:
83 void valueChanged(const QVariant &newValue);
85 private:
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);
96 QVariant m_value;
97 QVariant m_defaultValue;
98 QString m_settingsKey;
99 QString m_settingsGroup;
100 QString m_textPattern;
101 QString m_textData;
102 QWidget *m_widget;
103 ApplyMode m_applyMode;
106 class QTCREATOR_UTILS_EXPORT SavedActionSet {
107 public:
108 SavedActionSet() {}
109 ~SavedActionSet() {}
111 void insert(SavedAction *action, QWidget *widget);
112 void apply(QSettings *settings);
113 void finish();
114 void clear()
116 m_list.clear();
119 private:
120 QList<SavedAction *> m_list;
122 } // namespace Utils
124 #endif // SAVED_ACTION_H