create a single timer for storage event compression

This commit is contained in:
Marco Martin 2011-04-28 11:22:08 +02:00
parent 97b37637fa
commit 67dbcb59b8
2 changed files with 8 additions and 2 deletions

View File

@ -31,6 +31,8 @@ DataContainer::DataContainer(QObject *parent)
: QObject(parent), : QObject(parent),
d(new DataContainerPrivate(this)) d(new DataContainerPrivate(this))
{ {
d->storageTimer = new QTimer(this);
QObject::connect(d->storageTimer, SIGNAL(timeOut()), this, SLOT(store()));
} }
DataContainer::~DataContainer() DataContainer::~DataContainer()
@ -59,7 +61,7 @@ void DataContainer::setData(const QString &key, const QVariant &value)
//setData() since the last time it was stored. This //setData() since the last time it was stored. This
//gives us only one singleShot timer. //gives us only one singleShot timer.
if (isStorageEnabled() || !needsToBeStored()) { if (isStorageEnabled() || !needsToBeStored()) {
QTimer::singleShot(180000, this, SLOT(store())); d->storageTimer->start(180000);
} }
setNeedsToBeStored(true); setNeedsToBeStored(true);

View File

@ -25,6 +25,8 @@
#include "servicejob.h" #include "servicejob.h"
#include "storage_p.h" #include "storage_p.h"
class QTimer;
namespace Plasma namespace Plasma
{ {
class ServiceJob; class ServiceJob;
@ -41,7 +43,8 @@ public:
enableStorage(false), enableStorage(false),
isStored(true), isStored(true),
storageCount(0) storageCount(0)
{} {
}
SignalRelay *signalRelay(const DataContainer *dc, QObject *visualization, SignalRelay *signalRelay(const DataContainer *dc, QObject *visualization,
uint pollingInterval, Plasma::IntervalAlignment align, uint pollingInterval, Plasma::IntervalAlignment align,
@ -68,6 +71,7 @@ public:
DataEngine::Data data; DataEngine::Data data;
QMap<QObject *, SignalRelay *> relayObjects; QMap<QObject *, SignalRelay *> relayObjects;
QMap<uint, SignalRelay *> relays; QMap<uint, SignalRelay *> relays;
QTimer *storageTimer;
QTime updateTs; QTime updateTs;
Storage* storage; Storage* storage;
bool dirty : 1; bool dirty : 1;