QML UI: Fully port dive edit to Kirigami2

Completely adapt to the api changes of OverlaySheet in Kirigami2
in order to achieve the same look and behavior for the dive
edits that had with kirigami1

Port most components to QtQuickContrls2, except comboboxes
in the dive edit sheet that will need a new control type

Signed-off-by: Marco Martin <notmart@gmail.com>
This commit is contained in:
Marco Martin 2017-03-31 16:15:14 +02:00 committed by Dirk Hohndel
parent 34a42d7f04
commit 751626eec5
20 changed files with 124 additions and 167 deletions

View file

@ -1,10 +1,9 @@
import QtQuick 2.4
import QtQuick.Controls 1.4
import QtQuick.Controls.Styles 1.4
import QtQuick.Controls 2.0
import QtQuick.Dialogs 1.2
import QtQuick.Layouts 1.2
import org.subsurfacedivelog.mobile 1.0
import org.kde.kirigami 1.0 as Kirigami
import org.kde.kirigami 2.0 as Kirigami
Kirigami.Page {
id: diveDetailsPage // but this is referenced as detailsWindow
@ -52,23 +51,23 @@ Kirigami.Page {
left: diveDetailsListView.currentItem ? (diveDetailsListView.currentItem.modelData.dive.gps !== "" ? mapAction : null) : null
}
}
PropertyChanges { target: detailsEditScroll; opened: false }
PropertyChanges { target: detailsEditScroll; sheetOpen: false }
PropertyChanges { target: pageStack.contentItem; interactive: true }
},
State {
name: "edit"
PropertyChanges { target: detailsEditScroll; opened: true }
PropertyChanges { target: detailsEditScroll; sheetOpen: true }
PropertyChanges { target: pageStack.contentItem; interactive: false }
},
State {
name: "add"
PropertyChanges { target: detailsEditScroll; opened: true }
PropertyChanges { target: detailsEditScroll; sheetOpen: true }
PropertyChanges { target: pageStack.contentItem; interactive: false }
}
]
property QtObject deleteAction: Action {
property QtObject deleteAction: Kirigami.Action {
text: qsTr("Delete dive")
iconName: "trash-empty"
onTriggered: {
@ -85,7 +84,7 @@ Kirigami.Page {
}
}
property QtObject mapAction: Action {
property QtObject mapAction: Kirigami.Action {
text: qsTr("Show on map")
iconName: "gps"
onTriggered: {
@ -93,7 +92,7 @@ Kirigami.Page {
}
}
actions.main: Action {
actions.main: Kirigami.Action {
iconName: state !== "view" ? "document-save" : "document-edit"
onTriggered: {
manager.appendTextToLog("save/edit button triggered")
@ -175,48 +174,44 @@ Kirigami.Page {
Item {
anchors.fill: parent
ScrollView {
id: diveDetailList
ListView {
id: diveDetailsListView
anchors.fill: parent
ListView {
id: diveDetailsListView
anchors.fill: parent
model: diveModel
currentIndex: -1
boundsBehavior: Flickable.StopAtBounds
maximumFlickVelocity: parent.width * 5
orientation: ListView.Horizontal
highlightFollowsCurrentItem: true
focus: true
clip: false
//cacheBuffer: parent.width * 3 // cache one item on either side (this is in pixels)
snapMode: ListView.SnapOneItem
highlightRangeMode: ListView.StrictlyEnforceRange
onMovementEnded: {
currentIndex = indexAt(contentX+1, 1);
}
delegate: ScrollView {
id: internalScrollView
width: diveDetailsListView.width
height: diveDetailsListView.height
property var modelData: model
Flickable {
//contentWidth: parent.width
contentHeight: diveDetails.height
boundsBehavior: Flickable.StopAtBounds
DiveDetailsView {
id: diveDetails
width: internalScrollView.width
}
}
}
model: diveModel
currentIndex: -1
boundsBehavior: Flickable.StopAtBounds
maximumFlickVelocity: parent.width * 5
orientation: ListView.Horizontal
highlightFollowsCurrentItem: true
focus: true
clip: false
//cacheBuffer: parent.width * 3 // cache one item on either side (this is in pixels)
snapMode: ListView.SnapOneItem
highlightRangeMode: ListView.StrictlyEnforceRange
onMovementEnded: {
currentIndex = indexAt(contentX+1, 1);
}
delegate: Flickable {
id: internalScrollView
width: diveDetailsListView.width
height: diveDetailsListView.height
contentHeight: diveDetails.height
boundsBehavior: Flickable.StopAtBounds
property var modelData: model
DiveDetailsView {
id: diveDetails
width: internalScrollView.width
}
ScrollBar.vertical: ScrollBar { }
}
ScrollIndicator.horizontal: ScrollIndicator { }
}
Kirigami.OverlaySheet {
id: detailsEditScroll
anchors.fill: parent
onOpenedChanged: {
if (!opened) {
parent: diveDetailsPage
rootItem.z: 0
onSheetOpenChanged: {
if (!sheetOpen) {
endEditMode()
}
}