mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
QML UI: enable edit of cylinder pressures
First cylinder only, show warning if there are more than one cylinder defined. Signed-off-by: Joakim Bygdell <j.bygdell@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
f3b35d175a
commit
8c9883cfcf
5 changed files with 53 additions and 3 deletions
|
@ -22,6 +22,8 @@ MobileComponents.Page {
|
||||||
property alias notes: detailsEdit.notesText
|
property alias notes: detailsEdit.notesText
|
||||||
property alias suit: detailsEdit.suitText
|
property alias suit: detailsEdit.suitText
|
||||||
property alias weight: detailsEdit.weightText
|
property alias weight: detailsEdit.weightText
|
||||||
|
property alias startpressure: detailsEdit.startpressureText
|
||||||
|
property alias endpressure: detailsEdit.endpressureText
|
||||||
|
|
||||||
state: "view"
|
state: "view"
|
||||||
|
|
||||||
|
@ -99,6 +101,14 @@ MobileComponents.Page {
|
||||||
// careful when translating, this text is "magic" in DiveDetailsEdit.qml
|
// careful when translating, this text is "magic" in DiveDetailsEdit.qml
|
||||||
weight = "cannot edit multiple weight systems"
|
weight = "cannot edit multiple weight systems"
|
||||||
}
|
}
|
||||||
|
if (diveDetailsListView.currentItem.modelData.dive.getCylinder != "Multiple" ) {
|
||||||
|
startpressure = diveDetailsListView.currentItem.modelData.dive.startPressure
|
||||||
|
endpressure = diveDetailsListView.currentItem.modelData.dive.endPressure
|
||||||
|
} else {
|
||||||
|
// careful when translating, this text is "magic" in DiveDetailsEdit.qml
|
||||||
|
startpressure = "cannot edit multiple cylinders"
|
||||||
|
endpressure = "cannot edit multiple cylinders"
|
||||||
|
}
|
||||||
|
|
||||||
diveDetailsPage.state = "edit"
|
diveDetailsPage.state = "edit"
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,8 @@ Item {
|
||||||
property alias durationText: txtDuration.text
|
property alias durationText: txtDuration.text
|
||||||
property alias depthText: txtDepth.text
|
property alias depthText: txtDepth.text
|
||||||
property alias weightText: txtWeight.text
|
property alias weightText: txtWeight.text
|
||||||
|
property alias startpressureText: txtStartPressure.text
|
||||||
|
property alias endpressureText: txtEndPressure.text
|
||||||
|
|
||||||
height: editArea.height
|
height: editArea.height
|
||||||
ColumnLayout {
|
ColumnLayout {
|
||||||
|
@ -143,6 +145,27 @@ Item {
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MobileComponents.Label {
|
||||||
|
Layout.alignment: Qt.AlignRight
|
||||||
|
text: "Start Pressure:"
|
||||||
|
}
|
||||||
|
TextField {
|
||||||
|
id: txtStartPressure
|
||||||
|
readOnly: (text == "cannot edit multiple cylinders" ? true : false)
|
||||||
|
Layout.fillWidth: true
|
||||||
|
}
|
||||||
|
|
||||||
|
MobileComponents.Label {
|
||||||
|
Layout.alignment: Qt.AlignRight
|
||||||
|
text: "End Pressure:"
|
||||||
|
}
|
||||||
|
TextField {
|
||||||
|
id: txtEndPressure
|
||||||
|
readOnly: (text == "cannot edit multiple cylinders" ? true : false)
|
||||||
|
Layout.fillWidth: true
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
MobileComponents.Label {
|
MobileComponents.Label {
|
||||||
Layout.columnSpan: 2
|
Layout.columnSpan: 2
|
||||||
Layout.alignment: Qt.AlignLeft
|
Layout.alignment: Qt.AlignLeft
|
||||||
|
@ -168,7 +191,8 @@ Item {
|
||||||
// apply the changes to the dive_table
|
// apply the changes to the dive_table
|
||||||
manager.commitChanges(dive_id, detailsEdit.dateText, detailsEdit.locationText, detailsEdit.gpsText, detailsEdit.durationText,
|
manager.commitChanges(dive_id, detailsEdit.dateText, detailsEdit.locationText, detailsEdit.gpsText, detailsEdit.durationText,
|
||||||
detailsEdit.depthText, detailsEdit.airtempText, detailsEdit.watertempText, detailsEdit.suitText,
|
detailsEdit.depthText, detailsEdit.airtempText, detailsEdit.watertempText, detailsEdit.suitText,
|
||||||
detailsEdit.buddyText, detailsEdit.divemasterText, detailsEdit.weightText, detailsEdit.notesText)
|
detailsEdit.buddyText, detailsEdit.divemasterText, detailsEdit.weightText, detailsEdit.notesText,
|
||||||
|
detailsEdit.startpressureText, detailsEdit.endpressureText)
|
||||||
// apply the changes to the dive detail view - since the edit could have changed the order
|
// 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
|
// 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
|
// up the index based on the unique dive_id
|
||||||
|
|
|
@ -71,6 +71,8 @@ MobileComponents.ApplicationWindow {
|
||||||
detailsWindow.duration = ""
|
detailsWindow.duration = ""
|
||||||
detailsWindow.suit = ""
|
detailsWindow.suit = ""
|
||||||
detailsWindow.weight = ""
|
detailsWindow.weight = ""
|
||||||
|
detailsWindow.startpressure = ""
|
||||||
|
detailsWindow.endpressure = ""
|
||||||
stackView.push(detailsWindow)
|
stackView.push(detailsWindow)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -335,7 +335,8 @@ void QMLManager::refreshDiveList()
|
||||||
|
|
||||||
// update the dive and return the notes field, stripped of the HTML junk
|
// 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 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 airtemp, QString watertemp, QString suit, QString buddy, QString diveMaster, QString weight, QString notes,
|
||||||
|
QString startpressure, QString endpressure)
|
||||||
{
|
{
|
||||||
#define DROP_EMPTY_PLACEHOLDER(_s) if ((_s) == QLatin1Literal("--")) (_s).clear()
|
#define DROP_EMPTY_PLACEHOLDER(_s) if ((_s) == QLatin1Literal("--")) (_s).clear()
|
||||||
|
|
||||||
|
@ -348,6 +349,8 @@ QString QMLManager::commitChanges(QString diveId, QString date, QString location
|
||||||
DROP_EMPTY_PLACEHOLDER(buddy);
|
DROP_EMPTY_PLACEHOLDER(buddy);
|
||||||
DROP_EMPTY_PLACEHOLDER(diveMaster);
|
DROP_EMPTY_PLACEHOLDER(diveMaster);
|
||||||
DROP_EMPTY_PLACEHOLDER(weight);
|
DROP_EMPTY_PLACEHOLDER(weight);
|
||||||
|
DROP_EMPTY_PLACEHOLDER(startpressure);
|
||||||
|
DROP_EMPTY_PLACEHOLDER(endpressure);
|
||||||
DROP_EMPTY_PLACEHOLDER(notes);
|
DROP_EMPTY_PLACEHOLDER(notes);
|
||||||
|
|
||||||
#undef DROP_EMPTY_PLACEHOLDER
|
#undef DROP_EMPTY_PLACEHOLDER
|
||||||
|
@ -489,6 +492,16 @@ QString QMLManager::commitChanges(QString diveId, QString date, QString location
|
||||||
d->weightsystem[0].weight.grams = parseWeightToGrams(weight);
|
d->weightsystem[0].weight.grams = parseWeightToGrams(weight);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// start and end pressures for first cylinder only
|
||||||
|
if (get_pressure_string(d->cylinder[0].start, true) != startpressure || get_pressure_string(d->cylinder[0].end, true) != endpressure) {
|
||||||
|
diveChanged = true;
|
||||||
|
if (startpressure.contains(tr("bar")) || endpressure.contains(tr("bar")))
|
||||||
|
prefs.units.pressure = units::BAR;
|
||||||
|
else if (startpressure.contains(tr("psi")) || endpressure.contains(tr("psi")))
|
||||||
|
prefs.units.pressure = units::PSI;
|
||||||
|
d->cylinder[0].start.mbar = parsePressureToMbar(startpressure);
|
||||||
|
d->cylinder[0].end.mbar = parsePressureToMbar(endpressure);
|
||||||
|
}
|
||||||
if (!same_string(d->suit, qPrintable(suit))) {
|
if (!same_string(d->suit, qPrintable(suit))) {
|
||||||
diveChanged = true;
|
diveChanged = true;
|
||||||
free(d->suit);
|
free(d->suit);
|
||||||
|
|
|
@ -74,7 +74,8 @@ public slots:
|
||||||
QString commitChanges(QString diveId, QString date, QString location,
|
QString commitChanges(QString diveId, QString date, QString location,
|
||||||
QString gps, QString duration, QString depth,
|
QString gps, QString duration, QString depth,
|
||||||
QString airtemp, QString watertemp, QString suit,
|
QString airtemp, QString watertemp, QString suit,
|
||||||
QString buddy, QString diveMaster, QString weight, QString notes);
|
QString buddy, QString diveMaster, QString weight, QString notes,
|
||||||
|
QString startpressure, QString endpressure);
|
||||||
|
|
||||||
void saveChanges();
|
void saveChanges();
|
||||||
QString addDive();
|
QString addDive();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue