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

View File

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

View File

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

View File

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