diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2019-08-14 23:53:28 +0200 |
---|---|---|
committer | bstoeger <32835590+bstoeger@users.noreply.github.com> | 2019-09-14 13:20:59 +0200 |
commit | 1b9581369af95bdf366f08c0d00d24c315d339bb (patch) | |
tree | a7c38c8993f14acc8eac4d8ba8a6f8d49e0975d8 /qt-models/divelistmodel.cpp | |
parent | b7cddcc737886ee3e99cee30a78423570de15f00 (diff) | |
download | subsurface-1b9581369af95bdf366f08c0d00d24c315d339bb.tar.gz |
Mobile: move tripId from DiveObjectHelper to DiveListModel
The canonical way of displaying lists in Qt is via models.
Thus, return the tripId directly from the DiveListModel instead
of going indirectly via a DiveObjectHelper. In the future, this
will allow us to make the DiveObjectHelper value-based, as it
is not generated numerous times for every list item.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'qt-models/divelistmodel.cpp')
-rw-r--r-- | qt-models/divelistmodel.cpp | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/qt-models/divelistmodel.cpp b/qt-models/divelistmodel.cpp index cad745dd3..caa31dcae 100644 --- a/qt-models/divelistmodel.cpp +++ b/qt-models/divelistmodel.cpp @@ -240,9 +240,11 @@ QVariant DiveListModel::data(const QModelIndex &index, int role) const return QVariant(); DiveObjectHelper *curr_dive = m_dives[index.row()]; + const dive *d = curr_dive->getDive(); switch(role) { case DiveRole: return QVariant::fromValue<QObject*>(curr_dive); case DiveDateRole: return (qlonglong)curr_dive->timestamp(); + case TripIdRole: return d->divetrip ? QString::number((quint64)d->divetrip, 16) : QString(); } return QVariant(); @@ -253,6 +255,7 @@ QHash<int, QByteArray> DiveListModel::roleNames() const QHash<int, QByteArray> roles; roles[DiveRole] = "dive"; roles[DiveDateRole] = "date"; + roles[TripIdRole] = "tripId"; return roles; } |