dRonin  adbada4
dRonin GCS
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Groups Pages
uavgadgetinstancemanager.h
Go to the documentation of this file.
1 
13 /*
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.
18  *
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.
23  *
24  * You should have received a copy of the GNU General Public License along
25  * with this program; if not, see <http://www.gnu.org/licenses/>
26  */
27 
28 #ifndef UAVGADGETINSTANCEMANAGER_H
29 #define UAVGADGETINSTANCEMANAGER_H
30 
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"
38 
39 namespace ExtensionSystem {
40 class PluginManager;
41 }
42 
43 namespace Core {
44 
45 namespace Internal {
46  class SettingsDialog;
47 }
48 
49 class IUAVGadget;
50 class IUAVGadgetConfiguration;
51 class IOptionsPage;
52 class IUAVGadgetFactory;
53 
54 class CORE_EXPORT UAVGadgetInstanceManager : public QObject
55 {
56 
57  Q_OBJECT
58 public:
59  explicit UAVGadgetInstanceManager(QObject *parent = nullptr);
61  void readSettings(QSettings *qs);
62  void saveSettings(QSettings *qs);
63  IUAVGadget *createGadget(QString classId, QWidget *parent, bool forceLoadConfiguration = false);
64  void removeGadget(IUAVGadget *gadget);
65  void removeAllGadgets();
66  bool canDeleteConfiguration(IUAVGadgetConfiguration *config);
67  void deleteConfiguration(IUAVGadgetConfiguration *config);
68  void cloneConfiguration(IUAVGadgetConfiguration *config);
69  void applyChanges(IUAVGadgetConfiguration *config);
70  void configurationNameEdited(QString text, bool hasText = true);
71  QStringList classIds() const { return m_classIdNameMap.keys(); }
72  QStringList configurationNames(QString classId) const;
73  QString gadgetName(QString classId) const;
74  QIcon gadgetIcon(QString classId) const;
75 
76 signals:
77  void splashMessages(QString);
78  void configurationChanged(IUAVGadgetConfiguration *config);
79  void configurationAdded(IUAVGadgetConfiguration *config);
80  void configurationToBeDeleted(IUAVGadgetConfiguration *config);
81  void configurationNameChanged(IUAVGadgetConfiguration *config, QString oldName,
82  QString newName);
83 
84 public slots:
85  void settingsDialogShown(Core::Internal::SettingsDialog *settingsDialog);
86  void settingsDialogRemoved();
87 
88 private:
89  IUAVGadgetFactory *factory(QString classId) const;
90  void createOptionsPages();
91  QList<IUAVGadgetConfiguration *> *configurations(QString classId) const;
92  QString suggestName(QString classId, QString name);
93  QList<IUAVGadget *> m_gadgetInstances;
94  QList<IUAVGadgetFactory *> m_factories;
95  QList<IUAVGadgetConfiguration *> m_configurations;
96  QList<IOptionsPage *> m_optionsPages;
97  QMap<QString, QString> m_classIdNameMap;
98  QMap<QString, QIcon> m_classIdIconMap;
99  QMap<QString, QStringList> m_takenNames;
100  QList<IUAVGadgetConfiguration *> m_provisionalConfigs;
101  QList<IUAVGadgetConfiguration *> m_provisionalDeletes;
102  QList<IOptionsPage *> m_provisionalOptionsPages;
103  Core::Internal::SettingsDialog *m_settingsDialog;
105  int indexForConfig(QList<IUAVGadgetConfiguration *> configurations, QString classId,
106  QString configName);
107  void readConfigs_1_1_0(QSettings *qs);
108  void readConfigs_1_2_0(QSettings *qs);
109 };
110 
111 } // namespace Core
112 
113 #endif // UAVGADGETINSTANCEMANAGER_H
Core plugin system that manages the plugins, their life cycle and their registered objects...
Definition: pluginmanager.h:53
Definition: icore.h:39