QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
LinkConfiguration.h
Go to the documentation of this file.
1#pragma once
2
3#include <QtCore/QSettings>
4#include <QtCore/QString>
5#include <QtQmlIntegration/QtQmlIntegration>
6
7class LinkInterface;
8
11class LinkConfiguration : public QObject
12{
13 Q_OBJECT
14 QML_ELEMENT
15 QML_UNCREATABLE("")
16 Q_MOC_INCLUDE("LinkInterface.h")
17
18 Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
19 Q_PROPERTY(LinkInterface *link READ link NOTIFY linkChanged)
20 Q_PROPERTY(LinkType linkType READ type CONSTANT)
21 Q_PROPERTY(bool dynamic READ isDynamic WRITE setDynamic NOTIFY dynamicChanged)
22 Q_PROPERTY(bool autoConnect READ isAutoConnect WRITE setAutoConnect NOTIFY autoConnectChanged)
23 Q_PROPERTY(QString settingsURL READ settingsURL CONSTANT)
24 Q_PROPERTY(QString settingsTitle READ settingsTitle CONSTANT)
25 Q_PROPERTY(bool highLatency READ isHighLatency WRITE setHighLatency NOTIFY highLatencyChanged)
26
27public:
28 LinkConfiguration(const QString &name, QObject *parent = nullptr);
29 LinkConfiguration(const LinkConfiguration *copy, QObject *parent = nullptr);
30 virtual ~LinkConfiguration();
31
32 QString name() const { return _name; }
33 void setName(const QString &name);
34
35 LinkInterface *link() const { return _link.lock().get(); }
36 void setLink(const std::shared_ptr<LinkInterface> link);
37
40 bool isDynamic() const { return _dynamic; }
41
43 void setDynamic(bool dynamic = true);
44
47 bool isForwarding() const { return _forwarding; }
48
50 void setForwarding(bool forwarding = true) { _forwarding = forwarding; };
51
52 bool isAutoConnect() const { return _autoConnect; }
53
55 virtual void setAutoConnect(bool autoc = true);
56
59 bool isHighLatency() const { return _highLatency; }
60
62 void setHighLatency(bool hl = false);
63
67 virtual void copyFrom(const LinkConfiguration *source);
68
71 enum LinkType {
72#ifndef QGC_NO_SERIAL_LINK
74#endif
78#ifdef QT_DEBUG
79 TypeMock,
80#endif
82 TypeLast // Last type value (type >= TypeLast == invalid)
83 };
84 Q_ENUM(LinkType)
85
86
88 virtual LinkType type() const = 0;
89
93 virtual void loadSettings(QSettings &settings, const QString &root) = 0;
94
98 virtual void saveSettings(QSettings &settings, const QString &root) const = 0;
99
101 virtual QString settingsURL() const = 0;
102
104 virtual QString settingsTitle() const = 0;
105
108 static LinkConfiguration *createSettings(int type, const QString &name);
109
113
116 static QString settingsRoot() { return QStringLiteral("LinkConfigurations"); }
117
118signals:
119 void nameChanged(const QString &name);
124
125protected:
126 std::weak_ptr<LinkInterface> _link;
127
128private:
129 QString _name;
130 bool _dynamic = false;
131 bool _forwarding = false;
132 bool _autoConnect = false;
133 bool _highLatency = false;
134};
135
136typedef std::shared_ptr<LinkConfiguration> SharedLinkConfigurationPtr;
137typedef std::weak_ptr<LinkConfiguration> WeakLinkConfigurationPtr;
std::shared_ptr< LinkConfiguration > SharedLinkConfigurationPtr
std::weak_ptr< LinkConfiguration > WeakLinkConfigurationPtr
Interface holding link specific settings.
std::weak_ptr< LinkInterface > _link
Link currently using this configuration (if any)
@ TypeSerial
Serial Link.
@ TypeBluetooth
Bluetooth Link.
virtual void loadSettings(QSettings &settings, const QString &root)=0
virtual LinkType type() const =0
static LinkConfiguration * duplicateSettings(const LinkConfiguration *source)
virtual void copyFrom(const LinkConfiguration *source)
bool isAutoConnect() const
void setDynamic(bool dynamic=true)
Set if this is this a dynamic configuration. (decided at runtime)
virtual QString settingsURL() const =0
Settings URL, Pure virtual method providing the URL for the (QML) settings dialog.
virtual void saveSettings(QSettings &settings, const QString &root) const =0
void setHighLatency(bool hl=false)
Set if this is this an High Latency configuration.
static LinkConfiguration * createSettings(int type, const QString &name)
void setForwarding(bool forwarding=true)
Set if this is this a forwarding link configuration. (decided at runtime)
static QString settingsRoot()
LinkInterface * link() const
void autoConnectChanged()
void highLatencyChanged()
void nameChanged(const QString &name)
void setName(const QString &name)
QString name() const
virtual QString settingsTitle() const =0
Settings Title, Pure virtual method providing the Title for the (QML) settings dialog.
void setLink(const std::shared_ptr< LinkInterface > link)
bool isForwarding() const
bool isHighLatency() const
virtual void setAutoConnect(bool autoc=true)
Set if this is this an Auto Connect configuration.
The link interface defines the interface for all links used to communicate with the ground station ap...