From 8aa667e342e8c8dc203fb6811f01523bacfcffab Mon Sep 17 00:00:00 2001 From: Max Horn Date: Thu, 2 Jul 2009 21:16:36 +0000 Subject: [PATCH] Enhanced the quicksearch box in the launcher to match words in the search string individually svn-id: r42038 --- gui/ListWidget.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/gui/ListWidget.cpp b/gui/ListWidget.cpp index e46d5e9b1e2..07d22973ac0 100644 --- a/gui/ListWidget.cpp +++ b/gui/ListWidget.cpp @@ -561,8 +561,10 @@ void ListWidget::setFilter(const String &filter, bool redraw) { // No filter -> display everything _list = _dataList; } else { - // Restrict the list to everything which contains _filter as a substring, - // ignoring case. + // Restrict the list to everything which contains all words in _filter + // as substrings, ignoring case. + + Common::StringTokenizer tok(filter); String tmp; int n = 0; @@ -572,7 +574,16 @@ void ListWidget::setFilter(const String &filter, bool redraw) { for (StringList::iterator i = _dataList.begin(); i != _dataList.end(); ++i, ++n) { tmp = *i; tmp.toLowercase(); - if (tmp.contains(_filter)) { + bool matches = true; + tok.reset(); + while (!tok.empty()) { + if (!tmp.contains(tok.nextToken())) { + matches = false; + break; + } + } + + if (matches) { _list.push_back(*i); _listIndex.push_back(n); }