libplasma
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 RUNNER_H
00021 #define RUNNER_H
00022
00023 #include <QtCore/QObject>
00024 #include <QtCore/QMutex>
00025 #include <QtCore/QStringList>
00026
00027 #include <KDE/KConfigGroup>
00028 #include <KDE/KService>
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 KCompletion;
00036
00037 namespace Plasma
00038 {
00039
00040 class Package;
00041 class RunnerScript;
00042 class QueryMatch;
00043 class AbstractRunnerPrivate;
00044
00053 class PLASMA_EXPORT AbstractRunner : public QObject
00054 {
00055 Q_OBJECT
00056
00057 public:
00058 enum Speed { SlowSpeed,
00059 NormalSpeed
00060 };
00061
00062 enum Priority { LowestPriority = 0,
00063 LowPriority,
00064 NormalPriority,
00065 HighPriority,
00066 HighestPriority
00067 };
00068
00069 typedef QList<AbstractRunner*> List;
00070
00071 virtual ~AbstractRunner();
00072
00094 virtual void match(Plasma::RunnerContext &context);
00095
00101 void performMatch(Plasma::RunnerContext &context);
00102
00108 bool hasRunOptions();
00109
00117 virtual void createRunOptions(QWidget *widget);
00118
00123 virtual void run(const Plasma::RunnerContext &context, const Plasma::QueryMatch &action);
00124
00129 Speed speed() const;
00130
00135 Priority priority() const;
00136
00142 RunnerContext::Types ignoredTypes() const;
00143
00148 void setIgnoredTypes(RunnerContext::Types types);
00149
00153 QString name() const;
00154
00158 QString id() const;
00159
00163 QString description() const;
00164
00170 const Package* package() const;
00171
00175 virtual void reloadConfiguration();
00176
00177 protected:
00178 friend class RunnerManager;
00179 friend class RunnerManagerPrivate;
00180
00186 explicit AbstractRunner(QObject* parent = 0, const QString& serviceId = QString());
00187 AbstractRunner(QObject* parent, const QVariantList& args);
00188
00192 KConfigGroup config() const;
00193
00197 void setHasRunOptions(bool hasRunOptions);
00198
00205 void setSpeed(Speed newSpeed);
00206
00211 void setPriority(Priority newPriority);
00212
00224 KService::List serviceQuery(const QString &serviceType,
00225 const QString &constraint = QString()) const;
00226
00227 QMutex* bigLock() const;
00228
00229 protected Q_SLOTS:
00230 void init();
00231
00232 private:
00233 AbstractRunnerPrivate* const d;
00234 };
00235
00236 }
00237
00238 #define K_EXPORT_PLASMA_RUNNER( libname, classname ) \
00239 K_PLUGIN_FACTORY(factory, registerPlugin<classname>();) \
00240 K_EXPORT_PLUGIN(factory("plasma_runner_" #libname)) \
00241 K_EXPORT_PLUGIN_VERSION(PLASMA_VERSION)
00242
00243
00244 #define K_EXPORT_RUNNER_CONFIG( name, classname ) \
00245 K_PLUGIN_FACTORY(ConfigFactory, registerPlugin<classname>();) \
00246 K_EXPORT_PLUGIN(ConfigFactory("kcm_krunner_" #name)) \
00247 K_EXPORT_PLUGIN_VERSION(PLASMA_VERSION)
00248
00249 #endif