Add missing functions to RunnerScript.

Review: http://reviewboard.kde.org/r/2054/

svn path=/trunk/KDE/kdelibs/; revision=1045443
This commit is contained in:
Petri Damstén 2009-11-06 06:33:24 +00:00
parent 75e482fae2
commit 0244d72222
4 changed files with 143 additions and 6 deletions

View File

@ -132,6 +132,9 @@ KConfigGroup AbstractRunner::config() const
void AbstractRunner::reloadConfiguration()
{
if (d->script) {
emit d->script->reloadConfiguration();
}
}
void AbstractRunner::addSyntax(const RunnerSyntax &syntax)
@ -237,7 +240,9 @@ void AbstractRunner::setHasRunOptions(bool hasRunOptions)
void AbstractRunner::createRunOptions(QWidget *parent)
{
Q_UNUSED(parent)
if (d->script) {
emit d->script->createRunOptions(parent);
}
}
AbstractRunner::Speed AbstractRunner::speed() const

View File

@ -81,7 +81,7 @@ class PLASMA_EXPORT AbstractRunner : public QObject
/**
* This is the main query method. It should trigger creation of
* QueryMatch instances through RunnerContext::addMatch and
* QueryMatch instances through RunnerContext::addMatch and
* RunnerContext::addMatches. It is called internally by performMatch().
*
* If the runner can run precisely the requested term (RunnerContext::query()),
@ -97,7 +97,7 @@ class PLASMA_EXPORT AbstractRunner : public QObject
* to be reported once this method returns. Asyncroneous runners therefore need
* to make use of a local event loop to wait for all matches.
*
* It is recommended to use local status data in async runners. The simplest way is
* It is recommended to use local status data in async runners. The simplest way is
* to have a separate class doing all the work like so:
*
* \code
@ -395,6 +395,8 @@ class PLASMA_EXPORT AbstractRunner : public QObject
void init();
private:
friend class RunnerScript;
AbstractRunnerPrivate *const d;
};

View File

@ -45,6 +45,8 @@ RunnerScript::~RunnerScript()
void RunnerScript::setRunner(AbstractRunner *runner)
{
d->runner = runner;
connect(runner, SIGNAL(prepare()), this, SIGNAL(prepare()));
connect(runner, SIGNAL(teardown()), this, SIGNAL(teardown()));
}
AbstractRunner *RunnerScript::runner() const
@ -63,6 +65,110 @@ void RunnerScript::run(const Plasma::RunnerContext &search, const Plasma::QueryM
Q_UNUSED(action);
}
KConfigGroup RunnerScript::config() const
{
if (d->runner) {
return d->runner->config();
}
return KConfigGroup();
}
void RunnerScript::setIgnoredTypes(RunnerContext::Types types)
{
if (d->runner) {
d->runner->setIgnoredTypes(types);
}
}
void RunnerScript::setHasRunOptions(bool hasRunOptions)
{
if (d->runner) {
d->runner->setHasRunOptions(hasRunOptions);
}
}
void RunnerScript::setSpeed(AbstractRunner::Speed newSpeed)
{
if (d->runner) {
d->runner->setSpeed(newSpeed);
}
}
void RunnerScript::setPriority(AbstractRunner::Priority newPriority)
{
if (d->runner) {
d->runner->setPriority(newPriority);
}
}
KService::List RunnerScript::serviceQuery(const QString &serviceType,
const QString &constraint) const
{
if (d->runner) {
return d->runner->serviceQuery(serviceType, constraint);
}
return KService::List();
}
QAction* RunnerScript::addAction(const QString &id, const QIcon &icon, const QString &text)
{
if (d->runner) {
return d->runner->addAction(id, icon, text);
}
return 0;
}
void RunnerScript::addAction(const QString &id, QAction *action)
{
if (d->runner) {
d->runner->addAction(id, action);
}
}
void RunnerScript::removeAction(const QString &id)
{
if (d->runner) {
d->runner->removeAction(id);
}
}
QAction* RunnerScript::action(const QString &id) const
{
if (d->runner) {
return d->runner->action(id);
}
return 0;
}
QHash<QString, QAction*> RunnerScript::actions() const
{
if (d->runner) {
return d->runner->actions();
}
return QHash<QString, QAction*>();
}
void RunnerScript::clearActions()
{
if (d->runner) {
d->runner->clearActions();
}
}
void RunnerScript::addSyntax(const RunnerSyntax &syntax)
{
if (d->runner) {
d->runner->addSyntax(syntax);
}
}
void RunnerScript::setSyntaxes(const QList<RunnerSyntax> &syns)
{
if (d->runner) {
d->runner->setSyntaxes(syns);
}
}
const Package *RunnerScript::package() const
{
return d->runner ? d->runner->package() : 0;

View File

@ -23,14 +23,12 @@
#include <kgenericfactory.h>
#include <plasma/plasma_export.h>
#include <plasma/abstractrunner.h>
#include <plasma/scripting/scriptengine.h>
namespace Plasma
{
class AbstractRunner;
class RunnerContext;
class QueryMatch;
class RunnerScriptPrivate;
/**
@ -76,6 +74,14 @@ public:
*/
virtual void run(const Plasma::RunnerContext &search, const Plasma::QueryMatch &action);
Q_SIGNALS:
void prepare();
void teardown();
void createRunOptions(QWidget *widget);
void reloadConfiguration();
//TODO: QList<QAction*> actionsForMatch(const Plasma::QueryMatch &match);
protected:
/**
* @return absolute path to the main script file for this plasmoid
@ -89,7 +95,25 @@ protected:
*/
const Package *package() const;
KConfigGroup config() const;
void setIgnoredTypes(RunnerContext::Types types);
void setHasRunOptions(bool hasRunOptions);
void setSpeed(AbstractRunner::Speed newSpeed);
void setPriority(AbstractRunner::Priority newPriority);
KService::List serviceQuery(const QString &serviceType,
const QString &constraint = QString()) const;
QAction* addAction(const QString &id, const QIcon &icon, const QString &text);
void addAction(const QString &id, QAction *action);
void removeAction(const QString &id);
QAction* action(const QString &id) const;
QHash<QString, QAction*> actions() const;
void clearActions();
void addSyntax(const RunnerSyntax &syntax);
void setSyntaxes(const QList<RunnerSyntax> &syns);
private:
friend class AbstractRunner;
RunnerScriptPrivate *const d;
};