| 
									
										
										
										
											2017-04-27 20:30:36 +02:00
										 |  |  | // SPDX-License-Identifier: GPL-2.0
 | 
					
						
							| 
									
										
										
										
											2017-01-21 16:22:15 -08:00
										 |  |  | import QtQuick 2.6 | 
					
						
							| 
									
										
										
										
											2018-10-27 07:17:33 -07:00
										 |  |  | import QtQuick.Controls 2.2 as Controls | 
					
						
							| 
									
										
										
										
											2015-11-29 17:30:41 +01:00
										 |  |  | import QtQuick.Layouts 1.2 | 
					
						
							| 
									
										
										
										
											2015-07-10 11:40:30 +03:00
										 |  |  | import QtQuick.Window 2.2 | 
					
						
							|  |  |  | import QtQuick.Dialogs 1.2 | 
					
						
							| 
									
										
										
										
											2018-10-12 14:57:43 +02:00
										 |  |  | import org.kde.kirigami 2.5 as Kirigami | 
					
						
							| 
									
										
										
										
											2015-07-10 11:40:30 +03:00
										 |  |  | import org.subsurfacedivelog.mobile 1.0 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-03-08 21:26:54 +01:00
										 |  |  | Kirigami.ScrollablePage { | 
					
						
							| 
									
										
										
										
											2015-07-10 11:40:30 +03:00
										 |  |  | 	id: page | 
					
						
							| 
									
										
										
										
											2015-08-20 11:44:01 +03:00
										 |  |  | 	objectName: "DiveList" | 
					
						
							| 
									
										
										
										
											2016-05-03 21:24:00 +02:00
										 |  |  | 	title: qsTr("Dive list") | 
					
						
							| 
									
										
										
										
											2018-04-15 07:28:41 -07:00
										 |  |  | 	verticalScrollBarPolicy: Qt.ScrollBarAlwaysOff | 
					
						
							| 
									
										
										
										
											2018-06-13 18:06:11 +02:00
										 |  |  | 	property int credentialStatus: prefs.credentialStatus | 
					
						
							| 
									
										
										
										
											2016-02-10 18:09:16 -08:00
										 |  |  | 	property int numDives: diveListView.count | 
					
						
							| 
									
										
										
										
											2017-06-23 18:07:48 -07:00
										 |  |  | 	property color textColor: subsurfaceTheme.textColor | 
					
						
							| 
									
										
										
										
											2017-06-24 11:18:18 -07:00
										 |  |  | 	property color secondaryTextColor: subsurfaceTheme.secondaryTextColor | 
					
						
							| 
									
										
										
										
											2017-06-20 10:05:45 -07:00
										 |  |  | 	property int horizontalPadding: Kirigami.Units.gridUnit / 2 - Kirigami.Units.smallSpacing  + 1 | 
					
						
							| 
									
										
										
										
											2019-11-06 07:23:44 +01:00
										 |  |  | 	property QtObject diveListModel: diveTripModel | 
					
						
							| 
									
										
										
										
											2018-10-20 11:57:36 -04:00
										 |  |  | 	property string numShownText | 
					
						
							| 
									
										
										
										
											2016-03-30 20:39:25 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-21 15:54:34 -07:00
										 |  |  | 	supportsRefreshing: true | 
					
						
							|  |  |  | 	onRefreshingChanged: { | 
					
						
							|  |  |  | 		if (refreshing) { | 
					
						
							| 
									
										
										
										
											2018-09-04 11:18:43 +02:00
										 |  |  | 			if (prefs.credentialStatus === CloudStatus.CS_VERIFIED) { | 
					
						
							| 
									
										
										
										
											2017-06-21 15:54:34 -07:00
										 |  |  | 				detailsWindow.endEditMode() | 
					
						
							|  |  |  | 				manager.saveChangesCloud(true) | 
					
						
							|  |  |  | 				refreshing = false | 
					
						
							|  |  |  | 			} else { | 
					
						
							| 
									
										
										
										
											2019-10-30 09:16:58 +01:00
										 |  |  | 				manager.appendTextToLog("sync with cloud storage requested, but credentialStatus is " + prefs.credentialStatus) | 
					
						
							|  |  |  | 				manager.appendTextToLog("no syncing, turn off spinner") | 
					
						
							| 
									
										
										
										
											2017-06-22 21:22:21 +12:00
										 |  |  | 				refreshing = false | 
					
						
							| 
									
										
										
										
											2017-06-21 15:54:34 -07:00
										 |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-10 11:40:30 +03:00
										 |  |  | 	Component { | 
					
						
							|  |  |  | 		id: diveDelegate | 
					
						
							| 
									
										
										
										
											2016-03-08 21:26:54 +01:00
										 |  |  | 		Kirigami.AbstractListItem { | 
					
						
							| 
									
										
										
										
											2019-10-07 17:29:18 -05:00
										 |  |  | 			// this allows us to access properties of the currentItem from outside
 | 
					
						
							|  |  |  | 			property variant myData: model | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-20 09:13:12 -07:00
										 |  |  | 			leftPadding: 0 | 
					
						
							|  |  |  | 			topPadding: 0 | 
					
						
							| 
									
										
										
										
											2017-04-14 13:06:37 -07:00
										 |  |  | 			id: innerListItem | 
					
						
							| 
									
										
										
										
											2015-11-29 21:13:57 +01:00
										 |  |  | 			enabled: true | 
					
						
							| 
									
										
										
										
											2016-03-08 21:26:54 +01:00
										 |  |  | 			supportsMouseEvents: true | 
					
						
							| 
									
										
										
										
											2019-11-06 07:23:44 +01:00
										 |  |  | 			checked: model.selected | 
					
						
							| 
									
										
										
										
											2015-12-27 12:28:08 -08:00
										 |  |  | 			width: parent.width | 
					
						
							| 
									
										
										
										
											2019-11-06 07:23:44 +01:00
										 |  |  | 			height: (collapsed & 1) ? diveListEntry.height + Kirigami.Units.smallSpacing : 0 | 
					
						
							|  |  |  | 			visible: collapsed & 1 | 
					
						
							| 
									
										
										
										
											2017-06-21 15:47:29 -07:00
										 |  |  | 			backgroundColor: checked ? subsurfaceTheme.primaryColor : subsurfaceTheme.backgroundColor | 
					
						
							| 
									
										
										
										
											2018-02-16 09:38:24 +01:00
										 |  |  | 			activeBackgroundColor: subsurfaceTheme.primaryColor | 
					
						
							| 
									
										
										
										
											2017-06-23 18:07:48 -07:00
										 |  |  | 			textColor: checked ? subsurfaceTheme.primaryTextColor : subsurfaceTheme.textColor | 
					
						
							| 
									
										
										
										
											2015-07-10 11:40:30 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-14 17:39:13 -07:00
										 |  |  | 			states: [ | 
					
						
							|  |  |  | 				State { | 
					
						
							|  |  |  | 					name: "isHidden"; | 
					
						
							| 
									
										
										
										
											2019-11-06 07:23:44 +01:00
										 |  |  | 					when: (collapsed & 1) == 0 | 
					
						
							| 
									
										
										
										
											2018-04-14 17:39:13 -07:00
										 |  |  | 					PropertyChanges { | 
					
						
							|  |  |  | 						target: innerListItem | 
					
						
							|  |  |  | 						height: 0 | 
					
						
							|  |  |  | 						visible: false | 
					
						
							|  |  |  | 					} | 
					
						
							|  |  |  | 				}, | 
					
						
							|  |  |  | 				State { | 
					
						
							|  |  |  | 					name: "isVisible"; | 
					
						
							| 
									
										
										
										
											2019-11-06 07:23:44 +01:00
										 |  |  | 					when: (collapsed & 1) == 1 | 
					
						
							| 
									
										
										
										
											2018-04-14 17:39:13 -07:00
										 |  |  | 					PropertyChanges { | 
					
						
							|  |  |  | 						target: innerListItem | 
					
						
							|  |  |  | 						height: diveListEntry.height + Kirigami.Units.smallSpacing | 
					
						
							|  |  |  | 						visible: true | 
					
						
							|  |  |  | 					} | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 			] | 
					
						
							| 
									
										
										
										
											2016-01-12 01:15:02 +01:00
										 |  |  | 			// When clicked, the mode changes to details view
 | 
					
						
							| 
									
										
										
										
											2015-11-29 21:13:57 +01:00
										 |  |  | 			onClicked: { | 
					
						
							| 
									
										
										
										
											2016-02-13 21:28:32 -08:00
										 |  |  | 				if (detailsWindow.state === "view") { | 
					
						
							| 
									
										
										
										
											2019-11-06 07:23:44 +01:00
										 |  |  | 					//diveListView.currentIndex = index
 | 
					
						
							|  |  |  | 					detailsWindow.showDiveIndex(id); | 
					
						
							| 
									
										
										
										
											2019-10-07 16:23:28 -05:00
										 |  |  | 					// switch to detailsWindow (or push it if it's not in the stack)
 | 
					
						
							| 
									
										
										
										
											2019-10-07 22:33:44 -05:00
										 |  |  | 					var i = rootItem.pageIndex(detailsWindow) | 
					
						
							| 
									
										
										
										
											2019-10-07 16:23:28 -05:00
										 |  |  | 					if (i === -1) | 
					
						
							|  |  |  | 						pageStack.push(detailsWindow) | 
					
						
							|  |  |  | 					else | 
					
						
							|  |  |  | 						pageStack.currentIndex = i | 
					
						
							| 
									
										
										
										
											2016-02-13 21:28:32 -08:00
										 |  |  | 				} | 
					
						
							| 
									
										
										
										
											2015-07-10 11:40:30 +03:00
										 |  |  | 			} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-02 07:49:28 -05:00
										 |  |  | 			property bool deleteButtonVisible: false | 
					
						
							| 
									
										
										
										
											2018-10-27 13:00:02 +03:00
										 |  |  | 			property bool copyButtonVisible: false | 
					
						
							| 
									
										
										
										
											2018-10-27 10:21:40 +03:00
										 |  |  | 			property bool pasteButtonVisible: false | 
					
						
							| 
									
										
										
										
											2016-04-02 07:49:28 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | 			onPressAndHold: { | 
					
						
							| 
									
										
										
										
											2018-10-27 13:00:02 +03:00
										 |  |  | 				deleteButtonVisible = true | 
					
						
							|  |  |  | 				copyButtonVisible = true | 
					
						
							| 
									
										
										
										
											2018-10-27 10:21:40 +03:00
										 |  |  | 				pasteButtonVisible = true | 
					
						
							| 
									
										
										
										
											2016-04-02 07:49:28 -05:00
										 |  |  | 				timer.restart() | 
					
						
							|  |  |  | 			} | 
					
						
							| 
									
										
										
										
											2017-06-20 09:13:12 -07:00
										 |  |  | 			Item { | 
					
						
							|  |  |  | 				Rectangle { | 
					
						
							|  |  |  | 					id: leftBarDive | 
					
						
							| 
									
										
										
										
											2019-08-14 23:53:28 +02:00
										 |  |  | 					width: tripId == "" ? 0 : Kirigami.Units.smallSpacing | 
					
						
							| 
									
										
										
										
											2017-06-21 09:55:03 -07:00
										 |  |  | 					height: diveListEntry.height * 0.8 | 
					
						
							| 
									
										
										
										
											2017-06-21 07:39:07 -07:00
										 |  |  | 					color: subsurfaceTheme.lightPrimaryColor | 
					
						
							| 
									
										
										
										
											2017-06-20 09:13:12 -07:00
										 |  |  | 					anchors { | 
					
						
							|  |  |  | 						left: parent.left | 
					
						
							|  |  |  | 						top: parent.top | 
					
						
							| 
									
										
										
										
											2017-06-21 09:55:03 -07:00
										 |  |  | 						leftMargin: Kirigami.Units.smallSpacing | 
					
						
							|  |  |  | 						topMargin: Kirigami.Units.smallSpacing * 2 | 
					
						
							|  |  |  | 						bottomMargin: Kirigami.Units.smallSpacing * 2 | 
					
						
							| 
									
										
										
										
											2017-06-20 09:13:12 -07:00
										 |  |  | 					} | 
					
						
							| 
									
										
										
										
											2016-04-02 07:49:28 -05:00
										 |  |  | 				} | 
					
						
							| 
									
										
										
										
											2016-04-02 10:40:54 -05:00
										 |  |  | 				Item { | 
					
						
							|  |  |  | 					id: diveListEntry | 
					
						
							| 
									
										
										
										
											2018-10-27 13:00:02 +03:00
										 |  |  | 					width: parent.width - Kirigami.Units.gridUnit * (innerListItem.deleteButtonVisible ? 3 * 3 : 1) | 
					
						
							| 
									
										
										
										
											2018-04-16 11:54:32 -07:00
										 |  |  | 					height: Math.ceil(childrenRect.height + Kirigami.Units.smallSpacing) | 
					
						
							| 
									
										
										
										
											2017-06-20 09:13:12 -07:00
										 |  |  | 					anchors.left: leftBarDive.right | 
					
						
							| 
									
										
										
										
											2017-10-12 14:25:22 +02:00
										 |  |  | 					Controls.Label { | 
					
						
							| 
									
										
										
										
											2016-04-02 10:40:54 -05:00
										 |  |  | 						id: locationText | 
					
						
							| 
									
										
										
										
											2019-10-22 16:45:37 -04:00
										 |  |  | 						text: (undefined !== location && "" != location) ? location : qsTr("<unnamed dive site>") | 
					
						
							| 
									
										
										
										
											2017-06-18 17:06:53 -07:00
										 |  |  | 						font.weight: Font.Bold | 
					
						
							| 
									
										
										
										
											2017-10-18 10:37:41 +02:00
										 |  |  | 						font.pointSize: subsurfaceTheme.regularPointSize | 
					
						
							| 
									
										
										
										
											2016-04-02 10:40:54 -05:00
										 |  |  | 						elide: Text.ElideRight | 
					
						
							|  |  |  | 						maximumLineCount: 1 // needed for elide to work at all
 | 
					
						
							| 
									
										
										
										
											2016-03-22 11:36:11 -07:00
										 |  |  | 						color: textColor | 
					
						
							| 
									
										
										
										
											2016-04-02 10:40:54 -05:00
										 |  |  | 						anchors { | 
					
						
							|  |  |  | 							left: parent.left | 
					
						
							| 
									
										
										
										
											2017-06-20 10:05:45 -07:00
										 |  |  | 							leftMargin: horizontalPadding * 2 | 
					
						
							| 
									
										
										
										
											2017-10-18 10:37:41 +02:00
										 |  |  | 							topMargin: Kirigami.Units.smallSpacing | 
					
						
							| 
									
										
										
										
											2016-04-02 10:40:54 -05:00
										 |  |  | 							top: parent.top | 
					
						
							|  |  |  | 							right: parent.right | 
					
						
							|  |  |  | 						} | 
					
						
							| 
									
										
										
										
											2015-10-09 05:05:23 +02:00
										 |  |  | 					} | 
					
						
							| 
									
										
										
										
											2016-04-02 10:40:54 -05:00
										 |  |  | 					Row { | 
					
						
							|  |  |  | 						anchors { | 
					
						
							| 
									
										
										
										
											2017-06-18 17:06:53 -07:00
										 |  |  | 							left: locationText.left | 
					
						
							|  |  |  | 							top: locationText.bottom | 
					
						
							| 
									
										
										
										
											2017-10-18 10:37:41 +02:00
										 |  |  | 							topMargin: Kirigami.Units.smallSpacing | 
					
						
							| 
									
										
										
										
											2017-06-18 17:38:03 -07:00
										 |  |  | 							bottom: numberText.bottom | 
					
						
							| 
									
										
										
										
											2016-04-02 10:40:54 -05:00
										 |  |  | 						} | 
					
						
							| 
									
										
										
										
											2017-06-18 17:06:53 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-10-12 14:25:22 +02:00
										 |  |  | 						Controls.Label { | 
					
						
							| 
									
										
										
										
											2017-06-18 17:06:53 -07:00
										 |  |  | 							id: dateLabel | 
					
						
							| 
									
										
										
										
											2019-10-22 16:20:55 -04:00
										 |  |  | 							text: (undefined !== dateTime) ? dateTime : "" | 
					
						
							| 
									
										
										
										
											2017-06-18 17:06:53 -07:00
										 |  |  | 							width: Math.max(locationText.width * 0.45, paintedWidth) // helps vertical alignment throughout listview
 | 
					
						
							| 
									
										
										
										
											2016-04-02 10:40:54 -05:00
										 |  |  | 							font.pointSize: subsurfaceTheme.smallPointSize | 
					
						
							| 
									
										
										
										
											2017-07-25 21:47:44 +02:00
										 |  |  | 							color: innerListItem.checked ? subsurfaceTheme.darkerPrimaryTextColor : secondaryTextColor | 
					
						
							| 
									
										
										
										
											2016-04-02 10:40:54 -05:00
										 |  |  | 						} | 
					
						
							| 
									
										
										
										
											2019-11-06 13:24:31 +01:00
										 |  |  | 						// spacer, just in case
 | 
					
						
							|  |  |  | 						Controls.Label { | 
					
						
							|  |  |  | 							text: " " | 
					
						
							|  |  |  | 							width: Kirigami.Units.largeSpacing | 
					
						
							|  |  |  | 						} | 
					
						
							| 
									
										
										
										
											2017-06-18 17:06:53 -07:00
										 |  |  | 						// let's try to show the depth / duration very compact
 | 
					
						
							| 
									
										
										
										
											2017-10-12 14:25:22 +02:00
										 |  |  | 						Controls.Label { | 
					
						
							| 
									
										
										
										
											2019-10-22 16:20:55 -04:00
										 |  |  | 							text: (undefined !== depthDuration) ? depthDuration : "" | 
					
						
							| 
									
										
										
										
											2016-04-02 10:40:54 -05:00
										 |  |  | 							width: Math.max(Kirigami.Units.gridUnit * 3, paintedWidth) // helps vertical alignment throughout listview
 | 
					
						
							|  |  |  | 							font.pointSize: subsurfaceTheme.smallPointSize | 
					
						
							| 
									
										
										
										
											2017-07-25 21:47:44 +02:00
										 |  |  | 							color: innerListItem.checked ? subsurfaceTheme.darkerPrimaryTextColor : secondaryTextColor | 
					
						
							| 
									
										
										
										
											2016-04-02 10:40:54 -05:00
										 |  |  | 						} | 
					
						
							| 
									
										
										
										
											2015-10-09 05:05:23 +02:00
										 |  |  | 					} | 
					
						
							| 
									
										
										
										
											2017-10-12 14:25:22 +02:00
										 |  |  | 					Controls.Label { | 
					
						
							| 
									
										
										
										
											2016-04-02 10:40:54 -05:00
										 |  |  | 						id: numberText | 
					
						
							| 
									
										
										
										
											2019-08-15 00:18:25 +02:00
										 |  |  | 						text: "#" + number | 
					
						
							| 
									
										
										
										
											2015-11-29 23:39:14 +01:00
										 |  |  | 						font.pointSize: subsurfaceTheme.smallPointSize | 
					
						
							| 
									
										
										
										
											2017-07-25 21:47:44 +02:00
										 |  |  | 						color: innerListItem.checked ? subsurfaceTheme.darkerPrimaryTextColor : secondaryTextColor | 
					
						
							| 
									
										
										
										
											2016-04-02 10:40:54 -05:00
										 |  |  | 						anchors { | 
					
						
							|  |  |  | 							right: parent.right | 
					
						
							| 
									
										
										
										
											2017-06-18 17:06:53 -07:00
										 |  |  | 							rightMargin: horizontalPadding | 
					
						
							| 
									
										
										
										
											2016-04-02 10:40:54 -05:00
										 |  |  | 							top: locationText.bottom | 
					
						
							| 
									
										
										
										
											2017-10-18 10:37:41 +02:00
										 |  |  | 							topMargin: Kirigami.Units.smallSpacing | 
					
						
							| 
									
										
										
										
											2016-04-02 10:40:54 -05:00
										 |  |  | 						} | 
					
						
							| 
									
										
										
										
											2015-10-09 05:05:23 +02:00
										 |  |  | 					} | 
					
						
							|  |  |  | 				} | 
					
						
							| 
									
										
										
										
											2016-04-02 10:40:54 -05:00
										 |  |  | 				Rectangle { | 
					
						
							| 
									
										
										
										
											2018-10-27 10:21:40 +03:00
										 |  |  | 					id: copyButton | 
					
						
							|  |  |  | 					visible: copyButtonVisible | 
					
						
							|  |  |  | 					height: diveListEntry.height - 2 * Kirigami.Units.smallSpacing | 
					
						
							| 
									
										
										
										
											2018-10-27 13:00:02 +03:00
										 |  |  | 					width: height | 
					
						
							| 
									
										
										
										
											2018-10-27 10:21:40 +03:00
										 |  |  | 					color: subsurfaceTheme.lightDrawerColor | 
					
						
							|  |  |  | 					antialiasing: true | 
					
						
							|  |  |  | 					radius: Kirigami.Units.smallSpacing | 
					
						
							|  |  |  | 					anchors { | 
					
						
							|  |  |  | 						left: diveListEntry.right | 
					
						
							|  |  |  | 						verticalCenter: diveListEntry.verticalCenter | 
					
						
							|  |  |  | 						verticalCenterOffset: Kirigami.Units.smallSpacing / 2 | 
					
						
							| 
									
										
										
										
											2018-10-27 13:00:02 +03:00
										 |  |  | 						rightMargin: horizontalPadding * 2 | 
					
						
							|  |  |  | 						leftMargin: horizontalPadding * 2 | 
					
						
							| 
									
										
										
										
											2018-10-27 10:21:40 +03:00
										 |  |  | 					} | 
					
						
							|  |  |  | 					Kirigami.Icon { | 
					
						
							|  |  |  | 						anchors { | 
					
						
							|  |  |  | 							horizontalCenter: parent.horizontalCenter | 
					
						
							|  |  |  | 							verticalCenter: parent.verticalCenter | 
					
						
							|  |  |  | 						} | 
					
						
							|  |  |  | 						source: ":/icons/edit-copy" | 
					
						
							|  |  |  | 						width: parent.height | 
					
						
							|  |  |  | 						height: width | 
					
						
							|  |  |  | 					} | 
					
						
							|  |  |  | 					MouseArea { | 
					
						
							|  |  |  | 						anchors.fill: parent | 
					
						
							|  |  |  | 						enabled: parent.visible | 
					
						
							|  |  |  | 						onClicked: { | 
					
						
							|  |  |  | 							deleteButtonVisible = false | 
					
						
							|  |  |  | 							copyButtonVisible = false | 
					
						
							|  |  |  | 							pasteButtonVisible = false | 
					
						
							|  |  |  | 							timer.stop() | 
					
						
							| 
									
										
										
										
											2019-08-15 00:15:30 +02:00
										 |  |  | 							manager.copyDiveData(id) | 
					
						
							| 
									
										
										
										
											2018-10-27 10:21:40 +03:00
										 |  |  | 						} | 
					
						
							| 
									
										
										
										
											2018-11-18 07:42:15 +02:00
										 |  |  | 						onPressAndHold: { | 
					
						
							|  |  |  | 								globalDrawer.close() | 
					
						
							| 
									
										
										
										
											2019-08-15 00:15:30 +02:00
										 |  |  | 								manager.copyDiveData(id) | 
					
						
							| 
									
										
										
										
											2018-11-18 07:42:15 +02:00
										 |  |  | 								pageStack.push(settingsCopyWindow) | 
					
						
							|  |  |  | 						} | 
					
						
							| 
									
										
										
										
											2018-10-27 10:21:40 +03:00
										 |  |  | 					} | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 				Rectangle { | 
					
						
							|  |  |  | 					id: pasteButton | 
					
						
							|  |  |  | 					visible: pasteButtonVisible | 
					
						
							|  |  |  | 					height: diveListEntry.height - 2 * Kirigami.Units.smallSpacing | 
					
						
							| 
									
										
										
										
											2018-10-27 13:00:02 +03:00
										 |  |  | 					width: height | 
					
						
							|  |  |  | 					color: subsurfaceTheme.lightDrawerColor | 
					
						
							| 
									
										
										
										
											2018-10-27 10:21:40 +03:00
										 |  |  | 					antialiasing: true | 
					
						
							|  |  |  | 					radius: Kirigami.Units.smallSpacing | 
					
						
							|  |  |  | 					anchors { | 
					
						
							| 
									
										
										
										
											2018-10-27 13:00:02 +03:00
										 |  |  | 						left: copyButton.right | 
					
						
							| 
									
										
										
										
											2018-10-27 10:21:40 +03:00
										 |  |  | 						verticalCenter: diveListEntry.verticalCenter | 
					
						
							|  |  |  | 						verticalCenterOffset: Kirigami.Units.smallSpacing / 2 | 
					
						
							| 
									
										
										
										
											2018-10-27 13:00:02 +03:00
										 |  |  | 						rightMargin: horizontalPadding * 2 | 
					
						
							|  |  |  | 						leftMargin: horizontalPadding * 2 | 
					
						
							| 
									
										
										
										
											2018-10-27 10:21:40 +03:00
										 |  |  | 					} | 
					
						
							|  |  |  | 					Kirigami.Icon { | 
					
						
							|  |  |  | 						anchors { | 
					
						
							|  |  |  | 							horizontalCenter: parent.horizontalCenter | 
					
						
							|  |  |  | 							verticalCenter: parent.verticalCenter | 
					
						
							|  |  |  | 						} | 
					
						
							|  |  |  | 						source: ":/icons/edit-paste" | 
					
						
							|  |  |  | 						width: parent.height | 
					
						
							|  |  |  | 						height: width | 
					
						
							|  |  |  | 					} | 
					
						
							|  |  |  | 					MouseArea { | 
					
						
							|  |  |  | 						anchors.fill: parent | 
					
						
							|  |  |  | 						enabled: parent.visible | 
					
						
							|  |  |  | 						onClicked: { | 
					
						
							|  |  |  | 							deleteButtonVisible = false | 
					
						
							|  |  |  | 							copyButtonVisible = false | 
					
						
							|  |  |  | 							pasteButtonVisible = false | 
					
						
							|  |  |  | 							timer.stop() | 
					
						
							| 
									
										
										
										
											2019-08-15 00:15:30 +02:00
										 |  |  | 							manager.pasteDiveData(id) | 
					
						
							| 
									
										
										
										
											2018-10-27 10:21:40 +03:00
										 |  |  | 						} | 
					
						
							|  |  |  | 					} | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 				Rectangle { | 
					
						
							|  |  |  | 					id: deleteButton | 
					
						
							| 
									
										
										
										
											2016-04-02 10:40:54 -05:00
										 |  |  | 					visible: deleteButtonVisible | 
					
						
							| 
									
										
										
										
											2018-09-30 14:30:03 +02:00
										 |  |  | 					height: diveListEntry.height - 2 * Kirigami.Units.smallSpacing | 
					
						
							| 
									
										
										
										
											2018-10-27 13:00:02 +03:00
										 |  |  | 					width: height | 
					
						
							| 
									
										
										
										
											2017-06-21 07:39:07 -07:00
										 |  |  | 					color: subsurfaceTheme.contrastAccentColor | 
					
						
							| 
									
										
										
										
											2016-04-02 10:40:54 -05:00
										 |  |  | 					antialiasing: true | 
					
						
							|  |  |  | 					radius: Kirigami.Units.smallSpacing | 
					
						
							| 
									
										
										
										
											2017-06-21 07:01:37 -07:00
										 |  |  | 					anchors { | 
					
						
							| 
									
										
										
										
											2018-10-27 13:00:02 +03:00
										 |  |  | 						left: pasteButton.right | 
					
						
							| 
									
										
										
										
											2017-06-21 07:01:37 -07:00
										 |  |  | 						right: parent.right | 
					
						
							| 
									
										
										
										
											2018-09-30 14:30:03 +02:00
										 |  |  | 						verticalCenter: diveListEntry.verticalCenter | 
					
						
							|  |  |  | 						verticalCenterOffset: Kirigami.Units.smallSpacing / 2 | 
					
						
							| 
									
										
										
										
											2018-10-27 13:00:02 +03:00
										 |  |  | 						rightMargin: horizontalPadding * 2 | 
					
						
							|  |  |  | 						leftMargin: horizontalPadding * 2 | 
					
						
							| 
									
										
										
										
											2017-06-21 07:01:37 -07:00
										 |  |  | 					} | 
					
						
							| 
									
										
										
										
											2016-04-02 10:40:54 -05:00
										 |  |  | 					Kirigami.Icon { | 
					
						
							|  |  |  | 						anchors { | 
					
						
							|  |  |  | 							horizontalCenter: parent.horizontalCenter | 
					
						
							|  |  |  | 							verticalCenter: parent.verticalCenter | 
					
						
							|  |  |  | 						} | 
					
						
							| 
									
										
										
										
											2018-04-16 17:28:53 -07:00
										 |  |  | 						source: ":/icons/trash-empty" | 
					
						
							| 
									
										
										
										
											2018-09-30 14:30:03 +02:00
										 |  |  | 						width: parent.height | 
					
						
							| 
									
										
										
										
											2018-05-26 22:16:59 +02:00
										 |  |  | 						height: width | 
					
						
							| 
									
										
										
										
											2016-04-02 07:49:28 -05:00
										 |  |  | 					} | 
					
						
							| 
									
										
										
										
											2016-04-02 10:40:54 -05:00
										 |  |  | 					MouseArea { | 
					
						
							|  |  |  | 						anchors.fill: parent | 
					
						
							|  |  |  | 						enabled: parent.visible | 
					
						
							|  |  |  | 						onClicked: { | 
					
						
							| 
									
										
										
										
											2018-01-07 16:08:25 +01:00
										 |  |  | 							deleteButtonVisible = false | 
					
						
							| 
									
										
										
										
											2018-10-27 10:21:40 +03:00
										 |  |  | 							copyButtonVisible = false | 
					
						
							|  |  |  | 							pasteButtonVisible = false | 
					
						
							| 
									
										
										
										
											2016-04-02 10:40:54 -05:00
										 |  |  | 							timer.stop() | 
					
						
							| 
									
										
										
										
											2019-08-15 00:15:30 +02:00
										 |  |  | 							manager.deleteDive(id) | 
					
						
							| 
									
										
										
										
											2016-04-02 10:40:54 -05:00
										 |  |  | 						} | 
					
						
							| 
									
										
										
										
											2016-04-02 07:49:28 -05:00
										 |  |  | 					} | 
					
						
							|  |  |  | 				} | 
					
						
							| 
									
										
										
										
											2018-10-02 18:51:35 +02:00
										 |  |  | 				Timer { | 
					
						
							|  |  |  | 					id: timer | 
					
						
							|  |  |  | 					interval: 4000 | 
					
						
							|  |  |  | 					onTriggered: { | 
					
						
							|  |  |  | 						deleteButtonVisible = false | 
					
						
							| 
									
										
										
										
											2018-10-27 10:21:40 +03:00
										 |  |  | 						copyButtonVisible = false | 
					
						
							|  |  |  | 						pasteButtonVisible = false | 
					
						
							| 
									
										
										
										
											2016-04-02 07:49:28 -05:00
										 |  |  | 					} | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 			} | 
					
						
							| 
									
										
										
										
											2015-07-10 11:40:30 +03:00
										 |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	Component { | 
					
						
							|  |  |  | 		id: tripHeading | 
					
						
							| 
									
										
										
										
											2015-10-09 03:56:36 +02:00
										 |  |  | 		Item { | 
					
						
							| 
									
										
										
										
											2017-10-27 10:57:55 +02:00
										 |  |  | 			width: page.width | 
					
						
							| 
									
										
										
										
											2018-04-14 17:37:44 -07:00
										 |  |  | 			height: childrenRect.height | 
					
						
							| 
									
										
										
										
											2017-06-20 07:46:55 -07:00
										 |  |  | 			Rectangle { | 
					
						
							|  |  |  | 				id: headingBackground | 
					
						
							| 
									
										
										
										
											2017-06-22 03:11:51 -07:00
										 |  |  | 				height: section == "" ? 0 : sectionText.height + Kirigami.Units.gridUnit | 
					
						
							| 
									
										
										
										
											2017-06-20 07:46:55 -07:00
										 |  |  | 				anchors { | 
					
						
							| 
									
										
										
										
											2017-06-20 16:21:47 -07:00
										 |  |  | 					left: parent.left | 
					
						
							| 
									
										
										
										
											2017-06-20 07:46:55 -07:00
										 |  |  | 					right: parent.right | 
					
						
							|  |  |  | 				} | 
					
						
							| 
									
										
										
										
											2017-06-21 07:39:07 -07:00
										 |  |  | 				color: subsurfaceTheme.lightPrimaryColor | 
					
						
							| 
									
										
										
										
											2017-06-20 09:14:05 -07:00
										 |  |  | 				visible: section != "" | 
					
						
							| 
									
										
										
										
											2017-06-24 13:13:04 -07:00
										 |  |  | 				Rectangle { | 
					
						
							|  |  |  | 					id: dateBox | 
					
						
							|  |  |  | 					visible: section != "" | 
					
						
							| 
									
										
										
										
											2018-10-01 10:58:57 +02:00
										 |  |  | 					height: section == "" ? 0 : parent.height - Kirigami.Units.smallSpacing | 
					
						
							|  |  |  | 					width: section == "" ? 0 : 2.5 * Kirigami.Units.gridUnit * PrefDisplay.mobile_scale | 
					
						
							| 
									
										
										
										
											2017-06-24 13:13:04 -07:00
										 |  |  | 					color: subsurfaceTheme.primaryColor | 
					
						
							|  |  |  | 					radius: Kirigami.Units.smallSpacing * 2 | 
					
						
							|  |  |  | 					antialiasing: true | 
					
						
							|  |  |  | 					anchors { | 
					
						
							|  |  |  | 						verticalCenter: parent.verticalCenter | 
					
						
							|  |  |  | 						left: parent.left | 
					
						
							|  |  |  | 						leftMargin: Kirigami.Units.smallSpacing | 
					
						
							|  |  |  | 					} | 
					
						
							| 
									
										
										
										
											2017-10-12 14:25:22 +02:00
										 |  |  | 					Controls.Label { | 
					
						
							| 
									
										
										
										
											2018-11-22 22:10:38 +01:00
										 |  |  | 						text: { | 
					
						
							| 
									
										
										
										
											2019-11-07 00:17:34 +01:00
										 |  |  | 							diveListModel ? diveListModel.tripShortDate(section) : "no data model" | 
					
						
							| 
									
										
										
										
											2018-11-22 22:10:38 +01:00
										 |  |  | 						} | 
					
						
							| 
									
										
										
										
											2017-06-24 13:13:04 -07:00
										 |  |  | 						color: subsurfaceTheme.primaryTextColor | 
					
						
							|  |  |  | 						font.pointSize: subsurfaceTheme.smallPointSize | 
					
						
							|  |  |  | 						lineHeightMode: Text.FixedHeight | 
					
						
							|  |  |  | 						lineHeight: Kirigami.Units.gridUnit *.9 | 
					
						
							|  |  |  | 						horizontalAlignment: Text.AlignHCenter | 
					
						
							|  |  |  | 						anchors { | 
					
						
							|  |  |  | 							horizontalCenter: parent.horizontalCenter | 
					
						
							|  |  |  | 							verticalCenter: parent.verticalCenter | 
					
						
							|  |  |  | 						} | 
					
						
							|  |  |  | 					} | 
					
						
							|  |  |  | 				} | 
					
						
							| 
									
										
										
										
											2018-04-14 17:37:44 -07:00
										 |  |  | 				MouseArea { | 
					
						
							|  |  |  | 					anchors.fill: headingBackground | 
					
						
							|  |  |  | 					onClicked: { | 
					
						
							| 
									
										
										
										
											2019-11-07 00:17:34 +01:00
										 |  |  | 						if (diveListModel) { | 
					
						
							|  |  |  | 							if (diveListModel.activeTrip()  === section) | 
					
						
							|  |  |  | 								diveListModel.setActiveTrip("") | 
					
						
							|  |  |  | 							else | 
					
						
							|  |  |  | 								diveListModel.setActiveTrip(section) | 
					
						
							|  |  |  | 						} | 
					
						
							| 
									
										
										
										
											2018-04-14 17:37:44 -07:00
										 |  |  | 					} | 
					
						
							|  |  |  | 				} | 
					
						
							| 
									
										
										
										
											2017-10-12 14:25:22 +02:00
										 |  |  | 				Controls.Label { | 
					
						
							| 
									
										
										
										
											2017-06-20 07:48:10 -07:00
										 |  |  | 					id: sectionText | 
					
						
							|  |  |  | 					text: { | 
					
						
							| 
									
										
										
										
											2019-11-07 00:17:34 +01:00
										 |  |  | 						diveListModel ? diveListModel.tripTitle(section) : "no data model" | 
					
						
							| 
									
										
										
										
											2016-01-26 20:06:30 -08:00
										 |  |  | 					} | 
					
						
							| 
									
										
										
										
											2017-06-22 03:11:51 -07:00
										 |  |  | 					wrapMode: Text.WrapAtWordBoundaryOrAnywhere | 
					
						
							| 
									
										
										
										
											2017-06-20 07:48:10 -07:00
										 |  |  | 					visible: text !== "" | 
					
						
							|  |  |  | 					font.weight: Font.Bold | 
					
						
							| 
									
										
										
										
											2018-09-25 13:09:15 +02:00
										 |  |  | 					font.pointSize: subsurfaceTheme.regularPointSize | 
					
						
							| 
									
										
										
										
											2017-06-20 07:48:10 -07:00
										 |  |  | 					anchors { | 
					
						
							|  |  |  | 						top: parent.top | 
					
						
							| 
									
										
										
										
											2017-06-24 13:13:04 -07:00
										 |  |  | 						left: dateBox.right | 
					
						
							| 
									
										
										
										
											2017-06-20 07:48:10 -07:00
										 |  |  | 						topMargin: Math.max(2, Kirigami.Units.gridUnit / 2) | 
					
						
							| 
									
										
										
										
											2017-06-20 16:21:47 -07:00
										 |  |  | 						leftMargin: horizontalPadding * 2 | 
					
						
							| 
									
										
										
										
											2017-06-20 07:48:10 -07:00
										 |  |  | 						right: parent.right | 
					
						
							|  |  |  | 					} | 
					
						
							| 
									
										
										
										
											2017-06-21 07:39:07 -07:00
										 |  |  | 					color: subsurfaceTheme.lightPrimaryTextColor | 
					
						
							| 
									
										
										
										
											2015-10-09 03:56:36 +02:00
										 |  |  | 				} | 
					
						
							| 
									
										
										
										
											2017-06-20 07:46:55 -07:00
										 |  |  | 			} | 
					
						
							| 
									
										
										
										
											2015-10-09 03:56:36 +02:00
										 |  |  | 			Rectangle { | 
					
						
							| 
									
										
										
										
											2018-09-30 16:07:30 +02:00
										 |  |  | 				height: section == "" ? 0 : 1 | 
					
						
							|  |  |  | 				width: parent.width | 
					
						
							|  |  |  | 				anchors.top: headingBackground.bottom | 
					
						
							|  |  |  | 				color: "#B2B2B2" | 
					
						
							| 
									
										
										
										
											2015-10-09 03:56:36 +02:00
										 |  |  | 			} | 
					
						
							| 
									
										
										
										
											2015-07-10 11:40:30 +03:00
										 |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-03 14:08:00 +02:00
										 |  |  | 	StartPage { | 
					
						
							|  |  |  | 		id: startPage | 
					
						
							| 
									
										
										
										
											2016-03-08 21:26:54 +01:00
										 |  |  | 		anchors.fill: parent | 
					
						
							| 
									
										
										
										
											2019-09-20 12:01:24 -07:00
										 |  |  | 		opacity: (credentialStatus === CloudStatus.CS_NOCLOUD || | 
					
						
							|  |  |  | 			 credentialStatus === CloudStatus.CS_VERIFIED) ? 0 : 1 | 
					
						
							| 
									
										
										
										
											2016-03-08 21:26:54 +01:00
										 |  |  | 		visible: opacity > 0 | 
					
						
							|  |  |  | 		Behavior on opacity { NumberAnimation { duration: Kirigami.Units.shortDuration } } | 
					
						
							| 
									
										
										
										
											2017-04-03 10:48:35 -07:00
										 |  |  | 		function setupActions() { | 
					
						
							| 
									
										
										
										
											2018-10-02 13:16:12 +02:00
										 |  |  | 			if (prefs.credentialStatus === CloudStatus.CS_VERIFIED || | 
					
						
							|  |  |  | 					prefs.credentialStatus === CloudStatus.CS_NOCLOUD) { | 
					
						
							| 
									
										
										
										
											2017-06-27 21:45:17 -07:00
										 |  |  | 				page.actions.main = page.downloadFromDCAction | 
					
						
							|  |  |  | 				page.actions.right = page.addDiveAction | 
					
						
							| 
									
										
										
										
											2018-02-04 16:46:03 +01:00
										 |  |  | 				page.actions.left = page.filterToggleAction | 
					
						
							| 
									
										
										
										
											2017-07-31 16:37:15 +02:00
										 |  |  | 				page.title = qsTr("Dive list") | 
					
						
							| 
									
										
										
										
											2016-04-22 05:19:34 -07:00
										 |  |  | 				if (diveListView.count === 0) | 
					
						
							| 
									
										
										
										
											2017-06-27 21:45:17 -07:00
										 |  |  | 					showPassiveNotification(qsTr("Please tap the '+' button to add a dive (or download dives from a supported dive computer)"), 3000) | 
					
						
							| 
									
										
										
										
											2016-04-20 06:56:01 -07:00
										 |  |  | 			} else { | 
					
						
							|  |  |  | 				page.actions.main = null | 
					
						
							| 
									
										
										
										
											2016-04-22 05:05:57 -07:00
										 |  |  | 				page.actions.right = null | 
					
						
							| 
									
										
										
										
											2019-09-20 12:01:24 -07:00
										 |  |  | 				page.actions.left = null | 
					
						
							| 
									
										
										
										
											2018-10-02 13:16:12 +02:00
										 |  |  | 				page.title = qsTr("Cloud credentials") | 
					
						
							| 
									
										
										
										
											2015-11-29 21:13:57 +01:00
										 |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2017-04-03 10:48:35 -07:00
										 |  |  | 		onVisibleChanged: { | 
					
						
							|  |  |  | 			setupActions(); | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2017-08-03 14:55:09 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-03 10:48:35 -07:00
										 |  |  | 		Component.onCompleted: { | 
					
						
							| 
									
										
										
										
											2017-09-09 13:15:14 +02:00
										 |  |  | 			manager.finishSetup(); | 
					
						
							| 
									
										
										
										
											2017-04-03 10:48:35 -07:00
										 |  |  | 			setupActions(); | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2015-11-29 21:13:57 +01:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2016-01-12 01:15:02 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-28 13:44:08 +02:00
										 |  |  | 	Controls.Label { | 
					
						
							|  |  |  | 		anchors.fill: parent | 
					
						
							|  |  |  | 		horizontalAlignment: Text.AlignHCenter | 
					
						
							|  |  |  | 		verticalAlignment: Text.AlignVCenter | 
					
						
							| 
									
										
										
										
											2018-10-20 12:20:07 -04:00
										 |  |  | 		text: diveListModel ? qsTr("No dives in dive list") : qsTr("Please wait, filtering dive list") | 
					
						
							| 
									
										
										
										
											2016-06-21 16:53:00 +02:00
										 |  |  | 		visible: diveListView.visible && diveListView.count === 0 | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2018-02-04 16:46:03 +01:00
										 |  |  | 	Component { | 
					
						
							|  |  |  | 		id: filterHeader | 
					
						
							| 
									
										
										
										
											2018-10-20 06:00:20 -04:00
										 |  |  | 		Rectangle { | 
					
						
							|  |  |  | 			id: filterRectangle | 
					
						
							| 
									
										
										
										
											2018-10-31 12:52:51 -07:00
										 |  |  | 			visible: filterBar.height > 0 | 
					
						
							| 
									
										
										
										
											2018-10-20 06:00:20 -04:00
										 |  |  | 			implicitHeight: filterBar.implicitHeight | 
					
						
							|  |  |  | 			implicitWidth: filterBar.implicitWidth | 
					
						
							|  |  |  | 			height: filterBar.height | 
					
						
							|  |  |  | 			anchors.left: parent.left | 
					
						
							|  |  |  | 			anchors.right: parent.right | 
					
						
							|  |  |  | 			color: subsurfaceTheme.backgroundColor | 
					
						
							|  |  |  | 			enabled: rootItem.filterToggle | 
					
						
							| 
									
										
										
										
											2018-10-20 06:02:15 -04:00
										 |  |  | 			RowLayout { | 
					
						
							|  |  |  | 				id: filterBar | 
					
						
							|  |  |  | 				z: 5 //make sure it sits on top
 | 
					
						
							|  |  |  | 				states: [ | 
					
						
							|  |  |  | 					State { | 
					
						
							|  |  |  | 						name: "isVisible" | 
					
						
							|  |  |  | 						when: rootItem.filterToggle | 
					
						
							|  |  |  | 						PropertyChanges { target: filterBar; height: sitefilter.implicitHeight } | 
					
						
							|  |  |  | 					}, | 
					
						
							|  |  |  | 					State { | 
					
						
							|  |  |  | 						name: "isHidden" | 
					
						
							|  |  |  | 						when: !rootItem.filterToggle | 
					
						
							|  |  |  | 						PropertyChanges { target: filterBar; height: 0 } | 
					
						
							|  |  |  | 					} | 
					
						
							| 
									
										
										
										
											2018-10-17 16:50:19 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-10-20 06:02:15 -04:00
										 |  |  | 				] | 
					
						
							|  |  |  | 				transitions: [ | 
					
						
							|  |  |  | 					Transition { | 
					
						
							|  |  |  | 						NumberAnimation { property: "height"; duration: 400; easing.type: Easing.InOutQuad } | 
					
						
							|  |  |  | 					} | 
					
						
							|  |  |  | 				] | 
					
						
							| 
									
										
										
										
											2018-10-17 16:50:19 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-10-20 06:02:15 -04:00
										 |  |  | 				anchors.left: parent.left | 
					
						
							|  |  |  | 				anchors.right: parent.right | 
					
						
							|  |  |  | 				anchors.leftMargin: Kirigami.Units.gridUnit / 2 | 
					
						
							|  |  |  | 				anchors.rightMargin: Kirigami.Units.gridUnit / 2 | 
					
						
							|  |  |  | 				Controls.TextField  { | 
					
						
							|  |  |  | 					id: sitefilter | 
					
						
							|  |  |  | 					z: 10 | 
					
						
							|  |  |  | 					verticalAlignment: TextInput.AlignVCenter | 
					
						
							|  |  |  | 					Layout.fillWidth: true | 
					
						
							|  |  |  | 					text: "" | 
					
						
							|  |  |  | 					placeholderText: "Full text search" | 
					
						
							|  |  |  | 					onAccepted: { | 
					
						
							| 
									
										
										
										
											2018-10-20 12:04:00 -04:00
										 |  |  | 						manager.setFilter(text) | 
					
						
							| 
									
										
										
										
											2018-10-20 06:02:15 -04:00
										 |  |  | 					} | 
					
						
							|  |  |  | 					onEnabledChanged: { | 
					
						
							|  |  |  | 						// reset the filter when it gets toggled
 | 
					
						
							|  |  |  | 						text = "" | 
					
						
							|  |  |  | 						if (visible) { | 
					
						
							|  |  |  | 							forceActiveFocus() | 
					
						
							|  |  |  | 						} | 
					
						
							| 
									
										
										
										
											2018-10-19 06:54:34 -04:00
										 |  |  | 					} | 
					
						
							| 
									
										
										
										
											2018-10-18 06:46:50 -04:00
										 |  |  | 				} | 
					
						
							| 
									
										
										
										
											2018-10-20 06:02:15 -04:00
										 |  |  | 				Controls.Label { | 
					
						
							|  |  |  | 					id: numShown | 
					
						
							|  |  |  | 					z: 10 | 
					
						
							|  |  |  | 					verticalAlignment: Text.AlignVCenter | 
					
						
							| 
									
										
										
										
											2018-10-20 11:57:36 -04:00
										 |  |  | 					text: numShownText | 
					
						
							| 
									
										
										
										
											2018-10-20 06:02:15 -04:00
										 |  |  | 				} | 
					
						
							| 
									
										
										
										
											2018-10-17 06:28:53 -04:00
										 |  |  | 			} | 
					
						
							| 
									
										
										
										
											2018-10-20 06:00:20 -04:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2018-02-04 16:46:03 +01:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-03-08 21:26:54 +01:00
										 |  |  | 	ListView { | 
					
						
							|  |  |  | 		id: diveListView | 
					
						
							| 
									
										
										
										
											2015-07-10 11:40:30 +03:00
										 |  |  | 		anchors.fill: parent | 
					
						
							| 
									
										
										
										
											2017-06-24 11:19:56 -07:00
										 |  |  | 		opacity: 1.0 - startPage.opacity | 
					
						
							| 
									
										
										
										
											2016-02-10 18:09:16 -08:00
										 |  |  | 		visible: opacity > 0 | 
					
						
							| 
									
										
										
										
											2019-11-07 00:17:34 +01:00
										 |  |  | 		model: diveListModel | 
					
						
							| 
									
										
										
										
											2016-03-08 21:26:54 +01:00
										 |  |  | 		currentIndex: -1 | 
					
						
							|  |  |  | 		delegate: diveDelegate | 
					
						
							| 
									
										
										
										
											2018-02-04 16:46:03 +01:00
										 |  |  | 		header: filterHeader | 
					
						
							| 
									
										
										
										
											2018-10-17 06:28:29 -04:00
										 |  |  | 		headerPositioning: ListView.OverlayHeader | 
					
						
							| 
									
										
										
										
											2017-06-28 19:55:19 +02:00
										 |  |  | 		boundsBehavior: Flickable.DragOverBounds | 
					
						
							| 
									
										
										
										
											2016-03-08 21:26:54 +01:00
										 |  |  | 		maximumFlickVelocity: parent.height * 5 | 
					
						
							|  |  |  | 		bottomMargin: Kirigami.Units.iconSizes.medium + Kirigami.Units.gridUnit | 
					
						
							| 
									
										
										
										
											2018-04-16 11:45:38 -07:00
										 |  |  | 		cacheBuffer: 40 // this will increase memory use, but should help with scrolling
 | 
					
						
							| 
									
										
										
										
											2019-08-14 23:53:28 +02:00
										 |  |  | 		section.property: "tripId" | 
					
						
							| 
									
										
										
										
											2016-03-08 21:26:54 +01:00
										 |  |  | 		section.criteria: ViewSection.FullString | 
					
						
							|  |  |  | 		section.delegate: tripHeading | 
					
						
							| 
									
										
										
										
											2017-06-21 11:48:29 -07:00
										 |  |  | 		section.labelPositioning: ViewSection.CurrentLabelAtStart | ViewSection.InlineLabels | 
					
						
							| 
									
										
										
										
											2018-10-20 12:04:00 -04:00
										 |  |  | 		onModelChanged: { | 
					
						
							|  |  |  | 			numShownText = diveModel.shown() | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2016-03-08 21:26:54 +01:00
										 |  |  | 		Connections { | 
					
						
							|  |  |  | 			target: detailsWindow | 
					
						
							|  |  |  | 			onCurrentIndexChanged: diveListView.currentIndex = detailsWindow.currentIndex | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2015-07-10 11:40:30 +03:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2016-02-13 21:09:33 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-08-08 06:05:02 -07:00
										 |  |  | 	function showDownloadPage(vendor, product, connection) { | 
					
						
							| 
									
										
										
										
											2018-08-06 18:37:47 -07:00
										 |  |  | 		downloadFromDc.dcImportModel.clearTable() | 
					
						
							| 
									
										
										
										
											2018-10-12 14:57:43 +02:00
										 |  |  | 		pageStack.push(downloadFromDc) | 
					
						
							| 
									
										
										
										
											2018-08-08 06:05:02 -07:00
										 |  |  | 		if (vendor !== undefined && product !== undefined && connection !== undefined) { | 
					
						
							|  |  |  | 			/* set up the correct values on the download page */ | 
					
						
							| 
									
										
										
										
											2018-08-09 07:39:01 -07:00
										 |  |  | 			if (vendor !== -1) | 
					
						
							|  |  |  | 				downloadFromDc.vendor = vendor | 
					
						
							|  |  |  | 			if (product !== -1) | 
					
						
							|  |  |  | 				downloadFromDc.product = product | 
					
						
							|  |  |  | 			if (connection !== -1) | 
					
						
							|  |  |  | 				downloadFromDc.connection = connection | 
					
						
							| 
									
										
										
										
											2018-08-08 06:05:02 -07:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2018-08-06 18:37:47 -07:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-27 21:45:17 -07:00
										 |  |  | 	property QtObject downloadFromDCAction: Kirigami.Action { | 
					
						
							| 
									
										
										
										
											2018-01-02 17:02:19 +01:00
										 |  |  | 		icon { | 
					
						
							| 
									
										
										
										
											2018-04-16 17:28:53 -07:00
										 |  |  | 			name: ":/icons/downloadDC" | 
					
						
							| 
									
										
										
										
											2017-11-19 19:27:45 +01:00
										 |  |  | 			color: subsurfaceTheme.primaryColor | 
					
						
							| 
									
										
										
										
											2018-01-02 17:02:19 +01:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2018-10-03 09:54:49 +02:00
										 |  |  | 		text: qsTr("Download dives") | 
					
						
							| 
									
										
										
										
											2017-06-27 21:45:17 -07:00
										 |  |  | 		onTriggered: { | 
					
						
							| 
									
										
										
										
											2018-08-06 18:37:47 -07:00
										 |  |  | 			showDownloadPage() | 
					
						
							| 
									
										
										
										
											2017-06-27 21:45:17 -07:00
										 |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-31 16:15:14 +02:00
										 |  |  | 	property QtObject addDiveAction: Kirigami.Action { | 
					
						
							| 
									
										
										
										
											2018-01-02 17:02:19 +01:00
										 |  |  | 		icon { | 
					
						
							| 
									
										
										
										
											2018-04-16 17:28:53 -07:00
										 |  |  | 			name: ":/icons/list-add" | 
					
						
							| 
									
										
										
										
											2018-01-02 17:02:19 +01:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2018-10-03 09:54:49 +02:00
										 |  |  | 		text: qsTr("Add dive") | 
					
						
							| 
									
										
										
										
											2016-04-01 22:31:33 -05:00
										 |  |  | 		onTriggered: { | 
					
						
							|  |  |  | 			startAddDive() | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2016-03-08 21:26:54 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-04 16:46:03 +01:00
										 |  |  | 	property QtObject filterToggleAction: Kirigami.Action { | 
					
						
							|  |  |  | 		icon { | 
					
						
							|  |  |  | 			name: ":icons/ic_filter_list" | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		text: qsTr("Filter dives") | 
					
						
							|  |  |  | 		onTriggered: { | 
					
						
							|  |  |  | 			rootItem.filterToggle = !rootItem.filterToggle | 
					
						
							| 
									
										
										
										
											2019-11-07 00:25:30 +01:00
										 |  |  | 			manager.setFilter("") | 
					
						
							| 
									
										
										
										
											2018-10-23 22:14:54 +01:00
										 |  |  | 			numShownText = diveModel.shown() | 
					
						
							| 
									
										
										
										
											2018-02-04 16:46:03 +01:00
										 |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-02-13 21:09:33 -08:00
										 |  |  | 	onBackRequested: { | 
					
						
							| 
									
										
										
										
											2018-06-13 18:06:11 +02:00
										 |  |  | 		if (startPage.visible && diveListView.count > 0 && | 
					
						
							| 
									
										
										
										
											2018-09-04 11:18:43 +02:00
										 |  |  | 			prefs.credentialStatus !== CloudStatus.CS_INCORRECT_USER_PASSWD) { | 
					
						
							| 
									
										
										
										
											2018-06-13 18:06:11 +02:00
										 |  |  | 			prefs.credentialStatus = oldStatus | 
					
						
							| 
									
										
										
										
											2016-02-14 12:17:24 -08:00
										 |  |  | 			event.accepted = true; | 
					
						
							| 
									
										
										
										
											2016-02-13 21:09:33 -08:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2017-04-03 14:08:00 +02:00
										 |  |  | 		if (!startPage.visible) { | 
					
						
							| 
									
										
										
										
											2016-04-21 12:14:37 -07:00
										 |  |  | 			if (Qt.platform.os != "ios") { | 
					
						
							|  |  |  | 				manager.quit() | 
					
						
							|  |  |  | 			} | 
					
						
							| 
									
										
										
										
											2016-06-12 12:12:37 -07:00
										 |  |  | 			// let's make sure Kirigami doesn't quit on our behalf
 | 
					
						
							|  |  |  | 			event.accepted = true | 
					
						
							| 
									
										
										
										
											2016-04-15 14:42:08 -07:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2016-02-13 21:09:33 -08:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2018-03-08 21:49:24 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	function setCurrentDiveListIndex(idx, noScroll) { | 
					
						
							| 
									
										
										
										
											2019-10-07 17:29:18 -05:00
										 |  |  | 		// pick the dive in the dive list and make sure its trip is expanded
 | 
					
						
							| 
									
										
										
										
											2018-03-08 21:49:24 +02:00
										 |  |  | 		diveListView.currentIndex = idx | 
					
						
							| 
									
										
										
										
											2019-11-07 00:17:34 +01:00
										 |  |  | 		if (diveListModel) | 
					
						
							|  |  |  | 			diveListModel.setActiveTrip(diveListView.currentItem.myData.tripId) | 
					
						
							| 
									
										
										
										
											2019-10-07 17:29:18 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		// update the diveDetails page to also show that dive
 | 
					
						
							| 
									
										
										
										
											2019-10-07 16:42:33 -05:00
										 |  |  | 		detailsWindow.showDiveIndex(idx) | 
					
						
							| 
									
										
										
										
											2019-10-07 17:29:18 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-08 21:49:24 +02:00
										 |  |  | 		// updating the index of the ListView triggers a non-linear scroll
 | 
					
						
							|  |  |  | 		// animation that can be very slow. the fix is to stop this animation
 | 
					
						
							|  |  |  | 		// by setting contentY to itself and then using positionViewAtIndex().
 | 
					
						
							|  |  |  | 		// the downside is that the view jumps to the index immediately.
 | 
					
						
							|  |  |  | 		if (noScroll) { | 
					
						
							|  |  |  | 			diveListView.contentY = diveListView.contentY | 
					
						
							|  |  |  | 			diveListView.positionViewAtIndex(idx, ListView.Center) | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2015-07-10 11:40:30 +03:00
										 |  |  | } |