Add a whitelist to loadRunners, change canBeConfigured to isConfigurable

svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=739989
This commit is contained in:
Ryan P. Bitanga 2007-11-22 09:08:58 +00:00
parent 2fbb4b5fee
commit 72a3b2b68b
2 changed files with 23 additions and 21 deletions

View File

@ -58,12 +58,12 @@ void AbstractRunner::createMatchOptions(QWidget *parent)
Q_UNUSED(parent)
}
bool AbstractRunner::canBeConfigured()
bool AbstractRunner::isConfigurable()
{
return d->hasConfig;
}
void AbstractRunner::setCanBeConfigured(bool hasConfig)
void AbstractRunner::setIsConfigurable(bool hasConfig)
{
d->hasConfig = hasConfig;
}
@ -78,7 +78,7 @@ void AbstractRunner::exec(Plasma::SearchAction *action)
Q_UNUSED(action)
}
AbstractRunner::List AbstractRunner::loadRunners(QObject* parent)
AbstractRunner::List AbstractRunner::loadRunners(QObject* parent, const QStringList& whitelist)
{
List firstRunners;
List runners;
@ -87,6 +87,7 @@ AbstractRunner::List AbstractRunner::loadRunners(QObject* parent)
KService::List offers = KServiceTypeTrader::self()->query("Plasma/Runner");
QString error;
foreach (KService::Ptr service, offers) {
if( whitelist.empty() || whitelist.contains( service->name() ) ) {
AbstractRunner* runner = service->createInstance<AbstractRunner>(parent, QVariantList(), &error);
if (runner) {
//kDebug() << "loaded runner : " << service->name();
@ -103,6 +104,7 @@ AbstractRunner::List AbstractRunner::loadRunners(QObject* parent)
kDebug() << "failed to load runner : " << service->name() << ". error reported: " << error;
}
}
}
firstRunners << runners << lastRunners;
return firstRunners;

View File

@ -44,10 +44,10 @@ class PLASMA_EXPORT AbstractRunner : public QObject
/**
* Static method is called to load and get a list available of Runners.
*/
static List loadRunners(QObject* parent);
static List loadRunners(QObject* parent, const QStringList& whitelist = QStringList() );
/**
* Constrcuts an Runner object. Since AbstractRunner has pure virtuals,
* Constructs a Runner object. Since AbstractRunner has pure virtuals,
* this constructor can not be called directly. Rather a subclass must
* be created
*/
@ -90,10 +90,10 @@ class PLASMA_EXPORT AbstractRunner : public QObject
/**
* If the runner itself has configuration options, this method returns true
*/
bool canBeConfigured();
bool isConfigurable();
/**
* If canBeConfigured() returns true, this method may to get
* If isConfigurable() returns true, this method may to get
* a widget displaying the options the user can interact with to modify
* the behaviour of what happens when a given match is selected.
*
@ -116,7 +116,7 @@ class PLASMA_EXPORT AbstractRunner : public QObject
/**
* Sets whether or not the runner has configuration options itself
*/
void setCanBeConfigured(bool canBeConfigured);
void setIsConfigurable(bool canBeConfigured);
private:
class Private;