fix timing bug (only the millisecond part of the timestamp was used)

now the update intervals will actually work.

svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=753663
This commit is contained in:
Chani Armitage 2007-12-28 05:00:56 +00:00
parent bc10b9a983
commit ca8f72c7bc
2 changed files with 6 additions and 15 deletions

View File

@ -53,7 +53,7 @@ void DataContainer::setData(const QString& key, const QVariant& value)
} }
d->dirty = true; d->dirty = true;
d->updateTs = QTime::currentTime().msec(); d->updateTs.start();
} }
void DataContainer::clearData() void DataContainer::clearData()
@ -82,17 +82,9 @@ void DataContainer::checkForUpdate()
int DataContainer::timeSinceLastUpdate() const int DataContainer::timeSinceLastUpdate() const
{ {
int msec = QTime::currentTime().msec(); //FIXME: we still assume it's been <24h
if (msec < d->updateTs) { //and ignore possible daylight savings changes
// we wrapped over midnight here, so return the current return d->updateTs.elapsed();
// msec's plus the number of msec left in the previous day.
// 86400000 is the # of msec in a day
//
// yes, we assume we don't wrap more than one day here.
return msec + (86400000 - d->updateTs);
}
return msec - d->updateTs;
} }
bool DataContainer::hasUpdates() const bool DataContainer::hasUpdates() const

View File

@ -32,8 +32,7 @@ class DataContainer::Private
{ {
public: public:
Private() Private()
: updateTs(0), : dirty(false)
dirty(false)
{} {}
QObject* signalRelay(const DataContainer* dc, QObject *visualization, QObject* signalRelay(const DataContainer* dc, QObject *visualization,
@ -42,7 +41,7 @@ public:
DataEngine::Data data; DataEngine::Data data;
QMap<QObject *, SignalRelay *> relayObjects; QMap<QObject *, SignalRelay *> relayObjects;
QMap<uint, SignalRelay *> relays; QMap<uint, SignalRelay *> relays;
int updateTs; QTime updateTs;
bool dirty : 1; bool dirty : 1;
}; };