mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
QML UI: handle editing of depth
Getting closer to being able to really edit / add dives in the mobile UI. This works for manually added dives - needs a bit more thought for dives downloaded from dive computers as we don't necessarily want to change the maxdepth in conflict with the samples. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
2c28b16b26
commit
a0aa27e864
6 changed files with 45 additions and 1 deletions
|
@ -59,7 +59,7 @@ MobileComponents.Page {
|
||||||
location = detailsEdit.locationText
|
location = detailsEdit.locationText
|
||||||
// gps = detailsEdit.gps
|
// gps = detailsEdit.gps
|
||||||
duration = detailsEdit.durationText
|
duration = detailsEdit.durationText
|
||||||
// depth = detailsEdit.depthText
|
depth = detailsEdit.depthText
|
||||||
airtemp = detailsEdit.airtempText
|
airtemp = detailsEdit.airtempText
|
||||||
watertemp = detailsEdit.watertempText
|
watertemp = detailsEdit.watertempText
|
||||||
suit = detailsEdit.suitText
|
suit = detailsEdit.suitText
|
||||||
|
|
|
@ -16,6 +16,7 @@ Item {
|
||||||
property alias divemasterText: txtDiveMaster.text
|
property alias divemasterText: txtDiveMaster.text
|
||||||
property alias notesText: txtNotes.text
|
property alias notesText: txtNotes.text
|
||||||
property alias durationText: txtDuration.text
|
property alias durationText: txtDuration.text
|
||||||
|
property alias depthText: txtDepth.text
|
||||||
ColumnLayout {
|
ColumnLayout {
|
||||||
anchors {
|
anchors {
|
||||||
left: parent.left
|
left: parent.left
|
||||||
|
@ -49,6 +50,15 @@ Item {
|
||||||
// (think of someone adding a dive while on the boat or
|
// (think of someone adding a dive while on the boat or
|
||||||
// at the dive site)
|
// at the dive site)
|
||||||
|
|
||||||
|
MobileComponents.Label {
|
||||||
|
Layout.alignment: Qt.AlignRight
|
||||||
|
text: "Depth:"
|
||||||
|
}
|
||||||
|
TextField {
|
||||||
|
id: txtDepth
|
||||||
|
text: depth
|
||||||
|
Layout.fillWidth: true
|
||||||
|
}
|
||||||
MobileComponents.Label {
|
MobileComponents.Label {
|
||||||
Layout.alignment: Qt.AlignRight
|
Layout.alignment: Qt.AlignRight
|
||||||
text: "Duration:"
|
text: "Duration:"
|
||||||
|
|
|
@ -361,6 +361,16 @@ void QMLManager::commitChanges(QString diveId, QString location, QString gps, QS
|
||||||
}
|
}
|
||||||
d->duration.seconds = h * 3600 + m * 60 + s;
|
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) {
|
if (get_temperature_string(d->airtemp) != airtemp) {
|
||||||
diveChanged = true;
|
diveChanged = true;
|
||||||
if (airtemp.contains(tr("C")))
|
if (airtemp.contains(tr("C")))
|
||||||
|
|
|
@ -130,6 +130,7 @@ QString DiveListModel::startAddDive()
|
||||||
if (pd && pd->number > 0)
|
if (pd && pd->number > 0)
|
||||||
nr = pd->number + 1;
|
nr = pd->number + 1;
|
||||||
d->number = nr;
|
d->number = nr;
|
||||||
|
d->dc.model = strdup("manually added dive");
|
||||||
add_single_dive(-1, d);
|
add_single_dive(-1, d);
|
||||||
addDive(d);
|
addDive(d);
|
||||||
return QString::number(d->id);
|
return QString::number(d->id);
|
||||||
|
|
|
@ -32,6 +32,7 @@ QString getPrintingTemplatePathBundle();
|
||||||
void copyPath(QString src, QString dst);
|
void copyPath(QString src, QString dst);
|
||||||
extern const QString get_dc_nickname(const char *model, uint32_t deviceid);
|
extern const QString get_dc_nickname(const char *model, uint32_t deviceid);
|
||||||
int gettimezoneoffset(timestamp_t when = 0);
|
int gettimezoneoffset(timestamp_t when = 0);
|
||||||
|
int parseLengthToMm(const QString &text);
|
||||||
int parseTemperatureToMkelvin(const QString &text);
|
int parseTemperatureToMkelvin(const QString &text);
|
||||||
QString get_dive_duration_string(timestamp_t when, QString hourText, QString minutesText);
|
QString get_dive_duration_string(timestamp_t when, QString hourText, QString minutesText);
|
||||||
QString get_dive_date_string(timestamp_t when);
|
QString get_dive_date_string(timestamp_t when);
|
||||||
|
|
|
@ -1119,6 +1119,28 @@ int gettimezoneoffset(timestamp_t when)
|
||||||
return dt2.secsTo(dt1);
|
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 parseTemperatureToMkelvin(const QString &text)
|
||||||
{
|
{
|
||||||
int mkelvin;
|
int mkelvin;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue