From d542a9f1be2c415717b9b99e04a2c50fa91e3901 Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Fri, 31 Jul 2015 12:20:16 +0200 Subject: [PATCH] Update airframe meta handler --- .../PX4/AirframeComponentAirframes.cc | 26 +++++++++++++++++-- .../PX4/AirframeComponentAirframes.h | 1 + 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/src/AutoPilotPlugins/PX4/AirframeComponentAirframes.cc b/src/AutoPilotPlugins/PX4/AirframeComponentAirframes.cc index 470d313a3..b282785cc 100644 --- a/src/AutoPilotPlugins/PX4/AirframeComponentAirframes.cc +++ b/src/AutoPilotPlugins/PX4/AirframeComponentAirframes.cc @@ -30,6 +30,7 @@ QMap AirframeComponentAirf QMap& AirframeComponentAirframes::get() { +#if 0 // Set a single airframe to prevent the UI from going crazy if (rgAirframeTypes.count() == 0) { // Standard planes @@ -45,18 +46,39 @@ QMap& AirframeComponentAir // Flying wings } +#endif return rgAirframeTypes; } +void AirframeComponentAirframes::insert(QString& group, QString& image, QString& name, int id) +{ + AirframeType_t *g; + if (!rgAirframeTypes.contains(group)) { + g = new AirframeType_t; + g->name = group; + g->imageResource = QString("qrc:/qmlimages/").append(image); + qDebug() << "IMAGE:" << g->imageResource; + rgAirframeTypes.insert(group, g); + } else { + g = rgAirframeTypes.value(group); + } + + AirframeInfo_t *i = new AirframeInfo_t; + i->name = name; + i->autostartId = id; + + g->rgAirframeInfo.append(i); +} + void AirframeComponentAirframes::clear() { // Run through all and delete them - for (unsigned tindex = 0; tindex < AirframeComponentAirframes::get().count(); tindex++) { + for (int tindex = 0; tindex < AirframeComponentAirframes::get().count(); tindex++) { const AirframeComponentAirframes::AirframeType_t* pType = AirframeComponentAirframes::get().values().at(tindex); - for (unsigned index = 0; index < pType->rgAirframeInfo.count(); index++) { + for (int index = 0; index < pType->rgAirframeInfo.count(); index++) { const AirframeComponentAirframes::AirframeInfo_t* pInfo = pType->rgAirframeInfo.at(index); delete pInfo; } diff --git a/src/AutoPilotPlugins/PX4/AirframeComponentAirframes.h b/src/AutoPilotPlugins/PX4/AirframeComponentAirframes.h index 6a56c798f..0a1116efc 100644 --- a/src/AutoPilotPlugins/PX4/AirframeComponentAirframes.h +++ b/src/AutoPilotPlugins/PX4/AirframeComponentAirframes.h @@ -52,6 +52,7 @@ public: static QMap& get(); static void clear(); + static void insert(QString& group, QString& image, QString& name, int id); protected: static QMap rgAirframeTypes; -- 2.22.0