Plasma
runnerscript.h
Go to the documentation of this file.
00001 /* 00002 * Copyright 2007 by 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_RUNNERSCRIPT_H 00021 #define PLASMA_RUNNERSCRIPT_H 00022 00023 #include <kgenericfactory.h> 00024 #include <kplugininfo.h> 00025 00026 #include <plasma/plasma_export.h> 00027 #include <plasma/abstractrunner.h> 00028 #include <plasma/scripting/scriptengine.h> 00029 00030 namespace Plasma 00031 { 00032 00033 class RunnerScriptPrivate; 00034 00040 class PLASMA_EXPORT RunnerScript : public ScriptEngine 00041 { 00042 Q_OBJECT 00043 00044 public: 00052 explicit RunnerScript(QObject *parent = 0); 00053 ~RunnerScript(); 00054 00058 void setRunner(AbstractRunner *runner); 00059 00063 AbstractRunner *runner() const; 00064 00070 virtual void match(Plasma::RunnerContext &search); 00071 00076 virtual void run(const Plasma::RunnerContext &search, const Plasma::QueryMatch &action); 00077 00078 00079 Q_SIGNALS: 00080 void prepare(); 00081 void teardown(); 00082 void createRunOptions(QWidget *widget); 00083 void reloadConfiguration(); 00084 void actionsForMatch(const Plasma::QueryMatch &match, QList<QAction*>* actions); 00085 00086 protected: 00090 QString mainScript() const; 00091 00097 const Package *package() const; 00098 00102 KPluginInfo description() const; 00103 00108 DataEngine *dataEngine(const QString &name); 00109 00110 KConfigGroup config() const; 00111 void setIgnoredTypes(RunnerContext::Types types); 00112 void setHasRunOptions(bool hasRunOptions); 00113 void setSpeed(AbstractRunner::Speed newSpeed); 00114 void setPriority(AbstractRunner::Priority newPriority); 00115 KService::List serviceQuery(const QString &serviceType, 00116 const QString &constraint = QString()) const; 00117 QAction* addAction(const QString &id, const QIcon &icon, const QString &text); 00118 void addAction(const QString &id, QAction *action); 00119 void removeAction(const QString &id); 00120 QAction* action(const QString &id) const; 00121 QHash<QString, QAction*> actions() const; 00122 void clearActions(); 00123 void addSyntax(const RunnerSyntax &syntax); 00124 void setSyntaxes(const QList<RunnerSyntax> &syns); 00125 00126 private: 00127 friend class AbstractRunner; 00128 00129 RunnerScriptPrivate *const d; 00130 }; 00131 00132 #define K_EXPORT_PLASMA_RUNNERSCRIPTENGINE(libname, classname) \ 00133 K_PLUGIN_FACTORY(factory, registerPlugin<classname>();) \ 00134 K_EXPORT_PLUGIN(factory("plasma_runnerscriptengine_" #libname)) 00135 00136 } //Plasma namespace 00137 00138 #endif
KDE 4.6 API Reference