Port Core.DataSource to Plasma2

This commit is contained in:
Sebastian Kügler 2013-02-15 03:33:22 +01:00
parent 3781fb6f6d
commit d8f9f8be9b
5 changed files with 19 additions and 21 deletions

View File

@ -13,9 +13,9 @@ set(corebindings_SRCS
# declarativeitemcontainer.cpp # declarativeitemcontainer.cpp
corebindingsplugin.cpp corebindingsplugin.cpp
# dataengineconsumer.cpp # dataengineconsumer.cpp
theme.cpp theme.cpp
# datamodel.cpp # datamodel.cpp
# datasource.cpp datasource.cpp
# runnermodel.cpp # runnermodel.cpp
svgitem.cpp svgitem.cpp
framesvgitem.cpp framesvgitem.cpp

View File

@ -66,7 +66,7 @@ void CoreBindingsPlugin::initializeEngine(QQmlEngine *engine, const char *uri)
registerDataEngineMetaTypes(scriptEngine); registerDataEngineMetaTypes(scriptEngine);
*/ */
qDebug() << "====> org.kde.plasma.core loaded."; //qDebug() << "====> org.kde.plasma.core loaded.";
} }
void CoreBindingsPlugin::registerTypes(const char *uri) void CoreBindingsPlugin::registerTypes(const char *uri)

View File

@ -120,6 +120,6 @@ DataEngine *DataEngineConsumer::remoteDataEngine(const KUrl &location, const QSt
} // namespace Plasma } // namespace Plasma
#include "dataengineconsumer_p.moc" #include "dataengineconsumer.moc"

View File

@ -1,8 +1,9 @@
/* /*
* Copyright 2009 by Alan Alpert <alan.alpert@nokia.com> * Copyright 2009 by Alan Alpert <alan.alpert@nokia.com>
* Copyright 2010 by Ménard Alexis <menard@kde.org> * Copyright 2010 by Ménard Alexis <menard@kde.org>
* Copyright 2010 by Marco MArtin <mart@kde.org> * Copyright 2010 by Marco Martin <mart@kde.org>
* Copyright 2013 by Sebastian Kügler <sebas@kde.org>
*
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as * it under the terms of the GNU Library General Public License as
* published by the Free Software Foundation; either version 2, or * published by the Free Software Foundation; either version 2, or
@ -21,19 +22,13 @@
#include "datasource.h" #include "datasource.h"
#include "qdeclarativeengine.h"
#include "qdeclarativecontext.h"
#include <Plasma/Applet>
namespace Plasma namespace Plasma
{ {
DataSource::DataSource(QObject* parent) DataSource::DataSource(QObject* parent)
: QObject(parent), : QObject(parent),
m_interval(0), m_interval(0),
m_dataEngine(0) m_dataEngine(0),
m_dataEngineConsumer(0)
{ {
setObjectName("DataSource"); setObjectName("DataSource");
} }
@ -98,16 +93,19 @@ void DataSource::setupData()
qDeleteAll(m_services); qDeleteAll(m_services);
m_services.clear(); m_services.clear();
m_dataEngineConsumer = new Plasma::DataEngineConsumer();
Plasma::DataEngine *engine = dataEngine(m_engine); Plasma::DataEngine *engine = dataEngine(m_engine);
if (!engine) { if (!engine) {
kWarning() << "DataEngine" << m_engine << "not found"; qWarning() << "DataEngine" << m_engine << "not found";
return; return;
} }
if (engine != m_dataEngine) { if (engine != m_dataEngine) {
if (m_dataEngine) { if (m_dataEngine) {
m_dataEngine->disconnect(this); m_dataEngine->disconnect(this);
finishedWithEngine(m_dataEngine->pluginName()); // Deleting the consumer triggers the reference counting
delete m_dataEngineConsumer;
m_dataEngineConsumer = 0;
} }
/* /*

View File

@ -2,7 +2,8 @@
* Copyright 2009 by Alan Alpert <alan.alpert@nokia.com> * Copyright 2009 by Alan Alpert <alan.alpert@nokia.com>
* Copyright 2010 by Ménard Alexis <menard@kde.org> * Copyright 2010 by Ménard Alexis <menard@kde.org>
* Copyright 2010 by Marco MArtin <mart@kde.org> * Copyright 2010 by Marco MArtin <mart@kde.org>
* Copyright 2013 by Sebastian Kügler <sebas@kde.org>
*
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as * it under the terms of the GNU Library General Public License as
* published by the Free Software Foundation; either version 2, or * published by the Free Software Foundation; either version 2, or
@ -23,13 +24,11 @@
#define DATASOURCE_H #define DATASOURCE_H
#include <QObject> #include <QObject>
#include <QtQml>
#include <QQmlPropertyMap> #include <QQmlPropertyMap>
#include "dataengineconsumer_p.h" #include <Plasma/DataEngineConsumer>
#include <Plasma/DataEngine> #include <Plasma/DataEngine>
#include <qdeclarative.h>
class QQmlPropertyMap; class QQmlPropertyMap;
@ -134,6 +133,7 @@ private:
QString m_engine; QString m_engine;
QVariantHash m_data; QVariantHash m_data;
Plasma::DataEngine* m_dataEngine; Plasma::DataEngine* m_dataEngine;
Plasma::DataEngineConsumer* m_dataEngineConsumer;
QStringList m_connectedSources; QStringList m_connectedSources;
QStringList m_oldSources; QStringList m_oldSources;
QStringList m_newSources; QStringList m_newSources;