diff options
author | Jocke <j.bygdell@gmail.com> | 2018-08-06 09:29:00 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2018-08-11 11:19:07 -0700 |
commit | 891e8acaa84adc213725f12778f469d40f29dde5 (patch) | |
tree | 4762b5908001129fa9a26b57f13f8b32708185e2 | |
parent | 9c9450748b088c7ffe2ab7c74e6b3d6e1688b104 (diff) | |
download | subsurface-891e8acaa84adc213725f12778f469d40f29dde5.tar.gz |
Mobile: save gasmixes
Same as for cylinder info, we need to make sure that the gasmixes gets saved to the correct cylinder.
Signed-off-by: Joakim Bygdell <j.bygdell@gmail.com>
-rw-r--r-- | mobile-widgets/qml/DiveDetailsEdit.qml | 7 | ||||
-rw-r--r-- | mobile-widgets/qmlmanager.cpp | 26 | ||||
-rw-r--r-- | mobile-widgets/qmlmanager.h | 2 |
3 files changed, 23 insertions, 12 deletions
diff --git a/mobile-widgets/qml/DiveDetailsEdit.qml b/mobile-widgets/qml/DiveDetailsEdit.qml index e144918ec..b7b7f8063 100644 --- a/mobile-widgets/qml/DiveDetailsEdit.qml +++ b/mobile-widgets/qml/DiveDetailsEdit.qml @@ -73,18 +73,23 @@ Item { // join cylinder info from separate string into a list. if (usedCyl[0] != null) { usedCyl[0] = cylinderBox0.currentText + usedGas[0] = txtGasMix0.text } if (usedCyl[1] != null) { usedCyl[1] = cylinderBox1.currentText + usedGas[1] = txtGasMix0.text } if (usedCyl[2] != null) { usedCyl[2] = cylinderBox2.currentText + usedGas[2] = txtGasMix0.text } if (usedCyl[3] != null) { usedCyl[3] = cylinderBox3.currentText + usedGas[3] = txtGasMix0.text } if (usedCyl[4] != null) { usedCyl[4] = cylinderBox4.currentText + usedGas[4] = txtGasMix0.text } // apply the changes to the dive_table @@ -93,7 +98,7 @@ Item { suitBox.currentText != "" ? suitBox.currentText : suitBox.editText, buddyBox.editText, divemasterBox.currentText != "" ? divemasterBox.currentText : divemasterBox.editText, detailsEdit.weightText, detailsEdit.notesText, detailsEdit.startpressureText, - detailsEdit.endpressureText, detailsEdit.gasmixText, usedCyl , + detailsEdit.endpressureText, usedGas, usedCyl , detailsEdit.rating, detailsEdit.visibility) // trigger the profile to be redrawn diff --git a/mobile-widgets/qmlmanager.cpp b/mobile-widgets/qmlmanager.cpp index 8bc9026e6..ad02a3b2b 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, QString gasmix, QStringList usedCylinder, int rating, int visibility) + QString startpressure, QString endpressure, QStringList gasmix, QStringList usedCylinder, int rating, int visibility) { struct dive *d = get_dive_by_uniq_id(diveId.toInt()); @@ -1057,15 +1057,21 @@ void QMLManager::commitChanges(QString diveId, QString date, QString location, Q } // gasmix for first cylinder if (myDive->firstGas() != gasmix) { - int o2 = parseGasMixO2(gasmix); - int he = parseGasMixHE(gasmix); - // the QML code SHOULD only accept valid gas mixes, but just to make sure - if (o2 >= 0 && o2 <= 1000 && - he >= 0 && he <= 1000 && - o2 + he <= 1000) { - diveChanged = true; - d->cylinder[0].gasmix.o2.permille = o2; - d->cylinder[0].gasmix.he.permille = he; + for ( int i = 0, j = 0 ; j < gasmix.length() ; i++ ) { + if (!is_cylinder_used(d, i)) + continue; + + int o2 = parseGasMixO2(gasmix[j]); + int he = parseGasMixHE(gasmix[j]); + // the QML code SHOULD only accept valid gas mixes, but just to make sure + if (o2 >= 0 && o2 <= 1000 && + he >= 0 && he <= 1000 && + o2 + he <= 1000) { + diveChanged = true; + d->cylinder[i].gasmix.o2.permille = o2; + d->cylinder[i].gasmix.he.permille = he; + } + j++; } } // info for first cylinder diff --git a/mobile-widgets/qmlmanager.h b/mobile-widgets/qmlmanager.h index 3f8633f22..5406c6f68 100644 --- a/mobile-widgets/qmlmanager.h +++ b/mobile-widgets/qmlmanager.h @@ -158,7 +158,7 @@ public slots: QString duration, QString depth, QString airtemp, QString watertemp, QString suit, QString buddy, QString diveMaster, QString weight, QString notes, QString startpressure, - QString endpressure, QString gasmix, QStringList usedCylinder, int rating, int visibility); + QString endpressure, QStringList gasmix, QStringList usedCylinder, int rating, int visibility); void changesNeedSaving(); void openNoCloudRepo(); void saveChangesLocal(); |