diff options
author | Orgad Shaneh <orgad.shaneh@audiocodes.com> | 2017-10-30 21:48:36 +0200 |
---|---|---|
committer | Orgad Shaneh <orgads@gmail.com> | 2017-11-04 16:12:03 +0000 |
commit | 4300041d246805b207397ba6163c72db627c47d1 (patch) | |
tree | 743841d11e5807e2234419b5f88be358c9b49879 /src/plugins/coreplugin/locator/ilocatorfilter.cpp | |
parent | 357caf3b44ead9c7a88be560b55f4725c6c0ff01 (diff) |
FuzzyMatcher: Improve wildcard matching
Make it equivalent to current wildcard implementation, and replace the
current one with FuzzyMatcher.
Change-Id: If83a4a8dfc7c8930bd92b49972647a519886a831
Reviewed-by: André Hartmann <aha_1980@gmx.de>
Diffstat (limited to 'src/plugins/coreplugin/locator/ilocatorfilter.cpp')
-rw-r--r-- | src/plugins/coreplugin/locator/ilocatorfilter.cpp | 31 |
1 files changed, 1 insertions, 30 deletions
diff --git a/src/plugins/coreplugin/locator/ilocatorfilter.cpp b/src/plugins/coreplugin/locator/ilocatorfilter.cpp index 5eccc6b00c..1e74741c7e 100644 --- a/src/plugins/coreplugin/locator/ilocatorfilter.cpp +++ b/src/plugins/coreplugin/locator/ilocatorfilter.cpp @@ -194,38 +194,9 @@ Qt::CaseSensitivity ILocatorFilter::caseSensitivity(const QString &str) return str == str.toLower() ? Qt::CaseInsensitive : Qt::CaseSensitive; } -/*! - Returns whether the search term \a str contains wildcard characters. - Can be used for choosing an optimal matching strategy. -*/ -bool ILocatorFilter::containsWildcard(const QString &str) -{ - return str.contains(QLatin1Char('*')) || str.contains(QLatin1Char('?')); -} - -/*! - * \brief Returns a simple regular expression to search for \a text. - * - * \a text may contain the simple '?' and '*' wildcards known from the shell. - * '?' matches exactly one character, '*' matches a number of characters - * (including none). - * - * The regular expression contains capture groups to allow highlighting - * matched characters after a match. - */ -static QRegularExpression createWildcardRegExp(const QString &text) -{ - QString pattern = '(' + text + ')'; - pattern.replace('?', ").("); - pattern.replace('*', ").*("); - pattern.remove("()"); - return QRegularExpression(pattern, QRegularExpression::CaseInsensitiveOption); -} - QRegularExpression ILocatorFilter::createRegExp(const QString &text) { - return containsWildcard(text) ? createWildcardRegExp(text) - : FuzzyMatcher::createRegExp(text); + return FuzzyMatcher::createRegExp(text); } LocatorFilterEntry::HighlightInfo ILocatorFilter::highlightInfo( |