diff --git a/CMakeLists.txt b/CMakeLists.txt index 489075c35..377e60940 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,9 +15,9 @@ set(plasma_LIB_SRCS applet.cpp configxml.cpp corona.cpp + datacontainer.cpp dataengine.cpp dataenginemanager.cpp - datasource.cpp packages.cpp phase.cpp plasma.cpp @@ -61,9 +61,9 @@ install(FILES applet.h configxml.h corona.h + datacontainer.h dataengine.h dataenginemanager.h - datasource.h phase.h plasma.h plasma_export.h @@ -94,9 +94,9 @@ install(FILES includes/Packager includes/PackageStructure includes/Theme + includes/DataContainer includes/DataEngine includes/DataEngineManager - includes/DataSource includes/Svg DESTINATION ${INCLUDE_INSTALL_DIR}/KDE/Plasma) diff --git a/datasource.cpp b/datacontainer.cpp similarity index 82% rename from datasource.cpp rename to datacontainer.cpp index 1e89aaff2..dbbeab2cc 100644 --- a/datasource.cpp +++ b/datacontainer.cpp @@ -16,7 +16,7 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#include "datasource.h" +#include "datacontainer.h" #include #include @@ -26,7 +26,7 @@ namespace Plasma { -class DataSource::Private +class DataContainer::Private { public: Private() @@ -38,23 +38,23 @@ class DataSource::Private bool dirty : 1; }; -DataSource::DataSource(QObject* parent) +DataContainer::DataContainer(QObject* parent) : QObject(parent), d(new Private()) { } -DataSource::~DataSource() +DataContainer::~DataContainer() { delete d; } -const DataEngine::Data DataSource::data() const +const DataEngine::Data DataContainer::data() const { 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 (!d->data.contains(key)) { @@ -69,7 +69,7 @@ void DataSource::setData(const QString& key, const QVariant& value) d->dirty = true; } -void DataSource::clearData() +void DataContainer::clearData() { if (d->data.count() < 1) { // avoid an update if we don't have any data anyways @@ -80,7 +80,7 @@ void DataSource::clearData() d->dirty = true; } -void DataSource::checkForUpdate() +void DataContainer::checkForUpdate() { if (d->dirty) { 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()) { 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 (d->connectCount > 0) { @@ -111,5 +111,5 @@ void DataSource::disconnectNotify(const char *signal) } // Plasma namespace -#include "datasource.moc" +#include "datacontainer.moc" diff --git a/datasource.h b/datacontainer.h similarity index 84% rename from datasource.h rename to datacontainer.h index cc22616ff..93db2ec70 100644 --- a/datasource.h +++ b/datacontainer.h @@ -16,8 +16,8 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#ifndef PLASMA_DATASOURCE_H -#define PLASMA_DATASOURCE_H +#ifndef PLASMA_DATACONTAINER_H +#define PLASMA_DATACONTAINER_H #include #include @@ -30,15 +30,15 @@ namespace Plasma /** * @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. * - * 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 * 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 @@ -46,14 +46,14 @@ class PLASMA_EXPORT DataSource : public QObject //typedef QHash Grouping; /** - * Constructs a default DataSource, which has no name or data + * Constructs a default DataContainer, which has no name or data * associated with it **/ - explicit DataSource(QObject* parent = 0); - virtual ~DataSource(); + explicit DataContainer(QObject* parent = 0); + virtual ~DataContainer(); /** - * Returns the data for this DataSource + * Returns the data for this DataContainer **/ const DataEngine::Data data() const; diff --git a/dataengine.cpp b/dataengine.cpp index 0684f81fe..12c49b835 100644 --- a/dataengine.cpp +++ b/dataengine.cpp @@ -24,7 +24,7 @@ #include -#include "datasource.h" +#include "datacontainer.h" namespace Plasma { @@ -41,13 +41,13 @@ class DataEngine::Private 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); if (it != sources.constEnd()) { - DataSource* s = it.value(); + DataContainer* s = it.value(); if (limit > 0) { - QQueue::iterator it = sourceQueue.begin(); + QQueue::iterator it = sourceQueue.begin(); while (it != sourceQueue.end()) { if (*it == s) { sourceQueue.erase(it); @@ -65,9 +65,9 @@ class DataEngine::Private } /* kDebug() << "DataEngine " << engine->objectName() - << ": could not find DataSource " << sourceName + << ": could not find DataContainer " << sourceName << ", creating" << endl;*/ - DataSource* s = new DataSource(engine); + DataContainer* s = new DataContainer(engine); s->setObjectName(sourceName); sources.insert(sourceName, s); @@ -82,7 +82,7 @@ class DataEngine::Private void trimQueue() { while (sourceQueue.count() >= limit) { - DataSource* punted = sourceQueue.dequeue(); + DataContainer* punted = sourceQueue.dequeue(); engine->removeSource(punted->objectName()); } } @@ -103,7 +103,7 @@ class DataEngine::Private QAtomic ref; DataEngine::SourceDict sources; - QQueue sourceQueue; + QQueue sourceQueue; DataEngine* engine; QTimer* updateTimer; QString icon; @@ -135,7 +135,7 @@ QStringList DataEngine::sources() const void DataEngine::connectSource(const QString& source, QObject* visualization) const { - DataSource* s = d->source(source, false); + DataContainer* s = d->source(source, false); if (!s) { // 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 { - DataSource* s = d->source(source, false); + DataContainer* s = d->source(source, false); if (!s) { return; @@ -174,12 +174,12 @@ void DataEngine::disconnectSource(const QString& source, QObject* visualization) 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)), visualization, SLOT(updated(QString,Plasma::DataEngine::Data))); } - foreach (const DataSource* s, d->sources) { + foreach (const DataContainer* s, d->sources) { QMetaObject::invokeMethod(visualization, SLOT(updated(QString,Plasma::DataEngine::Data)), Q_ARG(QString, s->objectName()), @@ -191,7 +191,7 @@ DataEngine::Data DataEngine::query(const QString& source) const { Q_UNUSED(source) - DataSource* s = d->source(source); + DataContainer* s = d->source(source); 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) { - DataSource* s = d->source(source); + DataContainer* s = d->source(source); s->setData(key, value); d->queueUpdate(); } 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(); while (it != data.constEnd()) { 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) { - DataSource* s = d->source(source, false); + DataContainer* s = d->source(source, false); if (s) { s->clearData(); d->queueUpdate(); @@ -248,14 +248,14 @@ void DataEngine::clearData(const QString& source) void DataEngine::removeData(const QString& source, const QString& key) { - DataSource* s = d->source(source, false); + DataContainer* s = d->source(source, false); if (s) { s->setData(key, QVariant()); d->queueUpdate(); } } -void DataEngine::addSource(DataSource* source) +void DataEngine::addSource(DataContainer* source) { SourceDict::const_iterator it = d->sources.find(source->objectName()); if (it != d->sources.constEnd()) { @@ -294,7 +294,7 @@ void DataEngine::removeSource(const QString& source) void DataEngine::clearSources() { - QMutableHashIterator it(d->sources); + QMutableHashIterator it(d->sources); while (it.hasNext()) { it.next(); emit sourceRemoved(it.key()); @@ -345,7 +345,7 @@ QString DataEngine::icon() const void DataEngine::checkForUpdates() { - QHashIterator it(d->sources); + QHashIterator it(d->sources); while (it.hasNext()) { it.next(); it.value()->checkForUpdate(); diff --git a/dataengine.h b/dataengine.h index 8501d41bd..fa2d56ea2 100644 --- a/dataengine.h +++ b/dataengine.h @@ -31,7 +31,7 @@ namespace Plasma { -class DataSource; +class DataContainer; /** * @class DataEngine @@ -55,7 +55,7 @@ class PLASMA_EXPORT DataEngine : public QObject typedef QHash Dict; typedef QHash Data; typedef QHashIterator DataIterator; - typedef QHash SourceDict; + typedef QHash SourceDict; /** * Default constructor. @@ -187,7 +187,7 @@ class PLASMA_EXPORT DataEngine : public QObject * otherwise the requesting visualization may not receive notice of a * 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); @@ -236,10 +236,10 @@ class PLASMA_EXPORT DataEngine : public QObject /** * Adds an already constructed data source. The DataEngine takes - * ownership of the DataSource object. - * @param source the DataSource to add to the DataEngine + * ownership of the DataContainer object. + * @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. @@ -250,8 +250,8 @@ class PLASMA_EXPORT DataEngine : public QObject **/ void setSourceLimit(uint limit); -/* DataSource* domain(const QString &domain); - void createDataSource(const QString& source, +/* DataContainer* domain(const QString &domain); + void createDataContainer(const QString& source, const QString& domain = QString());*/ /** @@ -269,13 +269,13 @@ class PLASMA_EXPORT DataEngine : public QObject void setValid(bool valid); /** - * @return the list of active DataSources. + * @return the list of active DataContainers. */ SourceDict sourceDict() const; 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. * If this method is not called, no updated(..) signals will be emitted! */ diff --git a/includes/DataContainer b/includes/DataContainer new file mode 100644 index 000000000..a93149547 --- /dev/null +++ b/includes/DataContainer @@ -0,0 +1 @@ +#include "../../plasma/datacontainer.h" diff --git a/includes/DataSource b/includes/DataSource deleted file mode 100644 index 09e957e7f..000000000 --- a/includes/DataSource +++ /dev/null @@ -1 +0,0 @@ -#include "../../plasma/datasource.h"