2008-11-04 00:08:39 +01:00
|
|
|
/*
|
|
|
|
* Copyright 2006-2007 Aaron Seigo <aseigo@kde.org>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Library General Public License as
|
|
|
|
* published by the Free Software Foundation; either version 2, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this program; if not, write to the
|
|
|
|
* Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef PLASMA_DATACONTAINER_P_H
|
|
|
|
#define PLASMA_DATACONTAINER_P_H
|
|
|
|
|
2010-07-29 01:28:31 +02:00
|
|
|
#include "servicejob.h"
|
2010-08-02 18:00:47 +02:00
|
|
|
#include "storage_p.h"
|
2008-11-04 00:08:39 +01:00
|
|
|
|
2011-10-30 10:35:29 +01:00
|
|
|
#include <QtCore/QTimerEvent>
|
|
|
|
#include <QtCore/QTime>
|
|
|
|
#include <QtCore/QBasicTimer>
|
|
|
|
|
2011-04-28 11:22:08 +02:00
|
|
|
class QTimer;
|
|
|
|
|
2008-11-04 00:08:39 +01:00
|
|
|
namespace Plasma
|
|
|
|
{
|
2010-07-29 01:28:31 +02:00
|
|
|
class ServiceJob;
|
2008-11-04 00:08:39 +01:00
|
|
|
class SignalRelay;
|
|
|
|
|
|
|
|
class DataContainerPrivate
|
|
|
|
{
|
|
|
|
public:
|
2010-08-06 04:28:50 +02:00
|
|
|
DataContainerPrivate(DataContainer *container)
|
|
|
|
: q(container),
|
2010-10-01 18:58:15 +02:00
|
|
|
storage(NULL),
|
2011-10-30 10:35:29 +01:00
|
|
|
storageCount(0),
|
2010-08-06 04:22:44 +02:00
|
|
|
dirty(false),
|
2010-07-15 23:41:29 +02:00
|
|
|
cached(false),
|
|
|
|
enableStorage(false),
|
2011-10-30 10:35:29 +01:00
|
|
|
isStored(true)
|
2011-04-28 11:22:08 +02:00
|
|
|
{
|
|
|
|
}
|
2008-11-04 00:08:39 +01:00
|
|
|
|
2011-06-03 16:04:50 +02:00
|
|
|
/**
|
|
|
|
* 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, because a listener
|
|
|
|
* to becameUnused() may have deleted it.
|
|
|
|
**/
|
|
|
|
void checkUsage();
|
|
|
|
|
2008-11-04 00:08:39 +01:00
|
|
|
SignalRelay *signalRelay(const DataContainer *dc, QObject *visualization,
|
|
|
|
uint pollingInterval, Plasma::IntervalAlignment align,
|
|
|
|
bool immediateUpdate);
|
|
|
|
|
|
|
|
bool hasUpdates();
|
|
|
|
|
2010-08-06 04:22:44 +02:00
|
|
|
/**
|
|
|
|
* Deletes the store member of DataContainerPrivate if
|
|
|
|
* there are no more references to it.
|
|
|
|
*/
|
|
|
|
void storeJobFinished(KJob *job);
|
|
|
|
|
2010-08-06 04:28:50 +02:00
|
|
|
/**
|
|
|
|
* Does the work of putting the data from disk into the DataContainer
|
|
|
|
* after retrieve() sets it up.
|
|
|
|
*/
|
|
|
|
void populateFromStoredData(KJob *job);
|
2010-08-06 04:22:44 +02:00
|
|
|
|
2010-10-01 18:58:15 +02:00
|
|
|
void store();
|
|
|
|
void retrieve();
|
|
|
|
|
2010-08-06 04:28:50 +02:00
|
|
|
DataContainer *q;
|
2008-11-04 00:08:39 +01:00
|
|
|
DataEngine::Data data;
|
|
|
|
QMap<QObject *, SignalRelay *> relayObjects;
|
|
|
|
QMap<uint, SignalRelay *> relays;
|
|
|
|
QTime updateTs;
|
2010-10-01 18:58:15 +02:00
|
|
|
Storage* storage;
|
2011-10-30 10:35:29 +01:00
|
|
|
QBasicTimer storageTimer;
|
|
|
|
QBasicTimer checkUsageTimer;
|
|
|
|
int storageCount;
|
2008-11-04 00:08:39 +01:00
|
|
|
bool dirty : 1;
|
|
|
|
bool cached : 1;
|
2010-07-15 23:41:29 +02:00
|
|
|
bool enableStorage : 1;
|
|
|
|
bool isStored : 1;
|
2008-11-04 00:08:39 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
class SignalRelay : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
SignalRelay(DataContainer *parent, DataContainerPrivate *data,
|
|
|
|
uint ival, Plasma::IntervalAlignment align, bool immediateUpdate);
|
|
|
|
|
|
|
|
int receiverCount() const;
|
2009-06-27 03:26:33 +02:00
|
|
|
bool isUnused() const;
|
2008-11-04 00:08:39 +01:00
|
|
|
|
|
|
|
void checkAlignment();
|
|
|
|
void checkQueueing();
|
2009-06-27 03:26:33 +02:00
|
|
|
void forceImmediateUpdate();
|
2008-11-04 00:08:39 +01:00
|
|
|
|
|
|
|
DataContainer *dc;
|
|
|
|
DataContainerPrivate *d;
|
|
|
|
uint m_interval;
|
|
|
|
Plasma::IntervalAlignment m_align;
|
|
|
|
int m_timerId;
|
|
|
|
bool m_resetTimer;
|
|
|
|
bool m_queued;
|
|
|
|
|
|
|
|
signals:
|
|
|
|
void dataUpdated(const QString &, const Plasma::DataEngine::Data &);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void timerEvent(QTimerEvent *event);
|
|
|
|
};
|
|
|
|
|
|
|
|
} // Plasma namespace
|
|
|
|
|
|
|
|
#endif // multiple inclusion guard
|
|
|
|
|