aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Jocke <j.bygdell@gmail.com>2018-07-29 15:42:56 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2018-08-11 11:19:07 -0700
commit0fb086a4a53dcbd90af01a9faac271d312b485cf (patch)
treefca0304609cf92a9ae1720e6b8e5f7fcea3d30dd
parentbd8eec5c8e97050b130bb2d9f02162fe189edbda (diff)
downloadsubsurface-0fb086a4a53dcbd90af01a9faac271d312b485cf.tar.gz
Mobile: fix saving new dive
With the new setup we need to know which state we are coming from when we are saving cylinder related info. When we are adding a new dive we explicitly should save cylinder data to the first cylinder. Signed-off-by: Joakim Bygdell <j.bygdell@gmail.com>
-rw-r--r--mobile-widgets/qml/DiveDetailsEdit.qml3
-rw-r--r--mobile-widgets/qmlmanager.cpp10
-rw-r--r--mobile-widgets/qmlmanager.h2
3 files changed, 8 insertions, 7 deletions
diff --git a/mobile-widgets/qml/DiveDetailsEdit.qml b/mobile-widgets/qml/DiveDetailsEdit.qml
index 91d7a9e23..2faa62d22 100644
--- a/mobile-widgets/qml/DiveDetailsEdit.qml
+++ b/mobile-widgets/qml/DiveDetailsEdit.qml
@@ -73,6 +73,7 @@ Item {
}
function saveData() {
+ var state = diveDetailsPage.state
diveDetailsPage.state = "view" // run the transition
// join cylinder info from separate string into a list.
if (usedCyl[0] != null) {
@@ -114,7 +115,7 @@ Item {
detailsEdit.weightText, detailsEdit.notesText, startpressure,
endpressure, usedGas, usedCyl ,
detailsEdit.rating,
- detailsEdit.visibility)
+ detailsEdit.visibility, state)
// trigger the profile to be redrawn
QMLProfile.diveId = dive_id
diff --git a/mobile-widgets/qmlmanager.cpp b/mobile-widgets/qmlmanager.cpp
index 1e62cf0ca..d557d0f34 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,
- QStringList startpressure, QStringList endpressure, QStringList gasmix, QStringList usedCylinder, int rating, int visibility)
+ QStringList startpressure, QStringList endpressure, QStringList gasmix, QStringList usedCylinder, int rating, int visibility, QString state)
{
struct dive *d = get_dive_by_uniq_id(diveId.toInt());
@@ -1051,7 +1051,7 @@ void QMLManager::commitChanges(QString diveId, QString date, QString location, Q
if (myDive->startPressure() != startpressure || myDive->endPressure() != endpressure) {
diveChanged = true;
for ( int i = 0, j = 0 ; j < startpressure.length() && j < endpressure.length() ; i++ ) {
- if (!is_cylinder_used(d, i))
+ if (state != "add" && !is_cylinder_used(d, i))
continue;
d->cylinder[i].start.mbar = parsePressureToMbar(startpressure[j]);
@@ -1065,7 +1065,7 @@ void QMLManager::commitChanges(QString diveId, QString date, QString location, Q
// gasmix for first cylinder
if (myDive->firstGas() != gasmix) {
for ( int i = 0, j = 0 ; j < gasmix.length() ; i++ ) {
- if (!is_cylinder_used(d, i))
+ if (state != "add" && !is_cylinder_used(d, i))
continue;
int o2 = parseGasMixO2(gasmix[j]);
@@ -1086,8 +1086,8 @@ void QMLManager::commitChanges(QString diveId, QString date, QString location, Q
diveChanged = true;
unsigned long i;
int size = 0, wp = 0, j = 0, k = 0;
- for (j = 0; k < usedCylinder.length() ; j++) {
- if (!is_cylinder_used(d, j))
+ for (j = 0; k < usedCylinder.length() && j < MAX_CYLINDERS; j++) {
+ if (state != "add" && !is_cylinder_used(d, j))
continue;
for (i = 0; i < MAX_TANK_INFO && tank_info[i].name != NULL; i++) {
diff --git a/mobile-widgets/qmlmanager.h b/mobile-widgets/qmlmanager.h
index 109f10f74..48e6540b5 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, QStringList startpressure,
- QStringList endpressure, QStringList gasmix, QStringList usedCylinder, int rating, int visibility);
+ QStringList endpressure, QStringList gasmix, QStringList usedCylinder, int rating, int visibility, QString state);
void changesNeedSaving();
void openNoCloudRepo();
void saveChangesLocal();