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>
This commit is contained in:
Tomaz Canabrava 2015-08-20 21:29:24 -03:00 committed by Dirk Hohndel
parent a081ffe48e
commit 118e978b5a

View file

@ -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())