Plasma
abstractrunner.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef PLASMA_ABSTRACTRUNNER_H
00021 #define PLASMA_ABSTRACTRUNNER_H
00022
00023 #include <QtCore/QObject>
00024 #include <QtCore/QMutex>
00025 #include <QtCore/QStringList>
00026
00027 #include <kconfiggroup.h>
00028 #include <kservice.h>
00029
00030 #include <plasma/plasma_export.h>
00031 #include <plasma/runnercontext.h>
00032 #include <plasma/querymatch.h>
00033 #include <plasma/version.h>
00034
00035 class QAction;
00036
00037 class KCompletion;
00038
00039 namespace Plasma
00040 {
00041
00042 class Package;
00043 class RunnerScript;
00044 class QueryMatch;
00045 class AbstractRunnerPrivate;
00046
00056 class PLASMA_EXPORT AbstractRunner : public QObject
00057 {
00058 Q_OBJECT
00059
00060 public:
00062 enum Speed {
00063 SlowSpeed,
00064 NormalSpeed
00065 };
00066
00068 enum Priority {
00069 LowestPriority = 0,
00070 LowPriority,
00071 NormalPriority,
00072 HighPriority,
00073 HighestPriority
00074 };
00075
00077 typedef QList<AbstractRunner*> List;
00078
00079 virtual ~AbstractRunner();
00080
00131 virtual void match(Plasma::RunnerContext &context);
00132
00138 void performMatch(Plasma::RunnerContext &context);
00139
00145 bool hasRunOptions();
00146
00154 virtual void createRunOptions(QWidget *widget);
00155
00164 virtual void run(const Plasma::RunnerContext &context, const Plasma::QueryMatch &match);
00165
00170 Speed speed() const;
00171
00176 Priority priority() const;
00177
00183 RunnerContext::Types ignoredTypes() const;
00184
00189 void setIgnoredTypes(RunnerContext::Types types);
00190
00194 QString name() const;
00195
00199 QString id() const;
00200
00204 QString description() const;
00205
00214 const Package *package() const;
00215
00219 virtual void reloadConfiguration();
00220
00233 static QMutex *bigLock();
00234
00235 protected:
00236 friend class RunnerManager;
00237 friend class RunnerManagerPrivate;
00238
00244 explicit AbstractRunner(QObject *parent = 0, const QString &serviceId = QString());
00245 AbstractRunner(QObject *parent, const QVariantList &args);
00246
00250 KConfigGroup config() const;
00251
00255 void setHasRunOptions(bool hasRunOptions);
00256
00263 void setSpeed(Speed newSpeed);
00264
00269 void setPriority(Priority newPriority);
00270
00282 KService::List serviceQuery(const QString &serviceType,
00283 const QString &constraint = QString()) const;
00284
00294 virtual QList<QAction*> actionsForMatch(const Plasma::QueryMatch &match);
00295
00305 QAction* addAction(const QString &id, const QIcon &icon, const QString &text);
00306
00316 void addAction(const QString &id, QAction *action);
00317
00324 void removeAction(const QString &id);
00325
00329 QAction* action(const QString &id) const;
00330
00334 QHash<QString, QAction*> actions() const;
00339 void clearActions();
00340
00341 protected Q_SLOTS:
00342 void init();
00343
00344 private:
00345 AbstractRunnerPrivate *const d;
00346 };
00347
00348 }
00349
00350 #define K_EXPORT_PLASMA_RUNNER( libname, classname ) \
00351 K_PLUGIN_FACTORY(factory, registerPlugin<classname>();) \
00352 K_EXPORT_PLUGIN(factory("plasma_runner_" #libname)) \
00353 K_EXPORT_PLUGIN_VERSION(PLASMA_VERSION)
00354
00355 #define K_EXPORT_RUNNER_CONFIG( name, classname ) \
00356 K_PLUGIN_FACTORY(ConfigFactory, registerPlugin<classname>();) \
00357 K_EXPORT_PLUGIN(ConfigFactory("kcm_krunner_" #name)) \
00358 K_EXPORT_PLUGIN_VERSION(PLASMA_VERSION)
00359
00360 #endif