Merged in f5soh/librepilot/update_credits (pull request #529)
[librepilot.git] / ground / gcs / src / plugins / coreplugin / uavgadgetinstancemanager.h
blob8460c1c9a16201d678039eac94e37bf16c3dd4a8
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 "core_global.h"
32 #include "uavconfiginfo.h"
34 #include <QObject>
35 #include <QSettings>
36 #include <QMap>
37 #include <QStringList>
38 #include <QIcon>
40 namespace ExtensionSystem {
41 class PluginManager;
44 namespace Core {
45 namespace Internal {
46 class SettingsDialog;
49 class IUAVGadget;
50 class IUAVGadgetConfiguration;
51 class IOptionsPage;
52 class IUAVGadgetFactory;
54 class CORE_EXPORT UAVGadgetInstanceManager : public QObject {
55 Q_OBJECT
56 public:
57 enum DeleteStatus { OK, KO_ACTIVE, KO_LONE };
59 explicit UAVGadgetInstanceManager(QObject *parent = 0);
60 ~UAVGadgetInstanceManager();
62 void readSettings(QSettings &settings);
63 void saveSettings(QSettings &settings) const;
65 IUAVGadget *createGadget(QString classId, QWidget *parent, bool loadDefaultConfiguration = true);
66 void removeGadget(IUAVGadget *gadget);
67 void removeAllGadgets();
69 bool isConfigurationActive(IUAVGadgetConfiguration *config);
70 DeleteStatus canDeleteConfiguration(IUAVGadgetConfiguration *config);
71 void deleteConfiguration(IUAVGadgetConfiguration *config);
72 void cloneConfiguration(IUAVGadgetConfiguration *config);
73 void applyChanges(IUAVGadgetConfiguration *config);
74 void configurationNameEdited(QString text, bool hasText = true);
76 QStringList classIds() const
78 return m_classIdNameMap.keys();
81 QStringList configurationNames(QString classId) const;
82 QString gadgetName(QString classId) const;
83 QIcon gadgetIcon(QString classId) const;
85 signals:
86 void configurationChanged(IUAVGadgetConfiguration *config);
87 void configurationAdded(IUAVGadgetConfiguration *config);
88 void configurationToBeDeleted(IUAVGadgetConfiguration *config);
89 void configurationNameChanged(IUAVGadgetConfiguration *config, QString oldName, QString newName);
91 public slots:
92 void settingsDialogShown(Core::Internal::SettingsDialog *settingsDialog);
93 void settingsDialogRemoved();
95 private:
96 QList<IUAVGadget *> m_gadgetInstances;
97 QList<IUAVGadgetFactory *> m_factories;
98 QList<IUAVGadgetConfiguration *> m_configurations;
99 QList<IOptionsPage *> m_optionsPages;
100 QMap<QString, QString> m_classIdNameMap;
101 QMap<QString, QIcon> m_classIdIconMap;
102 QMap<QString, QStringList> m_takenNames;
103 QList<IUAVGadgetConfiguration *> m_provisionalConfigs;
104 QList<IUAVGadgetConfiguration *> m_provisionalDeletes;
105 QList<IOptionsPage *> m_provisionalOptionsPages;
106 Core::Internal::SettingsDialog *m_settingsDialog;
107 ExtensionSystem::PluginManager *m_pm;
109 IUAVGadgetFactory *factory(QString classId) const;
111 void createOptionsPages();
113 QList<IUAVGadgetConfiguration *> *configurations(QString classId) const;
114 QList<IUAVGadgetConfiguration *> *provisionalConfigurations(QString classId) const;
116 QString suggestName(QString classId, QString name);
118 int indexForConfig(QList<IUAVGadgetConfiguration *> configurations, QString classId, QString configName);
120 void readConfigs_1_1_0(QSettings &settings);
121 void readConfigs_1_2_0(QSettings &settings);
123 } // namespace Core
125 #endif // UAVGADGETINSTANCEMANAGER_H