DataSource -> DataContainer, so it's more obvious that it isn't the -source- of the data.
the api remains the same however. svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=691134
This commit is contained in:
parent
45f1406a2b
commit
26b3b62ed7
@ -15,9 +15,9 @@ set(plasma_LIB_SRCS
|
|||||||
applet.cpp
|
applet.cpp
|
||||||
configxml.cpp
|
configxml.cpp
|
||||||
corona.cpp
|
corona.cpp
|
||||||
|
datacontainer.cpp
|
||||||
dataengine.cpp
|
dataengine.cpp
|
||||||
dataenginemanager.cpp
|
dataenginemanager.cpp
|
||||||
datasource.cpp
|
|
||||||
packages.cpp
|
packages.cpp
|
||||||
phase.cpp
|
phase.cpp
|
||||||
plasma.cpp
|
plasma.cpp
|
||||||
@ -61,9 +61,9 @@ install(FILES
|
|||||||
applet.h
|
applet.h
|
||||||
configxml.h
|
configxml.h
|
||||||
corona.h
|
corona.h
|
||||||
|
datacontainer.h
|
||||||
dataengine.h
|
dataengine.h
|
||||||
dataenginemanager.h
|
dataenginemanager.h
|
||||||
datasource.h
|
|
||||||
phase.h
|
phase.h
|
||||||
plasma.h
|
plasma.h
|
||||||
plasma_export.h
|
plasma_export.h
|
||||||
@ -94,9 +94,9 @@ install(FILES
|
|||||||
includes/Packager
|
includes/Packager
|
||||||
includes/PackageStructure
|
includes/PackageStructure
|
||||||
includes/Theme
|
includes/Theme
|
||||||
|
includes/DataContainer
|
||||||
includes/DataEngine
|
includes/DataEngine
|
||||||
includes/DataEngineManager
|
includes/DataEngineManager
|
||||||
includes/DataSource
|
|
||||||
includes/Svg
|
includes/Svg
|
||||||
DESTINATION ${INCLUDE_INSTALL_DIR}/KDE/Plasma)
|
DESTINATION ${INCLUDE_INSTALL_DIR}/KDE/Plasma)
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "datasource.h"
|
#include "datacontainer.h"
|
||||||
|
|
||||||
#include <QAtomic>
|
#include <QAtomic>
|
||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
@ -26,7 +26,7 @@
|
|||||||
namespace Plasma
|
namespace Plasma
|
||||||
{
|
{
|
||||||
|
|
||||||
class DataSource::Private
|
class DataContainer::Private
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Private()
|
Private()
|
||||||
@ -38,23 +38,23 @@ class DataSource::Private
|
|||||||
bool dirty : 1;
|
bool dirty : 1;
|
||||||
};
|
};
|
||||||
|
|
||||||
DataSource::DataSource(QObject* parent)
|
DataContainer::DataContainer(QObject* parent)
|
||||||
: QObject(parent),
|
: QObject(parent),
|
||||||
d(new Private())
|
d(new Private())
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
DataSource::~DataSource()
|
DataContainer::~DataContainer()
|
||||||
{
|
{
|
||||||
delete d;
|
delete d;
|
||||||
}
|
}
|
||||||
|
|
||||||
const DataEngine::Data DataSource::data() const
|
const DataEngine::Data DataContainer::data() const
|
||||||
{
|
{
|
||||||
return d->data;
|
return d->data;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DataSource::setData(const QString& key, const QVariant& value)
|
void DataContainer::setData(const QString& key, const QVariant& value)
|
||||||
{
|
{
|
||||||
if (value.isNull() || !value.isValid()) {
|
if (value.isNull() || !value.isValid()) {
|
||||||
if (!d->data.contains(key)) {
|
if (!d->data.contains(key)) {
|
||||||
@ -69,7 +69,7 @@ void DataSource::setData(const QString& key, const QVariant& value)
|
|||||||
d->dirty = true;
|
d->dirty = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DataSource::clearData()
|
void DataContainer::clearData()
|
||||||
{
|
{
|
||||||
if (d->data.count() < 1) {
|
if (d->data.count() < 1) {
|
||||||
// avoid an update if we don't have any data anyways
|
// avoid an update if we don't have any data anyways
|
||||||
@ -80,7 +80,7 @@ void DataSource::clearData()
|
|||||||
d->dirty = true;
|
d->dirty = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DataSource::checkForUpdate()
|
void DataContainer::checkForUpdate()
|
||||||
{
|
{
|
||||||
if (d->dirty) {
|
if (d->dirty) {
|
||||||
emit updated(objectName(), d->data);
|
emit updated(objectName(), d->data);
|
||||||
@ -88,14 +88,14 @@ void DataSource::checkForUpdate()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DataSource::connectNotify(const char *signal)
|
void DataContainer::connectNotify(const char *signal)
|
||||||
{
|
{
|
||||||
if (QLatin1String(signal) == QMetaObject::normalizedSignature(SIGNAL(updated(QString, Plasma::DataEngine::Data))).constData()) {
|
if (QLatin1String(signal) == QMetaObject::normalizedSignature(SIGNAL(updated(QString, Plasma::DataEngine::Data))).constData()) {
|
||||||
d->connectCount.ref();
|
d->connectCount.ref();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DataSource::disconnectNotify(const char *signal)
|
void DataContainer::disconnectNotify(const char *signal)
|
||||||
{
|
{
|
||||||
if (QLatin1String(signal) == QMetaObject::normalizedSignature(SIGNAL(updated(QString, Plasma::DataEngine::Data))).constData()) {
|
if (QLatin1String(signal) == QMetaObject::normalizedSignature(SIGNAL(updated(QString, Plasma::DataEngine::Data))).constData()) {
|
||||||
if (d->connectCount > 0) {
|
if (d->connectCount > 0) {
|
||||||
@ -111,5 +111,5 @@ void DataSource::disconnectNotify(const char *signal)
|
|||||||
|
|
||||||
} // Plasma namespace
|
} // Plasma namespace
|
||||||
|
|
||||||
#include "datasource.moc"
|
#include "datacontainer.moc"
|
||||||
|
|
@ -16,8 +16,8 @@
|
|||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef PLASMA_DATASOURCE_H
|
#ifndef PLASMA_DATACONTAINER_H
|
||||||
#define PLASMA_DATASOURCE_H
|
#define PLASMA_DATACONTAINER_H
|
||||||
|
|
||||||
#include <QtCore/QHash>
|
#include <QtCore/QHash>
|
||||||
#include <QtCore/QObject>
|
#include <QtCore/QObject>
|
||||||
@ -30,15 +30,15 @@ namespace Plasma
|
|||||||
/**
|
/**
|
||||||
* @brief A set of data exported via a DataEngine
|
* @brief A set of data exported via a DataEngine
|
||||||
*
|
*
|
||||||
* Plasma::DataSource wraps the data exported by a DataEngine
|
* Plasma::DataContainer wraps the data exported by a DataEngine
|
||||||
* implementation, providing a generic wrapper for the data.
|
* implementation, providing a generic wrapper for the data.
|
||||||
*
|
*
|
||||||
* A DataSource may have zero or more associated pieces of data which
|
* A DataContainer may have zero or more associated pieces of data which
|
||||||
* are keyed by strings. The data itself is stored as QVariants. This allows
|
* are keyed by strings. The data itself is stored as QVariants. This allows
|
||||||
* easy and flexible retrieval of the information associated with this object
|
* easy and flexible retrieval of the information associated with this object
|
||||||
* without writing DataSource or DataEngine specific code in visualizations.
|
* without writing DataContainer or DataEngine specific code in visualizations.
|
||||||
**/
|
**/
|
||||||
class PLASMA_EXPORT DataSource : public QObject
|
class PLASMA_EXPORT DataContainer : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
@ -46,14 +46,14 @@ class PLASMA_EXPORT DataSource : public QObject
|
|||||||
//typedef QHash<QString, DataEngine::SourceDict> Grouping;
|
//typedef QHash<QString, DataEngine::SourceDict> Grouping;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs a default DataSource, which has no name or data
|
* Constructs a default DataContainer, which has no name or data
|
||||||
* associated with it
|
* associated with it
|
||||||
**/
|
**/
|
||||||
explicit DataSource(QObject* parent = 0);
|
explicit DataContainer(QObject* parent = 0);
|
||||||
virtual ~DataSource();
|
virtual ~DataContainer();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the data for this DataSource
|
* Returns the data for this DataContainer
|
||||||
**/
|
**/
|
||||||
const DataEngine::Data data() const;
|
const DataEngine::Data data() const;
|
||||||
|
|
@ -24,7 +24,7 @@
|
|||||||
|
|
||||||
#include <KDebug>
|
#include <KDebug>
|
||||||
|
|
||||||
#include "datasource.h"
|
#include "datacontainer.h"
|
||||||
|
|
||||||
namespace Plasma
|
namespace Plasma
|
||||||
{
|
{
|
||||||
@ -41,13 +41,13 @@ class DataEngine::Private
|
|||||||
updateTimer->setSingleShot(true);
|
updateTimer->setSingleShot(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
DataSource* source(const QString& sourceName, bool createWhenMissing = true)
|
DataContainer* source(const QString& sourceName, bool createWhenMissing = true)
|
||||||
{
|
{
|
||||||
DataEngine::SourceDict::const_iterator it = sources.find(sourceName);
|
DataEngine::SourceDict::const_iterator it = sources.find(sourceName);
|
||||||
if (it != sources.constEnd()) {
|
if (it != sources.constEnd()) {
|
||||||
DataSource* s = it.value();
|
DataContainer* s = it.value();
|
||||||
if (limit > 0) {
|
if (limit > 0) {
|
||||||
QQueue<DataSource*>::iterator it = sourceQueue.begin();
|
QQueue<DataContainer*>::iterator it = sourceQueue.begin();
|
||||||
while (it != sourceQueue.end()) {
|
while (it != sourceQueue.end()) {
|
||||||
if (*it == s) {
|
if (*it == s) {
|
||||||
sourceQueue.erase(it);
|
sourceQueue.erase(it);
|
||||||
@ -65,9 +65,9 @@ class DataEngine::Private
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* kDebug() << "DataEngine " << engine->objectName()
|
/* kDebug() << "DataEngine " << engine->objectName()
|
||||||
<< ": could not find DataSource " << sourceName
|
<< ": could not find DataContainer " << sourceName
|
||||||
<< ", creating" << endl;*/
|
<< ", creating" << endl;*/
|
||||||
DataSource* s = new DataSource(engine);
|
DataContainer* s = new DataContainer(engine);
|
||||||
s->setObjectName(sourceName);
|
s->setObjectName(sourceName);
|
||||||
sources.insert(sourceName, s);
|
sources.insert(sourceName, s);
|
||||||
|
|
||||||
@ -82,7 +82,7 @@ class DataEngine::Private
|
|||||||
void trimQueue()
|
void trimQueue()
|
||||||
{
|
{
|
||||||
while (sourceQueue.count() >= limit) {
|
while (sourceQueue.count() >= limit) {
|
||||||
DataSource* punted = sourceQueue.dequeue();
|
DataContainer* punted = sourceQueue.dequeue();
|
||||||
engine->removeSource(punted->objectName());
|
engine->removeSource(punted->objectName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -103,7 +103,7 @@ class DataEngine::Private
|
|||||||
|
|
||||||
QAtomic ref;
|
QAtomic ref;
|
||||||
DataEngine::SourceDict sources;
|
DataEngine::SourceDict sources;
|
||||||
QQueue<DataSource*> sourceQueue;
|
QQueue<DataContainer*> sourceQueue;
|
||||||
DataEngine* engine;
|
DataEngine* engine;
|
||||||
QTimer* updateTimer;
|
QTimer* updateTimer;
|
||||||
QString icon;
|
QString icon;
|
||||||
@ -135,7 +135,7 @@ QStringList DataEngine::sources() const
|
|||||||
|
|
||||||
void DataEngine::connectSource(const QString& source, QObject* visualization) const
|
void DataEngine::connectSource(const QString& source, QObject* visualization) const
|
||||||
{
|
{
|
||||||
DataSource* s = d->source(source, false);
|
DataContainer* s = d->source(source, false);
|
||||||
|
|
||||||
if (!s) {
|
if (!s) {
|
||||||
// we didn't find a data source, so give the engine an opportunity to make one
|
// we didn't find a data source, so give the engine an opportunity to make one
|
||||||
@ -162,7 +162,7 @@ void DataEngine::connectSource(const QString& source, QObject* visualization) co
|
|||||||
|
|
||||||
void DataEngine::disconnectSource(const QString& source, QObject* visualization) const
|
void DataEngine::disconnectSource(const QString& source, QObject* visualization) const
|
||||||
{
|
{
|
||||||
DataSource* s = d->source(source, false);
|
DataContainer* s = d->source(source, false);
|
||||||
|
|
||||||
if (!s) {
|
if (!s) {
|
||||||
return;
|
return;
|
||||||
@ -174,12 +174,12 @@ void DataEngine::disconnectSource(const QString& source, QObject* visualization)
|
|||||||
|
|
||||||
void DataEngine::connectAllSources(QObject* visualization) const
|
void DataEngine::connectAllSources(QObject* visualization) const
|
||||||
{
|
{
|
||||||
foreach (const DataSource* s, d->sources) {
|
foreach (const DataContainer* s, d->sources) {
|
||||||
connect(s, SIGNAL(updated(QString,Plasma::DataEngine::Data)),
|
connect(s, SIGNAL(updated(QString,Plasma::DataEngine::Data)),
|
||||||
visualization, SLOT(updated(QString,Plasma::DataEngine::Data)));
|
visualization, SLOT(updated(QString,Plasma::DataEngine::Data)));
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (const DataSource* s, d->sources) {
|
foreach (const DataContainer* s, d->sources) {
|
||||||
QMetaObject::invokeMethod(visualization,
|
QMetaObject::invokeMethod(visualization,
|
||||||
SLOT(updated(QString,Plasma::DataEngine::Data)),
|
SLOT(updated(QString,Plasma::DataEngine::Data)),
|
||||||
Q_ARG(QString, s->objectName()),
|
Q_ARG(QString, s->objectName()),
|
||||||
@ -191,7 +191,7 @@ DataEngine::Data DataEngine::query(const QString& source) const
|
|||||||
{
|
{
|
||||||
Q_UNUSED(source)
|
Q_UNUSED(source)
|
||||||
|
|
||||||
DataSource* s = d->source(source);
|
DataContainer* s = d->source(source);
|
||||||
return s->data();
|
return s->data();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -220,14 +220,14 @@ void DataEngine::setData(const QString& source, const QVariant& value)
|
|||||||
|
|
||||||
void DataEngine::setData(const QString& source, const QString& key, const QVariant& value)
|
void DataEngine::setData(const QString& source, const QString& key, const QVariant& value)
|
||||||
{
|
{
|
||||||
DataSource* s = d->source(source);
|
DataContainer* s = d->source(source);
|
||||||
s->setData(key, value);
|
s->setData(key, value);
|
||||||
d->queueUpdate();
|
d->queueUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DataEngine::setData(const QString &source, const Data &data)
|
void DataEngine::setData(const QString &source, const Data &data)
|
||||||
{
|
{
|
||||||
DataSource *s = d->source(source);
|
DataContainer *s = d->source(source);
|
||||||
Data::const_iterator it = data.constBegin();
|
Data::const_iterator it = data.constBegin();
|
||||||
while (it != data.constEnd()) {
|
while (it != data.constEnd()) {
|
||||||
s->setData(it.key(), it.value());
|
s->setData(it.key(), it.value());
|
||||||
@ -239,7 +239,7 @@ void DataEngine::setData(const QString &source, const Data &data)
|
|||||||
|
|
||||||
void DataEngine::clearData(const QString& source)
|
void DataEngine::clearData(const QString& source)
|
||||||
{
|
{
|
||||||
DataSource* s = d->source(source, false);
|
DataContainer* s = d->source(source, false);
|
||||||
if (s) {
|
if (s) {
|
||||||
s->clearData();
|
s->clearData();
|
||||||
d->queueUpdate();
|
d->queueUpdate();
|
||||||
@ -248,14 +248,14 @@ void DataEngine::clearData(const QString& source)
|
|||||||
|
|
||||||
void DataEngine::removeData(const QString& source, const QString& key)
|
void DataEngine::removeData(const QString& source, const QString& key)
|
||||||
{
|
{
|
||||||
DataSource* s = d->source(source, false);
|
DataContainer* s = d->source(source, false);
|
||||||
if (s) {
|
if (s) {
|
||||||
s->setData(key, QVariant());
|
s->setData(key, QVariant());
|
||||||
d->queueUpdate();
|
d->queueUpdate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DataEngine::addSource(DataSource* source)
|
void DataEngine::addSource(DataContainer* source)
|
||||||
{
|
{
|
||||||
SourceDict::const_iterator it = d->sources.find(source->objectName());
|
SourceDict::const_iterator it = d->sources.find(source->objectName());
|
||||||
if (it != d->sources.constEnd()) {
|
if (it != d->sources.constEnd()) {
|
||||||
@ -294,7 +294,7 @@ void DataEngine::removeSource(const QString& source)
|
|||||||
|
|
||||||
void DataEngine::clearSources()
|
void DataEngine::clearSources()
|
||||||
{
|
{
|
||||||
QMutableHashIterator<QString, Plasma::DataSource*> it(d->sources);
|
QMutableHashIterator<QString, Plasma::DataContainer*> it(d->sources);
|
||||||
while (it.hasNext()) {
|
while (it.hasNext()) {
|
||||||
it.next();
|
it.next();
|
||||||
emit sourceRemoved(it.key());
|
emit sourceRemoved(it.key());
|
||||||
@ -345,7 +345,7 @@ QString DataEngine::icon() const
|
|||||||
|
|
||||||
void DataEngine::checkForUpdates()
|
void DataEngine::checkForUpdates()
|
||||||
{
|
{
|
||||||
QHashIterator<QString, Plasma::DataSource*> it(d->sources);
|
QHashIterator<QString, Plasma::DataContainer*> it(d->sources);
|
||||||
while (it.hasNext()) {
|
while (it.hasNext()) {
|
||||||
it.next();
|
it.next();
|
||||||
it.value()->checkForUpdate();
|
it.value()->checkForUpdate();
|
||||||
|
20
dataengine.h
20
dataengine.h
@ -31,7 +31,7 @@
|
|||||||
namespace Plasma
|
namespace Plasma
|
||||||
{
|
{
|
||||||
|
|
||||||
class DataSource;
|
class DataContainer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @class DataEngine
|
* @class DataEngine
|
||||||
@ -55,7 +55,7 @@ class PLASMA_EXPORT DataEngine : public QObject
|
|||||||
typedef QHash<QString, DataEngine*> Dict;
|
typedef QHash<QString, DataEngine*> Dict;
|
||||||
typedef QHash<QString, QVariant> Data;
|
typedef QHash<QString, QVariant> Data;
|
||||||
typedef QHashIterator<QString, QVariant> DataIterator;
|
typedef QHashIterator<QString, QVariant> DataIterator;
|
||||||
typedef QHash<QString, DataSource*> SourceDict;
|
typedef QHash<QString, DataContainer*> SourceDict;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default constructor.
|
* Default constructor.
|
||||||
@ -187,7 +187,7 @@ class PLASMA_EXPORT DataEngine : public QObject
|
|||||||
* otherwise the requesting visualization may not receive notice of a
|
* otherwise the requesting visualization may not receive notice of a
|
||||||
* data update.
|
* data update.
|
||||||
*
|
*
|
||||||
* @return true if a DataSource was set up, false otherwise
|
* @return true if a DataContainer was set up, false otherwise
|
||||||
*/
|
*/
|
||||||
virtual bool sourceRequested(const QString &name);
|
virtual bool sourceRequested(const QString &name);
|
||||||
|
|
||||||
@ -236,10 +236,10 @@ class PLASMA_EXPORT DataEngine : public QObject
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds an already constructed data source. The DataEngine takes
|
* Adds an already constructed data source. The DataEngine takes
|
||||||
* ownership of the DataSource object.
|
* ownership of the DataContainer object.
|
||||||
* @param source the DataSource to add to the DataEngine
|
* @param source the DataContainer to add to the DataEngine
|
||||||
**/
|
**/
|
||||||
void addSource(DataSource* source);
|
void addSource(DataContainer* source);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets an upper limit on the number of data sources to keep in this engine.
|
* Sets an upper limit on the number of data sources to keep in this engine.
|
||||||
@ -250,8 +250,8 @@ class PLASMA_EXPORT DataEngine : public QObject
|
|||||||
**/
|
**/
|
||||||
void setSourceLimit(uint limit);
|
void setSourceLimit(uint limit);
|
||||||
|
|
||||||
/* DataSource* domain(const QString &domain);
|
/* DataContainer* domain(const QString &domain);
|
||||||
void createDataSource(const QString& source,
|
void createDataContainer(const QString& source,
|
||||||
const QString& domain = QString());*/
|
const QString& domain = QString());*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -269,13 +269,13 @@ class PLASMA_EXPORT DataEngine : public QObject
|
|||||||
void setValid(bool valid);
|
void setValid(bool valid);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the list of active DataSources.
|
* @return the list of active DataContainers.
|
||||||
*/
|
*/
|
||||||
SourceDict sourceDict() const;
|
SourceDict sourceDict() const;
|
||||||
|
|
||||||
protected Q_SLOTS:
|
protected Q_SLOTS:
|
||||||
/**
|
/**
|
||||||
* Call this method when you call setData directly on a DataSource instead
|
* Call this method when you call setData directly on a DataContainer instead
|
||||||
* of using the DataEngine::setData methods.
|
* of using the DataEngine::setData methods.
|
||||||
* If this method is not called, no updated(..) signals will be emitted!
|
* If this method is not called, no updated(..) signals will be emitted!
|
||||||
*/
|
*/
|
||||||
|
1
includes/DataContainer
Normal file
1
includes/DataContainer
Normal file
@ -0,0 +1 @@
|
|||||||
|
#include "../../plasma/datacontainer.h"
|
@ -1 +0,0 @@
|
|||||||
#include "../../plasma/datasource.h"
|
|
Loading…
Reference in New Issue
Block a user