• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdelibs API Reference
  • KDE Home
  • Contact Us
 

Plasma

  • sources
  • kde-4.12
  • kdelibs
  • plasma
  • scripting
runnerscript.cpp
Go to the documentation of this file.
1 /*
2  * Copyright 2007 by Aaron Seigo <aseigo@kde.org>
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Library General Public License as
6  * published by the Free Software Foundation; either version 2, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details
13  *
14  * You should have received a copy of the GNU Library General Public
15  * License along with this program; if not, write to the
16  * Free Software Foundation, Inc.,
17  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18  */
19 
20 #include "plasma/scripting/runnerscript.h"
21 
22 #include "plasma/abstractrunner.h"
23 #include "plasma/dataenginemanager.h"
24 #include "plasma/package.h"
25 #include "plasma/private/abstractrunner_p.h"
26 
27 namespace Plasma
28 {
29 
30 class RunnerScriptPrivate
31 {
32 public:
33  AbstractRunner *runner;
34 };
35 
36 RunnerScript::RunnerScript(QObject *parent)
37  : ScriptEngine(parent),
38  d(new RunnerScriptPrivate)
39 {
40 }
41 
42 RunnerScript::~RunnerScript()
43 {
44  delete d;
45 }
46 
47 void RunnerScript::setRunner(AbstractRunner *runner)
48 {
49  d->runner = runner;
50  connect(runner, SIGNAL(prepare()), this, SIGNAL(prepare()));
51  connect(runner, SIGNAL(teardown()), this, SIGNAL(teardown()));
52 }
53 
54 AbstractRunner *RunnerScript::runner() const
55 {
56  return d->runner;
57 }
58 
59 void RunnerScript::match(Plasma::RunnerContext &search)
60 {
61  Q_UNUSED(search);
62 }
63 
64 void RunnerScript::run(const Plasma::RunnerContext &search, const Plasma::QueryMatch &action)
65 {
66  Q_UNUSED(search);
67  Q_UNUSED(action);
68 }
69 
70 DataEngine *RunnerScript::dataEngine(const QString &name)
71 {
72  if (d->runner) {
73  return d->runner->dataEngine(name);
74  }
75 
76  return DataEngineManager::self()->engine(QString());
77 }
78 
79 KConfigGroup RunnerScript::config() const
80 {
81  if (d->runner) {
82  return d->runner->config();
83  }
84  return KConfigGroup();
85 }
86 
87 void RunnerScript::setIgnoredTypes(RunnerContext::Types types)
88 {
89  if (d->runner) {
90  d->runner->setIgnoredTypes(types);
91  }
92 }
93 
94 void RunnerScript::setHasRunOptions(bool hasRunOptions)
95 {
96  if (d->runner) {
97  d->runner->setHasRunOptions(hasRunOptions);
98  }
99 }
100 
101 void RunnerScript::setSpeed(AbstractRunner::Speed newSpeed)
102 {
103  if (d->runner) {
104  d->runner->setSpeed(newSpeed);
105  }
106 }
107 
108 void RunnerScript::setPriority(AbstractRunner::Priority newPriority)
109 {
110  if (d->runner) {
111  d->runner->setPriority(newPriority);
112  }
113 }
114 
115 KService::List RunnerScript::serviceQuery(const QString &serviceType,
116  const QString &constraint) const
117 {
118  if (d->runner) {
119  return d->runner->serviceQuery(serviceType, constraint);
120  }
121  return KService::List();
122 }
123 
124 QAction* RunnerScript::addAction(const QString &id, const QIcon &icon, const QString &text)
125 {
126  if (d->runner) {
127  return d->runner->addAction(id, icon, text);
128  }
129  return 0;
130 }
131 
132 void RunnerScript::addAction(const QString &id, QAction *action)
133 {
134  if (d->runner) {
135  d->runner->addAction(id, action);
136  }
137 }
138 
139 void RunnerScript::removeAction(const QString &id)
140 {
141  if (d->runner) {
142  d->runner->removeAction(id);
143  }
144 }
145 
146 QAction* RunnerScript::action(const QString &id) const
147 {
148  if (d->runner) {
149  return d->runner->action(id);
150  }
151  return 0;
152 }
153 
154 QHash<QString, QAction*> RunnerScript::actions() const
155 {
156  if (d->runner) {
157  return d->runner->actions();
158  }
159  return QHash<QString, QAction*>();
160 }
161 
162 void RunnerScript::clearActions()
163 {
164  if (d->runner) {
165  d->runner->clearActions();
166  }
167 }
168 
169 void RunnerScript::addSyntax(const RunnerSyntax &syntax)
170 {
171  if (d->runner) {
172  d->runner->addSyntax(syntax);
173  }
174 }
175 
176 void RunnerScript::setSyntaxes(const QList<RunnerSyntax> &syns)
177 {
178  if (d->runner) {
179  d->runner->setSyntaxes(syns);
180  }
181 }
182 
183 const Package *RunnerScript::package() const
184 {
185  return d->runner ? d->runner->package() : 0;
186 }
187 
188 KPluginInfo RunnerScript::description() const
189 {
190  return d->runner ? d->runner->d->runnerDescription : KPluginInfo();
191 }
192 
193 QString RunnerScript::mainScript() const
194 {
195  if (!package()) {
196  return QString();
197  } else {
198  return package()->filePath("mainscript");
199  }
200 }
201 
202 } // Plasma namespace
203 
204 #include "runnerscript.moc"
Plasma::RunnerScript::clearActions
void clearActions()
Definition: runnerscript.cpp:162
abstractrunner.h
Plasma::DataEngineManager::engine
Plasma::DataEngine * engine(const QString &name) const
Returns a data engine object if one is loaded and available.
Definition: dataenginemanager.cpp:106
Plasma::AbstractRunner::Speed
Speed
Specifies a nominal speed for the runner.
Definition: abstractrunner.h:73
Plasma::RunnerScript::setPriority
void setPriority(AbstractRunner::Priority newPriority)
Definition: runnerscript.cpp:108
Plasma::RunnerScript::setSpeed
void setSpeed(AbstractRunner::Speed newSpeed)
Definition: runnerscript.cpp:101
Plasma::RunnerScript::runner
AbstractRunner * runner() const
Returns the Plasma::AbstractRunner associated with this script component.
Definition: runnerscript.cpp:54
Plasma::RunnerScript::config
KConfigGroup config() const
Definition: runnerscript.cpp:79
Plasma::RunnerScript::setSyntaxes
void setSyntaxes(const QList< RunnerSyntax > &syns)
Definition: runnerscript.cpp:176
Plasma::AbstractRunner
An abstract base class for Plasma Runner plugins.
Definition: abstractrunner.h:63
Plasma::RunnerScript::setHasRunOptions
void setHasRunOptions(bool hasRunOptions)
Definition: runnerscript.cpp:94
Plasma::RunnerScript::addAction
QAction * addAction(const QString &id, const QIcon &icon, const QString &text)
Definition: runnerscript.cpp:124
QObject
Plasma::RunnerScript::run
virtual void run(const Plasma::RunnerContext &search, const Plasma::QueryMatch &action)
Called whenever an exact or possible match associated with this runner is triggered.
Definition: runnerscript.cpp:64
Plasma::RunnerScript::actions
QHash< QString, QAction * > actions() const
Definition: runnerscript.cpp:154
Plasma::RunnerScript::package
const Package * package() const
Definition: runnerscript.cpp:183
Plasma::RunnerScript::teardown
void teardown()
Plasma::RunnerSyntax
Definition: runnersyntax.h:40
Plasma::RunnerScript::addSyntax
void addSyntax(const RunnerSyntax &syntax)
Definition: runnerscript.cpp:169
Plasma::RunnerScript::prepare
void prepare()
Plasma::ScriptEngine
The base class for scripting interfaces to be used in loading plasmoids of a given language...
Definition: scriptengine.h:65
Plasma::DataEngine
Data provider for plasmoids (Plasma plugins)
Definition: dataengine.h:58
Plasma::RunnerScript::match
virtual void match(Plasma::RunnerContext &search)
Called when the script should create QueryMatch instances through RunnerContext::addInformationalMatc...
Definition: runnerscript.cpp:59
Plasma::RunnerScript::RunnerScript
RunnerScript(QObject *parent=0)
Default constructor for a RunnerScript.
Definition: runnerscript.cpp:36
Plasma::AbstractRunner::Priority
Priority
Specifies a priority for the runner.
Definition: abstractrunner.h:79
Plasma::RunnerScript::mainScript
QString mainScript() const
Definition: runnerscript.cpp:193
Plasma::Package
object representing an installed Plasmagik package
Definition: package.h:42
Plasma::DataEngineManager::self
static DataEngineManager * self()
Singleton pattern accessor.
Definition: dataenginemanager.cpp:90
Plasma::RunnerContext
The RunnerContext class provides information related to a search, including the search term...
Definition: runnercontext.h:46
dataenginemanager.h
Plasma::RunnerScript::setRunner
void setRunner(AbstractRunner *runner)
Sets the Plasma::AbstractRunner associated with this RunnerScript.
Definition: runnerscript.cpp:47
Plasma::RunnerScript::dataEngine
DataEngine * dataEngine(const QString &name)
Definition: runnerscript.cpp:70
Plasma::RunnerScript::~RunnerScript
~RunnerScript()
Definition: runnerscript.cpp:42
Plasma::QueryMatch
A match returned by an AbstractRunner in response to a given RunnerContext.
Definition: querymatch.h:47
package.h
Plasma::RunnerScript::setIgnoredTypes
void setIgnoredTypes(RunnerContext::Types types)
Definition: runnerscript.cpp:87
runnerscript.h
Plasma::RunnerScript::serviceQuery
KService::List serviceQuery(const QString &serviceType, const QString &constraint=QString()) const
Definition: runnerscript.cpp:115
Plasma::RunnerScript::action
QAction * action(const QString &id) const
Definition: runnerscript.cpp:146
Plasma::RunnerScript::description
KPluginInfo description() const
Definition: runnerscript.cpp:188
Plasma::Package::filePath
QString filePath(const char *fileType, const QString &filename) const
Get the path to a given file.
Definition: package.cpp:213
Plasma::RunnerScript::removeAction
void removeAction(const QString &id)
Definition: runnerscript.cpp:139
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:48:34 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

Plasma

Skip menu "Plasma"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdelibs API Reference

Skip menu "kdelibs API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  • kjsembed
  •   WTF
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Nepomuk-Core
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal