From 935fb3c3df25e9982a097ddb8b2c380843d544d4 Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Thu, 21 Dec 2017 20:11:32 +0100 Subject: 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: Signed-off-by: Berthold Stoeger --- qt-models/filtermodels.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'qt-models/filtermodels.cpp') 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; -- cgit v1.2.3-70-g09d2