| 
									
										
										
										
											2020-01-24 10:36:54 +01:00
										 |  |  | // SPDX-License-Identifier: GPL-2.0
 | 
					
						
							|  |  |  | import QtQuick 2.12 | 
					
						
							|  |  |  | import QtQuick.Controls 2.12 | 
					
						
							|  |  |  | import QtQuick.Controls 1.4 | 
					
						
							|  |  |  | import QtQuick.Layouts 1.12 | 
					
						
							|  |  |  | import QtQuick.Dialogs 1.3 | 
					
						
							|  |  |  | import org.subsurfacedivelog.mobile 1.0 | 
					
						
							|  |  |  | import org.kde.kirigami 2.4 as Kirigami | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | Kirigami.ScrollablePage { | 
					
						
							| 
									
										
										
										
											2020-02-06 23:29:26 +01:00
										 |  |  | 	id: summary | 
					
						
							| 
									
										
										
										
											2020-02-08 12:08:15 +01:00
										 |  |  | 	DiveSummaryModel { id: summaryModel } | 
					
						
							| 
									
										
										
										
											2020-02-06 23:29:26 +01:00
										 |  |  | 	property string firstDive: "" | 
					
						
							|  |  |  | 	property string lastDive: "" | 
					
						
							| 
									
										
										
										
											2021-01-11 09:59:43 -08:00
										 |  |  | 	property int headerColumnWidth: Math.floor((width - Kirigami.Units.gridUnit) / 3) | 
					
						
							| 
									
										
										
										
											2020-02-06 23:29:26 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-01-24 10:36:54 +01:00
										 |  |  | 	background: Rectangle { color: subsurfaceTheme.backgroundColor } | 
					
						
							|  |  |  | 	title: qsTr("Dive summary") | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-02-08 12:08:15 +01:00
										 |  |  | 	function reload() { | 
					
						
							|  |  |  | 		summaryModel.setNumData(2) | 
					
						
							|  |  |  | 		summaryModel.calc(0, selectionPrimary.currentIndex) | 
					
						
							|  |  |  | 		summaryModel.calc(1, selectionSecondary.currentIndex) | 
					
						
							|  |  |  | 		firstDive = Backend.firstDiveDate() | 
					
						
							|  |  |  | 		lastDive = Backend.lastDiveDate() | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-01-24 10:36:54 +01:00
										 |  |  | 	onVisibleChanged: { | 
					
						
							| 
									
										
										
										
											2020-02-05 08:29:05 +01:00
										 |  |  | 		if (visible) { | 
					
						
							| 
									
										
										
										
											2020-02-08 12:08:15 +01:00
										 |  |  | 			reload() | 
					
						
							| 
									
										
										
										
											2020-02-05 08:29:05 +01:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2020-01-24 10:36:54 +01:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2020-01-30 09:42:55 +01:00
										 |  |  | 	Connections { | 
					
						
							|  |  |  | 		target: Backend | 
					
						
							| 
									
										
										
										
											2024-05-28 14:20:55 +12:00
										 |  |  | 		function onLengthChanged() { | 
					
						
							| 
									
										
										
										
											2020-02-08 11:39:49 +01:00
										 |  |  | 			reload() | 
					
						
							| 
									
										
										
										
											2020-01-30 09:42:55 +01:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2024-05-28 14:20:55 +12:00
										 |  |  | 		function onVolumeChanged() { | 
					
						
							| 
									
										
										
										
											2020-02-08 11:39:49 +01:00
										 |  |  | 			reload() | 
					
						
							| 
									
										
										
										
											2020-01-30 09:42:55 +01:00
										 |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-01-24 10:36:54 +01:00
										 |  |  | 	GridLayout { | 
					
						
							|  |  |  | 		columns: 3 | 
					
						
							|  |  |  | 		width: parent.width | 
					
						
							|  |  |  | 		columnSpacing: Kirigami.Units.smallSpacing | 
					
						
							|  |  |  | 		rowSpacing: Kirigami.Units.smallSpacing | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-01-29 11:14:50 +01:00
										 |  |  | 		ListModel { | 
					
						
							|  |  |  | 			id: monthModel | 
					
						
							| 
									
										
										
										
											2020-02-07 15:49:31 -08:00
										 |  |  | 			ListElement {text: qsTr("All")} | 
					
						
							|  |  |  | 			ListElement {text: qsTr("1 month")} | 
					
						
							|  |  |  | 			ListElement {text: qsTr("3 months")} | 
					
						
							|  |  |  | 			ListElement {text: qsTr("6 months")} | 
					
						
							|  |  |  | 			ListElement {text: qsTr("1 year")} | 
					
						
							| 
									
										
										
										
											2020-01-29 11:14:50 +01:00
										 |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-01-24 10:36:54 +01:00
										 |  |  | 		TemplateLabel { | 
					
						
							| 
									
										
										
										
											2020-02-08 12:08:15 +01:00
										 |  |  | 			text: qsTr("last dive:") | 
					
						
							| 
									
										
										
										
											2020-01-24 10:36:54 +01:00
										 |  |  | 			font.bold: true | 
					
						
							| 
									
										
										
										
											2020-02-08 12:08:15 +01:00
										 |  |  | 			width: headerColumnWidth | 
					
						
							| 
									
										
										
										
											2020-01-24 10:36:54 +01:00
										 |  |  | 		} | 
					
						
							|  |  |  | 		TemplateLabel { | 
					
						
							| 
									
										
										
										
											2020-02-08 12:08:15 +01:00
										 |  |  | 			Layout.alignment: Qt.AlignCenter | 
					
						
							|  |  |  | 			text: summary.lastDive | 
					
						
							| 
									
										
										
										
											2020-01-24 10:36:54 +01:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2020-02-08 12:08:15 +01:00
										 |  |  | 		TemplateLabel { /* just filling the third column with nothing */ } | 
					
						
							| 
									
										
										
										
											2020-01-24 10:36:54 +01:00
										 |  |  | 		TemplateLabel { | 
					
						
							| 
									
										
										
										
											2020-02-08 12:08:15 +01:00
										 |  |  | 			text: qsTr("first dive:") | 
					
						
							|  |  |  | 			font.bold: true | 
					
						
							|  |  |  | 			width: headerColumnWidth | 
					
						
							| 
									
										
										
										
											2020-01-24 10:36:54 +01:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2020-02-08 12:08:15 +01:00
										 |  |  | 		TemplateLabel { | 
					
						
							|  |  |  | 			Layout.alignment: Qt.AlignCenter | 
					
						
							|  |  |  | 			text: summary.firstDive | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		TemplateLabel { /* just filling the third column with nothing */ } | 
					
						
							| 
									
										
										
										
											2020-01-24 10:36:54 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		TemplateLabel { | 
					
						
							|  |  |  | 			Layout.columnSpan: 3 | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-02-08 11:56:26 +01:00
										 |  |  | 		TemplateButton { | 
					
						
							|  |  |  | 			/* Replace by signals from the core in due course. */ | 
					
						
							| 
									
										
										
										
											2020-02-09 21:15:55 -08:00
										 |  |  | 			text: qsTr("Refresh") | 
					
						
							| 
									
										
										
										
											2021-01-11 09:59:43 -08:00
										 |  |  | 			implicitWidth: headerColumnWidth - Kirigami.Units.largeSpacing | 
					
						
							| 
									
										
										
										
											2020-02-08 11:56:26 +01:00
										 |  |  | 			onClicked: reload() | 
					
						
							| 
									
										
										
										
											2020-01-24 10:36:54 +01:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2021-01-11 09:59:43 -08:00
										 |  |  | 		TemplateSlimComboBox { | 
					
						
							| 
									
										
										
										
											2020-01-24 10:36:54 +01:00
										 |  |  | 			id: selectionPrimary | 
					
						
							| 
									
										
										
										
											2021-01-11 09:59:43 -08:00
										 |  |  | 			Layout.maximumWidth: headerColumnWidth - Kirigami.Units.largeSpacing | 
					
						
							|  |  |  | 			Layout.preferredWidth: headerColumnWidth - Kirigami.Units.largeSpacing | 
					
						
							| 
									
										
										
										
											2020-01-24 10:36:54 +01:00
										 |  |  | 			currentIndex: 0 | 
					
						
							|  |  |  | 			model: monthModel | 
					
						
							| 
									
										
										
										
											2020-03-31 10:04:02 -07:00
										 |  |  | 			font.pointSize: subsurfaceTheme.smallPointSize | 
					
						
							| 
									
										
										
										
											2020-01-24 10:36:54 +01:00
										 |  |  | 			onActivated:  { | 
					
						
							| 
									
										
										
										
											2020-02-08 12:08:15 +01:00
										 |  |  | 				summaryModel.calc(0, currentIndex) | 
					
						
							| 
									
										
										
										
											2020-01-24 10:36:54 +01:00
										 |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2021-01-11 09:59:43 -08:00
										 |  |  | 		TemplateSlimComboBox { | 
					
						
							| 
									
										
										
										
											2020-01-24 10:36:54 +01:00
										 |  |  | 			id: selectionSecondary | 
					
						
							| 
									
										
										
										
											2021-01-11 09:59:43 -08:00
										 |  |  | 			Layout.maximumWidth: headerColumnWidth - Kirigami.Units.largeSpacing | 
					
						
							|  |  |  | 			Layout.preferredWidth: headerColumnWidth - Kirigami.Units.largeSpacing | 
					
						
							| 
									
										
										
										
											2020-01-24 10:36:54 +01:00
										 |  |  | 			currentIndex: 3 | 
					
						
							|  |  |  | 			model: monthModel | 
					
						
							| 
									
										
										
										
											2020-03-31 10:04:02 -07:00
										 |  |  | 			font.pointSize: subsurfaceTheme.smallPointSize | 
					
						
							| 
									
										
										
										
											2020-01-24 10:36:54 +01:00
										 |  |  | 			onActivated:  { | 
					
						
							| 
									
										
										
										
											2020-02-08 12:08:15 +01:00
										 |  |  | 				summaryModel.calc(1, currentIndex) | 
					
						
							| 
									
										
										
										
											2020-01-24 10:36:54 +01:00
										 |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-02-08 12:08:15 +01:00
										 |  |  | 		Component { | 
					
						
							|  |  |  | 			id: rowDelegate | 
					
						
							|  |  |  | 			Row { | 
					
						
							| 
									
										
										
										
											2021-01-11 09:59:43 -08:00
										 |  |  | 				Layout.leftMargin: 0 | 
					
						
							| 
									
										
										
										
											2020-02-08 12:08:15 +01:00
										 |  |  | 				height: headerLabel.height + Kirigami.Units.largeSpacing | 
					
						
							| 
									
										
										
										
											2020-02-07 14:55:23 -08:00
										 |  |  | 				Rectangle { | 
					
						
							| 
									
										
										
										
											2020-02-09 20:56:14 -08:00
										 |  |  | 					width: Kirigami.Units.gridUnit | 
					
						
							| 
									
										
										
										
											2020-02-07 14:55:23 -08:00
										 |  |  | 					height: parent.height | 
					
						
							|  |  |  | 					color: "transparent" | 
					
						
							|  |  |  | 				} | 
					
						
							| 
									
										
										
										
											2020-02-08 12:08:15 +01:00
										 |  |  | 				Rectangle { | 
					
						
							|  |  |  | 					color: index & 1 ? subsurfaceTheme.backgroundColor : subsurfaceTheme.lightPrimaryColor | 
					
						
							| 
									
										
										
										
											2020-02-09 20:56:14 -08:00
										 |  |  | 					width: headerColumnWidth + Kirigami.Units.gridUnit | 
					
						
							| 
									
										
										
										
											2020-02-08 12:08:15 +01:00
										 |  |  | 					height: headerLabel.height + Kirigami.Units.largeSpacing | 
					
						
							| 
									
										
										
										
											2020-02-07 14:55:23 -08:00
										 |  |  | 					Label { | 
					
						
							| 
									
										
										
										
											2020-02-08 12:08:15 +01:00
										 |  |  | 						id: headerLabel | 
					
						
							| 
									
										
										
										
											2020-02-07 14:55:23 -08:00
										 |  |  | 						color: subsurfaceTheme.textColor | 
					
						
							| 
									
										
										
										
											2020-02-07 14:34:30 -08:00
										 |  |  | 						anchors.verticalCenter: parent.verticalCenter | 
					
						
							| 
									
										
										
										
											2020-02-08 12:22:52 +01:00
										 |  |  | 						leftPadding: Kirigami.Units.largeSpacing | 
					
						
							| 
									
										
										
										
											2020-02-08 12:08:15 +01:00
										 |  |  | 						text: header !== undefined ? header : "" | 
					
						
							|  |  |  | 						font.bold: true | 
					
						
							|  |  |  | 					} | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 				Rectangle { | 
					
						
							|  |  |  | 					color: index & 1 ? subsurfaceTheme.backgroundColor : subsurfaceTheme.lightPrimaryColor | 
					
						
							| 
									
										
										
										
											2021-01-11 09:59:43 -08:00
										 |  |  | 					width: headerColumnWidth - 1.5 * Kirigami.Units.gridUnit | 
					
						
							| 
									
										
										
										
											2020-02-08 12:08:15 +01:00
										 |  |  | 					height: headerLabel.height + Kirigami.Units.largeSpacing | 
					
						
							| 
									
										
										
										
											2020-02-07 14:55:23 -08:00
										 |  |  | 					Label { | 
					
						
							|  |  |  | 						color: subsurfaceTheme.textColor | 
					
						
							| 
									
										
										
										
											2020-02-07 14:34:30 -08:00
										 |  |  | 						anchors.verticalCenter: parent.verticalCenter | 
					
						
							| 
									
										
										
										
											2020-02-08 12:08:15 +01:00
										 |  |  | 						text: col0 !== undefined ? col0 : "" | 
					
						
							|  |  |  | 					} | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 				Rectangle { | 
					
						
							|  |  |  | 					color: index & 1 ? subsurfaceTheme.backgroundColor : subsurfaceTheme.lightPrimaryColor | 
					
						
							| 
									
										
										
										
											2021-01-11 09:59:43 -08:00
										 |  |  | 					width: headerColumnWidth - 1.5 * Kirigami.Units.gridUnit | 
					
						
							| 
									
										
										
										
											2020-02-08 12:08:15 +01:00
										 |  |  | 					height: headerLabel.height + Kirigami.Units.largeSpacing | 
					
						
							| 
									
										
										
										
											2020-02-07 14:55:23 -08:00
										 |  |  | 					Label { | 
					
						
							|  |  |  | 						color: subsurfaceTheme.textColor | 
					
						
							| 
									
										
										
										
											2020-02-07 14:34:30 -08:00
										 |  |  | 						anchors.verticalCenter: parent.verticalCenter | 
					
						
							| 
									
										
										
										
											2020-02-08 12:08:15 +01:00
										 |  |  | 						text: col1 !== undefined ? col1 : "" | 
					
						
							|  |  |  | 					} | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 			} | 
					
						
							| 
									
										
										
										
											2020-01-29 11:26:22 +02:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2020-01-24 10:36:54 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-02-08 12:22:52 +01:00
										 |  |  | 		Component { | 
					
						
							|  |  |  | 			id: sectionDelegate | 
					
						
							| 
									
										
										
										
											2020-02-09 20:56:14 -08:00
										 |  |  | 			Column { | 
					
						
							|  |  |  | 				Rectangle { | 
					
						
							|  |  |  | 					width: headerColumnWidth * 3 - Kirigami.Units.gridUnit * 2 | 
					
						
							|  |  |  | 					height: Kirigami.Units.largeSpacing | 
					
						
							|  |  |  | 					color: subsurfaceTheme.backgroundColor | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 				Rectangle { | 
					
						
							|  |  |  | 					width: headerColumnWidth * 3 - Kirigami.Units.gridUnit * 2 | 
					
						
							|  |  |  | 					height: sectionLabel.height + Kirigami.Units.largeSpacing | 
					
						
							| 
									
										
										
										
											2020-12-19 14:21:57 -08:00
										 |  |  | 					color: subsurfaceTheme.backgroundColor | 
					
						
							| 
									
										
										
										
											2020-02-09 20:56:14 -08:00
										 |  |  | 					Label { | 
					
						
							|  |  |  | 						id: sectionLabel | 
					
						
							|  |  |  | 						anchors.verticalCenter: parent.verticalCenter | 
					
						
							|  |  |  | 						leftPadding: Kirigami.Units.largeSpacing | 
					
						
							|  |  |  | 						color: subsurfaceTheme.textColor | 
					
						
							|  |  |  | 						text: section | 
					
						
							|  |  |  | 						font.bold: true | 
					
						
							|  |  |  | 					} | 
					
						
							| 
									
										
										
										
											2020-02-08 12:22:52 +01:00
										 |  |  | 				} | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2020-02-08 12:08:15 +01:00
										 |  |  | 		ListView { | 
					
						
							|  |  |  | 			id: resultsTable | 
					
						
							|  |  |  | 			model: summaryModel | 
					
						
							| 
									
										
										
										
											2020-01-24 10:36:54 +01:00
										 |  |  | 			Layout.columnSpan: 3 | 
					
						
							| 
									
										
										
										
											2020-02-08 12:08:15 +01:00
										 |  |  | 			width: summary.width | 
					
						
							|  |  |  | 			height: summaryModel.rowCount() * 2 * Kirigami.Units.gridUnit | 
					
						
							|  |  |  | 			delegate: rowDelegate | 
					
						
							| 
									
										
										
										
											2020-02-08 12:22:52 +01:00
										 |  |  | 			section.property: "section" | 
					
						
							|  |  |  | 			section.delegate: sectionDelegate | 
					
						
							| 
									
										
										
										
											2020-01-24 10:36:54 +01:00
										 |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } |