diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2017-11-25 12:38:25 +0100 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2017-11-25 08:24:36 -0800 |
commit | 739b27427cfb5119eebe214c984843cd5d155620 (patch) | |
tree | 2f3d8969508b0e4f5ada29247d341b904dd41146 /qt-models | |
parent | e20e1aad0e88fab376ab5423bf03e721f2a76940 (diff) | |
download | subsurface-739b27427cfb5119eebe214c984843cd5d155620.tar.gz |
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>
Diffstat (limited to 'qt-models')
-rw-r--r-- | qt-models/filtermodels.cpp | 13 |
1 files changed, 5 insertions, 8 deletions
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; } |