ws, style fixes, use booleans rather than ints when returning a boolean
svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=803034
This commit is contained in:
parent
4c1e5b8e9d
commit
da4f6c6e72
@ -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();
|
||||
|
@ -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<SearchMatch *> 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;
|
||||
|
Loading…
Reference in New Issue
Block a user