Mobile: return location directly from DiveListModel

We don't want to generate a DiveObjectHelper numerous times for
every item in the dive list. Therefore, return this datum directly
from the model. In this case, don't remove from DiveObjectHelper,
as this datum might be used by grantlee templates.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2019-08-15 00:23:25 +02:00 committed by bstoeger
parent 4b389e267d
commit c4831d7ace
3 changed files with 4 additions and 1 deletions

View file

@ -147,7 +147,7 @@ Kirigami.ScrollablePage {
anchors.left: leftBarDive.right
Controls.Label {
id: locationText
text: dive.location
text: location
font.weight: Font.Bold
font.pointSize: subsurfaceTheme.regularPointSize
elide: Text.ElideRight

View file

@ -256,6 +256,7 @@ 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);
}
return QVariant();
}
@ -270,6 +271,7 @@ QHash<int, QByteArray> DiveListModel::roleNames() const
roles[DateTimeRole] = "dateTime";
roles[IdRole] = "id";
roles[NumberRole] = "number";
roles[LocationRole] = "location";
return roles;
}

View file

@ -43,6 +43,7 @@ public:
DateTimeRole,
IdRole,
NumberRole,
LocationRole,
};
static DiveListModel *instance();