mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
QML UI: change the dive add/edit action button to be save
Remove the button on the page and instead use the action button to save and the back key to cancel. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
5952b09b51
commit
0ce1dd80cc
2 changed files with 33 additions and 34 deletions
|
@ -74,12 +74,10 @@ MobileComponents.Page {
|
||||||
]
|
]
|
||||||
*/
|
*/
|
||||||
mainAction: Action {
|
mainAction: Action {
|
||||||
iconName: state !== "view" ? "dialog-cancel" : "document-edit"
|
iconName: state !== "view" ? "document-save" : "document-edit"
|
||||||
onTriggered: {
|
onTriggered: {
|
||||||
if (state === "edit") {
|
if (state === "edit" || state === "add") {
|
||||||
endEditMode()
|
detailsEdit.saveData()
|
||||||
} else if (state === "add") {
|
|
||||||
endAddMode()
|
|
||||||
} else {
|
} else {
|
||||||
startEditMode()
|
startEditMode()
|
||||||
}
|
}
|
||||||
|
@ -87,10 +85,14 @@ MobileComponents.Page {
|
||||||
}
|
}
|
||||||
|
|
||||||
onBackRequested: {
|
onBackRequested: {
|
||||||
if (state === "edit" || state === "add") {
|
if (state === "edit") {
|
||||||
endEditMode();
|
endEditMode()
|
||||||
|
event.accepted = true;
|
||||||
|
} else if (state === "add") {
|
||||||
|
endAddMode()
|
||||||
event.accepted = true;
|
event.accepted = true;
|
||||||
}
|
}
|
||||||
|
// if we were in view mode, don't accept the event and pop the page
|
||||||
}
|
}
|
||||||
|
|
||||||
function showDiveIndex(index) {
|
function showDiveIndex(index) {
|
||||||
|
|
|
@ -26,6 +26,30 @@ Item {
|
||||||
property alias endpressureText: txtEndPressure.text
|
property alias endpressureText: txtEndPressure.text
|
||||||
property alias gasmixText: txtGasMix.text
|
property alias gasmixText: txtGasMix.text
|
||||||
|
|
||||||
|
function saveData() {
|
||||||
|
// apply the changes to the dive_table
|
||||||
|
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.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
|
||||||
|
diveDetailsListView.currentIndex = diveModel.getIdxForId(dive_id)
|
||||||
|
diveDetailsListView.currentItem.modelData.date = detailsEdit.dateText
|
||||||
|
diveDetailsListView.currentItem.modelData.location = detailsEdit.locationText
|
||||||
|
diveDetailsListView.currentItem.modelData.duration = detailsEdit.durationText
|
||||||
|
diveDetailsListView.currentItem.modelData.depth = detailsEdit.depthText
|
||||||
|
diveDetailsListView.currentItem.modelData.airtemp = detailsEdit.airtempText
|
||||||
|
diveDetailsListView.currentItem.modelData.watertemp = detailsEdit.watertempText
|
||||||
|
diveDetailsListView.currentItem.modelData.suit = detailsEdit.suitText
|
||||||
|
diveDetailsListView.currentItem.modelData.buddy = detailsEdit.buddyText
|
||||||
|
diveDetailsListView.currentItem.modelData.divemaster = detailsEdit.divemasterText
|
||||||
|
diveDetailsListView.currentItem.modelData.notes = detailsEdit.notesText
|
||||||
|
diveDetailsPage.state = "view"
|
||||||
|
Qt.inputMethod.hide()
|
||||||
|
}
|
||||||
|
|
||||||
height: editArea.height
|
height: editArea.height
|
||||||
ColumnLayout {
|
ColumnLayout {
|
||||||
id: editArea
|
id: editArea
|
||||||
|
@ -195,33 +219,6 @@ Item {
|
||||||
wrapMode: TextEdit.WrapAtWordBoundaryOrAnywhere
|
wrapMode: TextEdit.WrapAtWordBoundaryOrAnywhere
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
SubsurfaceButton {
|
|
||||||
anchors.horizontalCenter: parent.horizontalCenter
|
|
||||||
text: "Save"
|
|
||||||
onClicked: {
|
|
||||||
// apply the changes to the dive_table
|
|
||||||
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.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
|
|
||||||
diveDetailsListView.currentIndex = diveModel.getIdxForId(dive_id)
|
|
||||||
diveDetailsListView.currentItem.modelData.date = detailsEdit.dateText
|
|
||||||
diveDetailsListView.currentItem.modelData.location = detailsEdit.locationText
|
|
||||||
diveDetailsListView.currentItem.modelData.duration = detailsEdit.durationText
|
|
||||||
diveDetailsListView.currentItem.modelData.depth = detailsEdit.depthText
|
|
||||||
diveDetailsListView.currentItem.modelData.airtemp = detailsEdit.airtempText
|
|
||||||
diveDetailsListView.currentItem.modelData.watertemp = detailsEdit.watertempText
|
|
||||||
diveDetailsListView.currentItem.modelData.suit = detailsEdit.suitText
|
|
||||||
diveDetailsListView.currentItem.modelData.buddy = detailsEdit.buddyText
|
|
||||||
diveDetailsListView.currentItem.modelData.divemaster = detailsEdit.divemasterText
|
|
||||||
diveDetailsListView.currentItem.modelData.notes = detailsEdit.notesText
|
|
||||||
diveDetailsPage.state = "view"
|
|
||||||
Qt.inputMethod.hide()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Item {
|
Item {
|
||||||
height: MobileComponents.Units.gridUnit * 3
|
height: MobileComponents.Units.gridUnit * 3
|
||||||
width: height // just to make sure the spacer doesn't produce scrollbars, but also isn't null
|
width: height // just to make sure the spacer doesn't produce scrollbars, but also isn't null
|
||||||
|
|
Loading…
Add table
Reference in a new issue