Plasma

dataenginescript.cpp
1 /*
2  SPDX-FileCopyrightText: 2007 Aaron Seigo <[email protected]>
3 
4  SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6 
7 #include "dataenginescript.h"
8 
9 #if PLASMA_BUILD_DEPRECATED_SINCE(5, 83)
10 #include "package.h"
11 #endif
12 #include "private/dataengine_p.h"
13 #include "private/service_p.h"
14 
15 namespace Plasma
16 {
17 class DataEngineScriptPrivate
18 {
19 public:
20  DataEngine *dataEngine;
21 };
22 
24  : ScriptEngine(parent)
25  , d(new DataEngineScriptPrivate)
26 {
27 }
28 
29 DataEngineScript::~DataEngineScript()
30 {
31  delete d;
32 }
33 
35 {
36  d->dataEngine = dataEngine;
37 }
38 
40 {
41  return d->dataEngine;
42 }
43 
45 {
46  return d->dataEngine->containerDict().keys();
47 }
48 
50 {
51  Q_UNUSED(name);
52  return false;
53 }
54 
56 {
57  Q_UNUSED(source);
58  return false;
59 }
60 
62 {
63  Q_ASSERT(d->dataEngine);
64  return new NullService(source, d->dataEngine);
65 }
66 
67 #if PLASMA_BUILD_DEPRECATED_SINCE(5, 83)
69 {
70  Q_ASSERT(d->dataEngine);
71  return d->dataEngine->package().filePath("mainscript");
72 }
73 
75 {
76  Q_ASSERT(d->dataEngine);
77  return d->dataEngine->package();
78 }
79 
81 {
82  return KPluginInfo(metadata());
83 }
84 #endif
85 
87 {
88  Q_ASSERT(d->dataEngine);
89  return d->dataEngine->metadata();
90 }
91 
92 void DataEngineScript::setData(const QString &source, const QString &key, const QVariant &value)
93 {
94  if (d->dataEngine) {
95  d->dataEngine->setData(source, key, value);
96  }
97 }
98 
99 void DataEngineScript::setData(const QString &source, const QVariant &value)
100 {
101  if (d->dataEngine) {
102  d->dataEngine->setData(source, value);
103  }
104 }
105 
106 void DataEngineScript::setData(const QString &source, const DataEngine::Data &values)
107 {
108  if (d->dataEngine) {
109  d->dataEngine->setData(source, values);
110  }
111 }
112 
113 void DataEngineScript::removeAllData(const QString &source)
114 {
115  if (d->dataEngine) {
116  d->dataEngine->removeAllData(source);
117  }
118 }
119 
120 void DataEngineScript::removeData(const QString &source, const QString &key)
121 {
122  if (d->dataEngine) {
123  d->dataEngine->removeData(source, key);
124  }
125 }
126 
127 void DataEngineScript::setMinimumPollingInterval(int minimumMs)
128 {
129  if (d->dataEngine) {
130  d->dataEngine->setMinimumPollingInterval(minimumMs);
131  }
132 }
133 
134 int DataEngineScript::minimumPollingInterval() const
135 {
136  if (d->dataEngine) {
137  return d->dataEngine->minimumPollingInterval();
138  }
139  return 0;
140 }
141 
142 void DataEngineScript::setPollingInterval(uint frequency)
143 {
144  if (d->dataEngine) {
145  d->dataEngine->setPollingInterval(frequency);
146  }
147 }
148 
149 void DataEngineScript::removeAllSources()
150 {
151  if (d->dataEngine) {
152  d->dataEngine->removeAllSources();
153  }
154 }
155 
156 void DataEngineScript::addSource(DataContainer *source)
157 {
158  if (d->dataEngine) {
159  d->dataEngine->addSource(source);
160  }
161 }
162 
163 DataEngine::SourceDict DataEngineScript::containerDict() const
164 {
165  if (d->dataEngine) {
166  return d->dataEngine->containerDict();
167  }
168  return DataEngine::SourceDict();
169 }
170 
171 void DataEngineScript::removeSource(const QString &source)
172 {
173  if (d->dataEngine) {
174  d->dataEngine->removeSource(source);
175  }
176 }
177 
178 void DataEngineScript::updateAllSources()
179 {
180  if (d->dataEngine) {
181  d->dataEngine->updateAllSources();
182  }
183 }
184 
185 void DataEngineScript::forceImmediateUpdateOfAllVisualizations()
186 {
187  if (d->dataEngine) {
188  d->dataEngine->forceImmediateUpdateOfAllVisualizations();
189  }
190 }
191 
192 } // Plasma namespace
193 
194 #include "moc_dataenginescript.cpp"
Data provider for plasmoids (Plasma plugins)
Definition: dataengine.h:50
Namespace for everything in libplasma.
Definition: datamodel.cpp:14
The base class for scripting interfaces to be used in loading plasmoids of a given language.
Definition: scriptengine.h:37
QString mainScript() const override
virtual QStringList sources() const
virtual bool updateSourceEvent(const QString &source)
Called when the script should refresh the data contained in a given source.
DataEngine * dataEngine() const
Returns the Plasma::DataEngine associated with this script component.
KPluginInfo description() const
This class provides a generic API for write access to settings or services.
Definition: service.h:77
KPluginMetaData metadata() const
DataEngineScript(QObject *parent=nullptr)
Default constructor for a DataEngineScript.
virtual Service * serviceForSource(const QString &source)
object representing an installed Plasma package
Definition: package.h:76
virtual bool sourceRequestEvent(const QString &name)
Called when the script should create a source that does not currently exist.
void setDataEngine(DataEngine *dataEngine)
Sets the Plasma::DataEngine associated with this DataEngineScript.
Package package() const override
QVector< V > values(const QMultiHash< K, V > &c)
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Tue Feb 7 2023 04:15:01 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.