Commit 741ec708 authored by Valentin Platzgummer's avatar Valentin Platzgummer

editing loading of MeasurementComplexItem

parent fc4a64de
......@@ -143,11 +143,10 @@ bool MeasurementComplexItem::load(const QJsonObject &complexObject,
return false;
}
{
QList<JsonHelper::KeyValidateInfo> keyInfoList = {
{VisualMissionItem::jsonTypeKey, QJsonValue::String, true},
{ComplexMissionItem::jsonComplexItemTypeKey, QJsonValue::String, true},
{variantName, QJsonValue::Double, false},
{altitudeName, QJsonValue::Double, true},
};
if (!JsonHelper::validateKeys(complexObject, keyInfoList, errorString)) {
......@@ -166,12 +165,25 @@ bool MeasurementComplexItem::load(const QJsonObject &complexObject,
.arg(complexType);
return false;
}
}
setSequenceNumber(sequenceNumber);
static_assert(false, "continue here");
// load variant
if (complexObject.contains(variantName) &&
complexObject[variantName].isDouble()) {
_variant.setRawValue(complexObject[variantName].toInt());
} else {
errorString.append(tr("Not able to load route variant number."));
}
// load altitude
if (complexObject.contains(altitudeName) &&
complexObject[altitudeName].isDouble()) {
_altitude.setRawValue(complexObject[altitudeName].toDouble());
} else {
errorString.append(tr("Not able to load altitude."));
}
return true;
}
......
......@@ -64,10 +64,10 @@ size_t TileData::size() const {
}
const char *MeasurementArea::settingsGroup = "MeasurementArea";
const char *MeasurementArea::tileHeightKey = "TileHeight";
const char *MeasurementArea::tileWidthName = "TileWidth";
const char *MeasurementArea::minTileAreaKey = "MinTileAreaPercent";
const char *MeasurementArea::showTilesKey = "ShowTiles";
const char *tileHeightKey = "TileHeight";
const char *tileWidthName = "TileWidth";
const char *minTileAreaKey = "MinTileAreaPercent";
const char *showTilesKey = "ShowTiles";
const char *MeasurementArea::name = "Measurement Area";
MeasurementArea::MeasurementArea(QObject *parent)
......@@ -186,12 +186,6 @@ int MeasurementArea::maxTiles() const { return SNAKE_MAX_TILES; }
bool MeasurementArea::ready() const { return this->_state == STATE::IDLE; }
const char *MeasurementArea::getTileWidthName() { return tileWidthName; }
void MeasurementArea::setTileWidthName(const char *value) {
tileWidthName = value;
}
bool MeasurementArea::saveToJson(QJsonObject &json) {
if (ready()) {
if (this->GeoArea::saveToJson(json)) {
......
......@@ -70,9 +70,6 @@ public:
static const char *settingsGroup;
static const char *name;
static const char *getTileWidthName();
static void setTileWidthName(const char *value);
signals:
void tilesChanged();
void maxTilesChanged();
......
......@@ -9,7 +9,7 @@
QGC_LOGGING_CATEGORY(SafeAreaLog, "SafeAreaLog")
const char *SafeArea::name = "Safe Area";
const char *SafeArea::depotKey = "Depot Point";
const char *depotKey = "Depot Point";
SafeArea::SafeArea(QObject *parent) : GeoArea(parent) { init(); }
......@@ -107,8 +107,7 @@ bool SafeArea::loadFromJson(const QJsonObject &json, QString &errorString) {
QList<JsonHelper::KeyValidateInfo> versionKeyInfoList = {
{depotKey, QJsonValue::Array, true},
};
if (!JsonHelper::validateKeys(complexObject, versionKeyInfoList,
errorString)) {
if (!JsonHelper::validateKeys(json, versionKeyInfoList, errorString)) {
returnValue = false;
} else {
const auto &jsonDepot = json[depotKey];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment