* get rid of Plasma-RunnerName; use Name and KPluginInfo's pluginName instead

* add AbstractRunner::id()
* add QueryMatch::id()

svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=804670
This commit is contained in:
Aaron J. Seigo 2008-05-06 18:43:55 +00:00
parent 08217c3504
commit e2ec9b03db
6 changed files with 56 additions and 15 deletions

View File

@ -134,7 +134,7 @@ void AbstractRunner::performMatch( Plasma::RunnerContext &globalContext )
if (!slowed && runtime > reasonableRunTime) {
// we punish runners that return too slowly, even if they don't bring
// back matches
kDebug() << name() << "runner is too slow, putting it on the back burner.";
kDebug() << id() << "runner is too slow, putting it on the back burner.";
d->fastRuns = 0;
setSpeed(SlowSpeed);
}
@ -146,7 +146,7 @@ void AbstractRunner::performMatch( Plasma::RunnerContext &globalContext )
if (d->fastRuns > 2) {
// we reward slowed runners who bring back matches fast enough
// 3 times in a row
kDebug() << name() << "runner is faster than we thought, kicking it up a notch";
kDebug() << id() << "runner is faster than we thought, kicking it up a notch";
setSpeed(NormalSpeed);
}
}
@ -244,7 +244,15 @@ QString AbstractRunner::name() const
if (!d->runnerDescription.isValid()) {
return objectName();
}
return d->runnerDescription.property("X-Plasma-RunnerName").toString();
return d->runnerDescription.name();
}
QString AbstractRunner::id() const
{
if (!d->runnerDescription.isValid()) {
return objectName();
}
return d->runnerDescription.pluginName();
}
QString AbstractRunner::description() const
@ -255,7 +263,6 @@ QString AbstractRunner::description() const
return d->runnerDescription.property("Comment").toString();
}
const Package* AbstractRunner::package() const
{
return d->package;

View File

@ -160,10 +160,15 @@ class PLASMA_EXPORT AbstractRunner : public QObject
void setIgnoredTypes(RunnerContext::Types types);
/**
* Returns the engine name for the Runner
* Returns the user visible engine name for the Runner
*/
QString name() const;
/**
* Returns an id string for the Runner
*/
QString id() const;
/**
* Returns the description of this Runner
*/

View File

@ -44,6 +44,7 @@ class QueryMatch::Private
QPointer<AbstractRunner> runner;
QueryMatch::Type type;
QString id;
QString text;
QString subtext;
QIcon icon;
@ -56,6 +57,7 @@ class QueryMatch::Private
QueryMatch::QueryMatch(AbstractRunner *runner)
: d(new Private(runner))
{
d->id = runner->id();
// kDebug() << "new match created";
}
@ -64,6 +66,11 @@ QueryMatch::~QueryMatch()
delete d;
}
QString QueryMatch::id() const
{
return d->id;
}
void QueryMatch::setType(Type type)
{
d->type = type;
@ -102,6 +109,7 @@ void QueryMatch::setSubtext(const QString& subtext)
void QueryMatch::setData(const QVariant& data)
{
d->data = data;
d->id = d->runner->id() + '_' + data.toString();
}
void QueryMatch::setIcon(const QIcon& icon)

View File

@ -32,6 +32,11 @@ namespace Plasma
class RunnerContext;
class AbstractRunner;
/**
* @short A match returned by an AbstractRunner in response to a given
* RunnerContext.
*/
class PLASMA_EXPORT QueryMatch
{
public:
@ -94,11 +99,15 @@ class PLASMA_EXPORT QueryMatch
*/
AbstractRunner* runner() const;
void setText(const QString& text);
void setSubtext(const QString& text);
void setData(const QVariant& data);
void setIcon(const QIcon& icon);
void setEnabled(bool enable);
/**
* A string that can be used as an ID for this match,
* even between different queries. It is based in part
* on the source of the match (the AbstractRunner) and
* distinguishing information provided by the runner,
* ensuring global uniqueness as well as consistency
* between query matches.
*/
QString id() const;
QString text() const;
QString subtext() const;
@ -110,6 +119,21 @@ class PLASMA_EXPORT QueryMatch
void run(const RunnerContext *context) const;
protected:
friend class AbstractRunner;
/**
* Sets data to be used internally by the associated
* AbstractRunner. When set, it also is used to form
* part of the id for the match.
*/
void setData(const QVariant& data);
void setText(const QString& text);
void setSubtext(const QString& text);
void setIcon(const QIcon& icon);
void setEnabled(bool enable);
private:
class Private;
Private * const d;

View File

@ -224,7 +224,7 @@ public:
QString error;
foreach (const KService::Ptr &service, offers) {
KPluginInfo description(service);
QString runnerName = description.property("X-Plasma-RunnerName").toString();
QString runnerName = description.pluginName();
if (blacklist.contains(runnerName)) {
kDebug() << "The plugin" << service->name() << "was blackListed and will not load";
continue;
@ -309,7 +309,7 @@ AbstractRunner* RunnerManager::runner(const QString &name) const
{
//TODO: using a list of runners, if this gets slow, switch to hash
foreach (Plasma::AbstractRunner* runner, d->runners) {
if (name == runner->name()) {
if (name == runner->id()) {
return runner;
}
}

View File

@ -55,9 +55,6 @@ Comment[x-test]=xxKRunner pluginxx
Comment[zh_CN]=KRunner
Comment[zh_TW]=KRunner
[PropertyDef::X-Plasma-RunnerName]
Type=QString
[PropertyDef::X-Plasma-RunnerPhase]
Type=QString