Fix the mutliple inheritence from QObject issue... people having this

problem: rejoice!

svn path=/trunk/KDE/kdelibs/; revision=1019153
This commit is contained in:
Rob Scheepmaker 2009-09-03 00:12:57 +00:00
parent 5b160ac802
commit a2206eddda
2 changed files with 73 additions and 44 deletions

View File

@ -32,6 +32,56 @@
namespace Plasma 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<QString, QString> 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() DataEngineConsumer::~DataEngineConsumer()
{ {
foreach (const QString &engine, m_loadedEngines) { foreach (const QString &engine, m_loadedEngines) {
@ -69,47 +119,11 @@ DataEngine *DataEngineConsumer::remoteDataEngine(const KUrl &location, const QSt
plasmoidService->setDestination(location.prettyUrl()); plasmoidService->setDestination(location.prettyUrl());
m_engineNameForService[plasmoidService] = name; m_engineNameForService[plasmoidService] = name;
kDebug() << "name = " << name; kDebug() << "name = " << name;
connect(plasmoidService, SIGNAL(serviceReady(Plasma::Service*)), QObject::connect(plasmoidService, SIGNAL(serviceReady(Plasma::Service*)),
this, SLOT(slotServiceReady(Plasma::Service*))); m_monitor, SLOT(slotServiceReady(Plasma::Service*)));
return engine; return engine;
} }
void DataEngineConsumer::slotJobFinished(Plasma::ServiceJob *job)
{
kDebug() << "engine ready!";
QString engineName = job->parameters()["EngineName"].toString();
QString location = job->destination();
QPair<QString, QString> 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 } // namespace Plasma

View File

@ -33,23 +33,38 @@
namespace Plasma namespace Plasma
{ {
class DataEngineConsumer : public QObject class DataEngineConsumer;
class ServiceMonitor : public QObject
{ {
Q_OBJECT Q_OBJECT
public: 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(); ~DataEngineConsumer();
DataEngine *dataEngine(const QString &name); DataEngine *dataEngine(const QString &name);
DataEngine *remoteDataEngine(const KUrl &location, 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: private:
QSet<QString> m_loadedEngines; QSet<QString> m_loadedEngines;
QMap<QPair<QString, QString>, RemoteDataEngine*> m_remoteEngines; QMap<QPair<QString, QString>, RemoteDataEngine*> m_remoteEngines;
QMap<Service*, QString> m_engineNameForService; QMap<Service*, QString> m_engineNameForService;
ServiceMonitor *m_monitor;
friend class ServiceMonitor;
}; };
} // namespace Plasma } // namespace Plasma