QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
AirframeComponentAirframes.cc
Go to the documentation of this file.
2#include <QtCore/QFile>
3
4QMap<QString, AirframeComponentAirframes::AirframeType_t*> AirframeComponentAirframes::rgAirframeTypes;
5
6QMap<QString, AirframeComponentAirframes::AirframeType_t*>& AirframeComponentAirframes::get() {
7
8#if 0
9 // Set a single airframe to prevent the UI from going crazy
10 if (rgAirframeTypes.count() == 0) {
11 // Standard planes
12 AirframeType_t *standardPlane = new AirframeType_t;
13 standardPlane->name = "Standard Airplane";
14 standardPlane->imageResource = "qrc:/qmlimages/AirframeStandardPlane.svg";
15 AirframeInfo_t *easystar = new AirframeInfo_t;
16 easystar->name = "Multiplex Easystar 1/2";
17 easystar->autostartId = 2100;
18 standardPlane->rgAirframeInfo.append(easystar);
19 rgAirframeTypes.insert("StandardPlane", standardPlane);
20 qDebug() << "Adding plane config";
21
22 // Flying wings
23 }
24#endif
25
26 return rgAirframeTypes;
27}
28
29void AirframeComponentAirframes::insert(QString& group, QString& image, QString& name, int id)
30{
32 if (!rgAirframeTypes.contains(group)) {
33 g = new AirframeType_t;
34 g->name = group;
35
36 if (image.length() > 0) {
37 g->imageResource = QString(":/qmlimages/Airframe/%1.svg").arg(image);
38 if (!QFile::exists(g->imageResource)) {
39 g->imageResource.clear();
40 } else {
41 g->imageResource.prepend(QStringLiteral("qrc"));
42 }
43 }
44
45 if (g->imageResource.isEmpty()) {
46 g->imageResource = QString("qrc:/qmlimages/Airframe/AirframeUnknown.svg");
47 }
48
49 rgAirframeTypes.insert(group, g);
50 } else {
51 g = rgAirframeTypes.value(group);
52 }
53
55 i->name = name;
56 i->autostartId = id;
57
58 g->rgAirframeInfo.append(i);
59}
60
62
63 // Run through all and delete them
64 for (int tindex = 0; tindex < AirframeComponentAirframes::get().count(); tindex++) {
65
67
68 for (int index = 0; index < pType->rgAirframeInfo.count(); index++) {
69 const AirframeComponentAirframes::AirframeInfo_t* pInfo = pType->rgAirframeInfo.at(index);
70 delete pInfo;
71 }
72
73 delete pType;
74 }
75
76 rgAirframeTypes.clear();
77}
static void insert(QString &group, QString &image, QString &name, int id)
static QMap< QString, AirframeComponentAirframes::AirframeType_t * > & get()
static QMap< QString, AirframeType_t * > rgAirframeTypes