+hasUpdates()->pimpl ok
+setNeedsUpdate()->protected used in dataengine line 306 +checkUsage()->protected used in dataengine line 293 protected or pimpl/modification in dataengine too? CCMAIL : ervin@kde.org svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=801168
This commit is contained in:
parent
13f4fae5f3
commit
2b235d2906
@ -69,35 +69,11 @@ void DataContainer::removeAllData()
|
||||
d->updateTs.start();
|
||||
}
|
||||
|
||||
bool DataContainer::hasUpdates() const
|
||||
{
|
||||
if (d->cached) {
|
||||
//some signalrelay needs us to pretend we did an update
|
||||
d->cached = false;
|
||||
return true;
|
||||
}
|
||||
return d->dirty;
|
||||
}
|
||||
|
||||
void DataContainer::setNeedsUpdate(bool update)
|
||||
{
|
||||
d->cached = update;
|
||||
}
|
||||
|
||||
bool DataContainer::visualizationIsConnected(QObject *visualization) const
|
||||
{
|
||||
return d->relayObjects.contains(visualization);
|
||||
}
|
||||
|
||||
void DataContainer::checkUsage()
|
||||
{
|
||||
if (d->relays.count() < 1 &&
|
||||
receivers(SIGNAL(dataUpdated(QString, Plasma::DataEngine::Data))) < 1) {
|
||||
// DO NOT CALL ANYTHING AFTER THIS LINE AS IT MAY GET DELETED!
|
||||
emit becameUnused(objectName());
|
||||
}
|
||||
}
|
||||
|
||||
void DataContainer::connectVisualization(QObject* visualization, uint pollingInterval, Plasma::IntervalAlignment alignment)
|
||||
{
|
||||
//kDebug() << "connecting visualization" << visualization << "at interval of" << pollingInterval;
|
||||
@ -193,6 +169,20 @@ uint DataContainer::timeSinceLastUpdate() const
|
||||
return d->updateTs.elapsed();
|
||||
}
|
||||
|
||||
void DataContainer::setNeedsUpdate(bool update)
|
||||
{
|
||||
d->cached = update;
|
||||
}
|
||||
|
||||
void DataContainer::checkUsage()
|
||||
{
|
||||
if (d->relays.count() < 1 &&
|
||||
receivers(SIGNAL(dataUpdated(QString, Plasma::DataEngine::Data))) < 1) {
|
||||
// DO NOT CALL ANYTHING AFTER THIS LINE AS IT MAY GET DELETED!
|
||||
emit becameUnused(objectName());
|
||||
}
|
||||
}
|
||||
|
||||
} // Plasma namespace
|
||||
|
||||
#include "datacontainer.moc"
|
||||
|
@ -76,21 +76,6 @@ class PLASMA_EXPORT DataContainer : public QObject
|
||||
**/
|
||||
void removeAllData();
|
||||
|
||||
/**
|
||||
* @internal
|
||||
**/
|
||||
bool hasUpdates() const;
|
||||
|
||||
/**
|
||||
* Indicates that the data should be treated as dirty the next time hasUpdates() is called.
|
||||
*
|
||||
* why? because if one SignalRelay times out just after another, the minimum update
|
||||
* interval stops a real update from being done - but that relay still needs to be given
|
||||
* data, because it won't have been in the queue and won't have gotten that last update.
|
||||
* when it checks hasUpdates() we'll lie, and then everything will return to normal.
|
||||
**/
|
||||
void setNeedsUpdate(bool update = true);
|
||||
|
||||
/**
|
||||
* @return true if the visualization is currently connected
|
||||
*/
|
||||
@ -106,12 +91,6 @@ class PLASMA_EXPORT DataContainer : public QObject
|
||||
void connectVisualization(QObject* visualization, uint pollingInterval, Plasma::IntervalAlignment alignment);
|
||||
|
||||
public Q_SLOTS:
|
||||
/**
|
||||
* Check if the DataContainer is still in use.
|
||||
* If not the signal "becameUnused" will be emitted.
|
||||
* Warning: The DataContainer may be invalid after calling this function.
|
||||
*/
|
||||
void checkUsage();
|
||||
|
||||
/**
|
||||
* Disconnects an object from this DataContainer.
|
||||
@ -147,6 +126,24 @@ class PLASMA_EXPORT DataContainer : public QObject
|
||||
**/
|
||||
uint timeSinceLastUpdate() const;
|
||||
|
||||
/**
|
||||
* Indicates that the data should be treated as dirty the next time hasUpdates() is called.
|
||||
*
|
||||
* why? because if one SignalRelay times out just after another, the minimum update
|
||||
* interval stops a real update from being done - but that relay still needs to be given
|
||||
* data, because it won't have been in the queue and won't have gotten that last update.
|
||||
* when it checks hasUpdates() we'll lie, and then everything will return to normal.
|
||||
**/
|
||||
void setNeedsUpdate(bool update = true);
|
||||
|
||||
protected Q_SLOTS:
|
||||
/**
|
||||
* Check if the DataContainer is still in use.
|
||||
* If not the signal "becameUnused" will be emitted.
|
||||
* Warning: The DataContainer may be invalid after calling this function.
|
||||
*/
|
||||
void checkUsage();
|
||||
|
||||
|
||||
private:
|
||||
friend class SignalRelay;
|
||||
|
@ -37,7 +37,9 @@ public:
|
||||
|
||||
SignalRelay* signalRelay(const DataContainer* dc, QObject *visualization,
|
||||
uint pollingInterval, Plasma::IntervalAlignment align);
|
||||
|
||||
|
||||
bool hasUpdates();
|
||||
|
||||
DataEngine::Data data;
|
||||
QMap<QObject *, SignalRelay *> relayObjects;
|
||||
QMap<uint, SignalRelay *> relays;
|
||||
@ -147,7 +149,7 @@ protected:
|
||||
}
|
||||
|
||||
emit dc->updateRequested(dc);
|
||||
if (!dc->hasUpdates()) {
|
||||
if (!d->hasUpdates()) {
|
||||
// the source wasn't actually updated; so let's put ourselves in the queue
|
||||
// so we get an dataUpdated() when the data does arrive
|
||||
m_queued = true;
|
||||
@ -175,6 +177,16 @@ SignalRelay* DataContainer::Private::signalRelay(const DataContainer* dc, QObjec
|
||||
return relay;
|
||||
}
|
||||
|
||||
bool DataContainer::Private::hasUpdates()
|
||||
{
|
||||
if (cached) {
|
||||
//some signalrelay needs us to pretend we did an update
|
||||
cached = false;
|
||||
return true;
|
||||
}
|
||||
return dirty;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif // multiple inclusion guard
|
||||
|
@ -297,7 +297,7 @@ DataEngine::Data DataEngine::query(const QString& source) const
|
||||
void DataEngine::internalUpdateSource(DataContainer* source)
|
||||
{
|
||||
if (d->minPollingInterval > 0 &&
|
||||
source->timeSinceLastUpdate() < d->minPollingInterval) {
|
||||
source->timeSinceLastUpdate() < (uint)d->minPollingInterval) {
|
||||
// skip updating this source; it's been too soon
|
||||
//kDebug() << "internal update source is delaying" << source->timeSinceLastUpdate() << d->minPollingInterval;
|
||||
//but fake an update so that the signalrelay that triggered this gets the data from the
|
||||
|
Loading…
Reference in New Issue
Block a user