mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Mobile: move tripId from DiveObjectHelper to DiveListModel
The canonical way of displaying lists in Qt is via models. Thus, return the tripId directly from the DiveListModel instead of going indirectly via a DiveObjectHelper. In the future, this will allow us to make the DiveObjectHelper value-based, as it is not generated numerous times for every list item. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
b7cddcc737
commit
1b9581369a
5 changed files with 8 additions and 11 deletions
|
@ -240,9 +240,11 @@ QVariant DiveListModel::data(const QModelIndex &index, int role) const
|
|||
return QVariant();
|
||||
|
||||
DiveObjectHelper *curr_dive = m_dives[index.row()];
|
||||
const dive *d = curr_dive->getDive();
|
||||
switch(role) {
|
||||
case DiveRole: return QVariant::fromValue<QObject*>(curr_dive);
|
||||
case DiveDateRole: return (qlonglong)curr_dive->timestamp();
|
||||
case TripIdRole: return d->divetrip ? QString::number((quint64)d->divetrip, 16) : QString();
|
||||
}
|
||||
return QVariant();
|
||||
|
||||
|
@ -253,6 +255,7 @@ QHash<int, QByteArray> DiveListModel::roleNames() const
|
|||
QHash<int, QByteArray> roles;
|
||||
roles[DiveRole] = "dive";
|
||||
roles[DiveDateRole] = "date";
|
||||
roles[TripIdRole] = "tripId";
|
||||
return roles;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue