First cylinder only, show warning if there are more than one cylinder defined.

Signed-off-by: Joakim Bygdell <j.bygd...@gmail.com>
---
 qt-mobile/qml/DiveDetails.qml     |  3 +++
 qt-mobile/qml/DiveDetailsEdit.qml | 13 ++++++++++++-
 qt-mobile/qml/main.qml            |  1 +
 qt-mobile/qmlmanager.cpp          |  9 ++++++++-
 qt-mobile/qmlmanager.h            |  2 +-
 5 files changed, 25 insertions(+), 3 deletions(-)

diff --git a/qt-mobile/qml/DiveDetails.qml b/qt-mobile/qml/DiveDetails.qml
index 5a39576..c906ba2 100644
--- a/qt-mobile/qml/DiveDetails.qml
+++ b/qt-mobile/qml/DiveDetails.qml
@@ -24,6 +24,7 @@ MobileComponents.Page {
        property alias weight: detailsEdit.weightText
        property alias startpressure: detailsEdit.startpressureText
        property alias endpressure: detailsEdit.endpressureText
+       property alias gasmix: detailsEdit.gasmixText
 
        state: "view"
 
@@ -128,10 +129,12 @@ MobileComponents.Page {
                if (diveDetailsListView.currentItem.modelData.dive.getCylinder 
!= "Multiple" ) {
                        startpressure = 
diveDetailsListView.currentItem.modelData.dive.startPressure
                        endpressure = 
diveDetailsListView.currentItem.modelData.dive.endPressure
+                       gasmix = 
diveDetailsListView.currentItem.modelData.dive.firstGas
                } else {
                        // careful when translating, this text is "magic" in 
DiveDetailsEdit.qml
                        startpressure = "cannot edit multiple cylinders"
                        endpressure = "cannot edit multiple cylinders"
+                       gasmix = "cannot edit multiple gases"
                }
 
                diveDetailsPage.state = "edit"
diff --git a/qt-mobile/qml/DiveDetailsEdit.qml 
b/qt-mobile/qml/DiveDetailsEdit.qml
index f2b0462..ae943ca 100644
--- a/qt-mobile/qml/DiveDetailsEdit.qml
+++ b/qt-mobile/qml/DiveDetailsEdit.qml
@@ -24,6 +24,7 @@ Item {
        property alias weightText: txtWeight.text
        property alias startpressureText: txtStartPressure.text
        property alias endpressureText: txtEndPressure.text
+       property alias gasmixText: txtGasMix.text
 
        height: editArea.height
        ColumnLayout {
@@ -147,6 +148,16 @@ Item {
 
                        MobileComponents.Label {
                                Layout.alignment: Qt.AlignRight
+                               text: "Gas mix:"
+                       }
+                       TextField {
+                               id: txtGasMix
+                               readOnly: (text == "cannot edit multiple gases" 
? true : false)
+                               Layout.fillWidth: true
+                       }
+
+                       MobileComponents.Label {
+                               Layout.alignment: Qt.AlignRight
                                text: "Start Pressure:"
                        }
                        TextField {
@@ -192,7 +203,7 @@ Item {
                                manager.commitChanges(dive_id, 
detailsEdit.dateText, detailsEdit.locationText, detailsEdit.gpsText, 
detailsEdit.durationText,
                                                      detailsEdit.depthText, 
detailsEdit.airtempText, detailsEdit.watertempText, detailsEdit.suitText,
                                                      detailsEdit.buddyText, 
detailsEdit.divemasterText, detailsEdit.weightText, detailsEdit.notesText,
-                                                     
detailsEdit.startpressureText, detailsEdit.endpressureText)
+                                                     
detailsEdit.startpressureText, detailsEdit.endpressureText, 
detailsEdit.gasmixText)
                                // apply the changes to the dive detail view - 
since the edit could have changed the order
                                // first make sure that we are looking at the 
correct dive - our model allows us to look
                                // up the index based on the unique dive_id
diff --git a/qt-mobile/qml/main.qml b/qt-mobile/qml/main.qml
index 2c066e2..68696b6 100644
--- a/qt-mobile/qml/main.qml
+++ b/qt-mobile/qml/main.qml
@@ -84,6 +84,7 @@ MobileComponents.ApplicationWindow {
                                                detailsWindow.duration = ""
                                                detailsWindow.suit = ""
                                                detailsWindow.weight = ""
+                                               detailsWindow.gasmix = ""
                                                detailsWindow.startpressure = ""
                                                detailsWindow.endpressure = ""
                                                stackView.push(detailsWindow)
diff --git a/qt-mobile/qmlmanager.cpp b/qt-mobile/qmlmanager.cpp
index cd45d30..422a77e 100644
--- a/qt-mobile/qmlmanager.cpp
+++ b/qt-mobile/qmlmanager.cpp
@@ -353,7 +353,7 @@ void QMLManager::refreshDiveList()
 // update the dive and return the notes field, stripped of the HTML junk
 QString 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 startpressure, QString endpressure, 
QString gasmix)
 {
 #define DROP_EMPTY_PLACEHOLDER(_s) if ((_s) == QLatin1Literal("--")) 
(_s).clear()
 
@@ -366,6 +366,7 @@ QString QMLManager::commitChanges(QString diveId, QString 
date, QString location
        DROP_EMPTY_PLACEHOLDER(buddy);
        DROP_EMPTY_PLACEHOLDER(diveMaster);
        DROP_EMPTY_PLACEHOLDER(weight);
+       DROP_EMPTY_PLACEHOLDER(gasmix);
        DROP_EMPTY_PLACEHOLDER(startpressure);
        DROP_EMPTY_PLACEHOLDER(endpressure);
        DROP_EMPTY_PLACEHOLDER(notes);
@@ -514,6 +515,12 @@ QString QMLManager::commitChanges(QString diveId, QString 
date, QString location
                d->cylinder[0].start.mbar = parsePressureToMbar(startpressure);
                d->cylinder[0].end.mbar = parsePressureToMbar(endpressure);
        }
+       // gasmix for first cylinder
+       if (get_gas_string(d->cylinder[0].gasmix) != gasmix) {
+               diveChanged = true;
+               d->cylinder[0].gasmix.o2.permille = parseGasMixO2(gasmix);
+               d->cylinder[0].gasmix.he.permille = parseGasMixHE(gasmix);
+       }
        if (!same_string(d->suit, qPrintable(suit))) {
                diveChanged = true;
                free(d->suit);
diff --git a/qt-mobile/qmlmanager.h b/qt-mobile/qmlmanager.h
index 2d44bfc..433001a 100644
--- a/qt-mobile/qmlmanager.h
+++ b/qt-mobile/qmlmanager.h
@@ -88,7 +88,7 @@ public slots:
                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 startpressure, QString endpressure, QString gasmix);
 
        void saveChanges();
        QString addDive();
-- 
2.4.9 (Apple Git-60)

_______________________________________________
subsurface mailing list
subsurface@subsurface-divelog.org
http://lists.subsurface-divelog.org/cgi-bin/mailman/listinfo/subsurface

Reply via email to