From 6540e95425eb4c8aad56c5c5388c25b2180817cb Mon Sep 17 00:00:00 2001 From: Sebastian Kügler Date: Tue, 12 Jan 2016 01:15:02 +0100 Subject: dive details navigation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This patch reworks the navigation of the dive details. - The detailsview is now a list view with page-sized delegates. This allows horizontal swiping to the next and previous dive. - The central button now allows to open the edit mode for the dive. Original patch was done by Marco Martin, but needed to be reapplied by hand. Signed-off-by: Sebastian Kügler --- qt-mobile/qml/DiveDetails.qml | 196 +++++++------------ qt-mobile/qml/DiveDetailsEdit.qml | 37 +++- qt-mobile/qml/DiveDetailsView.qml | 383 ++++++++++++++++++++------------------ qt-mobile/qml/DiveList.qml | 30 +-- qt-mobile/qml/main.qml | 2 + 5 files changed, 307 insertions(+), 341 deletions(-) (limited to 'qt-mobile/qml') diff --git a/qt-mobile/qml/DiveDetails.qml b/qt-mobile/qml/DiveDetails.qml index 0dd380311..1285d185a 100644 --- a/qt-mobile/qml/DiveDetails.qml +++ b/qt-mobile/qml/DiveDetails.qml @@ -1,149 +1,85 @@ -import QtQuick 2.3 +import QtQuick 2.4 import QtQuick.Controls 1.4 -import QtQuick.Controls.Styles 1.2 +import QtQuick.Controls.Styles 1.4 import QtQuick.Dialogs 1.2 -import QtQuick.Layouts 1.1 +import QtQuick.Layouts 1.2 import org.subsurfacedivelog.mobile 1.0 import org.kde.plasma.mobilecomponents 0.2 as MobileComponents MobileComponents.Page { - id: diveDetailsWindow - width: parent.width - objectName: "DiveDetails" - - property string location - property string gps - property string depth - property string dive_id - property string diveNumber - property string duration - property string airtemp - property string watertemp - property string suit - property int rating - property string buddy - property string divemaster; - property string notes; - property string date - property string number - property string weight - state: "view" - - states: [ - State { - name: "view" - PropertyChanges { target: detailsView; opacity: 1 } - PropertyChanges { target: detailsEdit; opacity: 0 } - }, - State { - name: "edit" - PropertyChanges { target: detailsView; opacity: 0 } - PropertyChanges { target: detailsEdit; opacity: 1 } - } - ] - property list viewActions: [ - Action { - id: editSelector - text: "Edit" - iconName: "document-edit" - onTriggered: { - diveDetailsWindow.state = "edit" - contextDrawer.close() - } - } - ] - property list editActions: [ - Action { - id: cancelSelector - text: "Cancel" - iconName: "dialog-cancel" - onTriggered: { - // reset the fields in the edit screen - detailsEdit.dateText = date - detailsEdit.locationText = location - detailsEdit.durationText = duration - detailsEdit.depthText = depth - detailsEdit.airtempText = airtemp - detailsEdit.watertempText = watertemp - detailsEdit.suitText = suit - detailsEdit.buddyText = buddy - detailsEdit.divemasterText = divemaster - detailsEdit.notesText = notes - // back to view state and close the drawer - diveDetailsWindow.state = "view" - contextDrawer.close() - } - }, - Action { - id: saveSelector - text: "Save" - iconName: "document-save" - onTriggered: { - // apply the changes to the dive_table - notes = 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.notesText) - // apply the changes to the dive detail view - date = detailsEdit.dateText - location = detailsEdit.locationText - duration = detailsEdit.durationText - depth = detailsEdit.depthText - airtemp = detailsEdit.airtempText - watertemp = detailsEdit.watertempText - suit = detailsEdit.suitText - buddy = detailsEdit.buddyText - divemaster = detailsEdit.divemasterText - // back to view state and close the drawer - diveDetailsWindow.state = "view" - contextDrawer.close() + id: page + objectName: "DiveList" + property alias currentIndex: diveListView.currentIndex + mainAction: Action { + iconName: editDrawer.opened ? "dialog-cancel" : "document-edit" + onTriggered: { + if (editDrawer.opened) { + editDrawer.close(); + return; } + detailsEdit.dive_id = diveListView.currentItem.modelData.dive.id + detailsEdit.number = diveListView.currentItem.modelData.dive.number + detailsEdit.dateText = diveListView.currentItem.modelData.dive.date + detailsEdit.locationText = diveListView.currentItem.modelData.dive.location + detailsEdit.durationText = diveListView.currentItem.modelData.dive.duration + detailsEdit.depthText = diveListView.currentItem.modelData.dive.depth + detailsEdit.airtempText = diveListView.currentItem.modelData.dive.airTemp + detailsEdit.watertempText = diveListView.currentItem.modelData.dive.waterTemp + detailsEdit.suitText = diveListView.currentItem.modelData.dive.suit + detailsEdit.buddyText = diveListView.currentItem.modelData.dive.buddy + detailsEdit.divemasterText = diveListView.currentItem.modelData.dive.divemaster + detailsEdit.notesText = diveListView.currentItem.modelData.dive.notes + editDrawer.open(); } - ] - contextualActions: diveDetailsWindow.state === "view" ? viewActions : editActions + } + + function showDiveIndex(index) { + diveListView.currentIndex = index; + diveListView.positionViewAtIndex(diveListView.currentIndex, ListView.Beginning); + } + onWidthChanged: diveListView.positionViewAtIndex(diveListView.currentIndex, ListView.Beginning); ScrollView { anchors.fill: parent - Flickable { - id: flick + ListView { + id: diveListView anchors.fill: parent - contentHeight: content.height - interactive: contentHeight > height + model: diveModel + currentIndex: -1 + boundsBehavior: Flickable.StopAtBounds + maximumFlickVelocity: parent.width/4 + cacheBuffer: parent.width/2 + orientation: ListView.Horizontal + focus: true clip: true - Item { - id: content - width: flick.width - height: childrenRect.height + MobileComponents.Units.smallSpacing * 2 - - DiveDetailsEdit { - id: detailsEdit - anchors { - left: parent.left - right: parent.right - top: parent.top - margins: MobileComponents.Units.gridUnit / 2 - } - visible: opacity > 0 - - Behavior on opacity { - NumberAnimation { duration: MobileComponents.Units.shortDuration } + snapMode: ListView.SnapOneItem + onMovementEnded: { + currentIndex = indexAt(contentX+1, 1); + } + delegate: ScrollView { + id: internalScrollView + width: diveListView.width + height: diveListView.height + property var modelData: model + Flickable { + //contentWidth: parent.width + contentHeight: diveDetails.height + DiveDetailsView { + id: diveDetails + width: internalScrollView.width } } - DiveDetailsView { - id: detailsView - anchors { - left: parent.left - right: parent.right - top: parent.top - margins: MobileComponents.Units.gridUnit / 2 - } - visible: opacity > 0 - - Behavior on opacity { - NumberAnimation { duration: MobileComponents.Units.shortDuration } - } - - } } } } + MobileComponents.OverlayDrawer { + id: editDrawer + anchors.fill: parent + edge: Qt.BottomEdge + contentItem: DiveDetailsEdit { + id: detailsEdit + implicitHeight: page.height - MobileComponents.Units.gridUnit*3 + } + } + } diff --git a/qt-mobile/qml/DiveDetailsEdit.qml b/qt-mobile/qml/DiveDetailsEdit.qml index b6ca4572a..51325b7ae 100644 --- a/qt-mobile/qml/DiveDetailsEdit.qml +++ b/qt-mobile/qml/DiveDetailsEdit.qml @@ -7,6 +7,9 @@ import org.subsurfacedivelog.mobile 1.0 import org.kde.plasma.mobilecomponents 0.2 as MobileComponents Item { + id: detailsEdit + property int dive_id + property int number property alias dateText: txtDate.text property alias locationText: txtLocation.text property string gpsText @@ -23,6 +26,7 @@ Item { left: parent.left right: parent.right top: parent.top + margins: MobileComponents.Units.gridUnit } spacing: MobileComponents.Units.smallSpacing @@ -42,7 +46,6 @@ Item { } TextField { id: txtDate; - text: date; Layout.fillWidth: true } MobileComponents.Label { @@ -50,7 +53,7 @@ Item { text: "Location:" } TextField { - id: txtLocation; text: location; + id: txtLocation; Layout.fillWidth: true } @@ -76,7 +79,6 @@ Item { } TextField { id: txtDepth - text: depth Layout.fillWidth: true } MobileComponents.Label { @@ -85,7 +87,6 @@ Item { } TextField { id: txtDuration - text: duration Layout.fillWidth: true } @@ -95,7 +96,6 @@ Item { } TextField { id: txtAirTemp - text: airtemp Layout.fillWidth: true } @@ -105,7 +105,6 @@ Item { } TextField { id: txtWaterTemp - text: watertemp Layout.fillWidth: true } @@ -115,7 +114,6 @@ Item { } TextField { id: txtSuit - text: suit Layout.fillWidth: true } @@ -125,7 +123,6 @@ Item { } TextField { id: txtBuddy - text: buddy Layout.fillWidth: true } @@ -135,7 +132,6 @@ Item { } TextField { id: txtDiveMaster - text: divemaster Layout.fillWidth: true } @@ -145,7 +141,6 @@ Item { } TextArea { id: txtNotes - text: notes textFormat: TextEdit.RichText focus: true Layout.fillWidth: true @@ -155,6 +150,28 @@ Item { wrapMode: TextEdit.WrapAtWordBoundaryOrAnywhere } } + Button { + 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.notesText) + // apply the changes to the dive detail view + diveListView.currentItem.modelData.date = detailsEdit.dateText + diveListView.currentItem.modelData.location = detailsEdit.locationText + diveListView.currentItem.modelData.duration = detailsEdit.durationText + diveListView.currentItem.modelData.depth = detailsEdit.depthText + diveListView.currentItem.modelData.airtemp = detailsEdit.airtempText + diveListView.currentItem.modelData.watertemp = detailsEdit.watertempText + diveListView.currentItem.modelData.suit = detailsEdit.suitText + diveListView.currentItem.modelData.buddy = detailsEdit.buddyText + diveListView.currentItem.modelData.divemaster = detailsEdit.divemasterText + diveListView.currentItem.modelData.notes = detailsEdit.notesText + editDrawer.close() + } + } Item { height: MobileComponents.Units.gridUnit * 3 width: height // just to make sure the spacer doesn't produce scrollbars, but also isn't null diff --git a/qt-mobile/qml/DiveDetailsView.qml b/qt-mobile/qml/DiveDetailsView.qml index c75fc91df..519bd7a65 100644 --- a/qt-mobile/qml/DiveDetailsView.qml +++ b/qt-mobile/qml/DiveDetailsView.qml @@ -9,211 +9,234 @@ import QtQuick.Layouts 1.1 import org.subsurfacedivelog.mobile 1.0 import org.kde.plasma.mobilecomponents 0.2 as MobileComponents -GridLayout { +Item { id: detailsView - - columns: 4 - rowSpacing: MobileComponents.Units.smallSpacing * 2 - columnSpacing: MobileComponents.Units.smallSpacing - property int labelWidth: MobileComponents.Units.gridUnit * 10 - - Connections { - target: diveDetailsWindow - onDive_idChanged: { - qmlProfile.diveId = diveDetailsWindow.dive_id - qmlProfile.update() + width: parent.width + height: mainLayout.implicitHeight + MobileComponents.Units.iconSizes.large + Rectangle { + z: 99 + color: MobileComponents.Theme.textColor + opacity: 0.3 + width: MobileComponents.Units.smallSpacing/4 + anchors { + right: parent.right + top: parent.top + bottom: parent.bottom } } + GridLayout { + id: mainLayout + anchors { + //fill: parent + top: parent.top + left: parent.left + right: parent.right + margins: MobileComponents.Units.gridUnit + } + columns: 4 + rowSpacing: MobileComponents.Units.smallSpacing * 2 + columnSpacing: MobileComponents.Units.smallSpacing + + /*Connections { + target: diveDetailsWindow + onDive_idChanged: { + qmlProfile.diveId = diveDetailsWindow.dive_id + qmlProfile.update() + } + }*/ - MobileComponents.Heading { - id: detailsViewHeading - Layout.fillWidth: true - text: location - font.underline: gps !== "" - Layout.columnSpan: 4 - wrapMode: TextEdit.WrapAtWordBoundaryOrAnywhere - MouseArea { - anchors.fill: parent - onClicked: { - if (gps !== "") - manager.showMap(gps) + MobileComponents.Heading { + id: detailsViewHeading + Layout.fillWidth: true + text: dive.location + font.underline: dive.gps !== "" + Layout.columnSpan: 4 + wrapMode: TextEdit.WrapAtWordBoundaryOrAnywhere + MouseArea { + anchors.fill: parent + onClicked: { + if (gps !== "") + manager.showMap(gps) + } } } - } - /* - Rectangle { - id: mapView - width: parent.width - height: parents.width * 0.7 - WebView { - id: webView - anchors.fill: parent - url: "http://www.google.com" + /* + Rectangle { + id: mapView + width: parent.width + height: parents.width * 0.7 + WebView { + id: webView + anchors.fill: parent + url: "http://www.google.com" + } + } + */ + MobileComponents.Label { + Layout.alignment: Qt.AlignRight + id: dateLabel + text: "Date: " + opacity: 0.6 + } + MobileComponents.Label { + text: dive.date + Layout.minimumWidth: Math.max(MobileComponents.Units.gridUnit * 4, paintedWidth) // helps vertical alignment throughout listview + Layout.columnSpan: 3 } - } -*/ - MobileComponents.Label { - Layout.alignment: Qt.AlignRight - id: dateLabel - text: "Date: " - opacity: 0.6 - } - MobileComponents.Label { - text: date - Layout.minimumWidth: Math.max(MobileComponents.Units.gridUnit * 4, paintedWidth) // helps vertical alignment throughout listview - Layout.columnSpan: 3 - } - MobileComponents.Label { - Layout.alignment: Qt.AlignRight - id: depthLabel - text: "Depth: " - opacity: 0.6 - } - MobileComponents.Label { - text: depth - Layout.minimumWidth: Math.max(MobileComponents.Units.gridUnit * 4, paintedWidth) // helps vertical alignment throughout listview - } - MobileComponents.Label { - Layout.alignment: Qt.AlignRight - text: "Duration: " - opacity: 0.6 - } - RowLayout { MobileComponents.Label { - text: duration + Layout.alignment: Qt.AlignRight + id: depthLabel + text: "Depth: " + opacity: 0.6 } - Item { - Layout.fillWidth: true - height: parent.height + MobileComponents.Label { + text: dive.depth + Layout.minimumWidth: Math.max(MobileComponents.Units.gridUnit * 4, paintedWidth) // helps vertical alignment throughout listview } MobileComponents.Label { - id: numberText - text: "#" + diveNumber - color: MobileComponents.Theme.textColor + Layout.alignment: Qt.AlignRight + text: "Duration: " + opacity: 0.6 + } + RowLayout { + MobileComponents.Label { + text: dive.duration + } + Item { + Layout.fillWidth: true + height: parent.height + } + MobileComponents.Label { + id: numberText + text: "#" + dive.number + color: MobileComponents.Theme.textColor + } } - } - - QMLProfile { - id: qmlProfile - Layout.fillWidth: true - Layout.preferredHeight: width * 0.66 - Layout.columnSpan: 4 - Rectangle { - color: "transparent" - opacity: 0.6 - border.width: 1 - border.color: MobileComponents.Theme.textColor; - anchors.fill: parent + QMLProfile { + id: qmlProfile + Layout.fillWidth: true + Layout.minimumHeight: Layout.preferredHeight + Layout.preferredHeight: width * 0.66 + Layout.columnSpan: 4 + Rectangle { + color: "transparent" + opacity: 0.6 + border.width: 1 + border.color: MobileComponents.Theme.textColor; + anchors.fill: parent + } + //Rectangle { color: "green"; opacity: 0.4; anchors.fill: parent } // used for debugging the dive profile sizing, will be removed later } - //Rectangle { color: "green"; opacity: 0.4; anchors.fill: parent } // used for debugging the dive profile sizing, will be removed later - } - MobileComponents.Heading { - Layout.fillWidth: true - level: 3 - text: "Dive Details" - Layout.columnSpan: 4 - } + MobileComponents.Heading { + Layout.fillWidth: true + level: 3 + text: "Dive Details" + Layout.columnSpan: 4 + } - MobileComponents.Label { - Layout.alignment: Qt.AlignRight - text: "Air Temp:" - opacity: 0.6 - } - MobileComponents.Label { - id: txtAirTemp - text: airtemp - Layout.fillWidth: true - wrapMode: TextEdit.WrapAtWordBoundaryOrAnywhere - } + MobileComponents.Label { + Layout.alignment: Qt.AlignRight + text: "Air Temp:" + opacity: 0.6 + } + MobileComponents.Label { + id: txtAirTemp + text: dive.airTemp + Layout.fillWidth: true + wrapMode: TextEdit.WrapAtWordBoundaryOrAnywhere + } - MobileComponents.Label { - Layout.alignment: Qt.AlignRight - text: "Water Temp:" - opacity: 0.6 - } - MobileComponents.Label { - id: txtWaterTemp - text: watertemp - Layout.fillWidth: true - wrapMode: TextEdit.WrapAtWordBoundaryOrAnywhere - } + MobileComponents.Label { + Layout.alignment: Qt.AlignRight + text: "Water Temp:" + opacity: 0.6 + } + MobileComponents.Label { + id: txtWaterTemp + text: dive.waterTemp + Layout.fillWidth: true + wrapMode: TextEdit.WrapAtWordBoundaryOrAnywhere + } - MobileComponents.Label { - Layout.alignment: Qt.AlignRight - text: "Suit:" - opacity: 0.6 - } - MobileComponents.Label { - id: txtSuit - text: suit - Layout.fillWidth: true - wrapMode: TextEdit.WrapAtWordBoundaryOrAnywhere - } + MobileComponents.Label { + Layout.alignment: Qt.AlignRight + text: "Suit:" + opacity: 0.6 + } + MobileComponents.Label { + id: txtSuit + text: dive.suit + Layout.fillWidth: true + wrapMode: TextEdit.WrapAtWordBoundaryOrAnywhere + } - MobileComponents.Label { - Layout.alignment: Qt.AlignRight - text: "Weight:" - opacity: 0.6 - } - MobileComponents.Label { - id: txtWeight - text: weight - Layout.fillWidth: true - wrapMode: TextEdit.WrapAtWordBoundaryOrAnywhere - } + MobileComponents.Label { + Layout.alignment: Qt.AlignRight + text: "Weight:" + opacity: 0.6 + } + MobileComponents.Label { + id: txtWeight + //text: dive.weights + Layout.fillWidth: true + wrapMode: TextEdit.WrapAtWordBoundaryOrAnywhere + } - MobileComponents.Label { - Layout.alignment: Qt.AlignRight - text: "Buddy:" - opacity: 0.6 - } - MobileComponents.Label { - id: txtBuddy - text: buddy - Layout.fillWidth: true - wrapMode: TextEdit.WrapAtWordBoundaryOrAnywhere - } + MobileComponents.Label { + Layout.alignment: Qt.AlignRight + text: "Buddy:" + opacity: 0.6 + } + MobileComponents.Label { + id: txtBuddy + text: dive.buddy + Layout.fillWidth: true + wrapMode: TextEdit.WrapAtWordBoundaryOrAnywhere + } - MobileComponents.Label { - Layout.alignment: Qt.AlignRight - text: "Dive Master:" - opacity: 0.6 - } - MobileComponents.Label { - id: txtDiveMaster - text: divemaster - Layout.fillWidth: true - wrapMode: TextEdit.WrapAtWordBoundaryOrAnywhere - } + MobileComponents.Label { + Layout.alignment: Qt.AlignRight + text: "Dive Master:" + opacity: 0.6 + } + MobileComponents.Label { + id: txtDiveMaster + text: dive.divemaster + Layout.fillWidth: true + wrapMode: TextEdit.WrapAtWordBoundaryOrAnywhere + } - MobileComponents.Heading { - Layout.fillWidth: true - level: 3 - text: "Notes" - Layout.columnSpan: 4 - } + MobileComponents.Heading { + Layout.fillWidth: true + level: 3 + text: "Notes" + Layout.columnSpan: 4 + } - MobileComponents.Label { - id: txtNotes - text: notes - focus: true - Layout.columnSpan: 4 - Layout.fillWidth: true - Layout.fillHeight: true - //selectByMouse: true - wrapMode: TextEdit.WrapAtWordBoundaryOrAnywhere - } - Item { - Layout.columnSpan: 4 - Layout.fillWidth: true - Layout.minimumHeight: MobileComponents.Units.gridUnit * 3 - } - Component.onCompleted: { - qmlProfile.setMargin(MobileComponents.Units.smallSpacing) + MobileComponents.Label { + id: txtNotes + text: dive.notes + focus: true + Layout.columnSpan: 4 + Layout.fillWidth: true + Layout.fillHeight: true + //selectByMouse: true + wrapMode: TextEdit.WrapAtWordBoundaryOrAnywhere + } + Item { + Layout.columnSpan: 4 + Layout.fillWidth: true + Layout.minimumHeight: MobileComponents.Units.gridUnit * 3 + } + Component.onCompleted: { + qmlProfile.setMargin(MobileComponents.Units.smallSpacing) + qmlProfile.diveId = model.dive.id; + qmlProfile.update(); + } } } diff --git a/qt-mobile/qml/DiveList.qml b/qt-mobile/qml/DiveList.qml index 06da8dee1..07b437c99 100644 --- a/qt-mobile/qml/DiveList.qml +++ b/qt-mobile/qml/DiveList.qml @@ -21,28 +21,11 @@ MobileComponents.Page { property real detailsOpacity : 0 property int horizontalPadding: MobileComponents.Units.gridUnit / 2 - MobileComponents.Units.smallSpacing + 1 - //When clicked, the mode changes to details view - + // When clicked, the mode changes to details view onClicked: { diveListView.currentIndex = model.index - detailsWindow.width = parent.width - detailsWindow.location = dive.location - detailsWindow.gps = dive.gps - detailsWindow.dive_id = dive.id - detailsWindow.diveNumber = dive.number - detailsWindow.duration = dive.duration - detailsWindow.depth = dive.depth - detailsWindow.rating = dive.rating - detailsWindow.buddy = dive.buddy - detailsWindow.suit = dive.suit - detailsWindow.airtemp = dive.airTemp - detailsWindow.watertemp = dive.waterTemp - detailsWindow.divemaster = dive.divemaster - detailsWindow.notes = dive.notes - detailsWindow.number = dive.number - detailsWindow.date = dive.date + " " + dive.time - // detailsWindow.weight = dive.weights - stackView.push(detailsWindow) + detailsWindow.showDiveIndex(index); + stackView.push(detailsWindow); } Item { @@ -154,6 +137,7 @@ MobileComponents.Page { } } } + ScrollView { anchors.fill: parent ListView { @@ -161,10 +145,14 @@ MobileComponents.Page { anchors.fill: parent model: diveModel currentIndex: -1 + Connections { + target: detailsWindow + onCurrentIndexChanged: diveListView.currentIndex = detailsWindow.currentIndex + } delegate: diveDelegate boundsBehavior: Flickable.StopAtBounds maximumFlickVelocity: parent.height * 5 - cacheBuffer: parent.height * 5 + cacheBuffer: Math.max(5000, parent.height * 5) //highlight: Rectangle { color: MobileComponents.Theme.highlightColor; width: MobileComponents.Units.smallSpacing } focus: true clip: true diff --git a/qt-mobile/qml/main.qml b/qt-mobile/qml/main.qml index 62e6698a8..bcbc310f1 100644 --- a/qt-mobile/qml/main.qml +++ b/qt-mobile/qml/main.qml @@ -219,6 +219,8 @@ MobileComponents.ApplicationWindow { DiveDetails { id: detailsWindow visible: false + width: parent.width + height: parent.height } DownloadFromDiveComputer { -- cgit v1.2.3-70-g09d2 From ae0f680c6e9ffc7804b99fe5058ca7c135ce1e42 Mon Sep 17 00:00:00 2001 From: Sebastian Kügler Date: Tue, 12 Jan 2016 01:59:09 +0100 Subject: Kill warning MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Apparently parent.height is negative sometimes. Signed-off-by: Sebastian Kügler --- qt-mobile/qml/GpsList.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'qt-mobile/qml') diff --git a/qt-mobile/qml/GpsList.qml b/qt-mobile/qml/GpsList.qml index 0ee654fc1..8e9349c3c 100644 --- a/qt-mobile/qml/GpsList.qml +++ b/qt-mobile/qml/GpsList.qml @@ -115,7 +115,7 @@ MobileComponents.Page { delegate: gpsDelegate boundsBehavior: Flickable.StopAtBounds maximumFlickVelocity: parent.height * 5 - cacheBuffer: parent.height *5 + cacheBuffer: Math.max(5000, parent.height * 5) focus: true clip: true header: MobileComponents.Heading { -- cgit v1.2.3-70-g09d2 From 142c8b218b1f9a4a3e217023531feedd7cf9713e Mon Sep 17 00:00:00 2001 From: Sebastian Kügler Date: Tue, 12 Jan 2016 03:01:15 +0100 Subject: Fix bugs in edit drawer MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 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 --- qt-mobile/qml/DiveDetails.qml | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'qt-mobile/qml') 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(); + } + } } } -- cgit v1.2.3-70-g09d2