allow kicking all visualizations immediately rather than wait for their timeouts in the case of changes that _must_ be reflected immediatley, e.g. time changes or network availability causing first fetch of data

svn path=/trunk/KDE/kdelibs/; revision=987939
This commit is contained in:
Aaron J. Seigo 2009-06-27 01:26:33 +00:00
parent 858e93afbd
commit 5bdb436709
6 changed files with 46 additions and 2 deletions

View File

@ -174,6 +174,18 @@ void DataContainer::checkForUpdate()
}
}
void DataContainer::forceImmediateUpdate()
{
if (d->dirty) {
d->dirty = false;
emit dataUpdated(objectName(), d->data);
}
foreach (SignalRelay *relay, d->relays) {
relay->forceImmediateUpdate();
}
}
uint DataContainer::timeSinceLastUpdate() const
{
//FIXME: we still assume it's been <24h

View File

@ -131,6 +131,12 @@ class PLASMA_EXPORT DataContainer : public QObject
**/
void disconnectVisualization(QObject *visualization);
/**
* Forces immediate update signals to all visualizations
* @since 4.4
*/
void forceImmediateUpdate();
Q_SIGNALS:
/**
* Emitted when the data has been updated, allowing visualizations to

View File

@ -400,6 +400,13 @@ void DataEngine::updateAllSources()
scheduleSourcesUpdated();
}
void DataEngine::forceImmediateUpdateOfAllVisualizations()
{
foreach (DataContainer *source, d->sources) {
source->forceImmediateUpdate();
}
}
void DataEngine::setIcon(const QString &icon)
{
d->icon = icon;

View File

@ -443,6 +443,18 @@ class PLASMA_EXPORT DataEngine : public QObject
*/
void updateAllSources();
/**
* Forces an immediate update to all connected sources, even those with
* timeouts that haven't yet expired. This should _only_ be used when
* there was no data available, e.g. due to network non-availability,
* and then it becomes available. Normal changes in data values due to
* calls to updateSource or in the natural progression of the monitored
* object (e.g. CPU heat) should not result in a call to this method!
*
* @since 4.4
*/
void forceImmediateUpdateOfAllVisualizations();
private:
friend class DataEnginePrivate;
friend class DataEngineScript;

View File

@ -77,7 +77,7 @@ int SignalRelay::receiverCount() const
return receivers(SIGNAL(dataUpdated(QString,Plasma::DataEngine::Data)));
}
bool SignalRelay::isUnused()
bool SignalRelay::isUnused() const
{
return receivers(SIGNAL(dataUpdated(QString,Plasma::DataEngine::Data))) < 1;
}
@ -129,6 +129,12 @@ void SignalRelay::checkQueueing()
}
}
void SignalRelay::forceImmediateUpdate()
{
emit dataUpdated(dc->objectName(), d->data);
m_queued = false;
}
void SignalRelay::timerEvent(QTimerEvent *event)
{
if (event->timerId() != m_timerId) {

View File

@ -58,10 +58,11 @@ public:
uint ival, Plasma::IntervalAlignment align, bool immediateUpdate);
int receiverCount() const;
bool isUnused();
bool isUnused() const;
void checkAlignment();
void checkQueueing();
void forceImmediateUpdate();
DataContainer *dc;
DataContainerPrivate *d;