Use QElapsedTimer for data engines

forward port of http://commits.kde.org/kdelibs/ac5d3d2f916c0a461121d4d033642227bd743edb

CCBUG: 336551
REVIEW: 118869
This commit is contained in:
Christoph Feck 2014-06-23 13:03:16 +02:00
parent ac4f519188
commit fec57bdaa2
4 changed files with 10 additions and 14 deletions

View File

@ -53,7 +53,7 @@ void DataContainer::setData(const QString &key, const QVariant &value)
}
d->dirty = true;
d->updateTs.start();
d->updateTimer.start();
//check if storage is enabled and if storage is needed.
//If it is not set to be stored,then this is the first
@ -95,7 +95,7 @@ void DataContainer::removeAllData()
d->data.clear();
d->dirty = true;
d->updateTs.start();
d->updateTimer.start();
}
bool DataContainer::visualizationIsConnected(QObject *visualization) const
@ -354,9 +354,7 @@ void DataContainer::forceImmediateUpdate()
uint DataContainer::timeSinceLastUpdate() const
{
//FIXME: we still assume it's been <24h
//and ignore possible daylight savings changes
return d->updateTs.elapsed();
return d->updateTimer.elapsed();
}
void DataContainer::setNeedsUpdate(bool update)

View File

@ -352,12 +352,12 @@ void DataEngine::timerEvent(QTimerEvent *event)
}
// minPollingInterval
if (d->updateTimestamp.elapsed() < d->minPollingInterval) {
if (d->updateTimer.elapsed() < d->minPollingInterval) {
//qDebug() << "hey now.. slow down!";
return;
}
d->updateTimestamp.restart();
d->updateTimer.start();
updateAllSources();
} else if (event->timerId() == d->checkSourcesTimerId) {
killTimer(d->checkSourcesTimerId);
@ -421,7 +421,7 @@ DataEnginePrivate::DataEnginePrivate(DataEngine *e, const KPluginInfo &info, con
script(0),
package(0)
{
updateTimestamp.start();
updateTimer.start();
if (dataEngineDescription.isValid()) {
e->setObjectName(dataEngineDescription.name());

View File

@ -24,7 +24,7 @@
#include "storage_p.h"
#include <QtCore/QTimerEvent>
#include <QtCore/QTime>
#include <QtCore/QElapsedTimer>
#include <QtCore/QBasicTimer>
#include <QAbstractItemModel>
@ -85,7 +85,7 @@ public:
DataEngine::Data data;
QMap<QObject *, SignalRelay *> relayObjects;
QMap<uint, SignalRelay *> relays;
QTime updateTs;
QElapsedTimer updateTimer;
Storage *storage;
QBasicTimer storageTimer;
QBasicTimer checkUsageTimer;

View File

@ -20,12 +20,10 @@
#ifndef DATAENGINE_P_H
#define DATAENGINE_P_H
#include <QTime>
#include <QElapsedTimer>
#include <kplugininfo.h>
class QTime;
namespace Plasma
{
@ -97,7 +95,7 @@ public:
int checkSourcesTimerId;
int updateTimerId;
int minPollingInterval;
QTime updateTimestamp;
QElapsedTimer updateTimer;
DataEngine::SourceDict sources;
bool valid;
DataEngineScript *script;