QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
VehicleComponent.cc
Go to the documentation of this file.
1#include "VehicleComponent.h"
2#include "ParameterManager.h"
4#include "Vehicle.h"
5
6#include <QtQml/QQmlContext>
7#include <QtQuick/QQuickItem>
8
9QGC_LOGGING_CATEGORY(VehicleComponentLog, "AutoPilotPlugins.VehicleComponent");
10
11VehicleComponent::VehicleComponent(Vehicle *vehicle, AutoPilotPlugin *autopilot, AutoPilotPlugin::KnownVehicleComponent KnownVehicleComponent, QObject *parent)
12 : QObject(parent)
13 , _vehicle(vehicle)
14 , _autopilot(autopilot)
15 , _KnownVehicleComponent(KnownVehicleComponent)
16{
17 // qCDebug(VehicleComponentLog) << Q_FUNC_INFO << this;
18
19 if (!vehicle || !autopilot) {
20 qCWarning(VehicleComponentLog) << "Internal error";
21 }
22}
23
24VehicleComponent::~VehicleComponent()
25{
26 // qCDebug(VehicleComponentLog) << Q_FUNC_INFO << this;
27}
28
29void VehicleComponent::addSummaryQmlComponent(QQmlContext *context, QQuickItem *parent)
30{
31 if (!context) {
32 qCWarning(VehicleComponentLog) << "Internal error";
33 return;
34 }
35
36 QQmlComponent component = new QQmlComponent(context->engine(), QUrl::fromUserInput("qrc:/qml/VehicleComponentSummaryButton.qml"), this);
37 if (component.status() == QQmlComponent::Error) {
38 qCWarning(VehicleComponentLog) << component.errors();
39 return;
40 }
41
42 QQuickItem *const item = qobject_cast<QQuickItem*>(component.create(context));
43 if (!item) {
44 qCWarning(VehicleComponentLog) << "Internal error";
45 return;
46 }
47
48 item->setParentItem(parent);
49 item->setProperty("vehicleComponent", QVariant::fromValue(this));
50}
51
52void VehicleComponent::setupTriggerSignals()
53{
54 // Watch for changed on trigger list params
55 for (const QString &paramName: setupCompleteChangedTriggerList()) {
58 (void) connect(fact, &Fact::valueChanged, this, &VehicleComponent::_triggerUpdated);
59 }
60 }
61}
#define QGC_LOGGING_CATEGORY(name, categoryStr)
A Fact is used to hold a single value within the system.
Definition Fact.h:19
void valueChanged(const QVariant &value)
This signal is only meant for use by the QT property system. It should not be connected to by client ...
bool parameterExists(int componentId, const QString &paramName) const
Fact * getParameter(int componentId, const QString &paramName)
static constexpr int defaultComponentId
void _triggerUpdated(QVariant)
ParameterManager * parameterManager()
Definition Vehicle.h:578