* don't emit sourceAdded until the data has been set on a new source
* remove removed items from the rate limit queue as well svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=789225
This commit is contained in:
parent
92dd45a555
commit
e088dc1348
@ -108,7 +108,6 @@ class DataEngine::Private
|
|||||||
trimQueue();
|
trimQueue();
|
||||||
sourceQueue.enqueue(s);
|
sourceQueue.enqueue(s);
|
||||||
}
|
}
|
||||||
emit engine->newSource(sourceName);
|
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -328,19 +327,41 @@ 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)
|
||||||
{
|
{
|
||||||
DataContainer* s = d->source(source);
|
DataContainer* s = d->source(source, false);
|
||||||
|
bool isNew = !s;
|
||||||
|
|
||||||
|
if (isNew) {
|
||||||
|
s = d->source(source);
|
||||||
|
}
|
||||||
|
|
||||||
s->setData(key, value);
|
s->setData(key, value);
|
||||||
|
|
||||||
|
if (isNew) {
|
||||||
|
emit newSource(source);
|
||||||
|
}
|
||||||
|
|
||||||
d->queueUpdate();
|
d->queueUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DataEngine::setData(const QString &source, const Data &data)
|
void DataEngine::setData(const QString &source, const Data &data)
|
||||||
{
|
{
|
||||||
DataContainer *s = d->source(source);
|
DataContainer *s = d->source(source, false);
|
||||||
|
bool isNew = !s;
|
||||||
|
|
||||||
|
if (isNew) {
|
||||||
|
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());
|
||||||
++it;
|
++it;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isNew) {
|
||||||
|
emit newSource(source);
|
||||||
|
}
|
||||||
|
|
||||||
d->queueUpdate();
|
d->queueUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -426,10 +447,23 @@ void DataEngine::removeSource(const QString& source)
|
|||||||
//kDebug() << "removing source " << source;
|
//kDebug() << "removing source " << source;
|
||||||
SourceDict::iterator it = d->sources.find(source);
|
SourceDict::iterator it = d->sources.find(source);
|
||||||
if (it != d->sources.end()) {
|
if (it != d->sources.end()) {
|
||||||
QString key = it.key();
|
DataContainer *s = it.value();
|
||||||
it.value()->deleteLater();
|
|
||||||
|
// remove it from the limit queue if we're keeping one
|
||||||
|
if (d->limit > 0) {
|
||||||
|
QQueue<DataContainer*>::iterator it = d->sourceQueue.begin();
|
||||||
|
while (it != d->sourceQueue.end()) {
|
||||||
|
if (*it == s) {
|
||||||
|
d->sourceQueue.erase(it);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
++it;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
s->deleteLater();
|
||||||
d->sources.erase(it);
|
d->sources.erase(it);
|
||||||
emit sourceRemoved(key);
|
emit sourceRemoved(source);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user