diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2017-12-21 20:11:32 +0100 |
---|---|---|
committer | Lubomir I. Ivanov <neolit123@gmail.com> | 2017-12-21 21:09:35 +0100 |
commit | 935fb3c3df25e9982a097ddb8b2c380843d544d4 (patch) | |
tree | 5dd4c3b615336717284db1801c73f199e8143310 /qt-models/filtermodels.cpp | |
parent | e4530cd5ef38e6120f451daf1a758b38b70a6f1c (diff) | |
download | subsurface-935fb3c3df25e9982a097ddb8b2c380843d544d4.tar.gz |
Fix BuddyFilterModel
Commit 6343515fedbc43be4fd2cb3f1b3fea384e362c59 introduced equality
instead of substring comparison for filters. This broke the buddy
filter in the case of more than one buddy, because in such a case
the buddy list is a comma-separated string.
Fix this by splitting the buddy string, trimming the individual
strings and search in the list.
Fixes #969
Reported-by: <yrevawerd@gmail.com>
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'qt-models/filtermodels.cpp')
-rw-r--r-- | qt-models/filtermodels.cpp | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/qt-models/filtermodels.cpp b/qt-models/filtermodels.cpp index 07ec1a250..31a84a8bb 100644 --- a/qt-models/filtermodels.cpp +++ b/qt-models/filtermodels.cpp @@ -228,10 +228,12 @@ bool BuddyFilterModel::doFilter(dive *d, QModelIndex &index0, QAbstractItemModel return true; } // Checked means 'Show', Unchecked means 'Hide'. - QString diveBuddy(d->buddy); - QString divemaster(d->divemaster); + QString persons = QString(d->buddy) + "," + QString(d->divemaster); + QStringList personsList = persons.split(',', QString::SkipEmptyParts); + for (QString &s: personsList) + s = s.trimmed(); // only show empty buddie dives if the user checked that. - if (diveBuddy.isEmpty() && divemaster.isEmpty()) { + if (personsList.isEmpty()) { if (rowCount() > 0) return checkState[rowCount() - 1]; else @@ -242,7 +244,7 @@ bool BuddyFilterModel::doFilter(dive *d, QModelIndex &index0, QAbstractItemModel QStringList buddyList = stringList(); // 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])) + if (checkState[i] && personsList.contains(buddyList[i], Qt::CaseInsensitive)) return true; } return false; |