Mobile: return dive-number 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:18:25 +02:00 committed by bstoeger
parent bf081866e9
commit 4b389e267d
3 changed files with 5 additions and 2 deletions

View file

@ -186,7 +186,7 @@ Kirigami.ScrollablePage {
} }
Controls.Label { Controls.Label {
id: numberText id: numberText
text: "#" + dive.number text: "#" + number
font.pointSize: subsurfaceTheme.smallPointSize font.pointSize: subsurfaceTheme.smallPointSize
color: innerListItem.checked ? subsurfaceTheme.darkerPrimaryTextColor : secondaryTextColor color: innerListItem.checked ? subsurfaceTheme.darkerPrimaryTextColor : secondaryTextColor
anchors { anchors {

View file

@ -255,6 +255,7 @@ QVariant DiveListModel::data(const QModelIndex &index, int role) const
localTime.time().toString(prefs.time_format)); localTime.time().toString(prefs.time_format));
} }
case IdRole: return d->id; case IdRole: return d->id;
case NumberRole: return d->number;
} }
return QVariant(); return QVariant();
} }
@ -268,6 +269,7 @@ QHash<int, QByteArray> DiveListModel::roleNames() const
roles[TripNrDivesRole] = "tripNrDives"; roles[TripNrDivesRole] = "tripNrDives";
roles[DateTimeRole] = "dateTime"; roles[DateTimeRole] = "dateTime";
roles[IdRole] = "id"; roles[IdRole] = "id";
roles[NumberRole] = "number";
return roles; return roles;
} }

View file

@ -41,7 +41,8 @@ public:
TripIdRole, TripIdRole,
TripNrDivesRole, TripNrDivesRole,
DateTimeRole, DateTimeRole,
IdRole IdRole,
NumberRole,
}; };
static DiveListModel *instance(); static DiveListModel *instance();