aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2019-08-10 18:10:02 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2019-08-11 12:23:33 -0700
commit6b92edc9ab3111cbd1e76938c16a56673cd3791f (patch)
treeff876ccde7f47d952b374efab8b346bfe9e4d11b
parent75be9e727d12ebd122f5dc96737248067afc9629 (diff)
downloadsubsurface-6b92edc9ab3111cbd1e76938c16a56673cd3791f.tar.gz
Mobile: support editing of dives with no weightsystem
If a dive has no weightsystems, editing the weight system has to add a new entry in the table. Implement that. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
-rw-r--r--mobile-widgets/qmlmanager.cpp13
1 files changed, 8 insertions, 5 deletions
diff --git a/mobile-widgets/qmlmanager.cpp b/mobile-widgets/qmlmanager.cpp
index 1289bcf64..fc8f12a20 100644
--- a/mobile-widgets/qmlmanager.cpp
+++ b/mobile-widgets/qmlmanager.cpp
@@ -1040,11 +1040,14 @@ void QMLManager::commitChanges(QString diveId, QString date, QString location, Q
diveChanged = true;
d->watertemp.mkelvin = parseTemperatureToMkelvin(watertemp);
}
- // not sure what we'd do if there was more than one weight system
- // defined - for now just ignore that case
- if (d->weightsystems.nr == 1) {
- if (myDive->sumWeight() != weight) {
- diveChanged = true;
+ if (myDive->sumWeight() != weight) {
+ diveChanged = true;
+ // not sure what we'd do if there was more than one weight system
+ // defined - for now just ignore that case
+ if (d->weightsystems.nr == 0) {
+ weightsystem_t ws = { { parseWeightToGrams(weight) } , "" };
+ add_cloned_weightsystem(&d->weightsystems, ws);
+ } else if (d->weightsystems.nr == 1) {
d->weightsystems.weightsystems[0].weight.grams = parseWeightToGrams(weight);
}
}