Commit b27b31a8 authored by Alexander Lohnau's avatar Alexander Lohnau 💬
Browse files

runners/services: Reduce relevance for category matches

parent df2fb3d3
......@@ -206,12 +206,12 @@ void ServiceRunnerTest::testCategories()
return match.text() == QLatin1String("Konsole ServiceRunnerTest") && match.relevance() == 0.64;
}));
// Multiple categories
// Multiple categories, this should still match, but now as relevant
context.setQuery(QStringLiteral("System KDE TerminalEmulator"));
runner.match(context);
matches = context.matches();
QVERIFY(std::any_of(matches.cbegin(), matches.cend(), [](const Plasma::QueryMatch &match) {
return match.text() == QLatin1String("Konsole ServiceRunnerTest") && match.relevance() == 0.64;
return match.text() == QLatin1String("Konsole ServiceRunnerTest") && match.relevance() == 0.44;
}));
// Multiple categories but at least one doesn't match
......
......@@ -316,8 +316,13 @@ private:
match.setType(Plasma::QueryMatch::PossibleMatch);
setupMatch(service, match);
qreal relevance = 0.6;
if (service->categories().contains(QLatin1String("X-KDE-More")) || !service->showInCurrentDesktop()) {
qreal relevance = 0.4;
const QStringList categories = service->categories();
if (std::any_of(categories.begin(), categories.end(), [this](const QString &category) {
return category.compare(term, Qt::CaseInsensitive) == 0;
})) {
relevance = 0.6;
} else if (service->categories().contains(QLatin1String("X-KDE-More")) || !service->showInCurrentDesktop()) {
relevance = 0.5;
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment