mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
QML UI: handle editing of duration
I don't think these regular expressions are sufficiently exhaustive - but this is forward progress. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
7f628404e6
commit
2c28b16b26
3 changed files with 40 additions and 2 deletions
|
@ -58,7 +58,7 @@ MobileComponents.Page {
|
||||||
detailsEdit.buddyText, detailsEdit.divemasterText, detailsEdit.notesText)
|
detailsEdit.buddyText, detailsEdit.divemasterText, detailsEdit.notesText)
|
||||||
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
|
||||||
|
|
|
@ -15,6 +15,7 @@ Item {
|
||||||
property alias buddyText: txtBuddy.text
|
property alias buddyText: txtBuddy.text
|
||||||
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
|
||||||
ColumnLayout {
|
ColumnLayout {
|
||||||
anchors {
|
anchors {
|
||||||
left: parent.left
|
left: parent.left
|
||||||
|
@ -48,6 +49,16 @@ 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: "Duration:"
|
||||||
|
}
|
||||||
|
TextField {
|
||||||
|
id: txtDuration
|
||||||
|
text: duration
|
||||||
|
Layout.fillWidth: true
|
||||||
|
}
|
||||||
|
|
||||||
MobileComponents.Label {
|
MobileComponents.Label {
|
||||||
Layout.alignment: Qt.AlignRight
|
Layout.alignment: Qt.AlignRight
|
||||||
text: "Air Temp:"
|
text: "Air Temp:"
|
||||||
|
|
|
@ -328,12 +328,39 @@ void QMLManager::commitChanges(QString diveId, QString location, QString gps, QS
|
||||||
ds = get_dive_site_by_uuid(create_dive_site(qPrintable(location), d->when));
|
ds = get_dive_site_by_uuid(create_dive_site(qPrintable(location), d->when));
|
||||||
d->dive_site_uuid = ds->uuid;
|
d->dive_site_uuid = ds->uuid;
|
||||||
}
|
}
|
||||||
// now we need to handle the string representations of duration, depth
|
// now we need to handle the string representations of depth
|
||||||
// and do something useful...
|
// and do something useful...
|
||||||
//
|
//
|
||||||
// FIXME
|
// FIXME
|
||||||
//
|
//
|
||||||
// TODO
|
// TODO
|
||||||
|
if (get_dive_duration_string(d->duration.seconds, tr("h:"), tr("min")) != duration) {
|
||||||
|
diveChanged = true;
|
||||||
|
int h = 0, m = 0, s = 0;
|
||||||
|
QRegExp r1(QString("(\\d*)%1[\\s,:]*(\\d*)%2[\\s,:]*(\\d*)%3").arg(tr("h")).arg(tr("min")).arg(tr("sec")), Qt::CaseInsensitive);
|
||||||
|
QRegExp r2(QString("(\\d*)%1[\\s,:]*(\\d*)%2").arg(tr("h")).arg(tr("min")), Qt::CaseInsensitive);
|
||||||
|
QRegExp r3(QString("(\\d*)%1").arg(tr("min")), Qt::CaseInsensitive);
|
||||||
|
QRegExp r4(QString("(\\d*):(\\d*):(\\d*)"));
|
||||||
|
QRegExp r5(QString("(\\d*):(\\d*)"));
|
||||||
|
if (r1.indexIn(duration) >= 0) {
|
||||||
|
h = r1.cap(1).toInt();
|
||||||
|
m = r1.cap(2).toInt();
|
||||||
|
s = r1.cap(3).toInt();
|
||||||
|
} else if (r2.indexIn(duration) >= 0) {
|
||||||
|
h = r2.cap(1).toInt();
|
||||||
|
m = r2.cap(2).toInt();
|
||||||
|
} else if (r3.indexIn(duration) >= 0) {
|
||||||
|
m = r3.cap(1).toInt();
|
||||||
|
} else if (r4.indexIn(duration) >= 0) {
|
||||||
|
h = r4.cap(1).toInt();
|
||||||
|
m = r4.cap(2).toInt();
|
||||||
|
s = r4.cap(3).toInt();
|
||||||
|
} else if (r5.indexIn(duration) >= 0) {
|
||||||
|
h = r5.cap(1).toInt();
|
||||||
|
m = r5.cap(2).toInt();
|
||||||
|
}
|
||||||
|
d->duration.seconds = h * 3600 + m * 60 + s;
|
||||||
|
}
|
||||||
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")))
|
||||||
|
|
Loading…
Add table
Reference in a new issue