summaryrefslogtreecommitdiffstats
path: root/mobile-widgets/qmlmanager.cpp
diff options
context:
space:
mode:
authorGravatar Jocke <j.bygdell@gmail.com>2018-08-06 09:34:39 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2018-08-11 11:19:07 -0700
commitae70a751c7b5292ed4a798601d17013479508d86 (patch)
tree791d634f75baad076865c336d346b62bbb70a46b /mobile-widgets/qmlmanager.cpp
parentc33a952582b986c8d99b4a0e41701560e45dad7d (diff)
downloadsubsurface-ae70a751c7b5292ed4a798601d17013479508d86.tar.gz
Mobile: save pressures
Save start and end pressures for used cylinders. Signed-off-by: Joakim Bygdell <j.bygdell@gmail.com>
Diffstat (limited to 'mobile-widgets/qmlmanager.cpp')
-rw-r--r--mobile-widgets/qmlmanager.cpp17
1 files changed, 12 insertions, 5 deletions
diff --git a/mobile-widgets/qmlmanager.cpp b/mobile-widgets/qmlmanager.cpp
index ad02a3b2b..2e3576596 100644
--- a/mobile-widgets/qmlmanager.cpp
+++ b/mobile-widgets/qmlmanager.cpp
@@ -1004,7 +1004,7 @@ bool QMLManager::checkDepth(DiveObjectHelper *myDive, dive *d, QString depth)
// update the dive and return the notes field, stripped of the HTML junk
void QMLManager::commitChanges(QString diveId, QString date, QString location, QString gps, QString duration, QString depth,
QString airtemp, QString watertemp, QString suit, QString buddy, QString diveMaster, QString weight, QString notes,
- QString startpressure, QString endpressure, QStringList gasmix, QStringList usedCylinder, int rating, int visibility)
+ QStringList startpressure, QStringList endpressure, QStringList gasmix, QStringList usedCylinder, int rating, int visibility)
{
struct dive *d = get_dive_by_uniq_id(diveId.toInt());
@@ -1050,10 +1050,17 @@ void QMLManager::commitChanges(QString diveId, QString date, QString location, Q
// start and end pressures for first cylinder only
if (myDive->startPressure() != startpressure || myDive->endPressure() != endpressure) {
diveChanged = true;
- d->cylinder[0].start.mbar = parsePressureToMbar(startpressure);
- d->cylinder[0].end.mbar = parsePressureToMbar(endpressure);
- if (d->cylinder[0].end.mbar > d->cylinder[0].start.mbar)
- d->cylinder[0].end.mbar = d->cylinder[0].start.mbar;
+ for ( int i = 0, j = 0 ; j < startpressure.length() && j < endpressure.length() ; i++ ) {
+ if (!is_cylinder_used(d, i))
+ continue;
+
+ d->cylinder[i].start.mbar = parsePressureToMbar(startpressure[j]);
+ d->cylinder[i].end.mbar = parsePressureToMbar(endpressure[j]);
+ if (d->cylinder[i].end.mbar > d->cylinder[i].start.mbar)
+ d->cylinder[i].end.mbar = d->cylinder[i].start.mbar;
+
+ j++;
+ }
}
// gasmix for first cylinder
if (myDive->firstGas() != gasmix) {