7#include "dataenginemanager_p.h"
14#include <QStandardPaths>
16#include "datacontainer.h"
18#include "pluginloader.h"
19#include "private/datacontainer_p.h"
20#include "private/dataengine_p.h"
37class DataEngineManagerPrivate
40 DataEngineManagerPrivate()
45 ~DataEngineManagerPrivate()
47 for (Plasma5Support::DataEngine *engine : std::as_const(engines)) {
54 DataEngine *nullEngine()
57 nullEng =
new NullEngine;
63 DataEngine::Dict engines;
67class DataEngineManagerSingleton
70 DataEngineManager self;
73Q_GLOBAL_STATIC(DataEngineManagerSingleton, privateDataEngineManagerSelf)
75DataEngineManager *DataEngineManager::self()
77 return &privateDataEngineManagerSelf()->self;
80DataEngineManager::DataEngineManager()
81 : d(new DataEngineManagerPrivate)
86DataEngineManager::~DataEngineManager()
94 return d->nullEngine();
97 Plasma5Support::DataEngine::Dict::const_iterator it = d->engines.constFind(name);
98 if (it != d->engines.constEnd()) {
102 return d->nullEngine();
108 qCDebug(LOG_PLASMA5SUPPORT) <<
"Asked an engine with empty name";
109 return d->nullEngine();
111 Plasma5Support::DataEngine::Dict::const_iterator it = d->engines.constFind(name);
113 if (it != d->engines.constEnd()) {
114 DataEngine *engine = *it;
120 const KPluginMetaData data(QLatin1String(
"plasma5support/dataengine/plasma_engine_") + name);
121 DataEngine *engine = KPluginFactory::instantiatePlugin<Plasma5Support::DataEngine>(data).plugin;
123 qCDebug(LOG_PLASMA5SUPPORT) <<
"Can't find a dataengine named" <<
name;
124 return d->nullEngine();
127 d->engines[
name] = engine;
131void DataEngineManager::unloadEngine(
const QString &name)
133 Plasma5Support::DataEngine::Dict::iterator it = d->engines.find(name);
135 if (it != d->engines.end()) {
136 Plasma5Support::DataEngine *engine = *it;
139 if (!engine->d->isUsed()) {
140 d->engines.erase(it);
158 QHashIterator<QString, DataEngine *> it(d->engines);
160 while (it.hasNext()) {
162 DataEngine *engine = it.value();
163 out <<
"DataEngine: " << it.key() <<
' ' << engine <<
'\n';
164 out <<
" Claimed # of sources: " << engine->sources().count() <<
'\n';
165 out <<
" Actual # of sources: " << engine->containerDict().count() <<
'\n';
166 out <<
"\n Source Details" <<
'\n';
168 const auto lst = engine->containerDict();
169 for (DataContainer *dc : lst) {
170 out <<
" * " << dc->objectName() <<
'\n';
171 out <<
" Data count: " << dc->d->data.count() <<
'\n';
172 out <<
" Stored: " << dc->isStorageEnabled() <<
" \n";
173 const int directs = dc->receivers(SIGNAL(dataUpdated(QString, Plasma5Support::DataEngine::Data)));
175 out <<
" Direction Connections: " << directs <<
" \n";
178 const int relays = dc->d->relays.count();
180 out <<
" Relays: " << dc->d->relays.count() <<
'\n';
182 for (SignalRelay *relay : std::as_const(dc->d->relays)) {
185 out <<
" Relay Timeouts: " << times <<
" \n";
198#include "moc_dataenginemanager_p.cpp"
Data provider for plasmoids (Plasma plugins)
void setValid(bool valid)
Sets whether or not this engine is valid, e.g.
DataEngine(const KPluginMetaData &plugin, QObject *parent=nullptr)
Constructor.
QString path(const QString &relativePath)
QString name(StandardAction id)
Namespace for everything in libplasma.
QDateTime currentDateTime()
QObject * parent() const const
QString writableLocation(StandardLocation type)
QString & append(QChar ch)
bool isEmpty() const const
QString number(double n, char format, int precision)