Commit 236327b8 authored by Valentin Platzgummer's avatar Valentin Platzgummer

files from 6485d280 checked out

parent e5b570c5
......@@ -37,7 +37,7 @@ FactGroup::FactGroup(int updateRateMsecs, QObject* parent, bool ignoreCamelCase)
QQmlEngine::setObjectOwnership(this, QQmlEngine::CppOwnership);
}
void FactGroup::_loadFromJsonArray(const QJsonObject jsonArray)
void FactGroup::_loadFromJsonArray(const QJsonArray jsonArray)
{
QMap<QString, QString> defineMap;
_nameToFactMetaDataMap = FactMetaData::createMapFromJsonArray(jsonArray, defineMap, this);
......
......@@ -64,7 +64,7 @@ protected slots:
protected:
void _addFact (Fact* fact, const QString& name);
void _addFactGroup (FactGroup* factGroup, const QString& name);
void _loadFromJsonArray (const QJsonObject jsonArray);
void _loadFromJsonArray (const QJsonArray jsonArray);
void _setTelemetryAvailable (bool telemetryAvailable);
int _updateRateMSecs; ///< Update rate for Fact::valueChanged signals, 0: immediate update
......
......@@ -1448,7 +1448,7 @@ QMap<QString, FactMetaData*> FactMetaData::createMapFromJsonFile(const QString&
return metaDataMap;
}
QJsonObject factArray;
QJsonArray factArray;
QMap<QString /* define name */, QString /* define value */> defineMap;
QList<JsonHelper::KeyValidateInfo> keyInfoList = {
......@@ -1466,7 +1466,7 @@ QMap<QString, FactMetaData*> FactMetaData::createMapFromJsonFile(const QString&
return createMapFromJsonArray(factArray, defineMap, metaDataParent);
}
QMap<QString, FactMetaData*> FactMetaData::createMapFromJsonArray(const QJsonObject jsonArray, QMap<QString, QString>& defineMap, QObject* metaDataParent)
QMap<QString, FactMetaData*> FactMetaData::createMapFromJsonArray(const QJsonArray jsonArray, QMap<QString, QString>& defineMap, QObject* metaDataParent)
{
QMap<QString, FactMetaData*> metaDataMap;
for (int i=0; i<jsonArray.count(); i++) {
......@@ -1554,7 +1554,7 @@ bool FactMetaData::_parseValuesArray(const QJsonObject& jsonObject, QStringList&
{ _enumValuesArrayValueJsonKey, QJsonValue::Double, true },
};
const QJsonObject& rgValueDescription = jsonObject[_enumValuesArrayJsonKey].toArray();
const QJsonArray& rgValueDescription = jsonObject[_enumValuesArrayJsonKey].toArray();
for (int i=0; i<rgValueDescription.count(); i++) {
if (rgValueDescription[i].type() != QJsonValue::Object) {
errorString = QStringLiteral("Value at index %1 in \"values\" array is not an object.").arg(i);
......@@ -1589,7 +1589,7 @@ bool FactMetaData::_parseBitmaskArray(const QJsonObject& jsonObject, QStringList
{ _enumBitmaskArrayIndexJsonKey, QJsonValue::Double, true },
};
const QJsonObject& rgValueDescription = jsonObject[_enumBitmaskArrayJsonKey].toArray();
const QJsonArray& rgValueDescription = jsonObject[_enumBitmaskArrayJsonKey].toArray();
for (int i=0; i<rgValueDescription.count(); i++) {
if (rgValueDescription[i].type() != QJsonValue::Object) {
errorString = QStringLiteral("Value at index %1 in \"values\" array is not an object.").arg(i);
......
......@@ -57,7 +57,7 @@ public:
typedef QMap<QString, QString> DefineMap_t;
static QMap<QString, FactMetaData*> createMapFromJsonFile(const QString& jsonFilename, QObject* metaDataParent);
static QMap<QString, FactMetaData*> createMapFromJsonArray(const QJsonObject jsonArray, DefineMap_t& defineMap, QObject* metaDataParent);
static QMap<QString, FactMetaData*> createMapFromJsonArray(const QJsonArray jsonArray, DefineMap_t& defineMap, QObject* metaDataParent);
static FactMetaData* createFromJsonObject(const QJsonObject& json, QMap<QString, QString>& defineMap, QObject* metaDataParent);
......
/****************************************************************************
*
* (c) 2009-2020 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
*
* QGroundControl is licensed according to the terms in the file
* COPYING.md in the root of the source code directory.
*
****************************************************************************/
#include "FactGroup.h"
#include "JsonHelper.h"
#include <QJsonDocument>
#include <QJsonParseError>
#include <QJsonArray>
#include <QDebug>
#include <QFile>
#include <QQmlEngine>
FactGroup::FactGroup(int updateRateMsecs, const QString& metaDataFile, QObject* parent, bool ignoreCamelCase)
: QObject(parent)
, _updateRateMSecs(updateRateMsecs)
, _ignoreCamelCase(ignoreCamelCase)
{
_setupTimer();
_nameToFactMetaDataMap = FactMetaData::createMapFromJsonFile(metaDataFile, this);
QQmlEngine::setObjectOwnership(this, QQmlEngine::CppOwnership);
}
FactGroup::FactGroup(int updateRateMsecs, QObject* parent, bool ignoreCamelCase)
: QObject(parent)
, _updateRateMSecs(updateRateMsecs)
, _ignoreCamelCase(ignoreCamelCase)
{
_setupTimer();
QQmlEngine::setObjectOwnership(this, QQmlEngine::CppOwnership);
}
void FactGroup::_loadFromJsonArray(const QJsonArray jsonArray)
{
QMap<QString, QString> defineMap;
_nameToFactMetaDataMap = FactMetaData::createMapFromJsonArray(jsonArray, defineMap, this);
}
void FactGroup::_setupTimer()
{
if (_updateRateMSecs > 0) {
connect(&_updateTimer, &QTimer::timeout, this, &FactGroup::_updateAllValues);
_updateTimer.setSingleShot(false);
_updateTimer.setInterval(_updateRateMSecs);
_updateTimer.start();
}
}
bool FactGroup::factExists(const QString& name)
{
if (name.contains(".")) {
QStringList parts = name.split(".");
if (parts.count() != 2) {
qWarning() << "Only single level of hierarchy supported";
return false;
}
FactGroup * factGroup = getFactGroup(parts[0]);
if (!factGroup) {
qWarning() << "Unknown FactGroup" << parts[0];
return false;
}
return factGroup->factExists(parts[1]);
}
QString camelCaseName = _ignoreCamelCase ? name : _camelCase(name);
return _nameToFactMap.contains(camelCaseName);
}
Fact* FactGroup::getFact(const QString& name)
{
if (name.contains(".")) {
QStringList parts = name.split(".");
if (parts.count() != 2) {
qWarning() << "Only single level of hierarchy supported";
return nullptr;
}
FactGroup * factGroup = getFactGroup(parts[0]);
if (!factGroup) {
qWarning() << "Unknown FactGroup" << parts[0];
return nullptr;
}
return factGroup->getFact(parts[1]);
}
Fact* fact = nullptr;
QString camelCaseName = _ignoreCamelCase ? name : _camelCase(name);
if (_nameToFactMap.contains(camelCaseName)) {
fact = _nameToFactMap[camelCaseName];
QQmlEngine::setObjectOwnership(fact, QQmlEngine::CppOwnership);
} else {
qWarning() << "Unknown Fact" << camelCaseName;
}
return fact;
}
FactGroup* FactGroup::getFactGroup(const QString& name)
{
FactGroup* factGroup = nullptr;
QString camelCaseName = _ignoreCamelCase ? name : _camelCase(name);
if (_nameToFactGroupMap.contains(camelCaseName)) {
factGroup = _nameToFactGroupMap[camelCaseName];
QQmlEngine::setObjectOwnership(factGroup, QQmlEngine::CppOwnership);
} else {
qWarning() << "Unknown FactGroup" << camelCaseName;
}
return factGroup;
}
void FactGroup::_addFact(Fact* fact, const QString& name)
{
if (_nameToFactMap.contains(name)) {
qWarning() << "Duplicate Fact" << name;
return;
}
fact->setSendValueChangedSignals(_updateRateMSecs == 0);
if (_nameToFactMetaDataMap.contains(name)) {
fact->setMetaData(_nameToFactMetaDataMap[name], true /* setDefaultFromMetaData */);
}
_nameToFactMap[name] = fact;
_factNames.append(name);
emit factNamesChanged();
}
void FactGroup::_addFactGroup(FactGroup* factGroup, const QString& name)
{
if (_nameToFactGroupMap.contains(name)) {
qWarning() << "Duplicate FactGroup" << name;
return;
}
_nameToFactGroupMap[name] = factGroup;
emit factGroupNamesChanged();
}
void FactGroup::_updateAllValues(void)
{
for(Fact* fact: _nameToFactMap) {
fact->sendDeferredValueChangedSignal();
}
}
void FactGroup::setLiveUpdates(bool liveUpdates)
{
if (_updateTimer.interval() == 0) {
return;
}
if (liveUpdates) {
_updateTimer.stop();
} else {
_updateTimer.start();
}
for(Fact* fact: _nameToFactMap) {
fact->setSendValueChangedSignals(liveUpdates);
}
}
QString FactGroup::_camelCase(const QString& text)
{
return text[0].toLower() + text.right(text.length() - 1);
}
void FactGroup::handleMessage(Vehicle* /* vehicle */, mavlink_message_t& /* message */)
{
// Default implementation does nothing
}
void FactGroup::_setTelemetryAvailable (bool telemetryAvailable)
{
if (telemetryAvailable != _telemetryAvailable) {
_telemetryAvailable = telemetryAvailable;
emit telemetryAvailableChanged(_telemetryAvailable);
}
}
This diff is collapsed.
This diff is collapsed.
......@@ -61,7 +61,7 @@ CorridorScanComplexItem::CorridorScanComplexItem(PlanMasterController* masterCon
setDirty(false);
}
void CorridorScanComplexItem::save(QJsonObject& planItems)
void CorridorScanComplexItem::save(QJsonArray& planItems)
{
QJsonObject saveObject;
......
......@@ -37,7 +37,7 @@ public:
// Overrides from TransectStyleComplexItem
QString patternName (void) const final { return name; }
void save (QJsonObject& planItems) final;
void save (QJsonArray& planItems) final;
bool specifiesCoordinate (void) const final;
double timeBetweenShots (void) final;
......
......@@ -81,7 +81,7 @@ void FWLandingPatternTest::_testDirty(void)
void FWLandingPatternTest::_testSaveLoad(void)
{
QJsonObject items;
QJsonArray items;
_fwItem->save(items);
......
......@@ -60,7 +60,7 @@ FixedWingLandingComplexItem::FixedWingLandingComplexItem(PlanMasterController* m
setDirty(false);
}
void FixedWingLandingComplexItem::save(QJsonObject& missionItems)
void FixedWingLandingComplexItem::save(QJsonArray& missionItems)
{
QJsonObject saveObject = _save();
......
......@@ -44,7 +44,7 @@ public:
QString mapVisualQML (void) const final { return QStringLiteral("FWLandingPatternMapVisual.qml"); }
// Overrides from VisualMissionItem
void save (QJsonObject& missionItems) final;
void save (QJsonArray& missionItems) final;
static const QString name;
......
......@@ -152,7 +152,7 @@ bool GeoFenceController::load(const QJsonObject& json, QString& errorString)
return false;
}
QJsonObject jsonPolygonArray = json[_jsonPolygonsKey].toArray();
QJsonArray jsonPolygonArray = json[_jsonPolygonsKey].toArray();
for (const QJsonValue jsonPolygonValue: jsonPolygonArray) {
if (jsonPolygonValue.type() != QJsonValue::Object) {
errorString = tr("GeoFence polygon not stored as object");
......@@ -166,7 +166,7 @@ bool GeoFenceController::load(const QJsonObject& json, QString& errorString)
_polygons.append(fencePolygon);
}
QJsonObject jsonCircleArray = json[_jsonCirclesKey].toArray();
QJsonArray jsonCircleArray = json[_jsonCirclesKey].toArray();
for (const QJsonValue jsonCircleValue: jsonCircleArray) {
if (jsonCircleValue.type() != QJsonValue::Object) {
errorString = tr("GeoFence circle not stored as object");
......@@ -200,7 +200,7 @@ void GeoFenceController::save(QJsonObject& json)
{
json[JsonHelper::jsonVersionKey] = _jsonCurrentVersion;
QJsonObject jsonPolygonArray;
QJsonArray jsonPolygonArray;
for (int i=0; i<_polygons.count(); i++) {
QJsonObject jsonPolygon;
QGCFencePolygon* fencePolygon = _polygons.value<QGCFencePolygon*>(i);
......@@ -209,7 +209,7 @@ void GeoFenceController::save(QJsonObject& json)
}
json[_jsonPolygonsKey] = jsonPolygonArray;
QJsonObject jsonCircleArray;
QJsonArray jsonCircleArray;
for (int i=0; i<_circles.count(); i++) {
QJsonObject jsonCircle;
QGCFenceCircle* fenceCircle = _circles.value<QGCFenceCircle*>(i);
......
......@@ -82,7 +82,7 @@ public:
QString mapVisualQML(void) const final { return QStringLiteral("FWLandingPatternMapVisual.qml"); }
// Overrides from VisualMissionItem
void save (QJsonObject& /*missionItems*/) { };
void save (QJsonArray& /*missionItems*/) { };
static const QString name;
......
......@@ -55,7 +55,7 @@ void MissionCommandList::_loadMavCmdInfoJson(const QString& jsonFilename, bool b
}
// Iterate over MissionCommandUIInfo objects
QJsonObject jsonArray = jsonValue.toArray();
QJsonArray jsonArray = jsonValue.toArray();
for(QJsonValue info: jsonArray) {
if (!info.isObject()) {
qWarning() << jsonFilename << "mavCmdArray should contain objects";
......
......@@ -744,7 +744,7 @@ bool MissionController::_loadJsonMissionFileV1(const QJsonObject &json,
// Read complex items
QList<SurveyComplexItem *> surveyItems;
QJsonObject complexArray(json[_jsonComplexItemsKey].toArray());
QJsonArray complexArray(json[_jsonComplexItemsKey].toArray());
qCDebug(MissionControllerLog)
<< "Json load: complex item count" << complexArray.count();
for (int i = 0; i < complexArray.count(); i++) {
......@@ -771,7 +771,7 @@ bool MissionController::_loadJsonMissionFileV1(const QJsonObject &json,
int nextSimpleItemIndex = 0;
int nextComplexItemIndex = 0;
int nextSequenceNumber = 1; // Start with 1 since home is in 0
QJsonObject itemArray(json[_jsonItemsKey].toArray());
QJsonArray itemArray(json[_jsonItemsKey].toArray());
MissionSettingsItem *settingsItem = _addMissionSettings(visualItems);
if (json.contains(_jsonPlannedHomePositionKey)) {
......@@ -932,7 +932,7 @@ bool MissionController::_loadJsonMissionFileV2(const QJsonObject &json,
// Read mission items
int nextSequenceNumber = 1; // Start with 1 since home is in 0
const QJsonObject rgMissionItems(json[_jsonItemsKey].toArray());
const QJsonArray rgMissionItems(json[_jsonItemsKey].toArray());
for (int i = 0; i < rgMissionItems.count(); i++) {
// Convert to QJsonObject
const QJsonValue &itemValue = rgMissionItems[i];
......@@ -1335,7 +1335,7 @@ void MissionController::save(QJsonObject &json) {
// Save the visual items
QJsonObject rgJsonMissionItems;
QJsonArray rgJsonMissionItems;
for (int i = 0; i < _visualItems->count(); i++) {
VisualMissionItem *visualItem =
qobject_cast<VisualMissionItem *>(_visualItems->get(i));
......
......@@ -147,7 +147,7 @@ void MissionItem::save(QJsonObject &json) const {
json[_jsonAutoContinueKey] = autoContinue();
json[_jsonDoJumpIdKey] = _sequenceNumber;
QJsonObject rgParams = {param1(), param2(), param3(), param4(),
QJsonArray rgParams = {param1(), param2(), param3(), param4(),
param5(), param6(), param7()};
json[_jsonParamsKey] = rgParams;
}
......@@ -206,7 +206,7 @@ bool MissionItem::_convertJsonV1ToV2(const QJsonObject &json,
VisualMissionItem::jsonTypeSimpleItemValue;
}
QJsonObject rgParams = {
QJsonArray rgParams = {
json[_jsonParam1Key].toDouble(), json[_jsonParam2Key].toDouble(),
json[_jsonParam3Key].toDouble(), json[_jsonParam4Key].toDouble()};
v2Json[_jsonParamsKey] = rgParams;
......@@ -241,7 +241,7 @@ bool MissionItem::_convertJsonV2ToV3(QJsonObject &json, QString &errorString) {
return false;
}
QJsonObject rgParam = json[_jsonParamsKey].toArray();
QJsonArray rgParam = json[_jsonParamsKey].toArray();
rgParam.append(coordinate.latitude());
rgParam.append(coordinate.longitude());
rgParam.append(coordinate.altitude());
......@@ -283,7 +283,7 @@ bool MissionItem::load(const QJsonObject &json, int sequenceNumber,
return false;
}
QJsonObject rgParams = convertedJson[_jsonParamsKey].toArray();
QJsonArray rgParams = convertedJson[_jsonParamsKey].toArray();
if (rgParams.count() != 7) {
errorString = tr("%1 key must contains 7 values").arg(_jsonParamsKey);
return false;
......
......@@ -342,7 +342,7 @@ void MissionItemTest::_testLoadFromJsonV2(void)
QVERIFY(!errorString.isEmpty());
qDebug() << errorString;
QJsonObject badCoordinateArray;
QJsonArray badCoordinateArray;
badCoordinateArray << -10.0 << -20.0 ;
badObject = jsonObject;
badObject.remove("coordinate");
......@@ -351,7 +351,7 @@ void MissionItemTest::_testLoadFromJsonV2(void)
QVERIFY(!errorString.isEmpty());
qDebug() << errorString;
QJsonObject badCoordinateArray_second;
QJsonArray badCoordinateArray_second;
badCoordinateArray_second << -10.0 << -20.0 << true;
badObject = jsonObject;
badObject.remove("coordinate");
......@@ -360,9 +360,9 @@ void MissionItemTest::_testLoadFromJsonV2(void)
QVERIFY(!errorString.isEmpty());
qDebug() << errorString;
QJsonObject badCoordinateArray2;
QJsonArray badCoordinateArray2;
badCoordinateArray2 << 1 << 2;
QJsonObject badCoordinateArray_third;
QJsonArray badCoordinateArray_third;
badCoordinateArray_third << -10.0 << -20.0 << badCoordinateArray2;
badObject = jsonObject;
badObject.remove("coordinate");
......@@ -412,7 +412,7 @@ void MissionItemTest::_testLoadFromJsonV3(void)
// Incorrect param count
badObject = jsonObject;
QJsonObject rgParam = badObject[MissionItem::_jsonParamsKey].toArray();
QJsonArray rgParam = badObject[MissionItem::_jsonParamsKey].toArray();
rgParam.removeFirst();
badObject[MissionItem::_jsonParamsKey] = rgParam;
QCOMPARE(missionItem.load(badObject, _seq, errorString), false);
......@@ -450,7 +450,7 @@ void MissionItemTest::_testSimpleLoadFromJson(void)
SimpleMissionItem simpleMissionItem(_masterController, false /* flyView */, false /* forLoad */, nullptr);
QString errorString;
QJsonObject coordinateArray;
QJsonArray coordinateArray;
QJsonObject jsonObject;
coordinateArray << -10.0 << -20.0 <<-30.0;
......@@ -460,7 +460,7 @@ void MissionItemTest::_testSimpleLoadFromJson(void)
jsonObject.insert(VisualMissionItem::jsonTypeKey, VisualMissionItem::jsonTypeSimpleItemValue);
jsonObject.insert(MissionItem::_jsonCoordinateKey, coordinateArray);
QJsonObject rgParams = { 10, 20, 30, 40 };
QJsonArray rgParams = { 10, 20, 30, 40 };
jsonObject.insert(MissionItem::_jsonParamsKey, rgParams);
QVERIFY(simpleMissionItem.load(jsonObject, _seq, errorString));
......@@ -489,7 +489,7 @@ void MissionItemTest::_testSaveToJson(void)
QJsonObject MissionItemTest::_createV1Json(void)
{
QJsonObject jsonObject;
QJsonObject coordinateArray;
QJsonArray coordinateArray;
coordinateArray << -10.0 << -20.0 <<-30.0;
jsonObject.insert(MissionItem::_jsonAutoContinueKey, true);
......@@ -508,7 +508,7 @@ QJsonObject MissionItemTest::_createV1Json(void)
QJsonObject MissionItemTest::_createV2Json(void)
{
QJsonObject jsonObject;
QJsonObject coordinateArray;
QJsonArray coordinateArray;
coordinateArray << -10.0 << -20.0 <<-30.0;
jsonObject.insert(MissionItem::_jsonAutoContinueKey, true);
......@@ -517,7 +517,7 @@ QJsonObject MissionItemTest::_createV2Json(void)
jsonObject.insert(VisualMissionItem::jsonTypeKey, VisualMissionItem::jsonTypeSimpleItemValue);
jsonObject.insert(MissionItem::_jsonCoordinateKey, coordinateArray);
QJsonObject rgParams = { 10, 20, 30, 40 };
QJsonArray rgParams = { 10, 20, 30, 40 };
jsonObject.insert(MissionItem::_jsonParamsKey, rgParams);
return jsonObject;
......@@ -533,10 +533,10 @@ QJsonObject MissionItemTest::_createV3Json(bool allNaNs)
jsonObject.insert(VisualMissionItem::jsonTypeKey, VisualMissionItem::jsonTypeSimpleItemValue);
if (allNaNs) {
QJsonObject rgParams = { NAN, NAN, NAN, NAN, NAN, NAN, NAN };
QJsonArray rgParams = { NAN, NAN, NAN, NAN, NAN, NAN, NAN };
jsonObject.insert(MissionItem::_jsonParamsKey, rgParams);
} else {
QJsonObject rgParams = { 10, 20, 30, 40, -10, -20, -30 };
QJsonArray rgParams = { 10, 20, 30, 40, -10, -20, -30 };
jsonObject.insert(MissionItem::_jsonParamsKey, rgParams);
}
......
......@@ -88,7 +88,7 @@ void MissionSettingsItem::setDirty(bool dirty)
}
}
void MissionSettingsItem::save(QJsonObject& missionItems)
void MissionSettingsItem::save(QJsonArray& missionItems)
{
QList<MissionItem*> items;
......
......@@ -87,7 +87,7 @@ public:
void setDirty (bool dirty) final;
void setCoordinate (const QGeoCoordinate& coordinate) final; // Should only be called if the end user is moving
void setSequenceNumber (int sequenceNumber) final;
void save (QJsonObject& missionItems) final;
void save (QJsonArray& missionItems) final;
double amslEntryAlt (void) const final { return _plannedHomePositionCoordinate.altitude(); }
double amslExitAlt (void) const final { return amslEntryAlt(); }
double minAMSLAltitude (void) const final { return amslEntryAlt(); }
......
......@@ -128,7 +128,7 @@ void RallyPointController::save(QJsonObject& json)
{
json[JsonHelper::jsonVersionKey] = _jsonCurrentVersion;
QJsonObject rgPoints;
QJsonArray rgPoints;
QJsonValue jsonPoint;
for (int i=0; i<_points.count(); i++) {
JsonHelper::saveGeoCoordinate(qobject_cast<RallyPoint*>(_points[i])->coordinate(), true /* writeAltitude */, jsonPoint);
......
......@@ -260,7 +260,7 @@ SimpleMissionItem::~SimpleMissionItem()
{
}
void SimpleMissionItem::save(QJsonObject& missionItems)
void SimpleMissionItem::save(QJsonArray& missionItems)
{
QList<MissionItem*> items;
......
......@@ -127,7 +127,7 @@ public:
void setCoordinate (const QGeoCoordinate& coordinate) override;
void setSequenceNumber (int sequenceNumber) final;
int lastSequenceNumber (void) const final;
void save (QJsonObject& missionItems) final;
void save (QJsonArray& missionItems) final;
signals:
void commandChanged (int command);
......
......@@ -177,7 +177,7 @@ void StructureScanComplexItem::setDirty(bool dirty)
}
}
void StructureScanComplexItem::save(QJsonObject& missionItems)
void StructureScanComplexItem::save(QJsonArray& missionItems)
{
QJsonObject saveObject;
......
......@@ -94,7 +94,7 @@ public:
void setDirty (bool dirty) final;
void setCoordinate (const QGeoCoordinate& coordinate) final { Q_UNUSED(coordinate); }
void setSequenceNumber (int sequenceNumber) final;
void save (QJsonObject& missionItems) final;
void save (QJsonArray& missionItems) final;
double amslEntryAlt (void) const final;
double amslExitAlt (void) const final { return amslEntryAlt(); };
double minAMSLAltitude (void) const final;
......
......@@ -110,7 +110,7 @@ void StructureScanComplexItemTest::_testSaveLoad(void)
{
_initItem();
QJsonObject items;
QJsonArray items;
_structureScanItem->save(items);
QString errorString;
......
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
......@@ -171,7 +171,7 @@ void TransectStyleComplexItem::_save(QJsonObject& complexObject)
innerObject[_jsonVisualTransectPointsKey] = transectPointsJson;
// Save the interal mission items
QJsonObject missionItemsJsonArray;
QJsonArray missionItemsJsonArray;
QObject* missionItemParent = new QObject();
QList<MissionItem*> missionItems;
appendMissionItems(missionItems, missionItemParent);
......@@ -242,7 +242,7 @@ bool TransectStyleComplexItem::_load(const QJsonObject& complexObject, bool forP
// Load generated mission items
_loadedMissionItemsParent = new QObject(this);
QJsonObject missionItemsJsonArray = innerObject[_jsonItemsKey].toArray();
QJsonArray missionItemsJsonArray = innerObject[_jsonItemsKey].toArray();
for (const QJsonValue missionItemJson: missionItemsJsonArray) {
MissionItem* missionItem = new MissionItem(_loadedMissionItemsParent);
if (!missionItem->load(missionItemJson.toObject(), 0 /* sequenceNumber */, errorString)) {
......
......@@ -86,7 +86,7 @@ public:
double greatestDistanceTo (const QGeoCoordinate &other) const final;
// Overrides from VisualMissionItem
void save (QJsonObject& planItems) override = 0;
void save (QJsonArray& planItems) override = 0;
bool specifiesCoordinate (void) const override = 0;
virtual void appendMissionItems (QList<MissionItem*>& items, QObject* missionItemParent) final;
virtual void applyNewAltitude (double newAltitude) final;
......
......@@ -88,7 +88,7 @@ public:
bool load (const QJsonObject& complexObject, int sequenceNumber, QString& errorString) final { Q_UNUSED(complexObject); Q_UNUSED(sequenceNumber); Q_UNUSED(errorString); return false; }
// Overrides from VisualMissionItem
void save (QJsonObject& missionItems) final { Q_UNUSED(missionItems); }
void save (QJsonArray& missionItems) final { Q_UNUSED(missionItems); }
bool specifiesCoordinate (void) const final { return true; }
double additionalTimeDelay (void) const final { return 0; }
......
......@@ -57,7 +57,7 @@ VTOLLandingComplexItem::VTOLLandingComplexItem(PlanMasterController* masterContr
setDirty(false);
}
void VTOLLandingComplexItem::save(QJsonObject& missionItems)
void VTOLLandingComplexItem::save(QJsonArray& missionItems)
{
QJsonObject saveObject = _save();
......
......@@ -35,7 +35,7 @@ public:
QString mapVisualQML (void) const final { return QStringLiteral("VTOLLandingPatternMapVisual.qml"); }
// Overrides from VisualMissionItem
void save (QJsonObject& missionItems) final;
void save (QJsonArray& missionItems) final;
static const QString name;
......
......@@ -177,7 +177,7 @@ public:
/// Save the item(s) in Json format
/// @param missionItems Current set of mission items, new items should be appended to the end
virtual void save(QJsonObject& missionItems) = 0;
virtual void save(QJsonArray& missionItems) = 0;
/// @return The QML resource file which contains the control which visualizes the item on the map.
virtual QString mapVisualQML(void) const = 0;
......
......@@ -97,7 +97,7 @@ enum QGCGeoCodeType {
class JasonMonger {
public:
JasonMonger();
QSet<int> json2QGCGeoCodeType(const QJsonObject &types);
QSet<int> json2QGCGeoCodeType(const QJsonArray &types);
private:
int _getCode(const QString &key);
QMap<QString, int> _m;
......@@ -145,7 +145,7 @@ int JasonMonger::_getCode(const QString &key) {
return _m.value(key, GeoCodeTypeUnknown);
}
QSet<int> JasonMonger::json2QGCGeoCodeType(const QJsonObject &types) {
QSet<int> JasonMonger::json2QGCGeoCodeType(const QJsonArray &types) {
QSet<int> result;