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 anchors.left: leftBarDive.right
Controls.Label { Controls.Label {
id: locationText id: locationText
text: dive.location text: location
font.weight: Font.Bold font.weight: Font.Bold
font.pointSize: subsurfaceTheme.regularPointSize font.pointSize: subsurfaceTheme.regularPointSize
elide: Text.ElideRight elide: Text.ElideRight

View file

@ -256,6 +256,7 @@ QVariant DiveListModel::data(const QModelIndex &index, int role) const
} }
case IdRole: return d->id; case IdRole: return d->id;
case NumberRole: return d->number; case NumberRole: return d->number;
case LocationRole: return get_dive_location(d);
} }
return QVariant(); return QVariant();
} }
@ -270,6 +271,7 @@ QHash<int, QByteArray> DiveListModel::roleNames() const
roles[DateTimeRole] = "dateTime"; roles[DateTimeRole] = "dateTime";
roles[IdRole] = "id"; roles[IdRole] = "id";
roles[NumberRole] = "number"; roles[NumberRole] = "number";
roles[LocationRole] = "location";
return roles; return roles;
} }

View file

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