LP-56 - Better txpid option namings, fix tabs-spaces, tooltips. headers, variable...
[librepilot.git] / ground / openpilotgcs / src / plugins / coreplugin / uavgadgetinstancemanager.h
blob7ecc517f0ffe9c1dfc0ef52774a2f48fcc35f946
1 /**
2 ******************************************************************************
4 * @file uavgadgetinstancemanager.h
5 * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
6 * @addtogroup GCSPlugins GCS Plugins
7 * @{
8 * @addtogroup CorePlugin Core Plugin
9 * @{
10 * @brief The Core GCS plugin
11 *****************************************************************************/
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 3 of the License, or
16 * (at your option) any later version.
18 * This program is distributed in the hope that it will be useful, but
19 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
20 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 * for more details.
23 * You should have received a copy of the GNU General Public License along
24 * with this program; if not, write to the Free Software Foundation, Inc.,
25 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28 #ifndef UAVGADGETINSTANCEMANAGER_H
29 #define UAVGADGETINSTANCEMANAGER_H
31 #include <QObject>
32 #include <QSettings>
33 #include <QtCore/QMap>
34 #include <QtCore/QStringList>
35 #include <QIcon>
36 #include "core_global.h"
37 #include "uavconfiginfo.h"
39 namespace ExtensionSystem {
40 class PluginManager;
43 namespace Core {
44 namespace Internal {
45 class SettingsDialog;
48 class IUAVGadget;
49 class IUAVGadgetConfiguration;
50 class IOptionsPage;
51 class IUAVGadgetFactory;
53 class CORE_EXPORT UAVGadgetInstanceManager : public QObject {
54 Q_OBJECT
55 public:
56 enum DeleteStatus { OK, KO_ACTIVE, KO_LONE };
58 explicit UAVGadgetInstanceManager(QObject *parent = 0);
59 ~UAVGadgetInstanceManager();
61 void readSettings(QSettings *qs);
62 void saveSettings(QSettings *qs);
64 IUAVGadget *createGadget(QString classId, QWidget *parent, bool loadDefaultConfiguration = true);
65 void removeGadget(IUAVGadget *gadget);
66 void removeAllGadgets();
68 bool isConfigurationActive(IUAVGadgetConfiguration *config);
69 DeleteStatus canDeleteConfiguration(IUAVGadgetConfiguration *config);
70 void deleteConfiguration(IUAVGadgetConfiguration *config);
71 void cloneConfiguration(IUAVGadgetConfiguration *config);
72 void applyChanges(IUAVGadgetConfiguration *config);
73 void configurationNameEdited(QString text, bool hasText = true);
75 QStringList classIds() const
77 return m_classIdNameMap.keys();
80 QStringList configurationNames(QString classId) const;
81 QString gadgetName(QString classId) const;
82 QIcon gadgetIcon(QString classId) const;
84 signals:
85 void configurationChanged(IUAVGadgetConfiguration *config);
86 void configurationAdded(IUAVGadgetConfiguration *config);
87 void configurationToBeDeleted(IUAVGadgetConfiguration *config);
88 void configurationNameChanged(IUAVGadgetConfiguration *config, QString oldName, QString newName);
90 public slots:
91 void settingsDialogShown(Core::Internal::SettingsDialog *settingsDialog);
92 void settingsDialogRemoved();
94 private:
95 QList<IUAVGadget *> m_gadgetInstances;
96 QList<IUAVGadgetFactory *> m_factories;
97 QList<IUAVGadgetConfiguration *> m_configurations;
98 QList<IOptionsPage *> m_optionsPages;
99 QMap<QString, QString> m_classIdNameMap;
100 QMap<QString, QIcon> m_classIdIconMap;
101 QMap<QString, QStringList> m_takenNames;
102 QList<IUAVGadgetConfiguration *> m_provisionalConfigs;
103 QList<IUAVGadgetConfiguration *> m_provisionalDeletes;
104 QList<IOptionsPage *> m_provisionalOptionsPages;
105 Core::Internal::SettingsDialog *m_settingsDialog;
106 ExtensionSystem::PluginManager *m_pm;
108 IUAVGadgetFactory *factory(QString classId) const;
110 void createOptionsPages();
112 QList<IUAVGadgetConfiguration *> *configurations(QString classId) const;
113 QList<IUAVGadgetConfiguration *> *provisionalConfigurations(QString classId) const;
115 QString suggestName(QString classId, QString name);
117 int indexForConfig(QList<IUAVGadgetConfiguration *> configurations, QString classId, QString configName);
119 void readConfigs_1_1_0(QSettings *qs);
120 void readConfigs_1_2_0(QSettings *qs);
122 } // namespace Core
124 #endif // UAVGADGETINSTANCEMANAGER_H