From a79c45e4010a18f8ffe0742ab844743eeeebab9e Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Thu, 15 Aug 2019 00:30:56 +0200 Subject: Mobile: return depthDuration directly from DiveListModel We don't want to generate a DiveObjectHelper numerous times for every item in the dive list. Therefore, return this data directly from the model. In this case, don't remove from DiveObjectHelper, as these data might be used by grantlee templates. Signed-off-by: Berthold Stoeger --- qt-models/divelistmodel.cpp | 3 +++ qt-models/divelistmodel.h | 1 + 2 files changed, 4 insertions(+) (limited to 'qt-models') diff --git a/qt-models/divelistmodel.cpp b/qt-models/divelistmodel.cpp index 05cf987c9..9c67ced8d 100644 --- a/qt-models/divelistmodel.cpp +++ b/qt-models/divelistmodel.cpp @@ -257,6 +257,8 @@ QVariant DiveListModel::data(const QModelIndex &index, int role) const case IdRole: return d->id; case NumberRole: return d->number; case LocationRole: return get_dive_location(d); + case DepthDurationRole: return QStringLiteral("%1 / %2").arg(get_depth_string(d->dc.maxdepth.mm, true, true), + get_dive_duration_string(d->duration.seconds, gettextFromC::tr("h"), gettextFromC::tr("min"))); } return QVariant(); } @@ -272,6 +274,7 @@ QHash DiveListModel::roleNames() const roles[IdRole] = "id"; roles[NumberRole] = "number"; roles[LocationRole] = "location"; + roles[DepthDurationRole] = "depthDuration"; return roles; } diff --git a/qt-models/divelistmodel.h b/qt-models/divelistmodel.h index 9e706dd3d..adda8b127 100644 --- a/qt-models/divelistmodel.h +++ b/qt-models/divelistmodel.h @@ -44,6 +44,7 @@ public: IdRole, NumberRole, LocationRole, + DepthDurationRole, }; static DiveListModel *instance(); -- cgit v1.2.3-70-g09d2