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-02-09 16:20:17 +00:00
|
|
|
property alias startpressure: detailsEdit.startpressureText
|
|
|
|
property alias endpressure: detailsEdit.endpressureText
|
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-29 14:47:27 +00:00
|
|
|
},
|
|
|
|
State {
|
|
|
|
name: "add"
|
|
|
|
PropertyChanges { target: diveDetailList; visible: false }
|
|
|
|
PropertyChanges { target: detailsEditScroll; visible: true }
|
2016-01-20 22:07:06 +00:00
|
|
|
}
|
2016-01-29 14:47:27 +00:00
|
|
|
|
2016-01-20 22:07:06 +00:00
|
|
|
]
|
2016-02-12 12:51:03 +00:00
|
|
|
|
|
|
|
function endAddMode() {
|
|
|
|
// edit was canceled - so remove the dive from the dive list
|
|
|
|
manager.addDiveAborted(dive_id)
|
|
|
|
state = "view"
|
|
|
|
Qt.inputMethod.hide()
|
|
|
|
}
|
2016-02-13 06:26:47 +00:00
|
|
|
/* this can be done by hitting the back key
|
2016-02-12 12:51:03 +00:00
|
|
|
contextualActions: [
|
|
|
|
Action {
|
|
|
|
text: state === "view" ? "Back to dive list" : "Cancel"
|
|
|
|
iconName: "dialog-cancel"
|
|
|
|
onTriggered: {
|
|
|
|
if (state === "view") {
|
|
|
|
stackView.pop()
|
|
|
|
contextDrawer.close()
|
|
|
|
} else if (state === "edit") {
|
|
|
|
endEditMode()
|
|
|
|
contextDrawer.close()
|
|
|
|
} else {
|
|
|
|
endAddMode()
|
|
|
|
contextDrawer.close()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
2016-02-13 06:26:47 +00:00
|
|
|
*/
|
2016-01-12 00:15:02 +00:00
|
|
|
mainAction: Action {
|
2016-01-29 14:47:27 +00:00
|
|
|
iconName: state !== "view" ? "dialog-cancel" : "document-edit"
|
2016-01-12 00:15:02 +00:00
|
|
|
onTriggered: {
|
2016-01-20 22:07:06 +00:00
|
|
|
if (state === "edit") {
|
2016-02-07 21:23:07 +00:00
|
|
|
endEditMode()
|
2016-01-29 14:47:27 +00:00
|
|
|
} else if (state === "add") {
|
2016-02-12 12:51:03 +00:00
|
|
|
endAddMode()
|
2016-01-29 14:47:27 +00:00
|
|
|
} else {
|
2016-02-07 21:23:06 +00:00
|
|
|
startEditMode()
|
2015-12-04 02:32:52 +00:00
|
|
|
}
|
|
|
|
}
|
2016-01-12 00:15:02 +00:00
|
|
|
}
|
|
|
|
|
2016-02-08 16:41:42 +00:00
|
|
|
onBackRequested: {
|
|
|
|
if (state === "edit" || state === "add") {
|
|
|
|
endEditMode();
|
|
|
|
event.accepted = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-01-12 00:15:02 +00:00
|
|
|
function showDiveIndex(index) {
|
2016-01-29 18:17:22 +00:00
|
|
|
currentIndex = index;
|
|
|
|
diveDetailsListView.positionViewAtIndex(index, ListView.Beginning);
|
2016-01-12 00:15:02 +00:00
|
|
|
}
|
2016-02-07 21:23:06 +00:00
|
|
|
|
2016-02-07 21:23:07 +00:00
|
|
|
function endEditMode() {
|
|
|
|
// just cancel the edit state
|
|
|
|
state = "view";
|
|
|
|
Qt.inputMethod.hide();
|
|
|
|
}
|
|
|
|
|
2016-02-07 21:23:06 +00:00
|
|
|
function startEditMode() {
|
|
|
|
// set things up for editing - so make sure that the detailsEdit has
|
|
|
|
// all the right data (using the property aliases set up above)
|
|
|
|
dive_id = diveDetailsListView.currentItem.modelData.dive.id
|
|
|
|
number = diveDetailsListView.currentItem.modelData.dive.number
|
|
|
|
date = diveDetailsListView.currentItem.modelData.dive.date + " " + diveDetailsListView.currentItem.modelData.dive.time
|
|
|
|
location = diveDetailsListView.currentItem.modelData.dive.location
|
|
|
|
duration = diveDetailsListView.currentItem.modelData.dive.duration
|
|
|
|
depth = diveDetailsListView.currentItem.modelData.dive.depth
|
|
|
|
airtemp = diveDetailsListView.currentItem.modelData.dive.airTemp
|
|
|
|
watertemp = diveDetailsListView.currentItem.modelData.dive.waterTemp
|
|
|
|
suit = diveDetailsListView.currentItem.modelData.dive.suit
|
|
|
|
buddy = diveDetailsListView.currentItem.modelData.dive.buddy
|
|
|
|
divemaster = diveDetailsListView.currentItem.modelData.dive.divemaster
|
|
|
|
notes = diveDetailsListView.currentItem.modelData.dive.notes
|
|
|
|
if (diveDetailsListView.currentItem.modelData.dive.singleWeight) {
|
|
|
|
// we have only one weight, go ahead, have fun and edit it
|
|
|
|
weight = diveDetailsListView.currentItem.modelData.dive.sumWeight
|
|
|
|
} else {
|
|
|
|
// careful when translating, this text is "magic" in DiveDetailsEdit.qml
|
|
|
|
weight = "cannot edit multiple weight systems"
|
|
|
|
}
|
2016-02-09 16:20:17 +00:00
|
|
|
if (diveDetailsListView.currentItem.modelData.dive.getCylinder != "Multiple" ) {
|
|
|
|
startpressure = diveDetailsListView.currentItem.modelData.dive.startPressure
|
|
|
|
endpressure = diveDetailsListView.currentItem.modelData.dive.endPressure
|
|
|
|
} else {
|
|
|
|
// careful when translating, this text is "magic" in DiveDetailsEdit.qml
|
|
|
|
startpressure = "cannot edit multiple cylinders"
|
|
|
|
endpressure = "cannot edit multiple cylinders"
|
|
|
|
}
|
2016-02-07 21:23:06 +00:00
|
|
|
|
|
|
|
diveDetailsPage.state = "edit"
|
|
|
|
}
|
|
|
|
|
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
|
2016-02-10 20:58:13 +00:00
|
|
|
maximumFlickVelocity: parent.width * 5
|
2016-01-12 00:15:02 +00:00
|
|
|
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
|
|
|
}
|