diff options
author | Tomaz Canabrava <tomaz.canabrava@intel.com> | 2015-08-20 21:29:24 -0300 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2015-08-20 22:23:25 -0700 |
commit | 118e978b5a3cd4b011d0e557bb5a550d75c3c8d7 (patch) | |
tree | a4d353a11d5bdb0b5784731cd7910caf5cddd149 /qt-models/filtermodels.cpp | |
parent | a081ffe48e5c07505afaccde69dbdabe6f82054b (diff) | |
download | subsurface-118e978b5a3cd4b011d0e557bb5a550d75c3c8d7.tar.gz |
Display dives from the same location on the list
Some dive sites are separated in more than one real dive site
(for instance, a 'blue hole' dive site that has different
entry points on the gps), so instead of checking only the
dive_site id, also check it's name.
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-models/filtermodels.cpp')
-rw-r--r-- | qt-models/filtermodels.cpp | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/qt-models/filtermodels.cpp b/qt-models/filtermodels.cpp index 6bec97c23..80ed0cfd5 100644 --- a/qt-models/filtermodels.cpp +++ b/qt-models/filtermodels.cpp @@ -308,17 +308,29 @@ bool MultiFilterSortModel::filterAcceptsRow(int source_row, const QModelIndex &s struct dive *d = (struct dive *)diveVariant.value<void *>(); if (curr_dive_site) { + struct dive_site *ds = NULL; if (!d) { // It's a trip, only show the ones that have dives to be shown. bool showTrip = false; for (int i = 0; i < sourceModel()->rowCount(index0); i++) { QModelIndex child = sourceModel()->index(i, 0, index0); d = (struct dive *) sourceModel()->data(child, DiveTripModel::DIVE_ROLE).value<void*>(); - if ( d->dive_site_uuid == curr_dive_site->uuid ) + ds = get_dive_site_by_uuid(d->dive_site_uuid); + if (!ds) + continue; + if ( same_string(ds->name, curr_dive_site->name) || ds->uuid == curr_dive_site->uuid) { + if (ds->uuid != curr_dive_site->uuid) { + qWarning() << "Warning, two different dive sites with same name have a different id" + << ds->uuid << "and" << curr_dive_site->uuid; + } showTrip = true; // do not shortcircuit the loop or the counts will be wrong + } } return showTrip; } - return d->dive_site_uuid == curr_dive_site->uuid; + ds = get_dive_site_by_uuid(d->dive_site_uuid); + if (!ds) + return false; + return ( same_string(ds->name, curr_dive_site->name) || ds->uuid == curr_dive_site->uuid); } if (justCleared || models.isEmpty()) |