summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2020-02-08 12:22:52 +0100
committerGravatar Dirk Hohndel <dirk@hohndel.org>2020-02-08 10:29:36 -0800
commita93c303b8b8a426e5236825c7be9c5a42c597afd (patch)
tree1dbf9d0152c14434ec468704d63b2928a021f173
parent1809dbd00a4d17bf65c60014801b893e8ebe3e3b (diff)
downloadsubsurface-a93c303b8b8a426e5236825c7be9c5a42c597afd.tar.gz
mobile/summary: add section headers
Add section headers to the dive summaries on mobile by adding a section-property. Of course, this will not work on desktop. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r--mobile-widgets/qml/DiveSummary.qml17
-rw-r--r--qt-models/divesummarymodel.cpp11
-rw-r--r--qt-models/divesummarymodel.h1
3 files changed, 28 insertions, 1 deletions
diff --git a/mobile-widgets/qml/DiveSummary.qml b/mobile-widgets/qml/DiveSummary.qml
index 8f592ba4d..07939b48f 100644
--- a/mobile-widgets/qml/DiveSummary.qml
+++ b/mobile-widgets/qml/DiveSummary.qml
@@ -123,6 +123,7 @@ Kirigami.ScrollablePage {
id: headerLabel
verticalAlignment: Qt.AlignVCenter
colorBackground: parent.color
+ leftPadding: Kirigami.Units.largeSpacing
text: header !== undefined ? header : ""
font.bold: true
}
@@ -150,6 +151,20 @@ Kirigami.ScrollablePage {
}
}
+ Component {
+ id: sectionDelegate
+ Rectangle {
+ width: headerColumnWidth * 4 - Kirigami.Units.gridUnit * 2
+ height: headerLabel.height + Kirigami.Units.largeSpacing
+ TemplateLabel {
+ id: headerLabel
+ verticalAlignment: Qt.AlignVCenter
+ colorBackground: parent.color
+ text: section
+ font.bold: true
+ }
+ }
+ }
ListView {
id: resultsTable
model: summaryModel
@@ -157,6 +172,8 @@ Kirigami.ScrollablePage {
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())
}
diff --git a/qt-models/divesummarymodel.cpp b/qt-models/divesummarymodel.cpp
index f7110fbf4..739463246 100644
--- a/qt-models/divesummarymodel.cpp
+++ b/qt-models/divesummarymodel.cpp
@@ -20,7 +20,8 @@ QHash<int, QByteArray> DiveSummaryModel::roleNames() const
{
return { { HEADER_ROLE, "header" },
{ COLUMN0_ROLE, "col0" },
- { COLUMN1_ROLE, "col1" } };
+ { COLUMN1_ROLE, "col1" },
+ { SECTION_ROLE, "section" } };
}
QVariant DiveSummaryModel::dataDisplay(int row, int col) const
@@ -61,6 +62,14 @@ QVariant DiveSummaryModel::data(const QModelIndex &index, int role) const
return dataDisplay(row, 0);
case COLUMN1_ROLE:
return dataDisplay(row, 1);
+ case SECTION_ROLE:
+ switch (row) {
+ case DIVES ... PLANS: return tr("Number of dives");
+ case TIME ... TIME_AVG: return tr("Time");
+ case DEPTH_MAX ... DEPTH_AVG: return tr("Depth");
+ case SAC_MIN ... SAC_AVG: return tr("SAC");
+ default: return QVariant();
+ }
}
// The unsupported case
diff --git a/qt-models/divesummarymodel.h b/qt-models/divesummarymodel.h
index 13d37ba17..1e28f26b0 100644
--- a/qt-models/divesummarymodel.h
+++ b/qt-models/divesummarymodel.h
@@ -32,6 +32,7 @@ public:
HEADER_ROLE = Qt::UserRole + 1,
COLUMN0_ROLE,
COLUMN1_ROLE,
+ SECTION_ROLE,
};
struct Result {