| 
									
										
										
										
											2017-04-27 20:30:36 +02:00
										 |  |  | // SPDX-License-Identifier: GPL-2.0
 | 
					
						
							| 
									
										
										
										
											2017-05-12 17:55:19 +02:00
										 |  |  | import QtQuick 2.6 | 
					
						
							| 
									
										
										
										
											2017-10-12 14:25:22 +02:00
										 |  |  | import QtQuick.Controls 2.2 as Controls | 
					
						
							| 
									
										
										
										
											2015-07-23 14:46:02 +03:00
										 |  |  | import QtQuick.Window 2.2 | 
					
						
							|  |  |  | import QtQuick.Dialogs 1.2 | 
					
						
							| 
									
										
										
										
											2017-05-12 17:55:19 +02:00
										 |  |  | import QtQuick.Layouts 1.3 | 
					
						
							| 
									
										
										
										
											2015-07-23 14:46:02 +03:00
										 |  |  | import org.subsurfacedivelog.mobile 1.0 | 
					
						
							| 
									
										
										
										
											2018-09-27 22:09:26 +02:00
										 |  |  | import org.kde.kirigami 2.4 as Kirigami | 
					
						
							| 
									
										
										
										
											2015-07-23 14:46:02 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-03-08 21:26:54 +01:00
										 |  |  | Kirigami.Page { | 
					
						
							| 
									
										
										
										
											2015-07-23 14:46:02 +03:00
										 |  |  | 	id: diveComputerDownloadWindow | 
					
						
							| 
									
										
										
										
											2018-09-26 14:57:12 +02:00
										 |  |  | 	leftPadding: Kirigami.Units.gridUnit / 2 | 
					
						
							|  |  |  | 	rightPadding: Kirigami.Units.gridUnit / 2 | 
					
						
							|  |  |  | 	topPadding: 0 | 
					
						
							|  |  |  | 	bottomPadding: 0 | 
					
						
							| 
									
										
										
										
											2016-05-03 21:24:00 +02:00
										 |  |  | 	title: qsTr("Dive Computer") | 
					
						
							| 
									
										
										
										
											2018-02-16 11:17:20 +01:00
										 |  |  | 	background: Rectangle { color: subsurfaceTheme.backgroundColor } | 
					
						
							| 
									
										
										
										
											2015-07-23 14:46:02 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-16 01:22:44 -07:00
										 |  |  | 	property alias dcImportModel: importModel | 
					
						
							| 
									
										
										
										
											2017-07-09 16:07:03 -07:00
										 |  |  | 	property bool divesDownloaded: false | 
					
						
							| 
									
										
										
										
											2017-10-12 09:43:40 +02:00
										 |  |  | 	property bool btEnabled: manager.btEnabled | 
					
						
							|  |  |  | 	property string btMessage: manager.btEnabled ? "" : qsTr("Bluetooth is not enabled") | 
					
						
							| 
									
										
										
										
											2018-08-08 06:02:49 -07:00
										 |  |  | 	property alias vendor: comboVendor.currentIndex | 
					
						
							|  |  |  | 	property alias product: comboProduct.currentIndex | 
					
						
							|  |  |  | 	property alias connection: comboConnection.currentIndex | 
					
						
							| 
									
										
										
										
											2020-03-09 14:41:55 -07:00
										 |  |  | 	property bool setupUSB: false | 
					
						
							| 
									
										
										
										
											2017-05-29 20:36:00 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-09-25 20:49:13 +02:00
										 |  |  | 	DCImportModel { | 
					
						
							|  |  |  | 		id: importModel | 
					
						
							| 
									
										
										
										
											2017-05-26 17:53:25 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-09-25 20:49:13 +02:00
										 |  |  | 		onDownloadFinished : { | 
					
						
							| 
									
										
										
										
											2017-07-09 16:07:03 -07:00
										 |  |  | 			progressBar.visible = false | 
					
						
							| 
									
										
										
										
											2019-09-25 20:49:13 +02:00
										 |  |  | 			if (rowCount() > 0) { | 
					
						
							| 
									
										
										
										
											2019-10-30 09:16:58 +01:00
										 |  |  | 				manager.appendTextToLog(rowCount() + " dive downloaded") | 
					
						
							| 
									
										
										
										
											2017-07-09 16:07:03 -07:00
										 |  |  | 				divesDownloaded = true | 
					
						
							|  |  |  | 			} else { | 
					
						
							| 
									
										
										
										
											2019-10-30 09:16:58 +01:00
										 |  |  | 				manager.appendTextToLog("no new dives downloaded") | 
					
						
							| 
									
										
										
										
											2017-07-09 16:07:03 -07:00
										 |  |  | 				divesDownloaded = false | 
					
						
							|  |  |  | 			} | 
					
						
							| 
									
										
										
										
											2017-05-28 02:44:24 -07:00
										 |  |  | 			manager.appendTextToLog("DCDownloadThread finished") | 
					
						
							| 
									
										
										
										
											2017-05-26 17:53:25 +02:00
										 |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-02-02 21:48:43 +02:00
										 |  |  | 	ColumnLayout { | 
					
						
							| 
									
										
										
										
											2015-07-23 14:46:02 +03:00
										 |  |  | 		anchors.top: parent.top | 
					
						
							|  |  |  | 		height: parent.height | 
					
						
							| 
									
										
										
										
											2016-02-02 21:48:43 +02:00
										 |  |  | 		width: parent.width | 
					
						
							| 
									
										
										
										
											2017-05-12 17:55:19 +02:00
										 |  |  | 		GridLayout { | 
					
						
							| 
									
										
										
										
											2017-10-19 15:41:05 +02:00
										 |  |  | 			id: buttonGrid | 
					
						
							| 
									
										
										
										
											2018-06-25 16:41:29 +08:00
										 |  |  | 			Layout.alignment: Qt.AlignTop | 
					
						
							|  |  |  | 			Layout.topMargin: Kirigami.Units.smallSpacing * 4 | 
					
						
							| 
									
										
										
										
											2017-05-12 17:55:19 +02:00
										 |  |  | 			columns: 2 | 
					
						
							| 
									
										
										
										
											2018-09-26 14:57:12 +02:00
										 |  |  | 			rowSpacing: 0 | 
					
						
							| 
									
										
										
										
											2020-05-18 07:20:01 -07:00
										 |  |  | 			TemplateLabel { | 
					
						
							| 
									
										
										
										
											2018-09-25 19:58:12 +02:00
										 |  |  | 				text: qsTr(" Vendor name: ") | 
					
						
							|  |  |  | 			} | 
					
						
							| 
									
										
										
										
											2020-12-20 17:18:47 -08:00
										 |  |  | 			TemplateComboBox { | 
					
						
							| 
									
										
										
										
											2017-05-12 18:29:45 +02:00
										 |  |  | 				id: comboVendor | 
					
						
							| 
									
										
										
										
											2017-05-12 18:17:23 +02:00
										 |  |  | 				Layout.fillWidth: true | 
					
						
							| 
									
										
										
										
											2020-01-14 21:29:08 +01:00
										 |  |  | 				Layout.preferredHeight: Kirigami.Units.gridUnit * 2.5 | 
					
						
							| 
									
										
										
										
											2017-05-12 18:17:23 +02:00
										 |  |  | 				model: vendorList | 
					
						
							| 
									
										
										
										
											2018-06-04 18:37:43 +02:00
										 |  |  | 				currentIndex: -1 | 
					
						
							| 
									
										
										
										
											2017-10-12 14:25:22 +02:00
										 |  |  | 				delegate: Controls.ItemDelegate { | 
					
						
							| 
									
										
										
										
											2017-07-17 12:07:19 -07:00
										 |  |  | 					width: comboVendor.width | 
					
						
							| 
									
										
										
										
											2020-01-14 21:29:08 +01:00
										 |  |  | 					height: Kirigami.Units.gridUnit * 2.5 | 
					
						
							| 
									
										
										
										
											2017-07-17 12:07:19 -07:00
										 |  |  | 					contentItem: Text { | 
					
						
							|  |  |  | 						text: modelData | 
					
						
							|  |  |  | 						font.pointSize: subsurfaceTheme.regularPointSize | 
					
						
							| 
									
										
										
										
											2020-12-20 17:18:47 -08:00
										 |  |  | 						color: subsurfaceTheme.textColor | 
					
						
							| 
									
										
										
										
											2017-07-17 12:07:19 -07:00
										 |  |  | 						verticalAlignment: Text.AlignVCenter | 
					
						
							|  |  |  | 						elide: Text.ElideRight | 
					
						
							|  |  |  | 					} | 
					
						
							|  |  |  | 					highlighted: comboVendor.highlightedIndex === index | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 				contentItem: Text { | 
					
						
							|  |  |  | 					text: comboVendor.displayText | 
					
						
							|  |  |  | 					font.pointSize: subsurfaceTheme.regularPointSize | 
					
						
							| 
									
										
										
										
											2020-12-20 17:18:47 -08:00
										 |  |  | 					color: subsurfaceTheme.textColor | 
					
						
							| 
									
										
										
										
											2017-07-17 12:07:19 -07:00
										 |  |  | 					leftPadding: Kirigami.Units.gridUnit * 0.5 | 
					
						
							|  |  |  | 					horizontalAlignment: Text.AlignLeft | 
					
						
							|  |  |  | 					verticalAlignment: Text.AlignVCenter | 
					
						
							|  |  |  | 					elide: Text.ElideRight | 
					
						
							|  |  |  | 				} | 
					
						
							| 
									
										
										
										
											2017-06-05 09:18:17 -07:00
										 |  |  | 				onCurrentTextChanged: { | 
					
						
							| 
									
										
										
										
											2018-06-20 12:07:08 +09:00
										 |  |  | 					manager.DC_vendor = currentText | 
					
						
							| 
									
										
										
										
											2018-06-10 18:33:28 +02:00
										 |  |  | 					comboProduct.model = manager.getProductListFromVendor(currentText) | 
					
						
							| 
									
										
										
										
											2020-03-14 20:30:56 -07:00
										 |  |  | 					// try to be clever if there is just one BT/BLE dive computer paired
 | 
					
						
							|  |  |  | 					if (currentIndex === manager.getDetectedVendorIndex()) | 
					
						
							| 
									
										
										
										
											2018-06-10 18:33:28 +02:00
										 |  |  | 						comboProduct.currentIndex = manager.getDetectedProductIndex(currentText) | 
					
						
							| 
									
										
										
										
											2017-06-05 09:18:17 -07:00
										 |  |  | 				} | 
					
						
							| 
									
										
										
										
											2017-05-12 18:17:23 +02:00
										 |  |  | 			} | 
					
						
							| 
									
										
										
										
											2020-05-18 07:20:01 -07:00
										 |  |  | 			TemplateLabel { | 
					
						
							| 
									
										
										
										
											2018-09-25 19:58:12 +02:00
										 |  |  | 				text: qsTr(" Dive Computer:") | 
					
						
							|  |  |  | 			} | 
					
						
							| 
									
										
										
										
											2020-12-20 17:18:47 -08:00
										 |  |  | 			TemplateComboBox { | 
					
						
							| 
									
										
										
										
											2017-05-12 18:29:45 +02:00
										 |  |  | 				id: comboProduct | 
					
						
							|  |  |  | 				Layout.fillWidth: true | 
					
						
							| 
									
										
										
										
											2020-01-14 21:29:08 +01:00
										 |  |  | 				Layout.preferredHeight: Kirigami.Units.gridUnit * 2.5 | 
					
						
							| 
									
										
										
										
											2017-06-05 09:18:17 -07:00
										 |  |  | 				model: null | 
					
						
							| 
									
										
										
										
											2018-06-04 18:37:43 +02:00
										 |  |  | 				currentIndex: -1 | 
					
						
							| 
									
										
										
										
											2017-10-12 14:25:22 +02:00
										 |  |  | 				delegate: Controls.ItemDelegate { | 
					
						
							| 
									
										
										
										
											2017-07-17 12:07:19 -07:00
										 |  |  | 					width: comboProduct.width | 
					
						
							| 
									
										
										
										
											2020-01-14 21:29:08 +01:00
										 |  |  | 					height: Kirigami.Units.gridUnit * 2.5 | 
					
						
							| 
									
										
										
										
											2017-07-17 12:07:19 -07:00
										 |  |  | 					contentItem: Text { | 
					
						
							|  |  |  | 						text: modelData | 
					
						
							|  |  |  | 						font.pointSize: subsurfaceTheme.regularPointSize | 
					
						
							| 
									
										
										
										
											2020-12-20 17:18:47 -08:00
										 |  |  | 						color: subsurfaceTheme.textColor | 
					
						
							| 
									
										
										
										
											2017-07-17 12:07:19 -07:00
										 |  |  | 						verticalAlignment: Text.AlignVCenter | 
					
						
							|  |  |  | 						elide: Text.ElideRight | 
					
						
							|  |  |  | 					} | 
					
						
							|  |  |  | 					highlighted: comboProduct.highlightedIndex === index | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 				contentItem: Text { | 
					
						
							|  |  |  | 					text: comboProduct.displayText | 
					
						
							|  |  |  | 					font.pointSize: subsurfaceTheme.regularPointSize | 
					
						
							| 
									
										
										
										
											2020-12-20 17:18:47 -08:00
										 |  |  | 					color: subsurfaceTheme.textColor | 
					
						
							| 
									
										
										
										
											2017-07-17 12:07:19 -07:00
										 |  |  | 					leftPadding: Kirigami.Units.gridUnit * 0.5 | 
					
						
							|  |  |  | 					horizontalAlignment: Text.AlignLeft | 
					
						
							|  |  |  | 					verticalAlignment: Text.AlignVCenter | 
					
						
							|  |  |  | 					elide: Text.ElideRight | 
					
						
							|  |  |  | 				} | 
					
						
							| 
									
										
										
										
											2017-07-16 21:50:28 -07:00
										 |  |  | 				onCurrentTextChanged: { | 
					
						
							| 
									
										
										
										
											2018-06-20 12:07:08 +09:00
										 |  |  | 					manager.DC_product = currentText | 
					
						
							| 
									
										
										
										
											2018-06-10 18:33:28 +02:00
										 |  |  | 					var newIdx = manager.getMatchingAddress(comboVendor.currentText, currentText) | 
					
						
							| 
									
										
										
										
											2017-07-17 06:06:22 -07:00
										 |  |  | 					if (newIdx != -1) | 
					
						
							|  |  |  | 						comboConnection.currentIndex = newIdx | 
					
						
							| 
									
										
										
										
											2017-07-16 21:50:28 -07:00
										 |  |  | 				} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
											
												Mobile: wrap up fixes for BT download on Android
Major functional change in this commit is the addition of found static BT devices
to the internal administration (on Android), in a way that is equivalent to
mobile-on-desktop. So, in both cases, the list of devices in the app are
as in the list of devices on the host OS (Linux or Android). To minimize code
duplication, the btDeviceDiscovered slot is split in two parts, the part to
act as slot for the Qt BT discovery agent (Linux, so mobile-on-desktop), and
the part only needed for Android.
Remaining to be fixed: the correct handling of the QML UI selection of
vendor/product. The first default dive computer is correctly detected,
all paired devices from the virtual vendow can be selected, but clicking
through vendors results in non logical selections. It is obvious why
this is, but a fix is not straigforward at this point.
Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
											
										 
											2017-06-12 10:38:24 +02:00
										 |  |  | 				onModelChanged: { | 
					
						
							| 
									
										
										
										
											2018-06-10 18:33:28 +02:00
										 |  |  | 					currentIndex = manager.getDetectedProductIndex(comboVendor.currentText) | 
					
						
							| 
									
										
										
											
												Mobile: wrap up fixes for BT download on Android
Major functional change in this commit is the addition of found static BT devices
to the internal administration (on Android), in a way that is equivalent to
mobile-on-desktop. So, in both cases, the list of devices in the app are
as in the list of devices on the host OS (Linux or Android). To minimize code
duplication, the btDeviceDiscovered slot is split in two parts, the part to
act as slot for the Qt BT discovery agent (Linux, so mobile-on-desktop), and
the part only needed for Android.
Remaining to be fixed: the correct handling of the QML UI selection of
vendor/product. The first default dive computer is correctly detected,
all paired devices from the virtual vendow can be selected, but clicking
through vendors results in non logical selections. It is obvious why
this is, but a fix is not straigforward at this point.
Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
											
										 
											2017-06-12 10:38:24 +02:00
										 |  |  | 				} | 
					
						
							| 
									
										
										
										
											2017-05-29 15:11:11 -07:00
										 |  |  | 			} | 
					
						
							| 
									
										
										
										
											2020-05-18 07:20:01 -07:00
										 |  |  | 			TemplateLabel { | 
					
						
							| 
									
										
										
										
											2018-09-25 19:58:12 +02:00
										 |  |  | 				text: qsTr(" Connection:") | 
					
						
							|  |  |  | 			} | 
					
						
							| 
									
										
										
										
											2020-12-20 17:18:47 -08:00
										 |  |  | 			TemplateComboBox { | 
					
						
							| 
									
										
										
										
											2017-07-16 21:50:28 -07:00
										 |  |  | 				id: comboConnection | 
					
						
							|  |  |  | 				Layout.fillWidth: true | 
					
						
							| 
									
										
										
										
											2020-01-14 21:29:08 +01:00
										 |  |  | 				Layout.preferredHeight: Kirigami.Units.gridUnit * 2.5 | 
					
						
							| 
									
										
										
										
											2017-07-16 21:50:28 -07:00
										 |  |  | 				model: connectionListModel | 
					
						
							|  |  |  | 				currentIndex: -1 | 
					
						
							| 
									
										
										
										
											2017-10-12 14:25:22 +02:00
										 |  |  | 				delegate: Controls.ItemDelegate { | 
					
						
							| 
									
										
										
										
											2017-07-17 12:07:19 -07:00
										 |  |  | 					width: comboConnection.width | 
					
						
							| 
									
										
										
										
											2020-01-14 21:29:08 +01:00
										 |  |  | 					height: Kirigami.Units.gridUnit * 2.5 | 
					
						
							| 
									
										
										
										
											2017-07-17 12:07:19 -07:00
										 |  |  | 					contentItem: Text { | 
					
						
							|  |  |  | 						text: modelData | 
					
						
							|  |  |  | 						font.pointSize: subsurfaceTheme.smallPointSize | 
					
						
							| 
									
										
										
										
											2020-12-20 17:18:47 -08:00
										 |  |  | 						color: subsurfaceTheme.textColor | 
					
						
							| 
									
										
										
										
											2017-07-17 12:07:19 -07:00
										 |  |  | 						verticalAlignment: Text.AlignVCenter | 
					
						
							|  |  |  | 						elide: Text.ElideRight | 
					
						
							|  |  |  | 					} | 
					
						
							|  |  |  | 					highlighted: comboConnection.highlightedIndex === index | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 				contentItem: Text { | 
					
						
							|  |  |  | 					text: comboConnection.displayText | 
					
						
							|  |  |  | 					font.pointSize: subsurfaceTheme.smallPointSize | 
					
						
							| 
									
										
										
										
											2020-12-20 17:18:47 -08:00
										 |  |  | 					color: subsurfaceTheme.textColor | 
					
						
							| 
									
										
										
										
											2017-07-17 12:07:19 -07:00
										 |  |  | 					leftPadding: Kirigami.Units.gridUnit * 0.5 | 
					
						
							|  |  |  | 					horizontalAlignment: Text.AlignLeft | 
					
						
							|  |  |  | 					verticalAlignment: Text.AlignVCenter | 
					
						
							|  |  |  | 					elide: Text.ElideRight | 
					
						
							|  |  |  | 				} | 
					
						
							| 
									
										
										
										
											2020-03-20 14:00:16 -07:00
										 |  |  | 				onCountChanged: { | 
					
						
							|  |  |  | 					// ensure that pick the first entry once we have any
 | 
					
						
							|  |  |  | 					// entries in the connection list
 | 
					
						
							|  |  |  | 					if (count === 0) | 
					
						
							|  |  |  | 						currentIndex = -1 | 
					
						
							|  |  |  | 					else if (currentIndex === -1) | 
					
						
							|  |  |  | 						currentIndex = 0 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-07-17 06:36:44 -07:00
										 |  |  | 				onCurrentTextChanged: { | 
					
						
							| 
									
										
										
										
											2019-12-22 18:43:47 +01:00
										 |  |  | 					var curVendor | 
					
						
							|  |  |  | 					var curProduct | 
					
						
							|  |  |  | 					var curDevice | 
					
						
							| 
									
										
										
										
											2018-09-30 17:43:59 +02:00
										 |  |  | 					dc1.enabled = dc2.enabled = dc3.enabled = dc4.enabled = true | 
					
						
							|  |  |  | 					for (var i = 1; i < 5; i++) { | 
					
						
							| 
									
										
										
										
											2019-12-22 18:43:47 +01:00
										 |  |  | 						switch (i) { | 
					
						
							| 
									
										
										
										
											2020-12-20 17:18:47 -08:00
										 |  |  | 							case 1: | 
					
						
							| 
									
										
										
										
											2019-12-22 18:43:47 +01:00
										 |  |  | 								curVendor = PrefDiveComputer.vendor1 | 
					
						
							|  |  |  | 								curProduct = PrefDiveComputer.product1 | 
					
						
							|  |  |  | 								curDevice = PrefDiveComputer.device1 | 
					
						
							|  |  |  | 								break | 
					
						
							|  |  |  | 							case 2: | 
					
						
							|  |  |  | 								curVendor = PrefDiveComputer.vendor2 | 
					
						
							|  |  |  | 								curProduct = PrefDiveComputer.product2 | 
					
						
							|  |  |  | 								curDevice = PrefDiveComputer.device2 | 
					
						
							|  |  |  | 								break | 
					
						
							|  |  |  | 							case 3: | 
					
						
							|  |  |  | 								curVendor = PrefDiveComputer.vendor3 | 
					
						
							|  |  |  | 								curProduct = PrefDiveComputer.product3 | 
					
						
							|  |  |  | 								curDevice = PrefDiveComputer.device3 | 
					
						
							|  |  |  | 								break | 
					
						
							|  |  |  | 							case 4: | 
					
						
							|  |  |  | 								curVendor = PrefDiveComputer.vendor4 | 
					
						
							|  |  |  | 								curProduct = PrefDiveComputer.product4 | 
					
						
							|  |  |  | 								curDevice = PrefDiveComputer.device4 | 
					
						
							|  |  |  | 								break | 
					
						
							|  |  |  | 						} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-30 17:43:59 +02:00
										 |  |  | 						if (comboProduct.currentIndex === -1 && currentText === "FTDI"){ | 
					
						
							| 
									
										
										
										
											2019-12-22 18:43:47 +01:00
										 |  |  | 							if ( curVendor === comboVendor.currentText && curDevice.toUpperCase() === currentText) | 
					
						
							|  |  |  | 								rememberedDCsGrid.setDC(curVendor, curProduct, curDevice) | 
					
						
							| 
									
										
										
										
											2018-09-30 17:43:59 +02:00
										 |  |  | 						}else if (comboProduct.currentIndex !== -1 && currentText === "FTDI") { | 
					
						
							| 
									
										
										
										
											2020-03-09 10:52:46 -07:00
										 |  |  | 							if ( curVendor === comboVendor.currentText && curProduct === comboProduct.currentText && curDevice.toUpperCase() === currentText) { | 
					
						
							| 
									
										
										
										
											2019-12-22 18:43:47 +01:00
										 |  |  | 								disableDC(i) | 
					
						
							| 
									
										
										
										
											2018-10-09 19:08:03 +02:00
										 |  |  | 								break | 
					
						
							| 
									
										
										
										
											2018-09-30 17:43:59 +02:00
										 |  |  | 							} | 
					
						
							| 
									
										
										
										
											2019-12-22 18:43:47 +01:00
										 |  |  | 						}else if ( curVendor === comboVendor.currentText && curProduct === comboProduct.currentText && curProduct +" " + curDevice === currentText) { | 
					
						
							|  |  |  | 							disableDC(i) | 
					
						
							| 
									
										
										
										
											2018-10-09 19:08:03 +02:00
										 |  |  | 							break | 
					
						
							| 
									
										
										
										
											2019-12-22 18:43:47 +01:00
										 |  |  | 						}else if ( curVendor === comboVendor.currentText && curProduct === comboProduct.currentText && curDevice === currentText) { | 
					
						
							|  |  |  | 							disableDC(i) | 
					
						
							| 
									
										
										
										
											2018-10-09 19:08:03 +02:00
										 |  |  | 							break | 
					
						
							| 
									
										
										
										
											2018-09-30 17:43:59 +02:00
										 |  |  | 						} | 
					
						
							|  |  |  | 					} | 
					
						
							| 
									
										
										
										
											2018-10-09 19:19:00 +02:00
										 |  |  | 					download.text = qsTr("Download") | 
					
						
							| 
									
										
										
										
											2017-07-08 18:59:48 +02:00
										 |  |  | 				} | 
					
						
							| 
									
										
										
										
											2017-05-12 18:29:45 +02:00
										 |  |  | 			} | 
					
						
							| 
									
										
										
										
											2016-02-02 21:48:43 +02:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2017-05-12 17:55:19 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-05-18 07:20:01 -07:00
										 |  |  | 		TemplateLabel { | 
					
						
							| 
									
										
										
										
											2018-09-22 09:17:12 -07:00
										 |  |  | 			text: qsTr(" Previously used dive computers: ") | 
					
						
							|  |  |  | 			visible: PrefDiveComputer.vendor1 !== "" | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		Flow { | 
					
						
							| 
									
										
										
										
											2018-09-21 15:42:34 -07:00
										 |  |  | 			id: rememberedDCsGrid | 
					
						
							|  |  |  | 			visible: PrefDiveComputer.vendor1 !== "" | 
					
						
							|  |  |  | 			Layout.alignment: Qt.AlignTop | 
					
						
							| 
									
										
										
										
											2018-09-22 09:17:12 -07:00
										 |  |  | 			Layout.topMargin: Kirigami.Units.smallSpacing * 2 | 
					
						
							|  |  |  | 			spacing: Kirigami.Units.smallSpacing; | 
					
						
							| 
									
										
										
										
											2018-09-23 11:21:19 +02:00
										 |  |  | 			Layout.fillWidth: true | 
					
						
							| 
									
										
										
										
											2018-09-21 15:42:34 -07:00
										 |  |  | 			function setDC(vendor, product, device) { | 
					
						
							| 
									
										
										
										
											2020-03-09 14:41:55 -07:00
										 |  |  | 				manager.appendTextToLog("setDC called with " + vendor + "/" + product + "/" + device) | 
					
						
							| 
									
										
										
										
											2018-09-21 15:42:34 -07:00
										 |  |  | 				comboVendor.currentIndex = comboVendor.find(vendor); | 
					
						
							|  |  |  | 				comboProduct.currentIndex = comboProduct.find(product); | 
					
						
							| 
									
										
										
										
											2018-09-22 22:53:43 -07:00
										 |  |  | 				comboConnection.currentIndex = manager.getConnectionIndex(device); | 
					
						
							| 
									
										
										
										
											2018-09-21 15:42:34 -07:00
										 |  |  | 			} | 
					
						
							| 
									
										
										
										
											2019-12-22 18:43:47 +01:00
										 |  |  | 			function disableDC(inx) { | 
					
						
							|  |  |  | 				switch (inx) { | 
					
						
							| 
									
										
										
										
											2020-12-20 17:18:47 -08:00
										 |  |  | 					case 1: | 
					
						
							| 
									
										
										
										
											2019-12-22 18:43:47 +01:00
										 |  |  | 						dc1.enabled = false | 
					
						
							|  |  |  | 						break; | 
					
						
							|  |  |  | 					case 2: | 
					
						
							|  |  |  | 						dc2.enabled = false | 
					
						
							|  |  |  | 						break; | 
					
						
							|  |  |  | 					case 3: | 
					
						
							|  |  |  | 						dc3.enabled = false | 
					
						
							|  |  |  | 						break; | 
					
						
							|  |  |  | 					case 4: | 
					
						
							|  |  |  | 						dc4.enabled = false | 
					
						
							|  |  |  | 						break; | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-02-11 17:09:51 +01:00
										 |  |  | 			TemplateButton { | 
					
						
							| 
									
										
										
										
											2018-09-21 15:42:34 -07:00
										 |  |  | 				id: dc1 | 
					
						
							|  |  |  | 				visible: PrefDiveComputer.vendor1 !== "" | 
					
						
							|  |  |  | 				text: PrefDiveComputer.vendor1 + " - " + PrefDiveComputer.product1 | 
					
						
							|  |  |  | 				onClicked: { | 
					
						
							|  |  |  | 					// update comboboxes
 | 
					
						
							|  |  |  | 					rememberedDCsGrid.setDC(PrefDiveComputer.vendor1, PrefDiveComputer.product1, PrefDiveComputer.device1) | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 			} | 
					
						
							| 
									
										
										
										
											2019-02-11 17:09:51 +01:00
										 |  |  | 			TemplateButton { | 
					
						
							| 
									
										
										
										
											2018-09-21 15:42:34 -07:00
										 |  |  | 				id: dc2 | 
					
						
							|  |  |  | 				visible: PrefDiveComputer.vendor2 !== "" | 
					
						
							|  |  |  | 				text: PrefDiveComputer.vendor2 + " - " + PrefDiveComputer.product2 | 
					
						
							|  |  |  | 				onClicked: { | 
					
						
							|  |  |  | 					// update comboboxes
 | 
					
						
							|  |  |  | 					rememberedDCsGrid.setDC(PrefDiveComputer.vendor2, PrefDiveComputer.product2, PrefDiveComputer.device2) | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 			} | 
					
						
							| 
									
										
										
										
											2019-02-11 17:09:51 +01:00
										 |  |  | 			TemplateButton { | 
					
						
							| 
									
										
										
										
											2018-09-21 15:42:34 -07:00
										 |  |  | 				id: dc3 | 
					
						
							|  |  |  | 				visible: PrefDiveComputer.vendor3 !== "" | 
					
						
							|  |  |  | 				text: PrefDiveComputer.vendor3 + " - " + PrefDiveComputer.product3 | 
					
						
							|  |  |  | 				onClicked: { | 
					
						
							|  |  |  | 					// update comboboxes
 | 
					
						
							|  |  |  | 					rememberedDCsGrid.setDC(PrefDiveComputer.vendor3, PrefDiveComputer.product3, PrefDiveComputer.device3) | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 			} | 
					
						
							| 
									
										
										
										
											2019-02-11 17:09:51 +01:00
										 |  |  | 			TemplateButton { | 
					
						
							| 
									
										
										
										
											2018-09-21 15:42:34 -07:00
										 |  |  | 				id: dc4 | 
					
						
							|  |  |  | 				visible: PrefDiveComputer.vendor4 !== "" | 
					
						
							|  |  |  | 				text: PrefDiveComputer.vendor4 + " - " + PrefDiveComputer.product4 | 
					
						
							|  |  |  | 				onClicked: { | 
					
						
							|  |  |  | 					// update comboboxes
 | 
					
						
							|  |  |  | 					rememberedDCsGrid.setDC(PrefDiveComputer.vendor4, PrefDiveComputer.product4, PrefDiveComputer.device4) | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-10-12 14:25:22 +02:00
										 |  |  | 		Controls.ProgressBar { | 
					
						
							| 
									
										
										
										
											2017-07-09 16:07:03 -07:00
										 |  |  | 			id: progressBar | 
					
						
							| 
									
										
										
										
											2018-06-25 16:41:29 +08:00
										 |  |  | 			Layout.topMargin: Kirigami.Units.smallSpacing * 4 | 
					
						
							| 
									
										
										
										
											2016-02-02 21:48:43 +02:00
										 |  |  | 			Layout.fillWidth: true | 
					
						
							| 
									
										
										
										
											2017-06-25 15:52:07 -07:00
										 |  |  | 			indeterminate: true | 
					
						
							| 
									
										
										
										
											2017-05-12 17:55:19 +02:00
										 |  |  | 			visible: false | 
					
						
							| 
									
										
										
										
											2016-02-02 21:48:43 +02:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2017-05-12 17:55:19 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-02-02 21:48:43 +02:00
										 |  |  | 		RowLayout { | 
					
						
							| 
									
										
										
										
											2017-10-19 15:41:05 +02:00
										 |  |  | 			id: buttonBar | 
					
						
							| 
									
										
										
										
											2018-06-25 16:41:29 +08:00
										 |  |  | 			Layout.fillWidth: true | 
					
						
							| 
									
										
										
										
											2019-05-05 16:07:15 -07:00
										 |  |  | 			Layout.topMargin: Kirigami.Units.smallSpacing | 
					
						
							| 
									
										
										
										
											2017-07-23 17:45:55 -07:00
										 |  |  | 			spacing: Kirigami.Units.smallSpacing | 
					
						
							| 
									
										
										
										
											2020-03-15 12:27:10 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			function doDownload() { | 
					
						
							|  |  |  | 				var message = "DCDownloadThread started for " + manager.DC_vendor + " " + manager.DC_product + " on " + manager.DC_devName; | 
					
						
							|  |  |  | 				message += " downloading " + (manager.DC_forceDownload ? "all" : "only new" ) + " dives"; | 
					
						
							|  |  |  | 				manager.appendTextToLog(message) | 
					
						
							|  |  |  | 				progressBar.visible = true | 
					
						
							|  |  |  | 				divesDownloaded = false // this allows the progressMessage to be displayed
 | 
					
						
							|  |  |  | 				importModel.startDownload() | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			Connections { | 
					
						
							|  |  |  | 				target: manager | 
					
						
							|  |  |  | 				onRestartDownloadSignal: { | 
					
						
							|  |  |  | 					buttonBar.doDownload() | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-02-11 17:09:51 +01:00
										 |  |  | 			TemplateButton { | 
					
						
							| 
									
										
										
										
											2017-07-08 15:16:42 +02:00
										 |  |  | 				id: download | 
					
						
							| 
									
										
										
										
											2016-05-03 21:24:00 +02:00
										 |  |  | 				text: qsTr("Download") | 
					
						
							| 
									
										
										
										
											2020-07-14 10:25:46 -07:00
										 |  |  | 				enabled: comboVendor.currentIndex != -1 && comboProduct.currentIndex != -1 && comboConnection.currentIndex != -1 | 
					
						
							| 
									
										
										
										
											2016-02-02 21:48:43 +02:00
										 |  |  | 				onClicked: { | 
					
						
							| 
									
										
										
										
											2017-06-13 00:54:21 -07:00
										 |  |  | 					text = qsTr("Retry") | 
					
						
							| 
									
										
										
										
											2018-12-21 14:53:43 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 					var connectionString = comboConnection.currentText | 
					
						
							|  |  |  | 					// separate BT address and BT name (if applicable)
 | 
					
						
							|  |  |  | 					// pattern that matches BT addresses
 | 
					
						
							|  |  |  | 					var btAddr = "(LE:)?([0-9A-Fa-f]{2}:){5}[0-9A-Fa-f]{2}"; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 					// On iOS we store UUID instead of device address.
 | 
					
						
							|  |  |  | 					if (Qt.platform.os === 'ios') | 
					
						
							|  |  |  | 						btAddr = "(LE:)?\{?[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}\}"; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 					var pattern = new RegExp(btAddr); | 
					
						
							|  |  |  | 					var devAddress = ""; | 
					
						
							|  |  |  | 					devAddress = pattern.exec(connectionString); | 
					
						
							|  |  |  | 					if (devAddress !== null) { | 
					
						
							|  |  |  | 						manager.DC_bluetoothMode = true; | 
					
						
							|  |  |  | 						manager.DC_devName = devAddress[0]; // exec returns an array with the matched text in element 0
 | 
					
						
							|  |  |  | 						manager.retrieveBluetoothName(); | 
					
						
							|  |  |  | 						manager.appendTextToLog("setting btName to " + manager.DC_devBluetoothName); | 
					
						
							|  |  |  | 					} else { | 
					
						
							|  |  |  | 						manager.DC_bluetoothMode = false; | 
					
						
							|  |  |  | 						manager.DC_devName = connectionString; | 
					
						
							|  |  |  | 					} | 
					
						
							| 
									
										
										
										
											2020-03-15 12:27:10 -07:00
										 |  |  | 					buttonBar.doDownload() | 
					
						
							| 
									
										
										
										
											2016-02-02 21:48:43 +02:00
										 |  |  | 				} | 
					
						
							|  |  |  | 			} | 
					
						
							| 
									
										
										
										
											2019-02-11 17:09:51 +01:00
										 |  |  | 			TemplateButton { | 
					
						
							| 
									
										
										
										
											2016-02-02 21:48:43 +02:00
										 |  |  | 				id:quitbutton | 
					
						
							| 
									
										
										
										
											2017-07-19 09:16:47 +02:00
										 |  |  | 				text: progressBar.visible ? qsTr("Cancel") : qsTr("Quit") | 
					
						
							| 
									
										
										
										
											2016-02-02 21:48:43 +02:00
										 |  |  | 				onClicked: { | 
					
						
							| 
									
										
										
										
											2017-07-19 09:16:47 +02:00
										 |  |  | 					manager.cancelDownloadDC() | 
					
						
							| 
									
										
										
										
											2017-12-13 14:39:10 +01:00
										 |  |  | 					if (!progressBar.visible) { | 
					
						
							| 
									
										
										
										
											2020-03-09 10:52:46 -07:00
										 |  |  | 						// remove the download page and show dive list
 | 
					
						
							|  |  |  | 						pageStack.pop(downloadFromDc) | 
					
						
							|  |  |  | 						rootItem.showDiveList() | 
					
						
							| 
									
										
										
										
											2017-12-13 14:39:10 +01:00
										 |  |  | 						download.text = qsTr("Download") | 
					
						
							| 
									
										
										
										
											2017-12-13 15:30:51 +01:00
										 |  |  | 						divesDownloaded = false | 
					
						
							|  |  |  | 						manager.progressMessage = "" | 
					
						
							| 
									
										
										
										
											2020-03-09 10:52:46 -07:00
										 |  |  | 						manager.appendTextToLog("exit DCDownload screen") | 
					
						
							|  |  |  | 					} else { | 
					
						
							|  |  |  | 						manager.appendTextToLog("cancel download") | 
					
						
							| 
									
										
										
										
											2017-12-13 14:39:10 +01:00
										 |  |  | 					} | 
					
						
							| 
									
										
										
										
											2016-02-02 21:48:43 +02:00
										 |  |  | 				} | 
					
						
							|  |  |  | 			} | 
					
						
							| 
									
										
										
										
											2019-02-11 17:09:51 +01:00
										 |  |  | 			TemplateButton { | 
					
						
							| 
									
										
										
										
											2017-12-05 20:58:54 +01:00
										 |  |  | 				id:rescanbutton | 
					
						
							|  |  |  | 				text: qsTr("Rescan") | 
					
						
							| 
									
										
										
										
											2018-10-10 10:12:28 +02:00
										 |  |  | 				enabled: manager.btEnabled | 
					
						
							| 
									
										
										
										
											2017-12-05 20:58:54 +01:00
										 |  |  | 				onClicked: { | 
					
						
							| 
									
										
										
										
											2020-03-16 09:42:46 -07:00
										 |  |  | 					// refresh both USB and BT/BLE and make sure a reasonable entry is selected
 | 
					
						
							|  |  |  | 					var current = comboConnection.currentText | 
					
						
							| 
									
										
										
										
											2020-03-14 18:52:45 -07:00
										 |  |  | 					manager.rescanConnections() | 
					
						
							| 
									
										
										
										
											2020-03-16 09:42:46 -07:00
										 |  |  | 					// check if the same entry is still available; if not pick the first entry
 | 
					
						
							|  |  |  | 					var idx = comboConnection.find(current) | 
					
						
							|  |  |  | 					if (idx === -1) | 
					
						
							|  |  |  | 						idx = 0 | 
					
						
							|  |  |  | 					comboConnection.currentIndex = idx | 
					
						
							| 
									
										
										
										
											2017-12-05 20:58:54 +01:00
										 |  |  | 				} | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-05-18 07:20:01 -07:00
										 |  |  | 			TemplateLabel { | 
					
						
							| 
									
										
										
										
											2018-06-27 16:27:59 -07:00
										 |  |  | 				Layout.fillWidth: true | 
					
						
							| 
									
										
										
										
											2017-07-23 17:45:55 -07:00
										 |  |  | 				text: divesDownloaded ? qsTr(" Downloaded dives") : | 
					
						
							| 
									
										
										
										
											2017-07-23 17:51:48 -07:00
										 |  |  | 							(manager.progressMessage != "" ? qsTr("Info:") + " " + manager.progressMessage : btMessage) | 
					
						
							| 
									
										
										
										
											2017-07-23 17:45:55 -07:00
										 |  |  | 				wrapMode: Text.WrapAtWordBoundaryOrAnywhere | 
					
						
							|  |  |  | 			} | 
					
						
							| 
									
										
										
										
											2016-02-02 21:48:43 +02:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2017-05-26 17:53:25 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-05-05 16:07:15 -07:00
										 |  |  | 		RowLayout { | 
					
						
							|  |  |  | 			id: downloadOptions | 
					
						
							|  |  |  | 			Layout.fillWidth: true | 
					
						
							|  |  |  | 			Layout.topMargin: 0 | 
					
						
							|  |  |  | 			spacing: Kirigami.Units.smallSpacing | 
					
						
							| 
									
										
										
										
											2020-12-30 18:09:39 -08:00
										 |  |  | 			TemplateCheckBox { | 
					
						
							| 
									
										
										
										
											2019-05-05 16:07:15 -07:00
										 |  |  | 				id: forceAll | 
					
						
							|  |  |  | 				checked: manager.DC_forceDownload | 
					
						
							|  |  |  | 				enabled: forceAllLabel.visible | 
					
						
							|  |  |  | 				visible: enabled | 
					
						
							|  |  |  | 				height: forceAllLabel.height - Kirigami.Units.smallSpacing; | 
					
						
							|  |  |  | 				width: height | 
					
						
							|  |  |  | 				onClicked: { | 
					
						
							|  |  |  | 					manager.DC_forceDownload = !manager.DC_forceDownload; | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 			} | 
					
						
							| 
									
										
										
										
											2020-05-18 07:20:01 -07:00
										 |  |  | 			TemplateLabel { | 
					
						
							| 
									
										
										
										
											2019-05-05 16:07:15 -07:00
										 |  |  | 				id: forceAllLabel | 
					
						
							|  |  |  | 				text: qsTr("force downloading all dives") | 
					
						
							|  |  |  | 				visible: comboVendor.currentIndex != -1 && comboProduct.currentIndex != -1 && | 
					
						
							|  |  |  | 					 comboConnection.currentIndex != -1 | 
					
						
							|  |  |  | 				wrapMode: Text.WrapAtWordBoundaryOrAnywhere | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-05-29 19:55:36 +02:00
										 |  |  | 		ListView { | 
					
						
							| 
									
										
										
										
											2017-10-19 15:41:05 +02:00
										 |  |  | 			id: dlList | 
					
						
							| 
									
										
										
										
											2018-06-25 16:41:29 +08:00
										 |  |  | 			Layout.topMargin: Kirigami.Units.smallSpacing * 4 | 
					
						
							| 
									
										
										
										
											2018-09-26 14:57:12 +02:00
										 |  |  | 			Layout.bottomMargin: bottomButtons.height / 2 | 
					
						
							| 
									
										
										
										
											2017-05-29 19:55:36 +02:00
										 |  |  | 			Layout.fillWidth: true | 
					
						
							|  |  |  | 			Layout.fillHeight: true | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			model : importModel | 
					
						
							|  |  |  | 			delegate : DownloadedDiveDelegate { | 
					
						
							| 
									
										
										
										
											2017-05-29 20:36:00 +02:00
										 |  |  | 				id: delegate | 
					
						
							| 
									
										
										
										
											2017-06-25 16:12:07 -07:00
										 |  |  | 				datetime: model.datetime ? model.datetime : "" | 
					
						
							|  |  |  | 				duration: model.duration ? model.duration : "" | 
					
						
							|  |  |  | 				depth: model.depth ? model.depth : "" | 
					
						
							|  |  |  | 				selected: model.selected ? model.selected : false | 
					
						
							| 
									
										
										
										
											2017-05-29 20:36:00 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 				onClicked : { | 
					
						
							| 
									
										
										
										
											2019-10-30 09:16:58 +01:00
										 |  |  | 					manager.appendTextToLog("Selecting index" + index); | 
					
						
							| 
									
										
										
										
											2017-05-29 20:36:00 +02:00
										 |  |  | 					importModel.selectRow(index) | 
					
						
							|  |  |  | 				} | 
					
						
							| 
									
										
										
										
											2016-02-02 21:48:43 +02:00
										 |  |  | 			} | 
					
						
							| 
									
										
										
										
											2017-05-12 17:55:19 +02:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2020-05-18 07:20:01 -07:00
										 |  |  | 		TemplateLabel { | 
					
						
							| 
									
										
										
										
											2019-10-21 17:16:49 -04:00
										 |  |  | 			text: qsTr("Please wait while we record these dives...") | 
					
						
							|  |  |  | 			Layout.fillWidth: true | 
					
						
							|  |  |  | 			visible: acceptButton.busy | 
					
						
							|  |  |  | 			leftPadding: Kirigami.Units.gridUnit * 3 // trust me - that looks better
 | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2016-02-02 21:48:43 +02:00
										 |  |  | 		RowLayout { | 
					
						
							| 
									
										
										
										
											2017-10-27 14:29:23 +02:00
										 |  |  | 			id: bottomButtons | 
					
						
							| 
									
										
										
										
											2020-05-18 07:20:01 -07:00
										 |  |  | 			TemplateLabel { | 
					
						
							| 
									
										
										
										
											2017-06-25 16:12:45 -07:00
										 |  |  | 				text: ""  // Spacer on the left for hamburger menu
 | 
					
						
							| 
									
										
										
										
											2019-09-21 16:30:12 -07:00
										 |  |  | 				width: Kirigami.Units.gridUnit * 2.5 | 
					
						
							| 
									
										
										
										
											2017-06-25 16:12:45 -07:00
										 |  |  | 			} | 
					
						
							| 
									
										
										
										
											2019-02-11 17:09:51 +01:00
										 |  |  | 			TemplateButton { | 
					
						
							| 
									
										
										
										
											2017-05-28 03:22:46 -07:00
										 |  |  | 				id: acceptButton | 
					
						
							| 
									
										
										
										
											2019-10-21 17:16:49 -04:00
										 |  |  | 				property bool busy: false | 
					
						
							| 
									
										
										
										
											2017-07-09 16:07:03 -07:00
										 |  |  | 				enabled: divesDownloaded | 
					
						
							| 
									
										
										
										
											2016-05-03 21:24:00 +02:00
										 |  |  | 				text: qsTr("Accept") | 
					
						
							| 
									
										
										
										
											2018-09-26 14:57:12 +02:00
										 |  |  | 				bottomPadding: Kirigami.Units.gridUnit / 2 | 
					
						
							| 
									
										
										
										
											2016-02-02 21:48:43 +02:00
										 |  |  | 				onClicked: { | 
					
						
							| 
									
										
										
										
											2019-10-29 19:19:31 +01:00
										 |  |  | 					manager.appendTextToLog("Save downloaded dives that were selected") | 
					
						
							| 
									
										
										
										
											2019-10-21 17:16:49 -04:00
										 |  |  | 					busy = true | 
					
						
							| 
									
										
										
										
											2019-11-03 06:38:19 -08:00
										 |  |  | 					rootItem.showBusy("Save selected dives") | 
					
						
							| 
									
										
										
										
											2019-10-29 19:19:31 +01:00
										 |  |  | 					manager.appendTextToLog("Record dives") | 
					
						
							| 
									
										
										
										
											2017-05-28 11:48:30 -07:00
										 |  |  | 					importModel.recordDives() | 
					
						
							| 
									
										
										
										
											2020-01-02 16:38:04 +01:00
										 |  |  | 					// it's important to save the changes because the app could get killed once
 | 
					
						
							|  |  |  | 					// it's in the background - and the freshly downloaded dives would get lost
 | 
					
						
							| 
									
										
										
										
											2020-04-03 15:23:20 -07:00
										 |  |  | 					manager.changesNeedSaving() | 
					
						
							| 
									
										
										
										
											2019-10-25 19:59:06 -04:00
										 |  |  | 					pageStack.pop() | 
					
						
							| 
									
										
										
										
											2019-10-29 19:19:31 +01:00
										 |  |  | 					showDiveList() | 
					
						
							| 
									
										
										
										
											2017-12-13 14:39:10 +01:00
										 |  |  | 					download.text = qsTr("Download") | 
					
						
							| 
									
										
										
										
											2019-10-21 17:16:49 -04:00
										 |  |  | 					busy = false | 
					
						
							|  |  |  | 					rootItem.hideBusy() | 
					
						
							| 
									
										
										
										
											2017-12-13 15:30:51 +01:00
										 |  |  | 					divesDownloaded = false | 
					
						
							| 
									
										
										
										
											2015-07-23 14:46:02 +03:00
										 |  |  | 				} | 
					
						
							|  |  |  | 			} | 
					
						
							| 
									
										
										
										
											2020-05-18 07:20:01 -07:00
										 |  |  | 			TemplateLabel { | 
					
						
							| 
									
										
										
										
											2016-02-02 21:48:43 +02:00
										 |  |  | 				text: ""  // Spacer between 2 button groups
 | 
					
						
							|  |  |  | 				Layout.fillWidth: true | 
					
						
							|  |  |  | 			} | 
					
						
							| 
									
										
										
										
											2019-02-11 17:09:51 +01:00
										 |  |  | 			TemplateButton { | 
					
						
							| 
									
										
										
										
											2017-07-08 15:16:42 +02:00
										 |  |  | 				id: select | 
					
						
							| 
									
										
										
										
											2017-07-09 16:07:03 -07:00
										 |  |  | 				enabled: divesDownloaded | 
					
						
							| 
									
										
										
										
											2016-05-03 21:24:00 +02:00
										 |  |  | 				text: qsTr("Select All") | 
					
						
							| 
									
										
										
										
											2018-09-26 14:57:12 +02:00
										 |  |  | 				bottomPadding: Kirigami.Units.gridUnit / 2 | 
					
						
							| 
									
										
										
										
											2017-05-29 20:36:00 +02:00
										 |  |  | 				onClicked : { | 
					
						
							|  |  |  | 					importModel.selectAll() | 
					
						
							|  |  |  | 				} | 
					
						
							| 
									
										
										
										
											2016-02-02 21:48:43 +02:00
										 |  |  | 			} | 
					
						
							| 
									
										
										
										
											2019-02-11 17:09:51 +01:00
										 |  |  | 			TemplateButton { | 
					
						
							| 
									
										
										
										
											2017-07-08 15:16:42 +02:00
										 |  |  | 				id: unselect | 
					
						
							| 
									
										
										
										
											2017-07-09 16:07:03 -07:00
										 |  |  | 				enabled: divesDownloaded | 
					
						
							| 
									
										
										
										
											2016-05-03 21:24:00 +02:00
										 |  |  | 				text: qsTr("Unselect All") | 
					
						
							| 
									
										
										
										
											2018-09-26 14:57:12 +02:00
										 |  |  | 				bottomPadding: Kirigami.Units.gridUnit / 2 | 
					
						
							| 
									
										
										
										
											2017-05-29 20:36:00 +02:00
										 |  |  | 				onClicked : { | 
					
						
							|  |  |  | 					importModel.selectNone() | 
					
						
							|  |  |  | 				} | 
					
						
							| 
									
										
										
										
											2016-02-02 21:48:43 +02:00
										 |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2018-06-04 18:37:43 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		onVisibleChanged: { | 
					
						
							| 
									
										
										
										
											2020-03-09 14:41:55 -07:00
										 |  |  | 			if (!setupUSB) { | 
					
						
							|  |  |  | 				// if we aren't called with a known USB connection, check if we can find
 | 
					
						
							|  |  |  | 				// a known BT/BLE device
 | 
					
						
							|  |  |  | 				manager.appendTextToLog("download page -- looking for known BT/BLE device") | 
					
						
							|  |  |  | 				comboVendor.currentIndex = comboProduct.currentIndex = comboConnection.currentIndex = -1 | 
					
						
							|  |  |  | 				dc1.enabled = dc2.enabled = dc3.enabled = dc4.enabled = true | 
					
						
							|  |  |  | 				if (visible) { | 
					
						
							| 
									
										
										
										
											2020-03-15 11:45:12 -07:00
										 |  |  | 					// we started the BT/BLE scan when Subsurface-mobile started, let's see if
 | 
					
						
							|  |  |  | 					// that found something
 | 
					
						
							| 
									
										
										
										
											2020-03-09 14:41:55 -07:00
										 |  |  | 					comboVendor.currentIndex = manager.getDetectedVendorIndex() | 
					
						
							|  |  |  | 					comboProduct.currentIndex = manager.getDetectedProductIndex(comboVendor.currentText) | 
					
						
							|  |  |  | 					comboConnection.currentIndex = manager.getMatchingAddress(comboVendor.currentText, comboProduct.currentText) | 
					
						
							| 
									
										
										
										
											2020-03-15 11:45:12 -07:00
										 |  |  | 					// also check if there are USB devices (this only has an effect on Android)
 | 
					
						
							|  |  |  | 					manager.usbRescan() | 
					
						
							| 
									
										
										
										
											2020-03-09 14:41:55 -07:00
										 |  |  | 				} | 
					
						
							| 
									
										
										
										
											2018-06-04 18:37:43 +02:00
										 |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2015-07-23 14:46:02 +03:00
										 |  |  | 	} | 
					
						
							|  |  |  | } |