From d8f9f8be9bfabc25899a269b0795999e36feb740 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20K=C3=BCgler?= Date: Fri, 15 Feb 2013 03:33:22 +0100 Subject: [PATCH] Port Core.DataSource to Plasma2 --- src/declarativeimports/core/CMakeLists.txt | 4 ++-- .../core/corebindingsplugin.cpp | 2 +- .../core/dataengineconsumer.cpp | 2 +- src/declarativeimports/core/datasource.cpp | 22 +++++++++---------- src/declarativeimports/core/datasource.h | 10 ++++----- 5 files changed, 19 insertions(+), 21 deletions(-) diff --git a/src/declarativeimports/core/CMakeLists.txt b/src/declarativeimports/core/CMakeLists.txt index 339c69285..de2a8d8ae 100644 --- a/src/declarativeimports/core/CMakeLists.txt +++ b/src/declarativeimports/core/CMakeLists.txt @@ -13,9 +13,9 @@ set(corebindings_SRCS # declarativeitemcontainer.cpp corebindingsplugin.cpp # dataengineconsumer.cpp - theme.cpp + theme.cpp # datamodel.cpp -# datasource.cpp + datasource.cpp # runnermodel.cpp svgitem.cpp framesvgitem.cpp diff --git a/src/declarativeimports/core/corebindingsplugin.cpp b/src/declarativeimports/core/corebindingsplugin.cpp index 59839655d..9360f51b3 100644 --- a/src/declarativeimports/core/corebindingsplugin.cpp +++ b/src/declarativeimports/core/corebindingsplugin.cpp @@ -66,7 +66,7 @@ void CoreBindingsPlugin::initializeEngine(QQmlEngine *engine, const char *uri) registerDataEngineMetaTypes(scriptEngine); */ - qDebug() << "====> org.kde.plasma.core loaded."; + //qDebug() << "====> org.kde.plasma.core loaded."; } void CoreBindingsPlugin::registerTypes(const char *uri) diff --git a/src/declarativeimports/core/dataengineconsumer.cpp b/src/declarativeimports/core/dataengineconsumer.cpp index 2120e1c41..562a41ccc 100644 --- a/src/declarativeimports/core/dataengineconsumer.cpp +++ b/src/declarativeimports/core/dataengineconsumer.cpp @@ -120,6 +120,6 @@ DataEngine *DataEngineConsumer::remoteDataEngine(const KUrl &location, const QSt } // namespace Plasma -#include "dataengineconsumer_p.moc" +#include "dataengineconsumer.moc" diff --git a/src/declarativeimports/core/datasource.cpp b/src/declarativeimports/core/datasource.cpp index b9f74a285..38118c5e8 100644 --- a/src/declarativeimports/core/datasource.cpp +++ b/src/declarativeimports/core/datasource.cpp @@ -1,8 +1,9 @@ /* * Copyright 2009 by Alan Alpert * Copyright 2010 by Ménard Alexis - * Copyright 2010 by Marco MArtin - + * Copyright 2010 by Marco Martin + * Copyright 2013 by Sebastian Kügler + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Library General Public License as * published by the Free Software Foundation; either version 2, or @@ -21,19 +22,13 @@ #include "datasource.h" -#include "qdeclarativeengine.h" -#include "qdeclarativecontext.h" - - -#include - - namespace Plasma { DataSource::DataSource(QObject* parent) : QObject(parent), m_interval(0), - m_dataEngine(0) + m_dataEngine(0), + m_dataEngineConsumer(0) { setObjectName("DataSource"); } @@ -98,16 +93,19 @@ void DataSource::setupData() qDeleteAll(m_services); m_services.clear(); + m_dataEngineConsumer = new Plasma::DataEngineConsumer(); Plasma::DataEngine *engine = dataEngine(m_engine); if (!engine) { - kWarning() << "DataEngine" << m_engine << "not found"; + qWarning() << "DataEngine" << m_engine << "not found"; return; } if (engine != m_dataEngine) { if (m_dataEngine) { m_dataEngine->disconnect(this); - finishedWithEngine(m_dataEngine->pluginName()); + // Deleting the consumer triggers the reference counting + delete m_dataEngineConsumer; + m_dataEngineConsumer = 0; } /* diff --git a/src/declarativeimports/core/datasource.h b/src/declarativeimports/core/datasource.h index f5801f345..2f9da8629 100644 --- a/src/declarativeimports/core/datasource.h +++ b/src/declarativeimports/core/datasource.h @@ -2,7 +2,8 @@ * Copyright 2009 by Alan Alpert * Copyright 2010 by Ménard Alexis * Copyright 2010 by Marco MArtin - + * Copyright 2013 by Sebastian Kügler + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Library General Public License as * published by the Free Software Foundation; either version 2, or @@ -23,13 +24,11 @@ #define DATASOURCE_H #include - - +#include #include -#include "dataengineconsumer_p.h" +#include #include -#include class QQmlPropertyMap; @@ -134,6 +133,7 @@ private: QString m_engine; QVariantHash m_data; Plasma::DataEngine* m_dataEngine; + Plasma::DataEngineConsumer* m_dataEngineConsumer; QStringList m_connectedSources; QStringList m_oldSources; QStringList m_newSources;