From 4b389e267dcb8fd5dbeb9403fb8faf0f74ec18ce Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Thu, 15 Aug 2019 00:18:25 +0200 Subject: Mobile: return dive-number directly from DiveListModel We don't want to generate a DiveObjectHelper numerous times for every item in the dive list. Therefore, return this datum directly from the model. In this case, don't remove from DiveObjectHelper, as this datum might be used by grantlee templates. Signed-off-by: Berthold Stoeger --- qt-models/divelistmodel.cpp | 2 ++ qt-models/divelistmodel.h | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) (limited to 'qt-models') diff --git a/qt-models/divelistmodel.cpp b/qt-models/divelistmodel.cpp index ba2a7a407..1911a8f8d 100644 --- a/qt-models/divelistmodel.cpp +++ b/qt-models/divelistmodel.cpp @@ -255,6 +255,7 @@ QVariant DiveListModel::data(const QModelIndex &index, int role) const localTime.time().toString(prefs.time_format)); } case IdRole: return d->id; + case NumberRole: return d->number; } return QVariant(); } @@ -268,6 +269,7 @@ QHash DiveListModel::roleNames() const roles[TripNrDivesRole] = "tripNrDives"; roles[DateTimeRole] = "dateTime"; roles[IdRole] = "id"; + roles[NumberRole] = "number"; return roles; } diff --git a/qt-models/divelistmodel.h b/qt-models/divelistmodel.h index 9b39e5513..5bec0de10 100644 --- a/qt-models/divelistmodel.h +++ b/qt-models/divelistmodel.h @@ -41,7 +41,8 @@ public: TripIdRole, TripNrDivesRole, DateTimeRole, - IdRole + IdRole, + NumberRole, }; static DiveListModel *instance(); -- cgit v1.2.3-70-g09d2