QML UI: change the dive edit to not be an overlay

This way the accidental closing of the edit (and loss of data)
should no longer happen.

See: #495

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2017-10-04 12:22:36 -07:00
parent 41f24f2859
commit 7f0c7eeb24

View file

@ -58,18 +58,26 @@ Kirigami.Page {
left: currentItem ? (currentItem.modelData && currentItem.modelData.dive.gps !== "" ? mapAction : null) : null left: currentItem ? (currentItem.modelData && currentItem.modelData.dive.gps !== "" ? mapAction : null) : null
} }
} }
PropertyChanges { target: detailsEditScroll; sheetOpen: false }
PropertyChanges { target: pageStack.contentItem; interactive: true }
}, },
State { State {
name: "edit" name: "edit"
PropertyChanges { target: detailsEditScroll; sheetOpen: true } PropertyChanges {
PropertyChanges { target: pageStack.contentItem; interactive: false } target: diveDetailsPage;
actions {
right: cancelAction
left: null
}
}
}, },
State { State {
name: "add" name: "add"
PropertyChanges { target: detailsEditScroll; sheetOpen: true } PropertyChanges {
PropertyChanges { target: pageStack.contentItem; interactive: false } target: diveDetailsPage;
actions {
right: cancelAction
left: null
}
}
} }
] ]
@ -89,6 +97,14 @@ Kirigami.Page {
} }
} }
property QtObject cancelAction: Kirigami.Action {
text: qsTr("Cancel edit")
iconName: "dialog-cancel"
onTriggered: {
endEditMode()
}
}
property QtObject mapAction: Kirigami.Action { property QtObject mapAction: Kirigami.Action {
text: qsTr("Show on map") text: qsTr("Show on map")
iconName: "gps" iconName: "gps"
@ -183,10 +199,9 @@ Kirigami.Page {
diveDetailsPage.state = "edit" diveDetailsPage.state = "edit"
} }
//onWidthChanged: diveDetailsListView.positionViewAtIndex(diveDetailsListView.currentIndex, ListView.Beginning);
Item { Item {
anchors.fill: parent anchors.fill: parent
visible: diveDetailsPage.state == "view"
ListView { ListView {
id: diveDetailsListView id: diveDetailsListView
anchors.fill: parent anchors.fill: parent
@ -198,7 +213,6 @@ Kirigami.Page {
highlightFollowsCurrentItem: true highlightFollowsCurrentItem: true
focus: true focus: true
clip: false clip: false
//cacheBuffer: parent.width * 3 // cache one item on either side (this is in pixels)
snapMode: ListView.SnapOneItem snapMode: ListView.SnapOneItem
highlightRangeMode: ListView.StrictlyEnforceRange highlightRangeMode: ListView.StrictlyEnforceRange
onMovementEnded: { onMovementEnded: {
@ -219,18 +233,10 @@ Kirigami.Page {
} }
ScrollIndicator.horizontal: ScrollIndicator { } ScrollIndicator.horizontal: ScrollIndicator { }
} }
Kirigami.OverlaySheet { }
id: detailsEditScroll
parent: diveDetailsPage DiveDetailsEdit {
rootItem.z: 0 id: detailsEdit
onSheetOpenChanged: { visible: diveDetailsPage.state != "view" ? true : false
if (!sheetOpen) {
endEditMode()
}
}
DiveDetailsEdit {
id: detailsEdit
}
}
} }
} }