From ca939300e203c7cad5763e5d58de40e9afde063a Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Tue, 13 Aug 2019 21:05:55 +0200 Subject: 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 --- qt-models/divelistmodel.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'qt-models') 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(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; -- cgit v1.2.3-70-g09d2