mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-30 22:20:21 +00:00
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>
This commit is contained in:
parent
a4f3580e10
commit
ca939300e2
1 changed files with 2 additions and 3 deletions
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue