diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2017-11-25 18:26:00 +0100 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2017-11-25 15:41:55 -0800 |
commit | 6343515fedbc43be4fd2cb3f1b3fea384e362c59 (patch) | |
tree | ff2909b65341f21e693b2504838594c44b80ea39 | |
parent | 72318f289719cb678fa9158aef9cada0724d1f52 (diff) | |
download | subsurface-6343515fedbc43be4fd2cb3f1b3fea384e362c59.tar.gz |
Use equality instead of substring comparison in suits and buddy filter
This commit is a continuation of commit 739b27427cfb5119eebe214c984843cd5d155620,
in which a substring comparison was replaced by equality comparison to
avoid confusing UI behavior of the filter interface.
The suit and buddy filters were plagued by the same problem, so change
their code in analogy.
Fixes #551 (in conjunction with commit dd2466f51899aae406dc8c13904787710f30ec1c).
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
-rw-r--r-- | qt-models/filtermodels.cpp | 22 |
1 files changed, 8 insertions, 14 deletions
diff --git a/qt-models/filtermodels.cpp b/qt-models/filtermodels.cpp index 217d456bf..51587edc8 100644 --- a/qt-models/filtermodels.cpp +++ b/qt-models/filtermodels.cpp @@ -136,13 +136,10 @@ bool SuitsFilterModel::doFilter(dive *d, QModelIndex &index0, QAbstractItemModel // there is a suit selected QStringList suitList = stringList(); - if (!suitList.isEmpty()) { - suitList.removeLast(); // remove the "Show Empty Suits"; - for (int i = 0; i < rowCount(); i++) { - if (checkState[i] && (suit.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] && suit == suitList[i]) + return true; } return false; } @@ -243,13 +240,10 @@ bool BuddyFilterModel::doFilter(dive *d, QModelIndex &index0, QAbstractItemModel // have at least one buddy QStringList buddyList = stringList(); - if (!buddyList.isEmpty()) { - buddyList.removeLast(); // remove the "Show Empty Tags"; - for (int i = 0; i < rowCount(); i++) { - if (checkState[i] && (diveBuddy.indexOf(stringList()[i]) != -1 || divemaster.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] && (diveBuddy == buddyList[i] || divemaster == buddyList[i])) + return true; } return false; } |