QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
VehicleComponent.h
Go to the documentation of this file.
1#pragma once
2
3#include <QtCore/QObject>
4#include <QtCore/QStringList>
5#include <QtCore/QUrl>
6#include <QtCore/QVariant>
7#include <QtQmlIntegration/QtQmlIntegration>
8
9#include "AutoPilotPlugin.h"
10
11class Vehicle;
12class QQuickItem;
13class QQmlContext;
14
17
18class VehicleComponent : public QObject
19{
20 Q_OBJECT
21 QML_ELEMENT
22 QML_UNCREATABLE("")
23
24 Q_PROPERTY(QString name READ name CONSTANT)
25 Q_PROPERTY(QString description READ description CONSTANT)
26 Q_PROPERTY(bool requiresSetup READ requiresSetup CONSTANT)
27 Q_PROPERTY(bool setupComplete READ setupComplete STORED false NOTIFY setupCompleteChanged)
28 Q_PROPERTY(QString iconResource READ iconResource CONSTANT)
29 Q_PROPERTY(QUrl setupSource READ setupSource NOTIFY setupSourceChanged)
30 Q_PROPERTY(QUrl summaryQmlSource READ summaryQmlSource CONSTANT)
31 Q_PROPERTY(bool allowSetupWhileArmed READ allowSetupWhileArmed CONSTANT)
32 Q_PROPERTY(bool allowSetupWhileFlying READ allowSetupWhileFlying CONSTANT)
34 Q_PROPERTY(QStringList sections READ sections NOTIFY sectionsChanged)
35 Q_PROPERTY(QVariantMap sectionKeywords READ sectionKeywords NOTIFY sectionsChanged)
36 Q_PROPERTY(QString vehicleConfigJson READ vehicleConfigJson CONSTANT)
37 Q_PROPERTY(bool showFirstSectionOnRootClick READ showFirstSectionOnRootClick CONSTANT)
38
39public:
40 explicit VehicleComponent(Vehicle *vehicle, AutoPilotPlugin *autopilot, AutoPilotPlugin::KnownVehicleComponent KnownVehicleComponent, QObject *parent = nullptr);
41 virtual ~VehicleComponent();
42
43 virtual QString name() const = 0;
44 virtual QString description() const { return QString(); }
45 virtual QString iconResource() const = 0;
46 virtual bool requiresSetup() const = 0;
47 virtual bool setupComplete() const = 0;
48 virtual QUrl setupSource() const = 0;
49 virtual QUrl summaryQmlSource() const = 0;
50
52 virtual QString vehicleConfigJson() const { return QString(); }
53
56 virtual QStringList sections() const;
57
59 QVariantMap sectionKeywords() const;
60
62 virtual bool showFirstSectionOnRootClick() const { return false; }
63
65 Q_INVOKABLE virtual bool sectionSetupComplete(const QString &sectionName) const { Q_UNUSED(sectionName); return true; }
66
67 // @return true: Setup panel can be shown while vehicle is armed
68 virtual bool allowSetupWhileArmed() const { return false; }
69
70 // @return true: Setup panel can be shown while vehicle is flying (and armed)
71 virtual bool allowSetupWhileFlying() const { return false; }
72
73 virtual void addSummaryQmlComponent(QQmlContext* context, QQuickItem* parent);
74
77 virtual QStringList setupCompleteChangedTriggerList() const = 0;
78
81 virtual void setupTriggerSignals();
82
84
85signals:
89
90protected slots:
91 void _triggerUpdated(QVariant /*value*/) { emit setupCompleteChanged(); }
92
93protected:
94 Vehicle *_vehicle = nullptr;
97
98private:
100 void _ensureSectionsCached() const;
101
103 struct RepeatFilter {
104 QStringList sectionNames;
105 QStringList paramNames;
106 int disabledValue = 0;
107 QString disabledHeading;
108 };
109
110 mutable QStringList _expandedSections;
111 mutable QVector<RepeatFilter> _repeatFilters;
112 mutable QMap<QString, QStringList> _sectionKeywords;
113 mutable bool _sectionsCached = false;
114};
The AutoPilotPlugin class is an abstract base class which represents the methods and objects which ar...
A vehicle component is an object which abstracts the physical portion of a vehicle into a set of conf...
virtual bool allowSetupWhileFlying() const
virtual bool requiresSetup() const =0
void setupCompleteChanged()
virtual ~VehicleComponent()
virtual QString vehicleConfigJson() const
Resource path to a VehicleConfig.json page definition, or empty if none.
virtual bool setupComplete() const =0
virtual bool allowSetupWhileArmed() const
virtual QString iconResource() const =0
virtual QStringList sections() const
virtual bool showFirstSectionOnRootClick() const
When true, clicking the root component in the tree selects the first section instead of showing all.
virtual QString description() const
void _triggerUpdated(QVariant)
virtual QStringList setupCompleteChangedTriggerList() const =0
virtual void setupTriggerSignals()
AutoPilotPlugin::KnownVehicleComponent KnownVehicleComponent() const
virtual QUrl summaryQmlSource() const =0
void setupSourceChanged()
virtual QUrl setupSource() const =0
QVariantMap sectionKeywords() const
Search keywords per section, keyed by section title. Values are original-case translatable terms.
AutoPilotPlugin * _autopilot
virtual Q_INVOKABLE bool sectionSetupComplete(const QString &sectionName) const
Returns setup-complete status for a named section. Default returns true (no per-section tracking).
AutoPilotPlugin::KnownVehicleComponent _KnownVehicleComponent
virtual QString name() const =0
void sectionsChanged()
virtual void addSummaryQmlComponent(QQmlContext *context, QQuickItem *parent)