mirror of
https://github.com/subsurface/subsurface.git
synced 2025-01-19 14:25:27 +00:00
Fix BuddyFilterModel
Commit 6343515fed
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>
This commit is contained in:
parent
e4530cd5ef
commit
935fb3c3df
1 changed files with 6 additions and 4 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Reference in a new issue