when manually adding sources ... connect them to the engine!

svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=869754
This commit is contained in:
Aaron J. Seigo 2008-10-09 23:23:30 +00:00
parent eff56fa372
commit 4a63440530

View File

@ -154,7 +154,7 @@ bool DataEngine::updateSourceEvent(const QString& source)
if (d->script) { if (d->script) {
return d->script->updateSourceEvent(source); return d->script->updateSourceEvent(source);
} else { } else {
//kDebug() << "updateSource source" << endl; //kDebug() << source;
return false; //TODO: should this be true to trigger, even needless, updates on every tick? return false; //TODO: should this be true to trigger, even needless, updates on every tick?
} }
} }
@ -224,12 +224,13 @@ void DataEngine::removeData(const QString& source, const QString& key)
void DataEngine::addSource(DataContainer* source) void DataEngine::addSource(DataContainer* source)
{ {
SourceDict::const_iterator it = d->sources.find(source->objectName()); if (d->sources.contains(source->objectName())) {
if (it != d->sources.constEnd()) {
kDebug() << "source named \"" << source->objectName() << "\" already exists."; kDebug() << "source named \"" << source->objectName() << "\" already exists.";
return; return;
} }
QObject::connect(source, SIGNAL(updateRequested(DataContainer*)),
this, SLOT(internalUpdateSource(DataContainer*)));
d->sources.insert(source->objectName(), source); d->sources.insert(source->objectName(), source);
emit sourceAdded(source->objectName()); emit sourceAdded(source->objectName());
d->queueUpdate(); d->queueUpdate();
@ -349,6 +350,7 @@ DataEngine::SourceDict DataEngine::containerDict() const
void DataEngine::timerEvent(QTimerEvent *event) void DataEngine::timerEvent(QTimerEvent *event)
{ {
if (event->timerId() != d->updateTimerId) { if (event->timerId() != d->updateTimerId) {
kDebug() << "bzzzt";
return; return;
} }
@ -356,11 +358,13 @@ void DataEngine::timerEvent(QTimerEvent *event)
// if the freq update is less than 0, don't bother // if the freq update is less than 0, don't bother
if (d->minPollingInterval < 0) { if (d->minPollingInterval < 0) {
//kDebug() << "uh oh.. no polling allowed!";
return; return;
} }
// minPollingInterval // minPollingInterval
if (d->updateTimestamp.elapsed() < d->minPollingInterval) { if (d->updateTimestamp.elapsed() < d->minPollingInterval) {
//kDebug() << "hey now.. slow down!";
return; return;
} }
@ -368,8 +372,10 @@ void DataEngine::timerEvent(QTimerEvent *event)
QHashIterator<QString, Plasma::DataContainer*> it(d->sources); QHashIterator<QString, Plasma::DataContainer*> it(d->sources);
while (it.hasNext()) { while (it.hasNext()) {
it.next(); it.next();
//kDebug() << "updating" << it.key();
updateSourceEvent(it.key()); updateSourceEvent(it.key());
} }
scheduleSourcesUpdated(); scheduleSourcesUpdated();
} }
@ -470,7 +476,7 @@ void DataEnginePrivate::internalUpdateSource(DataContainer* source)
if (minPollingInterval > 0 && if (minPollingInterval > 0 &&
source->timeSinceLastUpdate() < (uint)minPollingInterval) { source->timeSinceLastUpdate() < (uint)minPollingInterval) {
// skip updating this source; it's been too soon // skip updating this source; it's been too soon
//kDebug() << "internal update source is delaying" << source->timeSinceLastUpdate() << d->minPollingInterval; //kDebug() << "internal update source is delaying" << source->timeSinceLastUpdate() << minPollingInterval;
//but fake an update so that the signalrelay that triggered this gets the data from the //but fake an update so that the signalrelay that triggered this gets the data from the
//recent update. this way we don't have to worry about queuing - the relay will send a //recent update. this way we don't have to worry about queuing - the relay will send a
//signal immediately and everyone else is undisturbed. //signal immediately and everyone else is undisturbed.
@ -479,8 +485,11 @@ void DataEnginePrivate::internalUpdateSource(DataContainer* source)
} }
if (q->updateSourceEvent(source->objectName())) { if (q->updateSourceEvent(source->objectName())) {
//kDebug() << "queuing an update";
queueUpdate(); queueUpdate();
} }/* else {
kDebug() << "no update";
}*/
} }
void DataEnginePrivate::ref() void DataEnginePrivate::ref()
@ -540,7 +549,7 @@ DataContainer* DataEnginePrivate::source(const QString& sourceName, bool createW
void DataEnginePrivate::connectSource(DataContainer* s, QObject* visualization, uint pollingInterval, void DataEnginePrivate::connectSource(DataContainer* s, QObject* visualization, uint pollingInterval,
Plasma::IntervalAlignment align, bool immediateCall) Plasma::IntervalAlignment align, bool immediateCall)
{ {
//kDebug() << "connect source called with interval" << pollingInterval; //kDebug() << "connect source called" << s->objectName() << "with interval" << pollingInterval;
if (pollingInterval > 0) { if (pollingInterval > 0) {
// never more frequently than allowed, never more than 20 times per second // never more frequently than allowed, never more than 20 times per second
uint min = qMax(50, minPollingInterval); // for qMax below uint min = qMax(50, minPollingInterval); // for qMax below