API consistency fixes; all methods now use "Source" to mean "DataSource"

svn path=/trunk/KDE/kdebase/workspace/lib/plasma/; revision=674784
This commit is contained in:
Aaron J. Seigo 2007-06-13 04:56:49 +00:00
parent d349f2bc5c
commit 029b2e8a54
2 changed files with 19 additions and 29 deletions

View File

@ -75,7 +75,7 @@ class DataEngine::Private
trimQueue(); trimQueue();
sourceQueue.enqueue(s); sourceQueue.enqueue(s);
} }
emit engine->newDataSource(sourceName); emit engine->newSource(sourceName);
return s; return s;
} }
@ -95,10 +95,10 @@ class DataEngine::Private
updateTimer->start(0); updateTimer->start(0);
} }
bool dataSourceRequested(const QString& source) bool sourceRequested(const QString& source)
{ {
//get around const! =P //get around const! =P
return engine->dataSourceRequested(source); return engine->sourceRequested(source);
} }
QAtomic ref; QAtomic ref;
@ -127,7 +127,7 @@ DataEngine::~DataEngine()
delete d; delete d;
} }
QStringList DataEngine::dataSources() const QStringList DataEngine::sources() const
{ {
return d->sources.keys(); return d->sources.keys();
} }
@ -138,7 +138,7 @@ void DataEngine::connectSource(const QString& source, QObject* visualization) co
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
if (d->dataSourceRequested(source)) { if (d->sourceRequested(source)) {
s = d->source(source); s = d->source(source);
if (s) { if (s) {
// now we have a source; since it was created on demand, assume // now we have a source; since it was created on demand, assume
@ -200,7 +200,7 @@ void DataEngine::init()
// start things in motion external to themselves before they can work // start things in motion external to themselves before they can work
} }
bool DataEngine::dataSourceRequested(const QString &name) bool DataEngine::sourceRequested(const QString &name)
{ {
Q_UNUSED(name) Q_UNUSED(name)
return false; return false;
@ -227,7 +227,7 @@ void DataEngine::addSource(DataSource* source)
} }
d->sources.insert(source->objectName(), source); d->sources.insert(source->objectName(), source);
emit newDataSource(source->objectName()); emit newSource(source->objectName());
} }
void DataEngine::setSourceLimit(uint limit) void DataEngine::setSourceLimit(uint limit)
@ -245,34 +245,22 @@ void DataEngine::setSourceLimit(uint limit)
} }
} }
/*
Plasma::DataSource* DataEngine::createDataSource(const QString& source, const QString& domain)
{
Q_UNUSED(domain)
//TODO: add support for domains of sources
if (d->source(source)) {
kDebug() << "DataEngine " << objectName() << ": source " << source << " already exists " << endl;
return s
}
}*/
void DataEngine::removeSource(const QString& source) void DataEngine::removeSource(const QString& source)
{ {
//kDebug() << "removing source " << source << endl; //kDebug() << "removing source " << source << endl;
SourceDict::iterator it = d->sources.find(source); SourceDict::iterator it = d->sources.find(source);
if (it != d->sources.end()) { if (it != d->sources.end()) {
emit dataSourceRemoved(it.key()); emit sourceRemoved(it.key());
d->sources.erase(it); d->sources.erase(it);
} }
} }
void DataEngine::clearAllDataSources() void DataEngine::clearSources()
{ {
QMutableHashIterator<QString, Plasma::DataSource*> it(d->sources); QMutableHashIterator<QString, Plasma::DataSource*> it(d->sources);
while (it.hasNext()) { while (it.hasNext()) {
it.next(); it.next();
emit dataSourceRemoved(it.key()); emit sourceRemoved(it.key());
delete it.value(); delete it.value();
it.remove(); it.remove();
} }

View File

@ -66,10 +66,12 @@ class PLASMA_EXPORT DataEngine : public QObject
virtual ~DataEngine(); virtual ~DataEngine();
/** /**
* @return a list of all the data sources currently available via this * @return a list of all the data sources available via this DataEngine
* DataEngine * Whether these sources are currently available (which is what
* the default implementation provides) or not is up to the
* DataEngine to decide.
**/ **/
virtual QStringList dataSources() const; virtual QStringList sources() const;
/** /**
* Connects a source to an object for data updates. The object must * Connects a source to an object for data updates. The object must
@ -158,13 +160,13 @@ class PLASMA_EXPORT DataEngine : public QObject
* Emitted when a new data source is created * Emitted when a new data source is created
* @param source the name of the new data source * @param source the name of the new data source
**/ **/
void newDataSource(const QString& source); void newSource(const QString& source);
/** /**
* Emitted when a data source is removed. * Emitted when a data source is removed.
* @param source the name of the data source that was removed * @param source the name of the data source that was removed
**/ **/
void dataSourceRemoved(const QString& source); void sourceRemoved(const QString& source);
protected: protected:
/** /**
@ -182,7 +184,7 @@ class PLASMA_EXPORT DataEngine : public QObject
* *
* @return true if a DataSource was set up, false otherwise * @return true if a DataSource was set up, false otherwise
*/ */
virtual bool dataSourceRequested(const QString &name); virtual bool sourceRequested(const QString &name);
/** /**
* Sets a value for a data source. If the source * Sets a value for a data source. If the source
@ -226,7 +228,7 @@ class PLASMA_EXPORT DataEngine : public QObject
/** /**
* Removes all data sources * Removes all data sources
**/ **/
void clearAllDataSources(); void clearSources();
/** /**
* Sets whether or not this engine is valid, e.g. can be used. * Sets whether or not this engine is valid, e.g. can be used.