2020-01-24 09:36:54 +00: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 22:29:26 +00:00
|
|
|
id: summary
|
2020-02-08 11:08:15 +00:00
|
|
|
DiveSummaryModel { id: summaryModel }
|
2020-02-06 22:29:26 +00:00
|
|
|
property string firstDive: ""
|
|
|
|
property string lastDive: ""
|
2020-02-07 22:55:23 +00:00
|
|
|
property int headerColumnWidth: Math.floor(width / 3)
|
2020-02-06 22:29:26 +00:00
|
|
|
|
2020-01-24 09:36:54 +00:00
|
|
|
background: Rectangle { color: subsurfaceTheme.backgroundColor }
|
|
|
|
title: qsTr("Dive summary")
|
|
|
|
|
2020-02-08 11:08:15 +00: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 09:36:54 +00:00
|
|
|
onVisibleChanged: {
|
2020-02-05 07:29:05 +00:00
|
|
|
if (visible) {
|
2020-02-08 11:08:15 +00:00
|
|
|
reload()
|
2020-02-05 07:29:05 +00:00
|
|
|
}
|
2020-01-24 09:36:54 +00:00
|
|
|
}
|
2020-01-30 08:42:55 +00:00
|
|
|
Connections {
|
|
|
|
target: Backend
|
|
|
|
onLengthChanged: {
|
2020-02-08 10:39:49 +00:00
|
|
|
reload()
|
2020-01-30 08:42:55 +00:00
|
|
|
}
|
|
|
|
onVolumeChanged: {
|
2020-02-08 10:39:49 +00:00
|
|
|
reload()
|
2020-01-30 08:42:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-01-24 09:36:54 +00:00
|
|
|
GridLayout {
|
|
|
|
columns: 3
|
|
|
|
width: parent.width
|
|
|
|
columnSpacing: Kirigami.Units.smallSpacing
|
|
|
|
rowSpacing: Kirigami.Units.smallSpacing
|
|
|
|
|
2020-01-29 10:14:50 +00:00
|
|
|
ListModel {
|
|
|
|
id: monthModel
|
2020-02-07 23:49:31 +00: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 10:14:50 +00:00
|
|
|
}
|
|
|
|
|
2020-01-24 09:36:54 +00:00
|
|
|
TemplateLabel {
|
2020-02-08 11:08:15 +00:00
|
|
|
text: qsTr("last dive:")
|
2020-01-24 09:36:54 +00:00
|
|
|
font.bold: true
|
2020-02-08 11:08:15 +00:00
|
|
|
width: headerColumnWidth
|
2020-01-24 09:36:54 +00:00
|
|
|
}
|
|
|
|
TemplateLabel {
|
2020-02-08 11:08:15 +00:00
|
|
|
Layout.alignment: Qt.AlignCenter
|
|
|
|
text: summary.lastDive
|
2020-01-24 09:36:54 +00:00
|
|
|
}
|
2020-02-08 11:08:15 +00:00
|
|
|
TemplateLabel { /* just filling the third column with nothing */ }
|
2020-01-24 09:36:54 +00:00
|
|
|
TemplateLabel {
|
2020-02-08 11:08:15 +00:00
|
|
|
text: qsTr("first dive:")
|
|
|
|
font.bold: true
|
|
|
|
width: headerColumnWidth
|
2020-01-24 09:36:54 +00:00
|
|
|
}
|
2020-02-08 11:08:15 +00:00
|
|
|
TemplateLabel {
|
|
|
|
Layout.alignment: Qt.AlignCenter
|
|
|
|
text: summary.firstDive
|
|
|
|
}
|
|
|
|
TemplateLabel { /* just filling the third column with nothing */ }
|
2020-01-24 09:36:54 +00:00
|
|
|
|
|
|
|
TemplateLabel {
|
|
|
|
Layout.columnSpan: 3
|
|
|
|
}
|
|
|
|
|
2020-02-08 10:56:26 +00:00
|
|
|
TemplateButton {
|
|
|
|
/* Replace by signals from the core in due course. */
|
|
|
|
text: "Refresh"
|
2020-02-08 11:08:15 +00:00
|
|
|
width: headerColumnWidth
|
2020-02-08 10:56:26 +00:00
|
|
|
onClicked: reload()
|
2020-01-24 09:36:54 +00:00
|
|
|
}
|
|
|
|
TemplateComboBox {
|
|
|
|
id: selectionPrimary
|
|
|
|
editable: false
|
|
|
|
currentIndex: 0
|
|
|
|
model: monthModel
|
|
|
|
onActivated: {
|
2020-02-08 11:08:15 +00:00
|
|
|
summaryModel.calc(0, currentIndex)
|
2020-01-24 09:36:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
TemplateComboBox {
|
|
|
|
id: selectionSecondary
|
|
|
|
editable: false
|
|
|
|
currentIndex: 3
|
|
|
|
model: monthModel
|
|
|
|
onActivated: {
|
2020-02-08 11:08:15 +00:00
|
|
|
summaryModel.calc(1, currentIndex)
|
2020-01-24 09:36:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-02-08 11:08:15 +00:00
|
|
|
Component {
|
|
|
|
id: rowDelegate
|
|
|
|
Row {
|
|
|
|
height: headerLabel.height + Kirigami.Units.largeSpacing
|
2020-02-07 22:55:23 +00:00
|
|
|
Rectangle {
|
|
|
|
width: Kirigami.Units.gridUnit * 2
|
|
|
|
height: parent.height
|
|
|
|
color: "transparent"
|
|
|
|
}
|
2020-02-08 11:08:15 +00:00
|
|
|
Rectangle {
|
|
|
|
color: index & 1 ? subsurfaceTheme.backgroundColor : subsurfaceTheme.lightPrimaryColor
|
|
|
|
width: headerColumnWidth
|
|
|
|
height: headerLabel.height + Kirigami.Units.largeSpacing
|
2020-02-07 22:55:23 +00:00
|
|
|
Label {
|
2020-02-08 11:08:15 +00:00
|
|
|
id: headerLabel
|
2020-02-07 22:55:23 +00:00
|
|
|
color: subsurfaceTheme.textColor
|
2020-02-07 22:34:30 +00:00
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
2020-02-08 11:22:52 +00:00
|
|
|
leftPadding: Kirigami.Units.largeSpacing
|
2020-02-08 11:08:15 +00:00
|
|
|
text: header !== undefined ? header : ""
|
|
|
|
font.bold: true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Rectangle {
|
|
|
|
color: index & 1 ? subsurfaceTheme.backgroundColor : subsurfaceTheme.lightPrimaryColor
|
2020-02-07 22:55:23 +00:00
|
|
|
width: headerColumnWidth - 2 * Kirigami.Units.gridUnit
|
2020-02-08 11:08:15 +00:00
|
|
|
height: headerLabel.height + Kirigami.Units.largeSpacing
|
2020-02-07 22:55:23 +00:00
|
|
|
Label {
|
|
|
|
color: subsurfaceTheme.textColor
|
2020-02-07 22:34:30 +00:00
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
2020-02-08 11:08:15 +00:00
|
|
|
text: col0 !== undefined ? col0 : ""
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Rectangle {
|
|
|
|
color: index & 1 ? subsurfaceTheme.backgroundColor : subsurfaceTheme.lightPrimaryColor
|
2020-02-07 22:55:23 +00:00
|
|
|
width: headerColumnWidth - 2 * Kirigami.Units.gridUnit
|
2020-02-08 11:08:15 +00:00
|
|
|
height: headerLabel.height + Kirigami.Units.largeSpacing
|
2020-02-07 22:55:23 +00:00
|
|
|
Label {
|
|
|
|
color: subsurfaceTheme.textColor
|
2020-02-07 22:34:30 +00:00
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
2020-02-08 11:08:15 +00:00
|
|
|
text: col1 !== undefined ? col1 : ""
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-01-29 09:26:22 +00:00
|
|
|
}
|
2020-01-24 09:36:54 +00:00
|
|
|
|
2020-02-08 11:22:52 +00:00
|
|
|
Component {
|
|
|
|
id: sectionDelegate
|
|
|
|
Rectangle {
|
2020-02-07 22:55:23 +00:00
|
|
|
width: headerColumnWidth * 3 - Kirigami.Units.gridUnit * 2
|
|
|
|
height: sectionLabel.height + Kirigami.Units.largeSpacing
|
|
|
|
Label {
|
|
|
|
id: sectionLabel
|
2020-02-07 22:34:30 +00:00
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
2020-02-07 22:55:23 +00:00
|
|
|
leftPadding: Kirigami.Units.largeSpacing
|
|
|
|
color: subsurfaceTheme.textColor
|
2020-02-08 11:22:52 +00:00
|
|
|
text: section
|
|
|
|
font.bold: true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-02-08 11:08:15 +00:00
|
|
|
ListView {
|
|
|
|
id: resultsTable
|
|
|
|
model: summaryModel
|
2020-01-24 09:36:54 +00:00
|
|
|
Layout.columnSpan: 3
|
2020-02-08 11:08:15 +00:00
|
|
|
width: summary.width
|
|
|
|
height: summaryModel.rowCount() * 2 * Kirigami.Units.gridUnit
|
|
|
|
delegate: rowDelegate
|
2020-02-08 11:22:52 +00:00
|
|
|
section.property: "section"
|
|
|
|
section.delegate: sectionDelegate
|
2020-02-08 11:08:15 +00:00
|
|
|
Component.onCompleted: {
|
|
|
|
manager.appendTextToLog("SUMMARY: width: " + width + " height: " + height + " rows: " + model.rowCount())
|
|
|
|
}
|
|
|
|
onModelChanged: {
|
|
|
|
manager.appendTextToLog("SUMMARY model changed; now width: " + width + " height: " + height + " rows: " + model.rowCount())
|
|
|
|
}
|
2020-01-24 09:36:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|