dRonin  adbada4
dRonin GCS
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Groups Pages
iuavgadgetfactory.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 IUAVGADGETFACTORY_H
29 #define IUAVGADGETFACTORY_H
30 #include "core_global.h"
31 
32 #include <QtCore/QObject>
33 #include <QIcon>
34 #include <QSettings>
35 #include "uavconfiginfo.h"
36 
37 QT_BEGIN_NAMESPACE
38 class QStringList;
39 QT_END_NAMESPACE
40 
41 namespace Core {
42 
43 class IUAVGadget;
44 class IUAVGadgetConfiguration;
45 class IOptionsPage;
46 
47 class CORE_EXPORT IUAVGadgetFactory : public QObject
48 {
49  Q_OBJECT
50 public:
51  IUAVGadgetFactory(QString classId, QString name, QObject *parent = nullptr)
52  : QObject(parent)
53  , m_classId(classId)
54  , m_name(name)
55  , m_icon(QIcon())
56  , m_singleConfigurationGadget(false)
57  {
58  }
59  virtual ~IUAVGadgetFactory() {}
60 
61  virtual IUAVGadget *createGadget(QWidget *parent) = 0;
62  virtual IUAVGadgetConfiguration *createConfiguration(QSettings * /*qSettings*/) { return nullptr; }
64  UAVConfigInfo * /*configInfo*/)
65  {
66  return createConfiguration(qs);
67  }
68  virtual IOptionsPage *createOptionsPage(IUAVGadgetConfiguration * /*config*/) { return nullptr; }
69  QString classId() const { return m_classId; }
70  QString name() const { return m_name; }
71  QIcon icon() const { return m_icon; }
72  bool isSingleConfigurationGadget() { return m_singleConfigurationGadget; }
73 protected:
74  void setIcon(QIcon icon) { m_icon = icon; }
75  void setSingleConfigurationGadgetTrue() { m_singleConfigurationGadget = true; }
76 private:
77  QString m_classId; // unique class id
78  QString m_name; // display name, should also be unique
79  QIcon m_icon;
80  bool m_singleConfigurationGadget; // true if there is exactly one configuration for this gadget
81 };
82 
83 } // namespace Core
84 
85 #endif // IUAVGADGETFACTORY_H
virtual IUAVGadgetConfiguration * createConfiguration(QSettings *)
virtual IOptionsPage * createOptionsPage(IUAVGadgetConfiguration *)
IUAVGadgetFactory(QString classId, QString name, QObject *parent=nullptr)
The Config Info is a helper-class to handle version changes in GCS configuration files.
Definition: uavconfiginfo.h:53
virtual IUAVGadgetConfiguration * createConfiguration(QSettings *qs, UAVConfigInfo *)
The IOptionsPage is an interface for providing options pages.
Definition: ioptionspage.h:42
void setIcon(QIcon icon)
QString classId() const