diff --git a/src/AutoPilotPlugins/PX4/AirframeComponentAirframes.cc b/src/AutoPilotPlugins/PX4/AirframeComponentAirframes.cc index 470d313a3e690a8909e6aea4d5471b4e5b977ad3..b282785cc01727c54a0e0dfe5618baf6635c1cfc 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 6a56c798ff759741f86b48df324e7fee261360e8..0a1116efc012af25c88d2c0d81ebfae1b913bf2e 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;