From da4f6c6e726c8e662e147633c2012c9470e59efb Mon Sep 17 00:00:00 2001 From: "Aaron J. Seigo" Date: Thu, 1 May 2008 17:42:34 +0000 Subject: [PATCH] ws, style fixes, use booleans rather than ints when returning a boolean svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=803034 --- runnermanager.cpp | 51 +++++++++++++++++++++++------------------------ runnermanager.h | 11 ++++------ 2 files changed, 29 insertions(+), 33 deletions(-) diff --git a/runnermanager.cpp b/runnermanager.cpp index 8b621066b..881758166 100644 --- a/runnermanager.cpp +++ b/runnermanager.cpp @@ -190,14 +190,14 @@ public: Private(RunnerManager *parent) : q(parent) - { - connect(&context, SIGNAL(matchesChanged()), q, SIGNAL(matchesChanged())); - connect(Weaver::instance(), SIGNAL(finished()), q, SIGNAL(matchesCompleted())); - } - - void configure(KConfigGroup& conf) { - config=conf; + connect(&context, SIGNAL(matchesChanged()), q, SIGNAL(matchesChanged())); + connect(Weaver::instance(), SIGNAL(finished()), q, SIGNAL(matchesCompleted())); + } + + void loadConfiguration(KConfigGroup& conf) + { + config = conf; //The number of threads used scales with the number of processors. const int numProcs = qMax(Solid::Device::listFromType(Solid::DeviceInterface::Processor).count(), 1); @@ -212,15 +212,14 @@ public: //If set, this list defines which runners won't be used at runtime blacklist = config.readEntry("blacklist", QStringList()); - } - + void loadAll() { AbstractRunner::List firstRunners; AbstractRunner::List normalRunners; AbstractRunner::List lastRunners; - + KService::List offers = KServiceTypeTrader::self()->query("Plasma/Runner"); QString error; foreach (const KService::Ptr &service, offers) { @@ -256,10 +255,10 @@ public: kDebug() << "failed to load runner : " << service->name() << ". error reported: " << error; } } - + firstRunners << normalRunners << lastRunners; runners.clear(); - runners = firstRunners; + runners = firstRunners; kDebug() << "All runners loaded, total:" << runners.count(); } @@ -283,7 +282,7 @@ RunnerManager::RunnerManager(QObject *parent) d(new Private(this)) { KConfigGroup config(KGlobal::config(), "PlasmaRunnerManager"); - d->configure(config); + d->loadConfiguration(config); d->loadAll(); //ThreadWeaver::setDebugLevel(true, 4); @@ -294,7 +293,7 @@ RunnerManager::RunnerManager(KConfigGroup& config, QObject *parent) : QObject(parent), d(new Private(this)) { - d->configure(config); + d->loadConfiguration(config); d->loadAll(); //ThreadWeaver::setDebugLevel(true, 4); } @@ -335,7 +334,6 @@ void RunnerManager::run(const SearchMatch *match) match->run(&d->context); } - void RunnerManager::launchQuery (const QString & term, const QString & runnerName) { if (term.isEmpty()) { @@ -360,6 +358,7 @@ void RunnerManager::launchQuery (const QString & term, const QString & runnerNam } else { runable = d->runners; } + bool jobsLaunched=false; foreach (Plasma::AbstractRunner* r, runable) { if ((r->ignoredTypes() & d->context.type()) == 0) { @@ -370,21 +369,22 @@ void RunnerManager::launchQuery (const QString & term, const QString & runnerNam d->searchJobs.append( job ); } } + if (!jobsLaunched) { emit matchesCompleted(); - } + } } bool RunnerManager::execQuery (const QString & term, const QString & runnerName) { if (term.isEmpty()) { reset(); - return 0; + return false; } if (d->context.searchTerm() == term) { // we already are searching for this! - return 0; + return false; } reset(); @@ -394,26 +394,25 @@ bool RunnerManager::execQuery (const QString & term, const QString & runnerName) AbstractRunner *r = runner(runnerName); if (!r) { - return 0; + return false; } if ((r->ignoredTypes() & d->context.type()) != 0) { - return 0; + return false; } r->performMatch(d->context); emit matchesCompleted(); - return 1; + return true; } void RunnerManager::reset() -{ +{ // If ThreadWeaver is idle, it is safe to clear previous jobs - if ( Weaver::instance()->isIdle() ) { - qDeleteAll( d->searchJobs ); + if (Weaver::instance()->isIdle()) { + qDeleteAll(d->searchJobs); d->searchJobs.clear(); - } - else { + } else { Weaver::instance()->dequeue(); } d->context.reset(); diff --git a/runnermanager.h b/runnermanager.h index 56dc39e21..a94ec3d6a 100644 --- a/runnermanager.h +++ b/runnermanager.h @@ -33,7 +33,7 @@ namespace Plasma class SearchMatch; class AbstractRunner; class SearchContext; - + /** * @short The RunnerManager class decides what installed runners are runnable, * and their ratings. It is the main proxy to the runners. @@ -41,10 +41,9 @@ namespace Plasma class PLASMA_EXPORT RunnerManager : public QObject { Q_OBJECT - + public: - explicit RunnerManager(QObject *parent=0); explicit RunnerManager(KConfigGroup& config, QObject *parent=0); ~RunnerManager(); @@ -67,7 +66,7 @@ class PLASMA_EXPORT RunnerManager : public QObject * @return List of matches */ QList matches() const; - + /** * Runs a given match * @arg pointer to the match to be executed @@ -75,7 +74,6 @@ class PLASMA_EXPORT RunnerManager : public QObject void run(const SearchMatch *match); public Q_SLOTS: - /** * Launch a query, this will create threads and return inmediately. * When the information will be available can be known using the @@ -103,7 +101,6 @@ class PLASMA_EXPORT RunnerManager : public QObject void reset(); Q_SIGNALS: - /** * Emited each time a new match is added to the list */ @@ -113,7 +110,7 @@ class PLASMA_EXPORT RunnerManager : public QObject * Emited when all the matches have been found */ void matchesCompleted(); - + private: class Private; Private * const d;