summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--qt-mobile/qml/DiveDetails.qml2
-rw-r--r--qt-mobile/qml/DiveDetailsEdit.qml10
-rw-r--r--qt-mobile/qmlmanager.cpp10
-rw-r--r--qt-models/divelistmodel.cpp1
-rw-r--r--subsurface-core/helpers.h1
-rw-r--r--subsurface-core/qthelper.cpp22
6 files changed, 45 insertions, 1 deletions
diff --git a/qt-mobile/qml/DiveDetails.qml b/qt-mobile/qml/DiveDetails.qml
index 4b0ee8e23..b4f30dab9 100644
--- a/qt-mobile/qml/DiveDetails.qml
+++ b/qt-mobile/qml/DiveDetails.qml
@@ -59,7 +59,7 @@ MobileComponents.Page {
location = detailsEdit.locationText
// gps = detailsEdit.gps
duration = detailsEdit.durationText
- // depth = detailsEdit.depthText
+ depth = detailsEdit.depthText
airtemp = detailsEdit.airtempText
watertemp = detailsEdit.watertempText
suit = detailsEdit.suitText
diff --git a/qt-mobile/qml/DiveDetailsEdit.qml b/qt-mobile/qml/DiveDetailsEdit.qml
index e77b3234a..051e38676 100644
--- a/qt-mobile/qml/DiveDetailsEdit.qml
+++ b/qt-mobile/qml/DiveDetailsEdit.qml
@@ -16,6 +16,7 @@ Item {
property alias divemasterText: txtDiveMaster.text
property alias notesText: txtNotes.text
property alias durationText: txtDuration.text
+ property alias depthText: txtDepth.text
ColumnLayout {
anchors {
left: parent.left
@@ -51,6 +52,15 @@ Item {
MobileComponents.Label {
Layout.alignment: Qt.AlignRight
+ text: "Depth:"
+ }
+ TextField {
+ id: txtDepth
+ text: depth
+ Layout.fillWidth: true
+ }
+ MobileComponents.Label {
+ Layout.alignment: Qt.AlignRight
text: "Duration:"
}
TextField {
diff --git a/qt-mobile/qmlmanager.cpp b/qt-mobile/qmlmanager.cpp
index d711e8945..70bc5264a 100644
--- a/qt-mobile/qmlmanager.cpp
+++ b/qt-mobile/qmlmanager.cpp
@@ -361,6 +361,16 @@ void QMLManager::commitChanges(QString diveId, QString location, QString gps, QS
}
d->duration.seconds = h * 3600 + m * 60 + s;
}
+ if (get_depth_string(d->maxdepth.mm, true, true) != depth) {
+ diveChanged = true;
+ if (depth.contains(tr("ft")))
+ prefs.units.length = units::FEET;
+ else if (depth.contains(tr("m")))
+ prefs.units.length = units::METERS;
+ d->maxdepth.mm = parseLengthToMm(depth);
+ if (same_string(d->dc.model, "manually added dive"))
+ d->dc.maxdepth.mm = d->maxdepth.mm;
+ }
if (get_temperature_string(d->airtemp) != airtemp) {
diveChanged = true;
if (airtemp.contains(tr("C")))
diff --git a/qt-models/divelistmodel.cpp b/qt-models/divelistmodel.cpp
index 56205e26a..e812f3df7 100644
--- a/qt-models/divelistmodel.cpp
+++ b/qt-models/divelistmodel.cpp
@@ -130,6 +130,7 @@ QString DiveListModel::startAddDive()
if (pd && pd->number > 0)
nr = pd->number + 1;
d->number = nr;
+ d->dc.model = strdup("manually added dive");
add_single_dive(-1, d);
addDive(d);
return QString::number(d->id);
diff --git a/subsurface-core/helpers.h b/subsurface-core/helpers.h
index b5c119870..5856c624f 100644
--- a/subsurface-core/helpers.h
+++ b/subsurface-core/helpers.h
@@ -32,6 +32,7 @@ QString getPrintingTemplatePathBundle();
void copyPath(QString src, QString dst);
extern const QString get_dc_nickname(const char *model, uint32_t deviceid);
int gettimezoneoffset(timestamp_t when = 0);
+int parseLengthToMm(const QString &text);
int parseTemperatureToMkelvin(const QString &text);
QString get_dive_duration_string(timestamp_t when, QString hourText, QString minutesText);
QString get_dive_date_string(timestamp_t when);
diff --git a/subsurface-core/qthelper.cpp b/subsurface-core/qthelper.cpp
index 25d5b4233..bddfd7608 100644
--- a/subsurface-core/qthelper.cpp
+++ b/subsurface-core/qthelper.cpp
@@ -1119,6 +1119,28 @@ int gettimezoneoffset(timestamp_t when)
return dt2.secsTo(dt1);
}
+int parseLengthToMm(const QString &text)
+{
+ int mm;
+ QString numOnly = text;
+ numOnly.replace(",", ".").remove(QRegExp("[^-0-9.]"));
+ if (numOnly.isEmpty())
+ return 0;
+ double number = numOnly.toDouble();
+ switch (prefs.units.length) {
+ case units::FEET:
+ mm = feet_to_mm(number);
+ break;
+ case units::METERS:
+ mm = number * 1000;
+ break;
+ default:
+ mm = 0;
+ }
+ return mm;
+
+}
+
int parseTemperatureToMkelvin(const QString &text)
{
int mkelvin;