Search: Lax separator matching when filtering results

Any separator will now match any other separator when filtering search results.

Example: Type "live server" in filter. Currently it would only match "live server". Consequently, if you type "live.server" it will only match "live.server" and not "live server" even though the user likely wants to see both.

With this update any separator now matches any other separator; A space now matches `.` `-` `_`, an underscore also matches a space and a dash, etcetera.

This means that a filter of "live server" will now show "live.server" in the results.

This is a lot more intuitive in my opinion.
This commit is contained in:
Alex Duchesne 2024-09-20 13:38:14 -04:00
parent 1c43286616
commit 08dae5feea

View file

@ -395,8 +395,12 @@ void SearchJobWidget::fillFilterComboBoxes()
void SearchJobWidget::filterSearchResults(const QString &name)
{
const QString pattern = (Preferences::instance()->getRegexAsFilteringPatternForSearchJob()
? name : Utils::String::wildcardToRegexPattern(name));
QString pattern = name;
if (!Preferences::instance()->getRegexAsFilteringPatternForSearchJob())
{
pattern.replace(QRegularExpression(u"[-.\\s_]+"_s), u"[-. _]"_s);
pattern = Utils::String::wildcardToRegexPattern(pattern);
}
m_proxyModel->setFilterRegularExpression(QRegularExpression(pattern, QRegularExpression::CaseInsensitiveOption));
updateResultsCount();
}