From 739b27427cfb5119eebe214c984843cd5d155620 Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Sat, 25 Nov 2017 12:38:25 +0100 Subject: 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 --- qt-models/filtermodels.cpp | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'qt-models/filtermodels.cpp') diff --git a/qt-models/filtermodels.cpp b/qt-models/filtermodels.cpp index 718611611..f6fa45617 100644 --- a/qt-models/filtermodels.cpp +++ b/qt-models/filtermodels.cpp @@ -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; } -- cgit v1.2.3-70-g09d2