mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Cleanup: introduce DiveTripModelBase::IS_TRIP_ROLE
To test whether an entry is a trip, we passed a pointer to the trip through a QVariant and tested that for null-ity. Passing pointers through QVariants has given us myriads of problems in QML, therefore introduce a bool IS_TRIP_ROLE Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
a474264cc8
commit
e434b5aa40
4 changed files with 5 additions and 4 deletions
|
@ -348,8 +348,7 @@ void DiveListView::clearTripSelection()
|
||||||
|
|
||||||
// we want to make sure no trips are selected
|
// we want to make sure no trips are selected
|
||||||
Q_FOREACH (const QModelIndex &index, selectionModel()->selectedRows()) {
|
Q_FOREACH (const QModelIndex &index, selectionModel()->selectedRows()) {
|
||||||
dive_trip_t *trip = index.data(DiveTripModelBase::TRIP_ROLE).value<dive_trip *>();
|
if (!index.data(DiveTripModelBase::IS_TRIP_ROLE).toBool())
|
||||||
if (!trip)
|
|
||||||
continue;
|
continue;
|
||||||
selectionModel()->select(index, QItemSelectionModel::Deselect);
|
selectionModel()->select(index, QItemSelectionModel::Deselect);
|
||||||
}
|
}
|
||||||
|
|
|
@ -723,6 +723,8 @@ QVariant DiveTripModelTree::data(const QModelIndex &index, int role) const
|
||||||
return defaultModelFont();
|
return defaultModelFont();
|
||||||
|
|
||||||
dive_or_trip entry = tripOrDive(index);
|
dive_or_trip entry = tripOrDive(index);
|
||||||
|
if (role == IS_TRIP_ROLE)
|
||||||
|
return !!entry.trip;
|
||||||
if (entry.trip)
|
if (entry.trip)
|
||||||
return tripData(entry.trip, index.column(), role);
|
return tripData(entry.trip, index.column(), role);
|
||||||
else if (entry.dive)
|
else if (entry.dive)
|
||||||
|
|
|
@ -49,6 +49,7 @@ public:
|
||||||
|
|
||||||
enum ExtraRoles {
|
enum ExtraRoles {
|
||||||
STAR_ROLE = Qt::UserRole + 1,
|
STAR_ROLE = Qt::UserRole + 1,
|
||||||
|
IS_TRIP_ROLE,
|
||||||
DIVE_ROLE,
|
DIVE_ROLE,
|
||||||
TRIP_ROLE,
|
TRIP_ROLE,
|
||||||
DIVE_IDX,
|
DIVE_IDX,
|
||||||
|
|
|
@ -228,8 +228,7 @@ void MultiFilterSortModel::myInvalidate()
|
||||||
for (int i = 0; i < m->rowCount(QModelIndex()); ++i) {
|
for (int i = 0; i < m->rowCount(QModelIndex()); ++i) {
|
||||||
QModelIndex idx = m->index(i, 0, QModelIndex());
|
QModelIndex idx = m->index(i, 0, QModelIndex());
|
||||||
|
|
||||||
dive_trip *trip = m->data(idx, DiveTripModelBase::TRIP_ROLE).value<dive_trip *>();
|
if (m->data(idx, DiveTripModelBase::IS_TRIP_ROLE).toBool()) {
|
||||||
if (trip) {
|
|
||||||
// This is a trip -> loop over all dives and see if any is selected
|
// This is a trip -> loop over all dives and see if any is selected
|
||||||
|
|
||||||
bool showTrip = false;
|
bool showTrip = false;
|
||||||
|
|
Loading…
Add table
Reference in a new issue