From a93c303b8b8a426e5236825c7be9c5a42c597afd Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Sat, 8 Feb 2020 12:22:52 +0100 Subject: 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 Signed-off-by: Dirk Hohndel --- qt-models/divesummarymodel.cpp | 11 ++++++++++- qt-models/divesummarymodel.h | 1 + 2 files changed, 11 insertions(+), 1 deletion(-) (limited to 'qt-models') 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 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 { -- cgit v1.2.3-70-g09d2