aboutsummaryrefslogtreecommitdiffstats
path: root/qt-mobile/qml
diff options
context:
space:
mode:
authorGravatar Sebastian Kügler <sebas@kde.org>2016-01-12 03:01:15 +0100
committerGravatar Sebastian Kügler <sebas@kde.org>2016-01-12 03:06:09 +0100
commit142c8b218b1f9a4a3e217023531feedd7cf9713e (patch)
tree536de1f3dab5abc4de528ac905bcd51cb5a85113 /qt-mobile/qml
parentae0f680c6e9ffc7804b99fe5058ca7c135ce1e42 (diff)
downloadsubsurface-142c8b218b1f9a4a3e217023531feedd7cf9713e.tar.gz
Fix bugs in edit drawer
- As the list may get reset on save, the dive_id effectively changes since currentItem isn't updated. So after editing, we end up with a different currentItem than visible. This is very unintuitive, but has to do with the model resetting. It would result in the edit view not showing the current dive when opened the second time. Let's make sure that out currentItem is always the visible one before we're filling the data into the edit page. - Close the drawer when we're navigating away from the dive item, for example when hitting the back button. Signed-off-by: Sebastian Kügler <sebas@kde.org>
Diffstat (limited to 'qt-mobile/qml')
-rw-r--r--qt-mobile/qml/DiveDetails.qml15
1 files changed, 14 insertions, 1 deletions
diff --git a/qt-mobile/qml/DiveDetails.qml b/qt-mobile/qml/DiveDetails.qml
index 1285d185a..cae8aab0c 100644
--- a/qt-mobile/qml/DiveDetails.qml
+++ b/qt-mobile/qml/DiveDetails.qml
@@ -10,6 +10,7 @@ MobileComponents.Page {
id: page
objectName: "DiveList"
property alias currentIndex: diveListView.currentIndex
+
mainAction: Action {
iconName: editDrawer.opened ? "dialog-cancel" : "document-edit"
onTriggered: {
@@ -17,6 +18,10 @@ MobileComponents.Page {
editDrawer.close();
return;
}
+ // After saving, the list may be shuffled, so first of all make sure that
+ // the listview's currentIndex is the visible item
+ // This makes sure that we always edit the currently visible item
+ diveListView.currentIndex = diveListView.indexAt(diveListView.contentX+1, 1);
detailsEdit.dive_id = diveListView.currentItem.modelData.dive.id
detailsEdit.number = diveListView.currentItem.modelData.dive.number
detailsEdit.dateText = diveListView.currentItem.modelData.dive.date
@@ -48,7 +53,7 @@ MobileComponents.Page {
currentIndex: -1
boundsBehavior: Flickable.StopAtBounds
maximumFlickVelocity: parent.width/4
- cacheBuffer: parent.width/2
+ //cacheBuffer: parent.width/2
orientation: ListView.Horizontal
focus: true
clip: true
@@ -80,6 +85,14 @@ MobileComponents.Page {
id: detailsEdit
implicitHeight: page.height - MobileComponents.Units.gridUnit*3
}
+ // Close the editDrawer when the pageStack navigates away, for example going
+ // back to the listview after the Back button was pressed
+ Connections {
+ target: rootItem.pageStack
+ onCurrentPageChanged: {
+ editDrawer.close();
+ }
+ }
}
}