Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:epopov:branches:openSUSE:Factory
krunner
2000-krunner.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 2000-krunner.patch of Package krunner
diff --git a/autotests/runnermanagerhistorytest.cpp b/autotests/runnermanagerhistorytest.cpp index dc5b20b3c496f444142228abeaf5778f941c6ccf..d3ccb985ac6d65dcbe81d68aada7431067d94d07 100644 --- a/autotests/runnermanagerhistorytest.cpp +++ b/autotests/runnermanagerhistorytest.cpp @@ -24,7 +24,7 @@ public: RunnerManagerHistoryTest() { QStandardPaths::setTestModeEnabled(true); - stateConfigFile = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + QDir::separator() + "krunnerstaterc"; + stateConfigFile = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + QDir::separator() + "krunner/krunnerstaterc"; } private: @@ -57,7 +57,6 @@ private Q_SLOTS: void testRunnerHistory(); void testRunnerHistory_data(); void testHistorySuggestionsAndRemoving(); - void testRelevanceForOftenLaunched(); }; void RunnerManagerHistoryTest::testRunnerHistory() @@ -103,44 +102,6 @@ void RunnerManagerHistoryTest::testHistorySuggestionsAndRemoving() QCOMPARE(manager.getHistorySuggestion("t"), "test2"); } -void RunnerManagerHistoryTest::testRelevanceForOftenLaunched() -{ - { - KConfig cfg(stateConfigFile); - cfg.group("PlasmaRunnerManager").writeEntry("LaunchCounts", "5 foo"); - cfg.sync(); - } - std::unique_ptr<RunnerManager> manager(new RunnerManager()); - manager->setAllowedRunners({QStringLiteral("fakerunnerplugin")}); - manager->loadRunner(KPluginMetaData::findPluginById(QStringLiteral("krunnertest"), QStringLiteral("fakerunnerplugin"))); - - launchQuery(QStringLiteral("foo"), manager.get()); - - const auto matches = manager->matches(); - QCOMPARE(matches.size(), 2); - QCOMPARE(matches.at(0).id(), QStringLiteral("foo")); - QCOMPARE(matches.at(1).id(), QStringLiteral("bar")); - QCOMPARE(matches.at(1).relevance(), 0.2); - - QVERIFY(matches.at(0).relevance() > matches.at(1).relevance()); - QVERIFY(matches.at(0).relevance() < 0.6); // 0.5 is the max we add as a bonus, 0.1 comes from the runner - { - KConfig cfg(stateConfigFile); - cfg.group("PlasmaRunnerManager").writeEntry("LaunchCounts", QStringList{"5 foo", "5 bar"}); - cfg.sync(); - KSharedConfig::openConfig(QStringLiteral("krunnerstaterc"), KConfig::NoGlobals, QStandardPaths::GenericDataLocation)->reparseConfiguration(); - } - manager.reset(new RunnerManager()); - manager->setAllowedRunners({QStringLiteral("fakerunnerplugin")}); - manager->loadRunner(KPluginMetaData::findPluginById(QStringLiteral("krunnertest"), QStringLiteral("fakerunnerplugin"))); - - launchQuery(QStringLiteral("foo"), manager.get()); - const auto newMatches = manager->matches(); - QCOMPARE(newMatches.size(), 2); - QCOMPARE(newMatches.at(0).type(), QueryMatch::ExactMatch); - QVERIFY(newMatches.at(0).relevance() < newMatches.at(1).relevance()); -} - QTEST_MAIN(RunnerManagerHistoryTest) #include "runnermanagerhistorytest.moc" diff --git a/src/runnercontext.cpp b/src/runnercontext.cpp index a259a9933387dd143863edbbb421ba169d5de905..54a5fc59856e73b798e2948caeb42c92e6512366 100644 --- a/src/runnercontext.cpp +++ b/src/runnercontext.cpp @@ -47,7 +47,6 @@ public: explicit RunnerContextPrivate(const RunnerContextPrivate &p) : QSharedData() - , launchCounts(p.launchCounts) , type(RunnerContext::None) , q(p.q) { @@ -166,7 +165,6 @@ public: QReadWriteLock lock; QList<QueryMatch> matches; - QHash<QString, int> launchCounts; QString term; QString mimeType; QStringList enabledCategories; @@ -319,11 +317,6 @@ bool RunnerContext::addMatches(const QList<QueryMatch> &matches) LOCK_FOR_WRITE(d) for (QueryMatch match : matches) { - // Give previously launched matches a slight boost in relevance - // The boost smoothly saturates to 0.5; - if (int count = d->launchCounts.value(match.id())) { - match.setRelevance(match.relevance() + 0.5 * (1 - exp(-count * 0.3))); - } d->addMatch(match); } UNLOCK(d); @@ -453,37 +446,14 @@ bool RunnerContext::shouldIgnoreCurrentMatchForHistory() const void RunnerContext::restore(const KConfigGroup &config) { - const QStringList cfgList = config.readEntry("LaunchCounts", QStringList()); - - static const QRegularExpression re(QStringLiteral("(\\d*) (.+)")); - for (const QString &entry : cfgList) { - const QRegularExpressionMatch match = re.match(entry); - if (!match.hasMatch()) { - continue; - } - const int count = match.captured(1).toInt(); - const QString id = match.captured(2); - d->launchCounts[id] = count; - } } void RunnerContext::save(KConfigGroup &config) { - QStringList countList; - - typedef QHash<QString, int>::const_iterator Iterator; - Iterator end = d->launchCounts.constEnd(); - for (Iterator i = d->launchCounts.constBegin(); i != end; ++i) { - countList << QStringLiteral("%2 %1").arg(i.key()).arg(i.value()); - } - - config.writeEntry("LaunchCounts", countList); - config.sync(); } void RunnerContext::run(const QueryMatch &match) { - ++d->launchCounts[match.id()]; match.run(*this); } diff --git a/src/runnermanager.cpp b/src/runnermanager.cpp index 1ab25c476f4676d32c59862c0e8e56033a21a4a9..fd39c3b417dfdf1968eb484b636b0a3ac5f1bcd5 100644 --- a/src/runnermanager.cpp +++ b/src/runnermanager.cpp @@ -542,15 +542,7 @@ RunnerManager::RunnerManager(const QString &configFile, QObject *parent) , d(new RunnerManagerPrivate(this)) { d->configPrt = KSharedConfig::openConfig(configFile); - // If the old config group still exists the migration script wasn't executed - // so we keep using this location - KConfigGroup oldStateDataGroup = d->configPrt->group("PlasmaRunnerManager"); - if (oldStateDataGroup.exists() && !oldStateDataGroup.readEntry("migrated", false)) { - d->stateData = oldStateDataGroup; - } else { - d->stateData = - KSharedConfig::openConfig(QStringLiteral("krunnerstaterc"), KConfig::NoGlobals, QStandardPaths::GenericDataLocation)->group("PlasmaRunnerManager"); - } + d->stateData = KSharedConfig::openConfig(QStringLiteral("krunner/krunnerstaterc"), KConfig::NoGlobals, QStandardPaths::GenericDataLocation)->group("PlasmaRunnerManager"); d->loadConfiguration(); }
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor