From 6f642343588060a9dc4b2ddce2c25e5abc9189ea Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Tue, 19 Jan 2016 16:58:38 +0100 Subject: Fix filter logic --- src/vsession.cpp | 9 +++++---- src/xsession.cpp | 11 +++++++++-- 2 files changed, 14 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/vsession.cpp b/src/vsession.cpp index 45587f1..79d3956 100644 --- a/src/vsession.cpp +++ b/src/vsession.cpp @@ -134,17 +134,18 @@ void VSession::readKeywords() { bool VSession::containsKeywords(const QList& keywords) const { for (int j = 0; j < keywords.length(); ++j) { - bool keywordFlag = true; if (!this->shortDescription().contains(keywords[j], Qt::CaseInsensitive) && !this->description().contains(keywords[j], Qt::CaseInsensitive) && !this->getAttribute("creator", "param").contains(keywords[j], Qt::CaseInsensitive)) { - keywordFlag = false; + bool match = false; for (int i = 0; i < this->keywords().length(); ++i) { if (this->keywords()[i].contains(keywords[j], Qt::CaseInsensitive)) { - keywordFlag = true; + match = true; + break; } } - if (!keywordFlag) return false; + if (!match) + return false; } } return true; diff --git a/src/xsession.cpp b/src/xsession.cpp index 3ae4320..ff5de57 100644 --- a/src/xsession.cpp +++ b/src/xsession.cpp @@ -149,6 +149,13 @@ bool XSession::operator<(const Session& other) const { return false; } -bool XSession::containsKeywords(const QList&) const { - return true; +bool XSession::containsKeywords(const QList& keywords) const { + for (int j = 0; j < keywords.length(); ++j) { + if (!this->shortDescription().contains(keywords[j], Qt::CaseInsensitive) + && !this->description().contains(keywords[j], Qt::CaseInsensitive)) { + return false; + } + } + return true; } + -- cgit v1.2.3-55-g7522