Plasma5Support

dataengineconsumer.cpp
1/*
2 SPDX-FileCopyrightText: 2005 Aaron Seigo <aseigo@kde.org>
3 SPDX-FileCopyrightText: 2007 Riccardo Iaconelli <riccardo@kde.org>
4 SPDX-FileCopyrightText: 2008 Ménard Alexis <darktears31@gmail.com>
5
6 SPDX-License-Identifier: LGPL-2.0-or-later
7*/
8
9#include "dataengineconsumer.h"
10#include "private/dataengineconsumer_p.h"
11
12#include <QSet>
13
14#include <QDebug>
15
16#include "debug_p.h"
17#include "private/dataenginemanager_p.h"
18#include "servicejob.h"
19
20namespace Plasma5Support
21{
22void DataEngineConsumerPrivate::slotJobFinished(Plasma5Support::ServiceJob *job)
23{
24#ifndef NDEBUG
25 // qCDebug(LOG_PLASMA) << "engine ready!";
26 QString engineName = job->parameters().value(QStringLiteral("EngineName")).toString();
27 QString location = job->destination();
28 QPair<QString, QString> pair(location, engineName);
29 // qCDebug(LOG_PLASMA) << "pair = " << pair;
30#endif
31}
32
33void DataEngineConsumerPrivate::slotServiceReady(Plasma5Support::Service *plasmoidService)
34{
35 QVariantMap op = plasmoidService->operationDescription(QStringLiteral("DataEngine"));
36 op[QStringLiteral("EngineName")] = engineNameForService.value(plasmoidService);
37 plasmoidService->startOperationCall(op);
38 connect(plasmoidService, SIGNAL(finished(Plasma5Support::ServiceJob *)), this, SLOT(slotJobFinished(Plasma5Support::ServiceJob *)));
39}
40
42 : d(new DataEngineConsumerPrivate)
43{
44}
45
46DataEngineConsumer::~DataEngineConsumer()
47{
48 for (const QString &engine : std::as_const(d->loadedEngines)) {
49 DataEngineManager::self()->unloadEngine(engine);
50 }
51
52 delete d;
53}
54
56{
57 if (d->loadedEngines.contains(name)) {
58 DataEngine *engine = DataEngineManager::self()->engine(name);
59 if (engine->isValid()) {
60 return engine;
61 }
62 }
63
64 DataEngine *engine = DataEngineManager::self()->loadEngine(name);
65 d->loadedEngines.insert(name);
66 return engine;
67}
68
69} // namespace Plasma5Support
70
71#include "private/moc_dataengineconsumer_p.cpp"
DataEngineConsumer()
Constructs a DataEngineConsumer.
DataEngine * dataEngine(const QString &name)
Returns a Plasma5Support::DataEngine.
Data provider for plasmoids (Plasma plugins)
Definition dataengine.h:45
bool isValid() const
Returns true if this engine is valid, otherwise returns false.
This class provides jobs for use with Plasma5Support::Service.
Definition servicejob.h:39
QVariantMap parameters() const
This class provides a generic API for write access to settings or services.
Definition service.h:78
Q_INVOKABLE QVariantMap operationDescription(const QString &operationName)
Retrieves the parameters for a given operation.
Definition service.cpp:61
Q_INVOKABLE ServiceJob * startOperationCall(const QVariantMap &description, QObject *parent=nullptr)
Called to create a ServiceJob which is associated with a given operation and parameter set.
Definition service.cpp:75
QVariant location(const QVariant &res)
Namespace for everything in libplasma.
Definition datamodel.cpp:15
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:08:57 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.