diff --git a/runners/services/autotests/servicerunnertest.cpp b/runners/services/autotests/servicerunnertest.cpp --- a/runners/services/autotests/servicerunnertest.cpp +++ b/runners/services/autotests/servicerunnertest.cpp @@ -29,7 +29,7 @@ #include "../servicerunner.h" -#include +#include class ServiceRunnerTest : public QObject { diff --git a/runners/services/servicerunner.h b/runners/services/servicerunner.h --- a/runners/services/servicerunner.h +++ b/runners/services/servicerunner.h @@ -41,7 +41,7 @@ ~ServiceRunner() override; void match(Plasma::RunnerContext &context) override; - void run(const Plasma::RunnerContext &context, const Plasma::QueryMatch &action) override; + void run(const Plasma::RunnerContext &context, const Plasma::QueryMatch &match) override; QStringList categories() const override; QIcon categoryIcon(const QString& category) const override; diff --git a/runners/services/servicerunner.cpp b/runners/services/servicerunner.cpp --- a/runners/services/servicerunner.cpp +++ b/runners/services/servicerunner.cpp @@ -105,27 +105,27 @@ return ret; } - qreal increaseMatchRelavance(const KService::Ptr &service, QVector &strList, QString category) + qreal increaseMatchRelavance(const KService::Ptr &service, const QVector &strList, const QString &category) { //Increment the relevance based on all the words (other than the first) of the query list qreal relevanceIncrement = 0; - for(int i=1; iname().contains(strList[i], Qt::CaseInsensitive)) { + if (service->name().contains(str, Qt::CaseInsensitive)) { relevanceIncrement += 0.01; } } else if (category == QLatin1String("GenericName")) { - if (service->genericName().contains(strList[i], Qt::CaseInsensitive)) { + if (service->genericName().contains(str, Qt::CaseInsensitive)) { relevanceIncrement += 0.01; } } else if (category == QLatin1String("Exec")) { - if (service->exec().contains(strList[i], Qt::CaseInsensitive)) { + if (service->exec().contains(str, Qt::CaseInsensitive)) { relevanceIncrement += 0.01; } } else if (category == QLatin1String("Comment")) { - if (service->comment().contains(strList[i], Qt::CaseInsensitive)) { + if (service->comment().contains(str, Qt::CaseInsensitive)) { relevanceIncrement += 0.01; } } @@ -337,7 +337,8 @@ continue; } - for (const KServiceAction &action : service->actions()) { + const auto actions = service->actions(); + for (const KServiceAction &action : actions) { if (action.text().isEmpty() || action.exec().isEmpty() || hasSeen(action)) { continue; } @@ -377,7 +378,7 @@ QList matches; QString query; QString term; - int weightedTermLength; + int weightedTermLength = -1; }; ServiceRunner::ServiceRunner(QObject *parent, const QVariantList &args) @@ -391,9 +392,7 @@ addSyntax(Plasma::RunnerSyntax(QStringLiteral(":q:"), i18n("Finds applications whose name or description match :q:"))); } -ServiceRunner::~ServiceRunner() -{ -} +ServiceRunner::~ServiceRunner() = default; QStringList ServiceRunner::categories() const { @@ -455,14 +454,14 @@ QString path = service->entryPath(); if (!QDir::isAbsolutePath(path)) { - path = QStandardPaths::locate(QStandardPaths::GenericDataLocation, QLatin1String("kservices5/") + path); + path = QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("kservices5/") + path); } if (path.isEmpty()) { return nullptr; } - QMimeData *data = new QMimeData(); + auto *data = new QMimeData(); data->setUrls(QList{QUrl::fromLocalFile(path)}); return data; }