| 
									
										
										
										
											2017-04-27 20:30:36 +02:00
										 |  |  | // SPDX-License-Identifier: GPL-2.0
 | 
					
						
							| 
									
										
										
										
											2017-10-29 08:44:06 +01:00
										 |  |  | import QtQuick 2.6 | 
					
						
							| 
									
										
										
										
											2017-10-29 13:44:22 +01:00
										 |  |  | import QtQuick.Controls 2.2 | 
					
						
							| 
									
										
										
										
											2015-07-21 15:00:29 +03:00
										 |  |  | import QtQuick.Dialogs 1.2 | 
					
						
							| 
									
										
										
										
											2016-01-12 01:15:02 +01:00
										 |  |  | import QtQuick.Layouts 1.2 | 
					
						
							| 
									
										
										
										
											2015-07-21 15:00:29 +03:00
										 |  |  | import org.subsurfacedivelog.mobile 1.0 | 
					
						
							| 
									
										
										
											
												QML UI: Kirigami to 2.2
When first tested this commit, especially the dive list was looking
terrible. However, after including newer SHA's from libkirigami, and
correcting lots of spacing/margin issue, a retest of this commit shows
no strange artifact any more, and the amount of warnings in the log
output is reduced significantly. So now, it appears save to
upgrade.
Notice that main.qml still uses Kirigami 2.0. and is not updated in
this commit. With version 2.2, there is a new way of theming, that
is not (yet) compatible with our current code. Blindly upgrading to
2.2 leads to a almost black dive list, wrong button colors, and
runtime errors in the log, due to the fact the direct setting from
QML Kirigami's Theme colors is not allowed any more.
Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
											
										 
											2017-10-14 21:13:01 +02:00
										 |  |  | import org.kde.kirigami 2.2 as Kirigami | 
					
						
							| 
									
										
										
										
											2015-07-21 15:00:29 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-03-08 21:26:54 +01:00
										 |  |  | Kirigami.Page { | 
					
						
							| 
									
										
										
										
											2017-03-18 14:19:18 -07:00
										 |  |  | 	id: diveDetailsPage // but this is referenced as detailsWindow
 | 
					
						
							| 
									
										
										
										
											2016-01-28 16:01:29 -08:00
										 |  |  | 	property alias currentIndex: diveDetailsListView.currentIndex | 
					
						
							| 
									
										
										
										
											2016-04-14 06:01:36 -07:00
										 |  |  | 	property alias currentItem: diveDetailsListView.currentItem | 
					
						
							| 
									
										
										
										
											2016-01-28 18:29:02 -08: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 | 
					
						
							| 
									
										
										
										
											2016-05-16 19:59:05 +02:00
										 |  |  | 	property alias buddyIndex: detailsEdit.buddyIndex | 
					
						
							| 
									
										
										
										
											2017-04-14 17:09:09 -07:00
										 |  |  | 	property alias buddyText: detailsEdit.buddyText | 
					
						
							| 
									
										
										
										
											2016-05-20 18:48:36 +02:00
										 |  |  | 	property alias buddyModel: detailsEdit.buddyModel | 
					
						
							| 
									
										
										
										
											2016-05-16 19:59:05 +02:00
										 |  |  | 	property alias divemasterIndex: detailsEdit.divemasterIndex | 
					
						
							| 
									
										
										
										
											2017-04-14 17:09:09 -07:00
										 |  |  | 	property alias divemasterText: detailsEdit.divemasterText | 
					
						
							| 
									
										
										
										
											2016-05-20 18:48:36 +02:00
										 |  |  | 	property alias divemasterModel: detailsEdit.divemasterModel | 
					
						
							| 
									
										
										
										
											2016-01-28 18:29:02 -08:00
										 |  |  | 	property alias depth: detailsEdit.depthText | 
					
						
							|  |  |  | 	property alias duration: detailsEdit.durationText | 
					
						
							|  |  |  | 	property alias location: detailsEdit.locationText | 
					
						
							| 
									
										
										
										
											2016-04-15 05:17:39 -07:00
										 |  |  | 	property alias gps: detailsEdit.gpsText | 
					
						
							| 
									
										
										
										
											2016-01-28 18:29:02 -08:00
										 |  |  | 	property alias notes: detailsEdit.notesText | 
					
						
							| 
									
										
										
										
											2016-05-16 19:59:05 +02:00
										 |  |  | 	property alias suitIndex: detailsEdit.suitIndex | 
					
						
							| 
									
										
										
										
											2017-04-14 17:09:09 -07:00
										 |  |  | 	property alias suitText: detailsEdit.suitText | 
					
						
							| 
									
										
										
										
											2016-05-20 18:48:36 +02:00
										 |  |  | 	property alias suitModel: detailsEdit.suitModel | 
					
						
							| 
									
										
										
										
											2016-01-28 18:29:02 -08:00
										 |  |  | 	property alias weight: detailsEdit.weightText | 
					
						
							| 
									
										
										
										
											2016-02-09 17:20:17 +01:00
										 |  |  | 	property alias startpressure: detailsEdit.startpressureText | 
					
						
							|  |  |  | 	property alias endpressure: detailsEdit.endpressureText | 
					
						
							| 
									
										
										
										
											2016-08-30 16:24:19 +02:00
										 |  |  | 	property alias cylinderIndex: detailsEdit.cylinderIndex | 
					
						
							| 
									
										
										
										
											2017-04-14 17:09:09 -07:00
										 |  |  | 	property alias cylinderText: detailsEdit.cylinderText | 
					
						
							| 
									
										
										
										
											2016-08-30 16:24:19 +02:00
										 |  |  | 	property alias cylinderModel: detailsEdit.cylinderModel | 
					
						
							| 
									
										
										
										
											2016-02-13 18:34:31 +01:00
										 |  |  | 	property alias gasmix: detailsEdit.gasmixText | 
					
						
							| 
									
										
										
										
											2016-04-15 05:17:39 -07:00
										 |  |  | 	property alias gpsCheckbox: detailsEdit.gpsCheckbox | 
					
						
							| 
									
										
										
										
											2016-04-14 06:01:36 -07:00
										 |  |  | 	property int updateCurrentIdx: manager.updateSelectedDive | 
					
						
							| 
									
										
										
										
											2017-07-28 17:43:26 +02:00
										 |  |  | 	property alias rating: detailsEdit.rating | 
					
						
							|  |  |  | 	property alias visibility: detailsEdit.visibility | 
					
						
							| 
									
										
										
										
											2016-01-12 03:01:15 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-21 16:30:10 -07:00
										 |  |  | 	title: currentItem && currentItem.modelData ? currentItem.modelData.dive.location : qsTr("Dive details") | 
					
						
							| 
									
										
										
										
											2016-01-20 14:07:06 -08:00
										 |  |  | 	state: "view" | 
					
						
							| 
									
										
										
										
											2016-04-19 19:11:07 +02:00
										 |  |  | 	leftPadding: 0 | 
					
						
							| 
									
										
										
										
											2017-10-04 08:47:14 -07:00
										 |  |  | 	topPadding: Kirigami.Units.gridUnit * 2 // make room for the title bar
 | 
					
						
							| 
									
										
										
										
											2016-04-19 19:11:07 +02:00
										 |  |  | 	rightPadding: 0 | 
					
						
							|  |  |  | 	bottomPadding: 0 | 
					
						
							| 
									
										
										
										
											2016-01-20 14:07:06 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	states: [ | 
					
						
							|  |  |  | 		State { | 
					
						
							|  |  |  | 			name: "view" | 
					
						
							| 
									
										
										
										
											2016-04-19 04:51:19 -07:00
										 |  |  | 			PropertyChanges { | 
					
						
							|  |  |  | 				target: diveDetailsPage; | 
					
						
							|  |  |  | 				actions { | 
					
						
							|  |  |  | 					right: deleteAction | 
					
						
							| 
									
										
										
										
											2017-06-21 16:30:10 -07:00
										 |  |  | 					left: currentItem ? (currentItem.modelData && currentItem.modelData.dive.gps !== "" ? mapAction : null) : null | 
					
						
							| 
									
										
										
										
											2016-04-19 04:51:19 -07:00
										 |  |  | 				} | 
					
						
							|  |  |  | 			} | 
					
						
							| 
									
										
										
										
											2016-01-20 14:07:06 -08:00
										 |  |  | 		}, | 
					
						
							|  |  |  | 		State { | 
					
						
							|  |  |  | 			name: "edit" | 
					
						
							| 
									
										
										
										
											2017-10-04 12:22:36 -07:00
										 |  |  | 			PropertyChanges { | 
					
						
							|  |  |  | 				target: diveDetailsPage; | 
					
						
							|  |  |  | 				actions { | 
					
						
							|  |  |  | 					right: cancelAction | 
					
						
							|  |  |  | 					left: null | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 			} | 
					
						
							| 
									
										
										
										
											2016-01-29 06:47:27 -08:00
										 |  |  | 		}, | 
					
						
							|  |  |  | 		State { | 
					
						
							|  |  |  | 			name: "add" | 
					
						
							| 
									
										
										
										
											2017-10-04 12:22:36 -07:00
										 |  |  | 			PropertyChanges { | 
					
						
							|  |  |  | 				target: diveDetailsPage; | 
					
						
							|  |  |  | 				actions { | 
					
						
							|  |  |  | 					right: cancelAction | 
					
						
							|  |  |  | 					left: null | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 			} | 
					
						
							| 
									
										
										
										
											2016-01-20 14:07:06 -08:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2017-10-04 21:53:40 -07:00
										 |  |  | 	] | 
					
						
							|  |  |  | 	transitions: [ | 
					
						
							|  |  |  | 		Transition { | 
					
						
							|  |  |  | 			from: "view" | 
					
						
							|  |  |  | 			to: "*" | 
					
						
							| 
									
										
										
										
											2017-10-05 12:14:57 -07:00
										 |  |  | 			ParallelAnimation { | 
					
						
							| 
									
										
										
										
											2017-10-05 12:15:33 -07:00
										 |  |  | 				SequentialAnimation { | 
					
						
							|  |  |  | 					NumberAnimation { | 
					
						
							|  |  |  | 						target: detailsEditFlickable | 
					
						
							|  |  |  | 						properties: "visible" | 
					
						
							|  |  |  | 						from: 0 | 
					
						
							|  |  |  | 						to: 1 | 
					
						
							|  |  |  | 						duration: 10 | 
					
						
							|  |  |  | 					} | 
					
						
							|  |  |  | 					ScaleAnimator { | 
					
						
							|  |  |  | 						target: detailsEditFlickable | 
					
						
							|  |  |  | 						from: 0.3 | 
					
						
							|  |  |  | 						to: 1 | 
					
						
							|  |  |  | 						duration: 400 | 
					
						
							|  |  |  | 						easing.type: Easing.InOutQuad | 
					
						
							|  |  |  | 					} | 
					
						
							| 
									
										
										
										
											2017-10-04 21:53:40 -07:00
										 |  |  | 				} | 
					
						
							| 
									
										
										
										
											2017-10-05 12:15:33 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | 				NumberAnimation { | 
					
						
							| 
									
										
										
										
											2017-10-04 21:53:40 -07:00
										 |  |  | 					target: detailsEditFlickable | 
					
						
							| 
									
										
										
										
											2017-10-05 12:15:33 -07:00
										 |  |  | 					property: "contentY" | 
					
						
							|  |  |  | 					to: 0 | 
					
						
							|  |  |  | 					duration: 200 | 
					
						
							| 
									
										
										
										
											2017-10-04 21:53:40 -07:00
										 |  |  | 					easing.type: Easing.InOutQuad | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		}, | 
					
						
							|  |  |  | 		Transition { | 
					
						
							|  |  |  | 			from: "*" | 
					
						
							|  |  |  | 			to: "view" | 
					
						
							|  |  |  | 			SequentialAnimation { | 
					
						
							|  |  |  | 				ScaleAnimator { | 
					
						
							|  |  |  | 					target: detailsEditFlickable | 
					
						
							|  |  |  | 					from: 1 | 
					
						
							|  |  |  | 					to: 0.3 | 
					
						
							|  |  |  | 					duration: 400 | 
					
						
							|  |  |  | 					easing.type: Easing.InOutQuad | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 				NumberAnimation { | 
					
						
							|  |  |  | 					target: detailsEditFlickable | 
					
						
							|  |  |  | 					properties: "visible" | 
					
						
							|  |  |  | 					from: 1 | 
					
						
							|  |  |  | 					to: 0 | 
					
						
							|  |  |  | 					duration: 10 | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 			} | 
					
						
							| 
									
										
										
										
											2016-01-29 06:47:27 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-10-04 21:53:40 -07:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2016-01-20 14:07:06 -08:00
										 |  |  | 	] | 
					
						
							| 
									
										
										
										
											2016-02-12 04:51:03 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-31 16:15:14 +02:00
										 |  |  | 	property QtObject deleteAction: Kirigami.Action { | 
					
						
							| 
									
										
										
										
											2016-05-03 21:24:00 +02:00
										 |  |  | 		text: qsTr("Delete dive") | 
					
						
							| 
									
										
										
										
											2016-03-23 20:33:17 -07:00
										 |  |  | 		iconName: "trash-empty" | 
					
						
							|  |  |  | 		onTriggered: { | 
					
						
							| 
									
										
										
										
											2017-06-21 16:30:10 -07:00
										 |  |  | 			var deletedId = currentItem.modelData.dive.id | 
					
						
							| 
									
										
										
										
											2016-04-11 21:10:46 +02:00
										 |  |  | 			var deletedIndex = diveDetailsListView.currentIndex | 
					
						
							| 
									
										
										
										
											2016-03-23 20:33:17 -07:00
										 |  |  | 			manager.deleteDive(deletedId) | 
					
						
							|  |  |  | 			stackView.pop() | 
					
						
							|  |  |  | 			showPassiveNotification("Dive deleted", 3000, "Undo", | 
					
						
							|  |  |  | 						function() { | 
					
						
							| 
									
										
										
										
											2016-04-11 21:10:46 +02:00
										 |  |  | 							diveDetailsListView.currentIndex = manager.undoDelete(deletedId) ? deletedIndex : diveDetailsListView.currentIndex | 
					
						
							| 
									
										
										
										
											2016-03-23 20:33:17 -07:00
										 |  |  | 						}); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-10-04 12:22:36 -07:00
										 |  |  | 	property QtObject cancelAction: Kirigami.Action { | 
					
						
							|  |  |  | 		text: qsTr("Cancel edit") | 
					
						
							|  |  |  | 		iconName: "dialog-cancel" | 
					
						
							|  |  |  | 		onTriggered: { | 
					
						
							|  |  |  | 			endEditMode() | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-31 16:15:14 +02:00
										 |  |  | 	property QtObject mapAction: Kirigami.Action { | 
					
						
							| 
									
										
										
										
											2016-05-03 21:24:00 +02:00
										 |  |  | 		text: qsTr("Show on map") | 
					
						
							| 
									
										
										
										
											2016-04-19 05:09:17 -07:00
										 |  |  | 		iconName: "gps" | 
					
						
							|  |  |  | 		onTriggered: { | 
					
						
							| 
									
										
										
										
											2017-06-21 16:30:10 -07:00
										 |  |  | 			showMap(currentItem.modelData.dive.gps_decimal) | 
					
						
							| 
									
										
										
										
											2016-04-19 05:09:17 -07:00
										 |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-31 16:15:14 +02:00
										 |  |  | 	actions.main: Kirigami.Action { | 
					
						
							| 
									
										
										
										
											2016-02-13 21:25:10 -08:00
										 |  |  | 		iconName: state !== "view" ? "document-save" : "document-edit" | 
					
						
							| 
									
										
										
										
											2016-01-12 01:15:02 +01:00
										 |  |  | 		onTriggered: { | 
					
						
							| 
									
										
										
										
											2017-03-18 14:25:59 -07:00
										 |  |  | 			manager.appendTextToLog("save/edit button triggered") | 
					
						
							| 
									
										
										
										
											2016-02-13 21:25:10 -08:00
										 |  |  | 			if (state === "edit" || state === "add") { | 
					
						
							|  |  |  | 				detailsEdit.saveData() | 
					
						
							| 
									
										
										
										
											2016-01-29 06:47:27 -08:00
										 |  |  | 			} else { | 
					
						
							| 
									
										
										
										
											2016-02-07 22:23:06 +01:00
										 |  |  | 				startEditMode() | 
					
						
							| 
									
										
										
										
											2015-12-04 03:32:52 +01:00
										 |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2016-01-12 01:15:02 +01:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-02-08 08:41:42 -08:00
										 |  |  | 	onBackRequested: { | 
					
						
							| 
									
										
										
										
											2016-02-13 21:25:10 -08:00
										 |  |  | 		if (state === "edit") { | 
					
						
							|  |  |  | 			endEditMode() | 
					
						
							|  |  |  | 			event.accepted = true; | 
					
						
							|  |  |  | 		} else if (state === "add") { | 
					
						
							| 
									
										
										
										
											2016-03-30 20:48:50 -05:00
										 |  |  | 			endEditMode() | 
					
						
							| 
									
										
										
										
											2016-02-13 23:54:40 -08:00
										 |  |  | 			stackView.pop() | 
					
						
							| 
									
										
										
										
											2016-02-08 08:41:42 -08:00
										 |  |  | 			event.accepted = true; | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2016-02-13 21:25:10 -08:00
										 |  |  | 		// if we were in view mode, don't accept the event and pop the page
 | 
					
						
							| 
									
										
										
										
											2016-02-08 08:41:42 -08:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-14 06:01:36 -07:00
										 |  |  | 	onCurrentItemChanged: { | 
					
						
							| 
									
										
										
										
											2017-06-21 16:30:10 -07:00
										 |  |  | 		manager.selectedDiveTimestamp = currentItem.modelData.dive.timestamp | 
					
						
							| 
									
										
										
										
											2016-04-14 06:01:36 -07:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-01-12 01:15:02 +01:00
										 |  |  | 	function showDiveIndex(index) { | 
					
						
							| 
									
										
										
										
											2016-01-29 10:17:22 -08:00
										 |  |  | 		currentIndex = index; | 
					
						
							| 
									
										
										
										
											2017-03-18 17:00:07 -07:00
										 |  |  | 		//diveDetailsListView.positionViewAtIndex(index, ListView.End);
 | 
					
						
							| 
									
										
										
										
											2016-01-12 01:15:02 +01:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2016-02-07 22:23:06 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-02-07 22:23:07 +01:00
										 |  |  | 	function endEditMode() { | 
					
						
							| 
									
										
										
										
											2016-03-30 20:48:50 -05:00
										 |  |  | 		// if we were adding a dive, we need to remove it
 | 
					
						
							|  |  |  | 		if (state === "add") | 
					
						
							|  |  |  | 			manager.addDiveAborted(dive_id) | 
					
						
							|  |  |  | 		// just cancel the edit/add state
 | 
					
						
							| 
									
										
										
										
											2016-02-07 22:23:07 +01:00
										 |  |  | 		state = "view"; | 
					
						
							| 
									
										
										
										
											2017-07-31 18:52:01 +02:00
										 |  |  | 		focus = false; | 
					
						
							| 
									
										
										
										
											2016-02-07 22:23:07 +01:00
										 |  |  | 		Qt.inputMethod.hide(); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-02-07 22:23:06 +01:00
										 |  |  | 	function startEditMode() { | 
					
						
							| 
									
										
										
										
											2017-06-21 16:30:10 -07:00
										 |  |  | 		if (!currentItem.modelData) { | 
					
						
							|  |  |  | 			console.log("DiveDetails trying to access undefined currentItem.modelData") | 
					
						
							|  |  |  | 			return | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-02-07 22:23:06 +01:00
										 |  |  | 		// set things up for editing - so make sure that the detailsEdit has
 | 
					
						
							|  |  |  | 		// all the right data (using the property aliases set up above)
 | 
					
						
							| 
									
										
										
										
											2017-06-21 16:30:10 -07:00
										 |  |  | 		dive_id = currentItem.modelData.dive.id | 
					
						
							|  |  |  | 		number = currentItem.modelData.dive.number | 
					
						
							|  |  |  | 		date = currentItem.modelData.dive.date + " " + currentItem.modelData.dive.time | 
					
						
							|  |  |  | 		location = currentItem.modelData.dive.location | 
					
						
							|  |  |  | 		gps = currentItem.modelData.dive.gps | 
					
						
							| 
									
										
										
										
											2016-04-15 05:17:39 -07:00
										 |  |  | 		gpsCheckbox = false | 
					
						
							| 
									
										
										
										
											2017-06-21 16:30:10 -07:00
										 |  |  | 		duration = currentItem.modelData.dive.duration | 
					
						
							|  |  |  | 		depth = currentItem.modelData.dive.depth | 
					
						
							|  |  |  | 		airtemp = currentItem.modelData.dive.airTemp | 
					
						
							|  |  |  | 		watertemp = currentItem.modelData.dive.waterTemp | 
					
						
							|  |  |  | 		suitIndex = currentItem.modelData.dive.suitList.indexOf(currentItem.modelData.dive.suit) | 
					
						
							|  |  |  | 		if (currentItem.modelData.dive.buddy.indexOf(",") > 0) { | 
					
						
							|  |  |  | 			buddyIndex = currentItem.modelData.dive.buddyList.indexOf(qsTr("Multiple Buddies")); | 
					
						
							| 
									
										
										
										
											2016-09-12 20:30:07 +02:00
										 |  |  | 		} else { | 
					
						
							| 
									
										
										
										
											2017-06-21 16:30:10 -07:00
										 |  |  | 			buddyIndex = currentItem.modelData.dive.buddyList.indexOf(currentItem.modelData.dive.buddy) | 
					
						
							| 
									
										
										
										
											2016-09-12 20:30:07 +02:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2017-06-21 16:30:10 -07:00
										 |  |  | 		divemasterIndex = currentItem.modelData.dive.divemasterList.indexOf(currentItem.modelData.dive.divemaster) | 
					
						
							|  |  |  | 		notes = currentItem.modelData.dive.notes | 
					
						
							|  |  |  | 		if (currentItem.modelData.dive.singleWeight) { | 
					
						
							| 
									
										
										
										
											2016-02-07 22:23:06 +01:00
										 |  |  | 			// we have only one weight, go ahead, have fun and edit it
 | 
					
						
							| 
									
										
										
										
											2017-06-21 16:30:10 -07:00
										 |  |  | 			weight = currentItem.modelData.dive.sumWeight | 
					
						
							| 
									
										
										
										
											2016-02-07 22:23:06 +01:00
										 |  |  | 		} else { | 
					
						
							|  |  |  | 			// careful when translating, this text is "magic" in DiveDetailsEdit.qml
 | 
					
						
							|  |  |  | 			weight = "cannot edit multiple weight systems" | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2017-06-21 16:30:10 -07:00
										 |  |  | 		startpressure = currentItem.modelData.dive.startPressure | 
					
						
							|  |  |  | 		endpressure = currentItem.modelData.dive.endPressure | 
					
						
							|  |  |  | 		gasmix = currentItem.modelData.dive.firstGas | 
					
						
							|  |  |  | 		cylinderIndex = currentItem.modelData.dive.cylinderList.indexOf(currentItem.modelData.dive.getCylinder) | 
					
						
							| 
									
										
										
										
											2017-07-28 17:43:26 +02:00
										 |  |  | 		rating = currentItem.modelData.dive.rating | 
					
						
							|  |  |  | 		visibility = currentItem.modelData.dive.visibility | 
					
						
							| 
									
										
										
										
											2016-02-07 22:23:06 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		diveDetailsPage.state = "edit" | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-03-08 21:26:54 +01:00
										 |  |  | 	Item { | 
					
						
							| 
									
										
										
										
											2015-11-12 00:40:13 +01:00
										 |  |  | 		anchors.fill: parent | 
					
						
							| 
									
										
										
										
											2017-10-04 12:22:36 -07:00
										 |  |  | 		visible: diveDetailsPage.state == "view" | 
					
						
							| 
									
										
										
										
											2017-03-31 16:15:14 +02:00
										 |  |  | 		ListView { | 
					
						
							|  |  |  | 			id: diveDetailsListView | 
					
						
							| 
									
										
										
										
											2015-11-30 01:12:47 +01:00
										 |  |  | 			anchors.fill: parent | 
					
						
							| 
									
										
										
										
											2017-03-31 16:15:14 +02:00
										 |  |  | 			model: diveModel | 
					
						
							|  |  |  | 			currentIndex: -1 | 
					
						
							|  |  |  | 			boundsBehavior: Flickable.StopAtBounds | 
					
						
							|  |  |  | 			maximumFlickVelocity: parent.width * 5 | 
					
						
							|  |  |  | 			orientation: ListView.Horizontal | 
					
						
							| 
									
										
										
										
											2017-10-26 22:26:14 +02:00
										 |  |  | 			highlightFollowsCurrentItem: false | 
					
						
							| 
									
										
										
										
											2017-03-31 16:15:14 +02:00
										 |  |  | 			focus: true | 
					
						
							|  |  |  | 			clip: false | 
					
						
							|  |  |  | 			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 | 
					
						
							| 
									
										
										
										
											2016-03-08 21:26:54 +01:00
										 |  |  | 				boundsBehavior: Flickable.StopAtBounds | 
					
						
							| 
									
										
										
										
											2017-03-31 16:15:14 +02:00
										 |  |  | 				property var modelData: model | 
					
						
							|  |  |  | 				DiveDetailsView { | 
					
						
							|  |  |  | 					id: diveDetails | 
					
						
							|  |  |  | 					width: internalScrollView.width | 
					
						
							| 
									
										
										
										
											2015-12-04 01:38:04 +01:00
										 |  |  | 				} | 
					
						
							| 
									
										
										
										
											2017-03-31 16:15:14 +02:00
										 |  |  | 				ScrollBar.vertical: ScrollBar { } | 
					
						
							| 
									
										
										
										
											2015-07-21 15:00:29 +03:00
										 |  |  | 			} | 
					
						
							| 
									
										
										
										
											2017-03-31 16:15:14 +02:00
										 |  |  | 			ScrollIndicator.horizontal: ScrollIndicator { } | 
					
						
							| 
									
										
										
										
											2015-07-21 15:00:29 +03:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2017-10-04 12:22:36 -07:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2017-10-04 12:27:13 -07:00
										 |  |  | 	Flickable { | 
					
						
							|  |  |  | 		id: detailsEditFlickable | 
					
						
							|  |  |  | 		anchors.fill: parent | 
					
						
							|  |  |  | 		leftMargin: Kirigami.Units.smallSpacing | 
					
						
							|  |  |  | 		rightMargin: Kirigami.Units.smallSpacing | 
					
						
							|  |  |  | 		contentHeight: detailsEdit.height | 
					
						
							| 
									
										
										
										
											2017-10-04 21:53:40 -07:00
										 |  |  | 		// start invisible and scaled down, to get the transition
 | 
					
						
							|  |  |  | 		// off to the right start
 | 
					
						
							|  |  |  | 		visible: false | 
					
						
							|  |  |  | 		scale: 0.3 | 
					
						
							| 
									
										
										
										
											2017-10-04 12:27:13 -07:00
										 |  |  | 		DiveDetailsEdit { | 
					
						
							|  |  |  | 			id: detailsEdit | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		ScrollBar.vertical: ScrollBar { } | 
					
						
							| 
									
										
										
										
											2016-01-12 01:15:02 +01:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2015-07-21 15:00:29 +03:00
										 |  |  | } |