Give runners priority levels

svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=758482
This commit is contained in:
Ryan P. Bitanga 2008-01-08 00:21:10 +00:00
parent 96e998763b
commit 3328d293ae
2 changed files with 65 additions and 3 deletions

View File

@ -31,9 +31,14 @@ class AbstractRunner::Private
public:
bool hasMatchOptions;
bool hasConfig;
Priority priority;
Speed speed;
int tier;
Private()
: speed(NormalSpeed)
: priority(NormalPriority),
speed(NormalSpeed),
tier(0)
{}
};
@ -121,6 +126,27 @@ void AbstractRunner::setSpeed(Speed speed)
d->speed = speed;
}
// For 4.1:
// int AbstractRunner::tier() const
// {
// return d->tier;
// }
//
// void AbstractRunner::setTier(int tier)
// {
// d->tier = tier;
// }
AbstractRunner::Priority AbstractRunner::priority() const
{
return d->priority;
}
void AbstractRunner::setPriority(Priority priority)
{
d->priority = priority;
}
void AbstractRunner::exec(Plasma::SearchMatch *action)
{
Q_UNUSED(action)

View File

@ -43,7 +43,15 @@ class PLASMA_EXPORT AbstractRunner : public QObject
public:
enum Speed { NormalSpeed,
SlowSpeed };
SlowSpeed
};
enum Priority { LowestPriority = 0,
LowPriority,
NormalPriority,
HighPriority,
HighestPriority
};
typedef QList<AbstractRunner*> List;
@ -124,8 +132,22 @@ class PLASMA_EXPORT AbstractRunner : public QObject
/**
* The nominal speed of the runner.
* @see setSpeed
*/
Speed speed() const;
Speed speed() const;
// For 4.1
// /**
// * The tier of the runner.
// * @see setTier
// */
// int tier() const;
/**
* The priority of the runner.
* @see setPriority
*/
Priority priority() const;
protected:
/**
@ -146,6 +168,20 @@ class PLASMA_EXPORT AbstractRunner : public QObject
*/
void setSpeed(Speed newSpeed);
//For 4.1
// /**
// * Sets the run tier of the runner. Higher tier runners execute only
// * after all lower-level runners execute. Call this method if your runner
// * depends on the output of previous runners.
// */
// void setTier(int tier);
/**
* Sets the priority of the runner. Lower priority runners are executed
* only after higher priority runners.
*/
void setPriority(Priority newPriority);
private:
class Private;
Private* const d;