From a2206eddda087b0b585008c7034a4c97266e3760 Mon Sep 17 00:00:00 2001 From: Rob Scheepmaker Date: Thu, 3 Sep 2009 00:12:57 +0000 Subject: [PATCH] Fix the mutliple inheritence from QObject issue... people having this problem: rejoice! svn path=/trunk/KDE/kdelibs/; revision=1019153 --- private/dataengineconsumer.cpp | 90 ++++++++++++++++++++-------------- private/dataengineconsumer_p.h | 27 +++++++--- 2 files changed, 73 insertions(+), 44 deletions(-) diff --git a/private/dataengineconsumer.cpp b/private/dataengineconsumer.cpp index 5fbcb6cf2..0a6faa90c 100644 --- a/private/dataengineconsumer.cpp +++ b/private/dataengineconsumer.cpp @@ -32,6 +32,56 @@ namespace Plasma { +ServiceMonitor::ServiceMonitor(DataEngineConsumer *consumer) + : m_consumer(consumer) +{ +} + +ServiceMonitor::~ServiceMonitor() +{ +} + +void ServiceMonitor::slotJobFinished(Plasma::ServiceJob *job) +{ + kDebug() << "engine ready!"; + QString engineName = job->parameters()["EngineName"].toString(); + QString location = job->destination(); + QPair pair(location, engineName); + kDebug() << "pair = " << pair; + if (!m_consumer->m_remoteEngines.contains(pair)) { + kDebug() << "engine doesnt exist yet!"; + } else { + KUrl engineLocation(location); + engineLocation.setFileName(job->result().toString()); + kDebug() << "setting location : " + << engineLocation.prettyUrl(); + m_consumer->m_remoteEngines[pair]->setLocation(engineLocation); + } +} + +void ServiceMonitor::slotServiceReady(Plasma::Service *plasmoidService) +{ + kDebug() << "service ready!"; + if (!m_consumer->m_engineNameForService.contains(plasmoidService)) { + kDebug() << "no engine name for service!"; + kDebug() << "amount of services in map: " << m_consumer->m_engineNameForService.count(); + } else { + kDebug() << "value = " << m_consumer->m_engineNameForService.value(plasmoidService); + } + + kDebug() << "requesting dataengine!"; + KConfigGroup op = plasmoidService->operationDescription("DataEngine"); + op.writeEntry("EngineName", m_consumer->m_engineNameForService.value(plasmoidService)); + plasmoidService->startOperationCall(op); + connect(plasmoidService, SIGNAL(finished(Plasma::ServiceJob*)), + this, SLOT(slotJobFinished(Plasma::ServiceJob*))); +} + +DataEngineConsumer::DataEngineConsumer() + : m_monitor(new ServiceMonitor(this)) +{ +} + DataEngineConsumer::~DataEngineConsumer() { foreach (const QString &engine, m_loadedEngines) { @@ -69,47 +119,11 @@ DataEngine *DataEngineConsumer::remoteDataEngine(const KUrl &location, const QSt plasmoidService->setDestination(location.prettyUrl()); m_engineNameForService[plasmoidService] = name; kDebug() << "name = " << name; - connect(plasmoidService, SIGNAL(serviceReady(Plasma::Service*)), - this, SLOT(slotServiceReady(Plasma::Service*))); + QObject::connect(plasmoidService, SIGNAL(serviceReady(Plasma::Service*)), + m_monitor, SLOT(slotServiceReady(Plasma::Service*))); return engine; } -void DataEngineConsumer::slotJobFinished(Plasma::ServiceJob *job) -{ - kDebug() << "engine ready!"; - QString engineName = job->parameters()["EngineName"].toString(); - QString location = job->destination(); - QPair pair(location, engineName); - kDebug() << "pair = " << pair; - if (!m_remoteEngines.contains(pair)) { - kDebug() << "engine doesnt exist yet!"; - } else { - KUrl engineLocation(location); - engineLocation.setFileName(job->result().toString()); - kDebug() << "setting location : " - << engineLocation.prettyUrl(); - m_remoteEngines[pair]->setLocation(engineLocation); - } -} - -void DataEngineConsumer::slotServiceReady(Plasma::Service *plasmoidService) -{ - kDebug() << "service ready!"; - if (!m_engineNameForService.contains(plasmoidService)) { - kDebug() << "no engine name for service!"; - kDebug() << "amount of services in map: " << m_engineNameForService.count(); - } else { - kDebug() << "value = " << m_engineNameForService.value(plasmoidService); - } - - kDebug() << "requesting dataengine!"; - KConfigGroup op = plasmoidService->operationDescription("DataEngine"); - op.writeEntry("EngineName", m_engineNameForService.value(plasmoidService)); - //m_engineNameForService.remove(service); - plasmoidService->startOperationCall(op); - connect(plasmoidService, SIGNAL(finished(Plasma::ServiceJob*)), - this, SLOT(slotJobFinished(Plasma::ServiceJob*))); -} } // namespace Plasma diff --git a/private/dataengineconsumer_p.h b/private/dataengineconsumer_p.h index e35746cc3..37f09c240 100644 --- a/private/dataengineconsumer_p.h +++ b/private/dataengineconsumer_p.h @@ -33,23 +33,38 @@ namespace Plasma { -class DataEngineConsumer : public QObject +class DataEngineConsumer; + +class ServiceMonitor : public QObject { Q_OBJECT - public: + ServiceMonitor(DataEngineConsumer *consumer); + ~ServiceMonitor(); + +public Q_SLOTS: + void slotJobFinished(Plasma::ServiceJob *job); + void slotServiceReady(Plasma::Service *service); + +private: + DataEngineConsumer *m_consumer; +}; + +class DataEngineConsumer +{ +public: + DataEngineConsumer(); ~DataEngineConsumer(); DataEngine *dataEngine(const QString &name); DataEngine *remoteDataEngine(const KUrl &location, const QString &name); -private Q_SLOTS: - void slotJobFinished(Plasma::ServiceJob *job); - void slotServiceReady(Plasma::Service *service); - private: QSet m_loadedEngines; QMap, RemoteDataEngine*> m_remoteEngines; QMap m_engineNameForService; + ServiceMonitor *m_monitor; + + friend class ServiceMonitor; }; } // namespace Plasma