2016-01-12 00:15:02 +00:00
|
|
|
import QtQuick 2.4
|
2015-12-04 02:38:58 +00:00
|
|
|
import QtQuick.Controls 1.4
|
2016-01-12 00:15:02 +00:00
|
|
|
import QtQuick.Controls.Styles 1.4
|
2015-07-21 12:00:29 +00:00
|
|
|
import QtQuick.Dialogs 1.2
|
2016-01-12 00:15:02 +00:00
|
|
|
import QtQuick.Layouts 1.2
|
2015-07-21 12:00:29 +00:00
|
|
|
import org.subsurfacedivelog.mobile 1.0
|
2015-11-29 20:13:57 +00:00
|
|
|
import org.kde.plasma.mobilecomponents 0.2 as MobileComponents
|
2015-07-21 12:00:29 +00:00
|
|
|
|
2015-11-29 20:13:57 +00:00
|
|
|
MobileComponents.Page {
|
2016-01-20 22:07:06 +00:00
|
|
|
id: diveDetailsPage
|
2016-01-29 00:01:29 +00:00
|
|
|
property alias currentIndex: diveDetailsListView.currentIndex
|
2016-01-29 02:29:02 +00:00
|
|
|
property alias dive_id: detailsEdit.dive_id
|
|
|
|
property alias number: detailsEdit.number
|
|
|
|
property alias date: detailsEdit.dateText
|
|
|
|
property alias airtemp: detailsEdit.airtempText
|
|
|
|
property alias watertemp: detailsEdit.watertempText
|
|
|
|
property alias buddy: detailsEdit.buddyText
|
|
|
|
property alias divemaster: detailsEdit.divemasterText
|
|
|
|
property alias depth: detailsEdit.depthText
|
|
|
|
property alias duration: detailsEdit.durationText
|
|
|
|
property alias location: detailsEdit.locationText
|
|
|
|
property alias notes: detailsEdit.notesText
|
|
|
|
property alias suit: detailsEdit.suitText
|
|
|
|
property alias weight: detailsEdit.weightText
|
2016-01-12 02:01:15 +00:00
|
|
|
|
2016-01-20 22:07:06 +00:00
|
|
|
state: "view"
|
|
|
|
|
|
|
|
states: [
|
|
|
|
State {
|
|
|
|
name: "view"
|
|
|
|
PropertyChanges { target: diveDetailList; visible: true }
|
|
|
|
PropertyChanges { target: detailsEditScroll; visible: false }
|
|
|
|
},
|
|
|
|
State {
|
|
|
|
name: "edit"
|
|
|
|
PropertyChanges { target: diveDetailList; visible: false }
|
|
|
|
PropertyChanges { target: detailsEditScroll; visible: true }
|
|
|
|
}
|
|
|
|
]
|
2016-01-12 00:15:02 +00:00
|
|
|
mainAction: Action {
|
2016-01-20 22:07:06 +00:00
|
|
|
iconName: state === "edit" ? "dialog-cancel" : "document-edit"
|
2016-01-12 00:15:02 +00:00
|
|
|
onTriggered: {
|
2016-01-20 22:07:06 +00:00
|
|
|
if (state === "edit") {
|
|
|
|
state = "view"
|
|
|
|
return
|
2015-12-04 02:32:52 +00:00
|
|
|
}
|
2016-01-29 00:01:29 +00:00
|
|
|
detailsEdit.dive_id = diveDetailsListView.currentItem.modelData.dive.id
|
|
|
|
detailsEdit.number = diveDetailsListView.currentItem.modelData.dive.number
|
|
|
|
detailsEdit.dateText = diveDetailsListView.currentItem.modelData.dive.date + " " + diveDetailsListView.currentItem.modelData.dive.time
|
|
|
|
detailsEdit.locationText = diveDetailsListView.currentItem.modelData.dive.location
|
|
|
|
detailsEdit.durationText = diveDetailsListView.currentItem.modelData.dive.duration
|
|
|
|
detailsEdit.depthText = diveDetailsListView.currentItem.modelData.dive.depth
|
|
|
|
detailsEdit.airtempText = diveDetailsListView.currentItem.modelData.dive.airTemp
|
|
|
|
detailsEdit.watertempText = diveDetailsListView.currentItem.modelData.dive.waterTemp
|
|
|
|
detailsEdit.suitText = diveDetailsListView.currentItem.modelData.dive.suit
|
|
|
|
detailsEdit.buddyText = diveDetailsListView.currentItem.modelData.dive.buddy
|
|
|
|
detailsEdit.divemasterText = diveDetailsListView.currentItem.modelData.dive.divemaster
|
|
|
|
detailsEdit.notesText = diveDetailsListView.currentItem.modelData.dive.notes
|
2016-01-20 22:07:06 +00:00
|
|
|
diveDetailsPage.state = "edit"
|
2015-12-04 02:32:52 +00:00
|
|
|
}
|
2016-01-12 00:15:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function showDiveIndex(index) {
|
2016-01-29 00:01:29 +00:00
|
|
|
diveDetailsListView.currentIndex = index;
|
|
|
|
diveDetailsListView.positionViewAtIndex(diveDetailsListView.currentIndex, ListView.Beginning);
|
2016-01-12 00:15:02 +00:00
|
|
|
}
|
2016-01-29 00:01:29 +00:00
|
|
|
onWidthChanged: diveDetailsListView.positionViewAtIndex(diveDetailsListView.currentIndex, ListView.Beginning);
|
2015-12-04 02:32:52 +00:00
|
|
|
|
2015-11-30 00:12:47 +00:00
|
|
|
ScrollView {
|
2016-01-20 22:07:06 +00:00
|
|
|
id: diveDetailList
|
2015-11-11 23:40:13 +00:00
|
|
|
anchors.fill: parent
|
2016-01-12 00:15:02 +00:00
|
|
|
ListView {
|
2016-01-29 00:01:29 +00:00
|
|
|
id: diveDetailsListView
|
2015-11-30 00:12:47 +00:00
|
|
|
anchors.fill: parent
|
2016-01-12 00:15:02 +00:00
|
|
|
model: diveModel
|
|
|
|
currentIndex: -1
|
|
|
|
boundsBehavior: Flickable.StopAtBounds
|
|
|
|
maximumFlickVelocity: parent.width/4
|
|
|
|
orientation: ListView.Horizontal
|
|
|
|
focus: true
|
2015-11-30 00:12:47 +00:00
|
|
|
clip: true
|
2016-01-12 00:15:02 +00:00
|
|
|
snapMode: ListView.SnapOneItem
|
|
|
|
onMovementEnded: {
|
|
|
|
currentIndex = indexAt(contentX+1, 1);
|
|
|
|
}
|
|
|
|
delegate: ScrollView {
|
|
|
|
id: internalScrollView
|
2016-01-29 00:01:29 +00:00
|
|
|
width: diveDetailsListView.width
|
|
|
|
height: diveDetailsListView.height
|
2016-01-12 00:15:02 +00:00
|
|
|
property var modelData: model
|
|
|
|
Flickable {
|
|
|
|
//contentWidth: parent.width
|
|
|
|
contentHeight: diveDetails.height
|
2016-01-12 02:15:05 +00:00
|
|
|
boundsBehavior: Flickable.StopAtBounds
|
2016-01-12 00:15:02 +00:00
|
|
|
DiveDetailsView {
|
|
|
|
id: diveDetails
|
|
|
|
width: internalScrollView.width
|
2015-12-04 00:38:04 +00:00
|
|
|
}
|
|
|
|
}
|
2015-07-21 12:00:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-01-20 22:07:06 +00:00
|
|
|
Flickable {
|
|
|
|
id: detailsEditScroll
|
2016-01-12 00:15:02 +00:00
|
|
|
anchors.fill: parent
|
2016-01-20 22:07:06 +00:00
|
|
|
anchors.margins: MobileComponents.Units.gridUnit
|
|
|
|
contentWidth: contentItem.childrenRect.width;
|
|
|
|
contentHeight: contentItem.childrenRect.height
|
|
|
|
clip: true
|
|
|
|
bottomMargin: MobileComponents.Units.gridUnit * 3
|
|
|
|
DiveDetailsEdit {
|
2016-01-12 00:15:02 +00:00
|
|
|
id: detailsEdit
|
2016-01-12 02:01:15 +00:00
|
|
|
}
|
2016-01-12 00:15:02 +00:00
|
|
|
}
|
2015-07-21 12:00:29 +00:00
|
|
|
}
|