Plasma
abstractrunner.h
Go to the documentation of this file.
00001 /* 00002 * Copyright 2006-2007 Aaron Seigo <aseigo@kde.org> 00003 * 00004 * This program is free software; you can redistribute it and/or modify 00005 * it under the terms of the GNU Library General Public License as 00006 * published by the Free Software Foundation; either version 2, or 00007 * (at your option) any later version. 00008 * 00009 * This program is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 * GNU General Public License for more details 00013 * 00014 * You should have received a copy of the GNU Library General Public 00015 * License along with this program; if not, write to the 00016 * Free Software Foundation, Inc., 00017 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 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 class QMimeData; 00038 00039 class KCompletion; 00040 00041 namespace Plasma 00042 { 00043 00044 class DataEngine; 00045 class Package; 00046 class RunnerScript; 00047 class QueryMatch; 00048 class AbstractRunnerPrivate; 00049 00063 class PLASMA_EXPORT AbstractRunner : public QObject 00064 { 00065 Q_OBJECT 00066 Q_PROPERTY(bool matchingSuspended READ isMatchingSuspended WRITE suspendMatching NOTIFY matchingSuspended) 00067 00068 public: 00070 enum Speed { 00071 SlowSpeed, 00072 NormalSpeed 00073 }; 00074 00076 enum Priority { 00077 LowestPriority = 0, 00078 LowPriority, 00079 NormalPriority, 00080 HighPriority, 00081 HighestPriority 00082 }; 00083 00085 typedef QList<AbstractRunner*> List; 00086 00087 virtual ~AbstractRunner(); 00088 00139 virtual void match(Plasma::RunnerContext &context); 00140 00146 void performMatch(Plasma::RunnerContext &context); 00147 00153 bool hasRunOptions(); 00154 00162 virtual void createRunOptions(QWidget *widget); 00163 00172 virtual void run(const Plasma::RunnerContext &context, const Plasma::QueryMatch &match); 00173 00178 Speed speed() const; 00179 00184 Priority priority() const; 00185 00191 RunnerContext::Types ignoredTypes() const; 00192 00197 void setIgnoredTypes(RunnerContext::Types types); 00198 00202 QString name() const; 00203 00207 QString id() const; 00208 00212 QString description() const; 00213 00217 QIcon icon() const; 00218 00227 const Package *package() const; 00228 00232 virtual void reloadConfiguration(); 00233 00238 QList<RunnerSyntax> syntaxes() const; 00239 00252 static QMutex *bigLock(); 00253 00259 RunnerSyntax *defaultSyntax() const; 00260 00266 bool isMatchingSuspended() const; 00267 00268 Q_SIGNALS: 00278 void prepare(); 00279 00286 void teardown(); 00287 00293 void matchingSuspended(bool suspended); 00294 00295 protected: 00296 friend class RunnerManager; 00297 friend class RunnerManagerPrivate; 00298 00299 explicit AbstractRunner(QObject *parent = 0, const QString &path = QString()); 00300 explicit AbstractRunner(const KService::Ptr service, QObject *parent = 0); 00301 00302 AbstractRunner(QObject *parent, const QVariantList &args); 00303 00308 void suspendMatching(bool suspend); 00309 00313 KConfigGroup config() const; 00314 00318 void setHasRunOptions(bool hasRunOptions); 00319 00326 void setSpeed(Speed newSpeed); 00327 00332 void setPriority(Priority newPriority); 00333 00346 KService::List serviceQuery(const QString &serviceType, 00347 const QString &constraint = QString()) const; 00348 00358 virtual QList<QAction*> actionsForMatch(const Plasma::QueryMatch &match); 00359 00369 QAction* addAction(const QString &id, const QIcon &icon, const QString &text); 00370 00380 void addAction(const QString &id, QAction *action); 00381 00388 void removeAction(const QString &id); 00389 00393 QAction* action(const QString &id) const; 00394 00398 QHash<QString, QAction*> actions() const; 00399 00404 void clearActions(); 00405 00414 void addSyntax(const RunnerSyntax &syntax); 00415 00430 void setDefaultSyntax(const RunnerSyntax &syntax); 00431 00439 void setSyntaxes(const QList<RunnerSyntax> &syns); 00440 00460 Q_INVOKABLE DataEngine *dataEngine(const QString &name) const; 00461 00462 protected Q_SLOTS: 00468 void init(); 00469 00475 QMimeData * mimeDataForMatch(const Plasma::QueryMatch *match); 00476 00477 private: 00478 friend class RunnerScript; 00479 00480 AbstractRunnerPrivate *const d; 00481 }; 00482 00483 } // Plasma namespace 00484 00485 #define K_EXPORT_PLASMA_RUNNER( libname, classname ) \ 00486 K_PLUGIN_FACTORY(factory, registerPlugin<classname>();) \ 00487 K_EXPORT_PLUGIN(factory("plasma_runner_" #libname)) \ 00488 K_EXPORT_PLUGIN_VERSION(PLASMA_VERSION) 00489 00495 #define K_EXPORT_RUNNER_CONFIG( name, classname ) \ 00496 K_PLUGIN_FACTORY(ConfigFactory, registerPlugin<classname>();) \ 00497 K_EXPORT_PLUGIN(ConfigFactory("kcm_krunner_" #name)) \ 00498 K_EXPORT_PLUGIN_VERSION(PLASMA_VERSION) 00499 00500 #endif
KDE 4.6 API Reference