mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
mobile/summary: implement frontend code for the new summary model
Implements the ListView and its delegate to use the dynamic data provided by the DiveSummaryModel Signed-off-by: Dirk Hohndel <dirk@hohndel.org> Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
1a85b0e941
commit
a5823a5b0d
1 changed files with 78 additions and 146 deletions
|
@ -9,18 +9,26 @@ import org.kde.kirigami 2.4 as Kirigami
|
||||||
|
|
||||||
Kirigami.ScrollablePage {
|
Kirigami.ScrollablePage {
|
||||||
id: summary
|
id: summary
|
||||||
|
DiveSummaryModel { id: summaryModel }
|
||||||
property string firstDive: ""
|
property string firstDive: ""
|
||||||
property string lastDive: ""
|
property string lastDive: ""
|
||||||
|
property int headerColumnWidth: Math.floor(width / 4)
|
||||||
|
|
||||||
background: Rectangle { color: subsurfaceTheme.backgroundColor }
|
background: Rectangle { color: subsurfaceTheme.backgroundColor }
|
||||||
title: qsTr("Dive summary")
|
title: qsTr("Dive summary")
|
||||||
|
|
||||||
onVisibleChanged: {
|
function reload() {
|
||||||
if (visible) {
|
summaryModel.setNumData(2)
|
||||||
Backend.summaryCalculation(selectionPrimary.currentIndex, selectionSecondary.currentIndex)
|
summaryModel.calc(0, selectionPrimary.currentIndex)
|
||||||
|
summaryModel.calc(1, selectionSecondary.currentIndex)
|
||||||
firstDive = Backend.firstDiveDate()
|
firstDive = Backend.firstDiveDate()
|
||||||
lastDive = Backend.lastDiveDate()
|
lastDive = Backend.lastDiveDate()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onVisibleChanged: {
|
||||||
|
if (visible) {
|
||||||
|
reload()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Connections {
|
Connections {
|
||||||
target: Backend
|
target: Backend
|
||||||
|
@ -57,15 +65,25 @@ Kirigami.ScrollablePage {
|
||||||
}
|
}
|
||||||
|
|
||||||
TemplateLabel {
|
TemplateLabel {
|
||||||
text: qsTr("oldest/newest dive")
|
text: qsTr("last dive:")
|
||||||
font.bold: true
|
font.bold: true
|
||||||
|
width: headerColumnWidth
|
||||||
}
|
}
|
||||||
TemplateLabel {
|
TemplateLabel {
|
||||||
text: summary.firstDive
|
Layout.alignment: Qt.AlignCenter
|
||||||
}
|
|
||||||
TemplateLabel {
|
|
||||||
text: summary.lastDive
|
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 {
|
TemplateLabel {
|
||||||
Layout.columnSpan: 3
|
Layout.columnSpan: 3
|
||||||
|
@ -73,6 +91,7 @@ Kirigami.ScrollablePage {
|
||||||
|
|
||||||
TemplateLabel {
|
TemplateLabel {
|
||||||
text: ""
|
text: ""
|
||||||
|
width: headerColumnWidth
|
||||||
}
|
}
|
||||||
TemplateComboBox {
|
TemplateComboBox {
|
||||||
id: selectionPrimary
|
id: selectionPrimary
|
||||||
|
@ -80,7 +99,7 @@ Kirigami.ScrollablePage {
|
||||||
currentIndex: 0
|
currentIndex: 0
|
||||||
model: monthModel
|
model: monthModel
|
||||||
onActivated: {
|
onActivated: {
|
||||||
Backend.summaryCalculation(selectionPrimary.currentIndex, selectionSecondary.currentIndex)
|
summaryModel.calc(0, currentIndex)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
TemplateComboBox {
|
TemplateComboBox {
|
||||||
|
@ -89,149 +108,62 @@ Kirigami.ScrollablePage {
|
||||||
currentIndex: 3
|
currentIndex: 3
|
||||||
model: monthModel
|
model: monthModel
|
||||||
onActivated: {
|
onActivated: {
|
||||||
Backend.summaryCalculation(selectionPrimary.currentIndex, selectionSecondary.currentIndex)
|
summaryModel.calc(1, currentIndex)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
TemplateLabel {
|
|
||||||
text: qsTr("dives")
|
|
||||||
font.bold: true
|
|
||||||
}
|
|
||||||
TemplateLabel {
|
|
||||||
text: Backend.diveSummaryText[2]
|
|
||||||
}
|
|
||||||
TemplateLabel {
|
|
||||||
text: Backend.diveSummaryText[3]
|
|
||||||
}
|
|
||||||
TemplateLabel {
|
|
||||||
text: qsTr("- EANx")
|
|
||||||
font.bold: true
|
|
||||||
}
|
|
||||||
TemplateLabel {
|
|
||||||
text: Backend.diveSummaryText[4]
|
|
||||||
}
|
|
||||||
TemplateLabel {
|
|
||||||
text: Backend.diveSummaryText[5]
|
|
||||||
}
|
|
||||||
TemplateLabel {
|
|
||||||
text: qsTr("- depth > 39m")
|
|
||||||
font.bold: true
|
|
||||||
}
|
|
||||||
TemplateLabel {
|
|
||||||
text: Backend.diveSummaryText[6]
|
|
||||||
}
|
|
||||||
TemplateLabel {
|
|
||||||
text: Backend.diveSummaryText[7]
|
|
||||||
}
|
|
||||||
|
|
||||||
|
Component {
|
||||||
|
id: rowDelegate
|
||||||
|
Row {
|
||||||
|
height: headerLabel.height + Kirigami.Units.largeSpacing
|
||||||
|
Rectangle {
|
||||||
|
color: index & 1 ? subsurfaceTheme.backgroundColor : subsurfaceTheme.lightPrimaryColor
|
||||||
|
width: headerColumnWidth
|
||||||
|
height: headerLabel.height + Kirigami.Units.largeSpacing
|
||||||
TemplateLabel {
|
TemplateLabel {
|
||||||
|
id: headerLabel
|
||||||
|
verticalAlignment: Qt.AlignVCenter
|
||||||
|
colorBackground: parent.color
|
||||||
|
text: header !== undefined ? header : ""
|
||||||
|
font.bold: true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Rectangle {
|
||||||
|
color: index & 1 ? subsurfaceTheme.backgroundColor : subsurfaceTheme.lightPrimaryColor
|
||||||
|
width: headerColumnWidth * 1.5 - Kirigami.Units.gridUnit
|
||||||
|
height: headerLabel.height + Kirigami.Units.largeSpacing
|
||||||
|
TemplateLabel {
|
||||||
|
verticalAlignment: Qt.AlignVCenter
|
||||||
|
colorBackground: parent.color
|
||||||
|
text: col0 !== undefined ? col0 : ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Rectangle {
|
||||||
|
color: index & 1 ? subsurfaceTheme.backgroundColor : subsurfaceTheme.lightPrimaryColor
|
||||||
|
width: headerColumnWidth * 1.5 - Kirigami.Units.gridUnit
|
||||||
|
height: headerLabel.height + Kirigami.Units.largeSpacing
|
||||||
|
TemplateLabel {
|
||||||
|
verticalAlignment: Qt.AlignVCenter
|
||||||
|
colorBackground: parent.color
|
||||||
|
text: col1 !== undefined ? col1 : ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ListView {
|
||||||
|
id: resultsTable
|
||||||
|
model: summaryModel
|
||||||
Layout.columnSpan: 3
|
Layout.columnSpan: 3
|
||||||
|
width: summary.width
|
||||||
|
height: summaryModel.rowCount() * 2 * Kirigami.Units.gridUnit
|
||||||
|
delegate: rowDelegate
|
||||||
|
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())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TemplateLabel {
|
|
||||||
text: qsTr("dive time")
|
|
||||||
font.bold: true
|
|
||||||
}
|
|
||||||
TemplateLabel {
|
|
||||||
text: Backend.diveSummaryText[8]
|
|
||||||
}
|
|
||||||
TemplateLabel {
|
|
||||||
text: Backend.diveSummaryText[9]
|
|
||||||
}
|
|
||||||
TemplateLabel {
|
|
||||||
text: qsTr("max dive time")
|
|
||||||
font.bold: true
|
|
||||||
}
|
|
||||||
TemplateLabel {
|
|
||||||
text: Backend.diveSummaryText[10]
|
|
||||||
}
|
|
||||||
TemplateLabel {
|
|
||||||
text: Backend.diveSummaryText[11]
|
|
||||||
}
|
|
||||||
TemplateLabel {
|
|
||||||
text: qsTr("avg. dive time")
|
|
||||||
font.bold: true
|
|
||||||
}
|
|
||||||
TemplateLabel {
|
|
||||||
text: Backend.diveSummaryText[12]
|
|
||||||
}
|
|
||||||
TemplateLabel {
|
|
||||||
text: Backend.diveSummaryText[13]
|
|
||||||
}
|
|
||||||
|
|
||||||
TemplateLabel {
|
|
||||||
Layout.columnSpan: 3
|
|
||||||
}
|
|
||||||
|
|
||||||
TemplateLabel {
|
|
||||||
text: qsTr("max depth")
|
|
||||||
font.bold: true
|
|
||||||
}
|
|
||||||
TemplateLabel {
|
|
||||||
text: Backend.diveSummaryText[14]
|
|
||||||
}
|
|
||||||
TemplateLabel {
|
|
||||||
text: Backend.diveSummaryText[15]
|
|
||||||
}
|
|
||||||
TemplateLabel {
|
|
||||||
text: qsTr("avg. max depth")
|
|
||||||
font.bold: true
|
|
||||||
}
|
|
||||||
TemplateLabel {
|
|
||||||
text: Backend.diveSummaryText[16]
|
|
||||||
}
|
|
||||||
TemplateLabel {
|
|
||||||
text: Backend.diveSummaryText[17]
|
|
||||||
}
|
|
||||||
|
|
||||||
TemplateLabel {
|
|
||||||
Layout.columnSpan: 3
|
|
||||||
}
|
|
||||||
|
|
||||||
TemplateLabel {
|
|
||||||
text: qsTr("min. SAC")
|
|
||||||
font.bold: true
|
|
||||||
}
|
|
||||||
TemplateLabel {
|
|
||||||
text: Backend.diveSummaryText[18]
|
|
||||||
}
|
|
||||||
TemplateLabel {
|
|
||||||
text: Backend.diveSummaryText[19]
|
|
||||||
}
|
|
||||||
TemplateLabel {
|
|
||||||
text: qsTr("max. SAC")
|
|
||||||
font.bold: true
|
|
||||||
}
|
|
||||||
TemplateLabel {
|
|
||||||
text: Backend.diveSummaryText[20]
|
|
||||||
}
|
|
||||||
TemplateLabel {
|
|
||||||
text: Backend.diveSummaryText[21]
|
|
||||||
}
|
|
||||||
TemplateLabel {
|
|
||||||
text: qsTr("avg. SAC")
|
|
||||||
font.bold: true
|
|
||||||
}
|
|
||||||
TemplateLabel {
|
|
||||||
text: Backend.diveSummaryText[22]
|
|
||||||
}
|
|
||||||
TemplateLabel {
|
|
||||||
text: Backend.diveSummaryText[23]
|
|
||||||
}
|
|
||||||
|
|
||||||
TemplateLabel {
|
|
||||||
Layout.columnSpan: 3
|
|
||||||
}
|
|
||||||
|
|
||||||
TemplateLabel {
|
|
||||||
text: qsTr("dive plan(s)")
|
|
||||||
font.bold: true
|
|
||||||
}
|
|
||||||
TemplateLabel {
|
|
||||||
text: Backend.diveSummaryText[24]
|
|
||||||
}
|
|
||||||
TemplateLabel {
|
|
||||||
text: Backend.diveSummaryText[25]
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue