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 Library 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 Q_PROPERTY(QString id READ id); 00068 Q_PROPERTY(QString description READ description); 00069 Q_PROPERTY(QString name READ name); 00070 Q_PROPERTY(QIcon icon READ icon); 00071 public: 00073 enum Speed { 00074 SlowSpeed, 00075 NormalSpeed 00076 }; 00077 00079 enum Priority { 00080 LowestPriority = 0, 00081 LowPriority, 00082 NormalPriority, 00083 HighPriority, 00084 HighestPriority 00085 }; 00086 00088 typedef QList<AbstractRunner*> List; 00089 00090 virtual ~AbstractRunner(); 00091 00142 virtual void match(Plasma::RunnerContext &context); 00143 00149 void performMatch(Plasma::RunnerContext &context); 00150 00156 bool hasRunOptions(); 00157 00165 virtual void createRunOptions(QWidget *widget); 00166 00175 virtual void run(const Plasma::RunnerContext &context, const Plasma::QueryMatch &match); 00176 00181 Speed speed() const; 00182 00187 Priority priority() const; 00188 00194 RunnerContext::Types ignoredTypes() const; 00195 00200 void setIgnoredTypes(RunnerContext::Types types); 00201 00205 QString name() const; 00206 00210 QString id() const; 00211 00215 QString description() const; 00216 00220 QIcon icon() const; 00221 00230 const Package *package() const; 00231 00235 virtual void reloadConfiguration(); 00236 00241 QList<RunnerSyntax> syntaxes() const; 00242 00255 static QMutex *bigLock(); 00256 00262 RunnerSyntax *defaultSyntax() const; 00263 00269 bool isMatchingSuspended() const; 00270 00271 Q_SIGNALS: 00281 void prepare(); 00282 00289 void teardown(); 00290 00296 void matchingSuspended(bool suspended); 00297 00298 protected: 00299 friend class RunnerManager; 00300 friend class RunnerManagerPrivate; 00301 00302 explicit AbstractRunner(QObject *parent = 0, const QString &path = QString()); 00303 explicit AbstractRunner(const KService::Ptr service, QObject *parent = 0); 00304 00305 AbstractRunner(QObject *parent, const QVariantList &args); 00306 00311 void suspendMatching(bool suspend); 00312 00316 KConfigGroup config() const; 00317 00321 void setHasRunOptions(bool hasRunOptions); 00322 00329 void setSpeed(Speed newSpeed); 00330 00335 void setPriority(Priority newPriority); 00336 00349 KService::List serviceQuery(const QString &serviceType, 00350 const QString &constraint = QString()) const; 00351 00361 virtual QList<QAction*> actionsForMatch(const Plasma::QueryMatch &match); 00362 00372 QAction* addAction(const QString &id, const QIcon &icon, const QString &text); 00373 00383 void addAction(const QString &id, QAction *action); 00384 00391 void removeAction(const QString &id); 00392 00396 QAction* action(const QString &id) const; 00397 00401 QHash<QString, QAction*> actions() const; 00402 00407 void clearActions(); 00408 00417 void addSyntax(const RunnerSyntax &syntax); 00418 00433 void setDefaultSyntax(const RunnerSyntax &syntax); 00434 00442 void setSyntaxes(const QList<RunnerSyntax> &syns); 00443 00463 Q_INVOKABLE DataEngine *dataEngine(const QString &name) const; 00464 00465 protected Q_SLOTS: 00471 void init(); 00472 00478 QMimeData * mimeDataForMatch(const Plasma::QueryMatch *match); 00479 00480 private: 00481 friend class RunnerScript; 00482 00483 AbstractRunnerPrivate *const d; 00484 }; 00485 00486 } // Plasma namespace 00487 00488 #define K_EXPORT_PLASMA_RUNNER( libname, classname ) \ 00489 K_PLUGIN_FACTORY(factory, registerPlugin<classname>();) \ 00490 K_EXPORT_PLUGIN(factory("plasma_runner_" #libname)) \ 00491 K_EXPORT_PLUGIN_VERSION(PLASMA_VERSION) 00492 00498 #define K_EXPORT_RUNNER_CONFIG( name, classname ) \ 00499 K_PLUGIN_FACTORY(ConfigFactory, registerPlugin<classname>();) \ 00500 K_EXPORT_PLUGIN(ConfigFactory("kcm_krunner_" #name)) \ 00501 K_EXPORT_PLUGIN_VERSION(PLASMA_VERSION) 00502 00503 #endif
This file is part of the KDE documentation.
Documentation copyright © 1996-2012 The KDE developers.
Generated on Thu May 10 2012 20:51:35 by doxygen 1.8.0 written by Dimitri van Heesch, © 1997-2006
Documentation copyright © 1996-2012 The KDE developers.
Generated on Thu May 10 2012 20:51:35 by doxygen 1.8.0 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.