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/querymatch.h>
00032 #include <plasma/runnercontext.h>
00033 #include <plasma/runnersyntax.h>
00034 #include <plasma/version.h>
00035
00036 class QAction;
00037
00038 class KCompletion;
00039
00040 namespace Plasma
00041 {
00042
00043 class Package;
00044 class RunnerScript;
00045 class QueryMatch;
00046 class AbstractRunnerPrivate;
00047
00057 class PLASMA_EXPORT AbstractRunner : public QObject
00058 {
00059 Q_OBJECT
00060
00061 public:
00063 enum Speed {
00064 SlowSpeed,
00065 NormalSpeed
00066 };
00067
00069 enum Priority {
00070 LowestPriority = 0,
00071 LowPriority,
00072 NormalPriority,
00073 HighPriority,
00074 HighestPriority
00075 };
00076
00078 typedef QList<AbstractRunner*> List;
00079
00080 virtual ~AbstractRunner();
00081
00132 virtual void match(Plasma::RunnerContext &context);
00133
00139 void performMatch(Plasma::RunnerContext &context);
00140
00146 bool hasRunOptions();
00147
00155 virtual void createRunOptions(QWidget *widget);
00156
00165 virtual void run(const Plasma::RunnerContext &context, const Plasma::QueryMatch &match);
00166
00171 Speed speed() const;
00172
00177 Priority priority() const;
00178
00184 RunnerContext::Types ignoredTypes() const;
00185
00190 void setIgnoredTypes(RunnerContext::Types types);
00191
00195 QString name() const;
00196
00200 QString id() const;
00201
00205 QString description() const;
00206
00210 QIcon icon() const;
00211
00220 const Package *package() const;
00221
00225 virtual void reloadConfiguration();
00226
00231 QList<RunnerSyntax> syntaxes() const;
00232
00245 static QMutex *bigLock();
00246
00247 protected:
00248 friend class RunnerManager;
00249 friend class RunnerManagerPrivate;
00250
00256 explicit AbstractRunner(QObject *parent = 0, const QString &serviceId = QString());
00257 AbstractRunner(QObject *parent, const QVariantList &args);
00258
00262 KConfigGroup config() const;
00263
00267 void setHasRunOptions(bool hasRunOptions);
00268
00275 void setSpeed(Speed newSpeed);
00276
00281 void setPriority(Priority newPriority);
00282
00295 KService::List serviceQuery(const QString &serviceType,
00296 const QString &constraint = QString()) const;
00297
00307 virtual QList<QAction*> actionsForMatch(const Plasma::QueryMatch &match);
00308
00318 QAction* addAction(const QString &id, const QIcon &icon, const QString &text);
00319
00329 void addAction(const QString &id, QAction *action);
00330
00337 void removeAction(const QString &id);
00338
00342 QAction* action(const QString &id) const;
00343
00347 QHash<QString, QAction*> actions() const;
00348
00353 void clearActions();
00354
00363 void addSyntax(const RunnerSyntax &syntax);
00364
00372 void setSyntaxes(const QList<RunnerSyntax> &syns);
00373
00374 protected Q_SLOTS:
00375 void init();
00376
00377 private:
00378 AbstractRunnerPrivate *const d;
00379 };
00380
00381 }
00382
00383 #define K_EXPORT_PLASMA_RUNNER( libname, classname ) \
00384 K_PLUGIN_FACTORY(factory, registerPlugin<classname>();) \
00385 K_EXPORT_PLUGIN(factory("plasma_runner_" #libname)) \
00386 K_EXPORT_PLUGIN_VERSION(PLASMA_VERSION)
00387
00393 #define K_EXPORT_RUNNER_CONFIG( name, classname ) \
00394 K_PLUGIN_FACTORY(ConfigFactory, registerPlugin<classname>();) \
00395 K_EXPORT_PLUGIN(ConfigFactory("kcm_krunner_" #name)) \
00396 K_EXPORT_PLUGIN_VERSION(PLASMA_VERSION)
00397
00398 #endif