From 118e978b5a3cd4b011d0e557bb5a550d75c3c8d7 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Thu, 20 Aug 2015 21:29:24 -0300 Subject: 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 Signed-off-by: Dirk Hohndel --- qt-models/filtermodels.cpp | 16 ++++++++++++++-- 1 file 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(); 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(); - 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()) -- cgit v1.2.3-70-g09d2