LocationFilter: use equality instead of substring comparison

The location filter used a substring comparison, which had
the side effect that dives with the location "Test 1" were
shown when filtering for "Test 12".

Moreover, avoid a deep copy of the location list. This is
done by looping over one item less than rowCount() instead
of removing the last item. While doing this, remove an
unnecessary if-statement.

This commit partially fixes #675.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2017-11-25 12:38:25 +01:00 committed by Dirk Hohndel
parent e20e1aad0e
commit 739b27427c

View file

@ -277,15 +277,12 @@ bool LocationFilterModel::doFilter(struct dive *d, QModelIndex &index0, QAbstrac
return true;
}
// there is a location selected
// There is a location selected
QStringList locationList = stringList();
if (!locationList.isEmpty()) {
locationList.removeLast(); // remove the "Show Empty Tags";
for (int i = 0; i < rowCount(); i++) {
if (checkState[i] && (location.indexOf(stringList()[i]) != -1)) {
return true;
}
}
// Ignore last item, since this is the "Show Empty Tags" entry
for (int i = 0; i < rowCount() - 1; i++) {
if (checkState[i] && location == locationList[i])
return true;
}
return false;
}