diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2019-08-15 00:30:56 +0200 |
---|---|---|
committer | bstoeger <32835590+bstoeger@users.noreply.github.com> | 2019-09-14 13:20:59 +0200 |
commit | a79c45e4010a18f8ffe0742ab844743eeeebab9e (patch) | |
tree | 6897b25f952ab17efba18113b0aca4539c1c71fd | |
parent | c4831d7ace59590e6cdf3c357eb140d4273a270c (diff) | |
download | subsurface-a79c45e4010a18f8ffe0742ab844743eeeebab9e.tar.gz |
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 <bstoeger@mail.tuwien.ac.at>
-rw-r--r-- | mobile-widgets/qml/DiveList.qml | 2 | ||||
-rw-r--r-- | qt-models/divelistmodel.cpp | 3 | ||||
-rw-r--r-- | qt-models/divelistmodel.h | 1 |
3 files changed, 5 insertions, 1 deletions
diff --git a/mobile-widgets/qml/DiveList.qml b/mobile-widgets/qml/DiveList.qml index 99a93be2a..6c3091883 100644 --- a/mobile-widgets/qml/DiveList.qml +++ b/mobile-widgets/qml/DiveList.qml @@ -178,7 +178,7 @@ Kirigami.ScrollablePage { } // let's try to show the depth / duration very compact Controls.Label { - text: dive.depth + ' / ' + dive.duration + text: depthDuration width: Math.max(Kirigami.Units.gridUnit * 3, paintedWidth) // helps vertical alignment throughout listview font.pointSize: subsurfaceTheme.smallPointSize color: innerListItem.checked ? subsurfaceTheme.darkerPrimaryTextColor : secondaryTextColor 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<int, QByteArray> 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(); |