diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2019-08-13 21:05:55 +0200 |
---|---|---|
committer | bstoeger <32835590+bstoeger@users.noreply.github.com> | 2019-09-14 13:20:59 +0200 |
commit | ca939300e203c7cad5763e5d58de40e9afde063a (patch) | |
tree | 99b9c66e82d63d801bf235612e0c2b4dd05a58c2 /qt-models | |
parent | a4f3580e10388a1aecfd10a3a70eaf10efe06640 (diff) | |
download | subsurface-ca939300e203c7cad5763e5d58de40e9afde063a.tar.gz |
Mobile: create DiveObjectHelper only when needed
In DiveListModel::data() a DiveObjectHelper was created for any
data-access. Create it only when a DiveObjectHelper is actually
returned.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'qt-models')
-rw-r--r-- | qt-models/divelistmodel.cpp | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/qt-models/divelistmodel.cpp b/qt-models/divelistmodel.cpp index 0fe17627e..e24ba08e8 100644 --- a/qt-models/divelistmodel.cpp +++ b/qt-models/divelistmodel.cpp @@ -197,12 +197,11 @@ QVariant DiveListModel::data(const QModelIndex &index, int role) const if(index.row() < 0 || index.row() >= dive_table.nr) return QVariant(); - DiveObjectHelper curr_dive(dive_table.dives[index.row()]); - const dive *d = curr_dive.getDive(); + dive *d = dive_table.dives[index.row()]; if (!d) return QVariant(); switch(role) { - case DiveRole: return QVariant::fromValue<DiveObjectHelper>(curr_dive); + case DiveRole: return QVariant::fromValue(DiveObjectHelper(d)); case DiveDateRole: return (qlonglong)d->when; case TripIdRole: return d->divetrip ? QString::number((quint64)d->divetrip, 16) : QString(); case TripNrDivesRole: return d->divetrip ? d->divetrip->dives.nr : 0; |