blob: bf206cc3e2fea138eb5a637d58eeb88bfb526ce4 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
|
// 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 {
id: summary
DiveSummaryModel { id: summaryModel }
property string firstDive: ""
property string lastDive: ""
property int headerColumnWidth: Math.floor(width / 3)
background: Rectangle { color: subsurfaceTheme.backgroundColor }
title: qsTr("Dive summary")
function reload() {
summaryModel.setNumData(2)
summaryModel.calc(0, selectionPrimary.currentIndex)
summaryModel.calc(1, selectionSecondary.currentIndex)
firstDive = Backend.firstDiveDate()
lastDive = Backend.lastDiveDate()
}
onVisibleChanged: {
if (visible) {
reload()
}
}
Connections {
target: Backend
onLengthChanged: {
reload()
}
onVolumeChanged: {
reload()
}
}
GridLayout {
columns: 3
width: parent.width
columnSpacing: Kirigami.Units.smallSpacing
rowSpacing: Kirigami.Units.smallSpacing
ListModel {
id: monthModel
ListElement {text: qsTr("All")}
ListElement {text: qsTr("1 month")}
ListElement {text: qsTr("3 months")}
ListElement {text: qsTr("6 months")}
ListElement {text: qsTr("1 year")}
}
TemplateLabel {
text: qsTr("last dive:")
font.bold: true
width: headerColumnWidth
}
TemplateLabel {
Layout.alignment: Qt.AlignCenter
text: summary.lastDive
}
TemplateLabel { /* just filling the third column with nothing */ }
TemplateLabel {
text: qsTr("first dive:")
font.bold: true
width: headerColumnWidth
}
TemplateLabel {
Layout.alignment: Qt.AlignCenter
text: summary.firstDive
}
TemplateLabel { /* just filling the third column with nothing */ }
TemplateLabel {
Layout.columnSpan: 3
}
TemplateButton {
/* Replace by signals from the core in due course. */
text: "Refresh"
width: headerColumnWidth
onClicked: reload()
}
TemplateComboBox {
id: selectionPrimary
editable: false
currentIndex: 0
model: monthModel
onActivated: {
summaryModel.calc(0, currentIndex)
}
}
TemplateComboBox {
id: selectionSecondary
editable: false
currentIndex: 3
model: monthModel
onActivated: {
summaryModel.calc(1, currentIndex)
}
}
Component {
id: rowDelegate
Row {
height: headerLabel.height + Kirigami.Units.largeSpacing
Rectangle {
width: Kirigami.Units.gridUnit
height: parent.height
color: "transparent"
}
Rectangle {
color: index & 1 ? subsurfaceTheme.backgroundColor : subsurfaceTheme.lightPrimaryColor
width: headerColumnWidth + Kirigami.Units.gridUnit
height: headerLabel.height + Kirigami.Units.largeSpacing
Label {
id: headerLabel
color: subsurfaceTheme.textColor
anchors.verticalCenter: parent.verticalCenter
leftPadding: Kirigami.Units.largeSpacing
text: header !== undefined ? header : ""
font.bold: true
}
}
Rectangle {
color: index & 1 ? subsurfaceTheme.backgroundColor : subsurfaceTheme.lightPrimaryColor
width: headerColumnWidth - 2 * Kirigami.Units.gridUnit
height: headerLabel.height + Kirigami.Units.largeSpacing
Label {
color: subsurfaceTheme.textColor
anchors.verticalCenter: parent.verticalCenter
text: col0 !== undefined ? col0 : ""
}
}
Rectangle {
color: index & 1 ? subsurfaceTheme.backgroundColor : subsurfaceTheme.lightPrimaryColor
width: headerColumnWidth - 2 * Kirigami.Units.gridUnit
height: headerLabel.height + Kirigami.Units.largeSpacing
Label {
color: subsurfaceTheme.textColor
anchors.verticalCenter: parent.verticalCenter
text: col1 !== undefined ? col1 : ""
}
}
}
}
Component {
id: sectionDelegate
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
Label {
id: sectionLabel
anchors.verticalCenter: parent.verticalCenter
leftPadding: Kirigami.Units.largeSpacing
color: subsurfaceTheme.textColor
text: section
font.bold: true
}
}
}
}
ListView {
id: resultsTable
model: summaryModel
Layout.columnSpan: 3
width: summary.width
height: summaryModel.rowCount() * 2 * Kirigami.Units.gridUnit
delegate: rowDelegate
section.property: "section"
section.delegate: sectionDelegate
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())
}
}
}
}
|