Plasma::DataContainer

Search for usage in LXR

#include <Plasma/DataContainer>

Inheritance diagram for Plasma::DataContainer:

Signals

void becameUnused (const QString &source)
 
void dataUpdated (const QString &source, const Plasma::DataEngine::Data &data)
 
void modelChanged (const QString &source, QAbstractItemModel *model)
 
void updateRequested (DataContainer *source)
 

Public Slots

void disconnectVisualization (QObject *visualization)
 
void forceImmediateUpdate ()
 

Public Member Functions

 DataContainer (QObject *parent=nullptr)
 
void connectVisualization (QObject *visualization, uint pollingInterval, Plasma::Types::IntervalAlignment alignment)
 
const DataEngine::Data data () const
 
DataEnginegetDataEngine ()
 
bool isStorageEnabled () const
 
bool isUsed () const
 
QAbstractItemModelmodel ()
 
bool needsToBeStored () const
 
void removeAllData ()
 
void setData (const QString &key, const QVariant &value)
 
void setModel (QAbstractItemModel *model)
 
void setNeedsToBeStored (bool store)
 
void setStorageEnabled (bool store)
 
bool visualizationIsConnected (QObject *visualization) const
 
- Public Member Functions inherited from QObject
 QObject (QObject *parent)
 
bool blockSignals (bool block)
 
const QObjectListchildren () const const
 
QMetaObject::Connection connect (const QObject *sender, const char *signal, const char *method, Qt::ConnectionType type) const const
 
void deleteLater ()
 
void destroyed (QObject *obj)
 
bool disconnect (const char *signal, const QObject *receiver, const char *method) const const
 
bool disconnect (const QObject *receiver, const char *method) const const
 
void dumpObjectInfo ()
 
void dumpObjectInfo () const const
 
void dumpObjectTree ()
 
void dumpObjectTree () const const
 
QList< QByteArraydynamicPropertyNames () const const
 
virtual bool event (QEvent *e)
 
virtual bool eventFilter (QObject *watched, QEvent *event)
 
findChild (const QString &name, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QRegExp &regExp, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QRegularExpression &re, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QString &name, Qt::FindChildOptions options) const const
 
bool inherits (const char *className) const const
 
void installEventFilter (QObject *filterObj)
 
bool isWidgetType () const const
 
bool isWindowType () const const
 
void killTimer (int id)
 
virtual const QMetaObjectmetaObject () const const
 
void moveToThread (QThread *targetThread)
 
QString objectName () const const
 
void objectNameChanged (const QString &objectName)
 
QObjectparent () const const
 
QVariant property (const char *name) const const
 
 Q_CLASSINFO (Name, Value)
 
 Q_DISABLE_COPY (Class)
 
 Q_DISABLE_COPY_MOVE (Class)
 
 Q_DISABLE_MOVE (Class)
 
 Q_EMIT Q_EMIT
 
 Q_ENUM (...)
 
 Q_ENUM_NS (...)
 
 Q_ENUMS (...)
 
 Q_FLAG (...)
 
 Q_FLAG_NS (...)
 
 Q_FLAGS (...)
 
 Q_GADGET Q_GADGET
 
 Q_INTERFACES (...)
 
 Q_INVOKABLE Q_INVOKABLE
 
 Q_NAMESPACE Q_NAMESPACE
 
 Q_NAMESPACE_EXPORT (EXPORT_MACRO)
 
 Q_OBJECT Q_OBJECT
 
 Q_PROPERTY (...)
 
 Q_REVISION Q_REVISION
 
 Q_SET_OBJECT_NAME (Object)
 
 Q_SIGNAL Q_SIGNAL
 
 Q_SIGNALS Q_SIGNALS
 
 Q_SLOT Q_SLOT
 
 Q_SLOTS Q_SLOTS
 
qFindChild (const QObject *obj, const QString &name)
 
QList< T > qFindChildren (const QObject *obj, const QRegExp &regExp)
 
QList< T > qFindChildren (const QObject *obj, const QString &name)
 
qobject_cast (const QObject *object)
 
qobject_cast (QObject *object)
 
 QT_NO_NARROWING_CONVERSIONS_IN_CONNECT QT_NO_NARROWING_CONVERSIONS_IN_CONNECT
 
void removeEventFilter (QObject *obj)
 
void setObjectName (const QString &name)
 
void setParent (QObject *parent)
 
bool setProperty (const char *name, const QVariant &value)
 
bool signalsBlocked () const const
 
int startTimer (int interval, Qt::TimerType timerType)
 
int startTimer (std::chrono::milliseconds time, Qt::TimerType timerType)
 
QThreadthread () const const
 

Protected Slots

void timerEvent (QTimerEvent *event) override
 

Protected Member Functions

void checkForUpdate ()
 
void setNeedsUpdate (bool update=true)
 
uint timeSinceLastUpdate () const
 
- Protected Member Functions inherited from QObject
virtual void childEvent (QChildEvent *event)
 
virtual void connectNotify (const QMetaMethod &signal)
 
virtual void customEvent (QEvent *event)
 
virtual void disconnectNotify (const QMetaMethod &signal)
 
bool isSignalConnected (const QMetaMethod &signal) const const
 
int receivers (const char *signal) const const
 
QObjectsender () const const
 
int senderSignalIndex () const const
 
virtual void timerEvent (QTimerEvent *event)
 

Additional Inherited Members

- Properties inherited from QObject
 objectName
 
- Static Public Member Functions inherited from QObject
QMetaObject::Connection connect (const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, const QObject *context, Functor functor, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, Functor functor)
 
bool disconnect (const QMetaObject::Connection &connection)
 
bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *method)
 
bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method)
 
bool disconnect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method)
 
QString tr (const char *sourceText, const char *disambiguation, int n)
 
QString trUtf8 (const char *sourceText, const char *disambiguation, int n)
 
- Public Attributes inherited from QObject
typedef QObjectList
 

Detailed Description

A set of data exported via a DataEngine.

Plasma::DataContainer wraps the data exported by a DataEngine implementation, providing a generic wrapper for the data.

A DataContainer may have zero or more associated pieces of data which are keyed by strings. The data itself is stored as QVariants. This allows easy and flexible retrieval of the information associated with this object without writing DataContainer or DataEngine specific code in visualizations.

If you are creating your own DataContainer objects (and are passing them to DataEngine::addSource()), you normally just need to listen to the updateRequested() signal (as well as any other methods you might have of being notified of new data) and call setData() to actually update the data. Then you need to either trigger the scheduleSourcesUpdated signal of the parent DataEngine or call checkForUpdate() on the DataContainer.

You also need to set a suitable name for the source with setObjectName(). See DataEngine::addSource() for more information.

Note that there is normally no need to subclass DataContainer, except as a way of encapsulating the data retrieval for a source, since all notifications are done via signals rather than virtual methods.

Definition at line 51 of file datacontainer.h.

Constructor & Destructor Documentation

◆ DataContainer()

Plasma::DataContainer::DataContainer ( QObject parent = nullptr)
explicit

Constructs a default DataContainer that has no name or data associated with it.

Definition at line 19 of file datacontainer.cpp.

Member Function Documentation

◆ becameUnused

void Plasma::DataContainer::becameUnused ( const QString source)
signal

Emitted when the last visualization is disconnected.

Note that if this source was created by DataEngine::sourceRequestEvent(), it will be deleted by DataEngine once control returns to the event loop after this signal is emitted.

Parameters
sourcethe name of the source that became unused

◆ checkForUpdate()

void Plasma::DataContainer::checkForUpdate ( )
protected

Checks whether any data has changed and, if so, emits dataUpdated().

Definition at line 321 of file datacontainer.cpp.

◆ connectVisualization()

void Plasma::DataContainer::connectVisualization ( QObject visualization,
uint  pollingInterval,
Plasma::Types::IntervalAlignment  alignment 
)

Connects an object to this DataContainer.

May be called repeatedly for the same visualization without side effects

Parameters
visualizationthe object to connect to this DataContainer
pollingIntervalthe time in milliseconds between updates
alignmentthe clock position to align updates to

Definition at line 94 of file datacontainer.cpp.

◆ data()

const DataEngine::Data Plasma::DataContainer::data ( ) const

Returns the data for this DataContainer.

Definition at line 30 of file datacontainer.cpp.

◆ dataUpdated

void Plasma::DataContainer::dataUpdated ( const QString source,
const Plasma::DataEngine::Data data 
)
signal

Emitted when the data has been updated, allowing visualizations to reflect the new data.

Note that you should not normally emit this directly. Instead, use checkForUpdate() or the DataEngine::scheduleSourcesUpdated() slot.

Parameters
sourcethe objectName() of the DataContainer (and hence the name of the source) that updated its data
datathe updated data

◆ disconnectVisualization

void Plasma::DataContainer::disconnectVisualization ( QObject visualization)
slot

Disconnects an object from this DataContainer.

Note that if this source was created by DataEngine::sourceRequestEvent(), it will be deleted by DataEngine once control returns to the event loop.

Definition at line 287 of file datacontainer.cpp.

◆ forceImmediateUpdate

void Plasma::DataContainer::forceImmediateUpdate ( )
slot

Forces immediate update signals to all visualizations.

Since
4.4

Definition at line 337 of file datacontainer.cpp.

◆ getDataEngine()

DataEngine * Plasma::DataContainer::getDataEngine ( )
Returns
the DataEngine that the DataContainer is a child of.

Definition at line 197 of file datacontainer.cpp.

◆ isStorageEnabled()

bool Plasma::DataContainer::isStorageEnabled ( ) const
Returns
true if the data container has been marked for storage
Since
4.6

Definition at line 182 of file datacontainer.cpp.

◆ isUsed()

bool Plasma::DataContainer::isUsed ( ) const
Returns
true if one or more visualizations is connected to this DataContainer

Definition at line 359 of file datacontainer.cpp.

◆ model()

QAbstractItemModel * Plasma::DataContainer::model ( )
Returns
the model owned by this DataSource

Definition at line 72 of file datacontainer.cpp.

◆ modelChanged

void Plasma::DataContainer::modelChanged ( const QString source,
QAbstractItemModel model 
)
signal

A new model has been associated to this source, visualizations can safely use it as long they are connected to this source.

Parameters
sourcethe objectName() of the DataContainer (and hence the name of the source) that owns the model
modelthe QAbstractItemModel instance

◆ needsToBeStored()

bool Plasma::DataContainer::needsToBeStored ( ) const
Returns
true if the data container has been updated, but not stored

Definition at line 187 of file datacontainer.cpp.

◆ removeAllData()

void Plasma::DataContainer::removeAllData ( )

Removes all data currently associated with this source.

If you call removeAllData() on a DataContainer, you need to either trigger the scheduleSourcesUpdated() slot for the data engine it belongs to or call checkForUpdate() on the DataContainer.

Definition at line 77 of file datacontainer.cpp.

◆ setData()

void Plasma::DataContainer::setData ( const QString key,
const QVariant value 
)

Set a value for a key.

This also marks this source as needing to signal an update.

If you call setData() directly on a DataContainer, you need to either trigger the scheduleSourcesUpdated() slot for the data engine it belongs to or call checkForUpdate() on the DataContainer.

Parameters
keya string used as the key for the data
valuea QVariant holding the actual data. If a invalid QVariant is passed in and the key currently exists in the data, then the data entry is removed

Definition at line 35 of file datacontainer.cpp.

◆ setModel()

void Plasma::DataContainer::setModel ( QAbstractItemModel model)

Associates a model with this DataContainer.

Use this for data that is intended to be a long list of items.

The ownership of the model is transferred to the DataContainer, so the model will be deleted when a new one is set or when the DataContainer itself is deleted, so it will be deleted when there won't be any visualization associated to this source.

Normally you should set the model from DataEngine::setModel instead from here.

Parameters
modelthe model that will be associated with this DataContainer

Definition at line 57 of file datacontainer.cpp.

◆ setNeedsToBeStored()

void Plasma::DataContainer::setNeedsToBeStored ( bool  store)

sets that the data container needs to be stored or not.

Parameters
whetherthe data container needs to be stored

Definition at line 192 of file datacontainer.cpp.

◆ setNeedsUpdate()

void Plasma::DataContainer::setNeedsUpdate ( bool  update = true)
protected

Indicates that the data should be treated as dirty the next time hasUpdates() is called.

This is needed for the case where updateRequested() is triggered but we don't want to update the data immediately because it has just been updated. The second request won't be fulfilled in this case, because we never updated the data and so never called checkForUpdate(). So we claim it needs an update anyway.

Definition at line 354 of file datacontainer.cpp.

◆ setStorageEnabled()

void Plasma::DataContainer::setStorageEnabled ( bool  store)

sets this data container to be automatically stored.

Parameters
whetherthis data container should be stored
Since
4.6

Definition at line 174 of file datacontainer.cpp.

◆ timerEvent

void Plasma::DataContainer::timerEvent ( QTimerEvent event)
overrideprotectedslot
Reimplemented from superclass. from QObject

Definition at line 371 of file datacontainer.cpp.

◆ timeSinceLastUpdate()

uint Plasma::DataContainer::timeSinceLastUpdate ( ) const
protected

Returns how long ago, in msecs, that the data in this container was last updated.

This is used by DataEngine to compress updates that happen more quickly than the minimum polling interval by calling setNeedsUpdate() instead of calling updateSourceEvent() immediately.

Definition at line 349 of file datacontainer.cpp.

◆ updateRequested

void Plasma::DataContainer::updateRequested ( DataContainer source)
signal

Emitted when an update is requested.

If a polling interval was passed connectVisualization(), this signal will be emitted every time the interval expires.

Note that if you create your own DataContainer (and pass it to DataEngine::addSource()), you will need to listen to this signal and refresh the data when it is triggered.

Parameters
sourcethe datacontainer the update was requested for. Useful for classes that update the data for several containers.

◆ visualizationIsConnected()

bool Plasma::DataContainer::visualizationIsConnected ( QObject visualization) const
Returns
true if the visualization is currently connected

Definition at line 89 of file datacontainer.cpp.


The documentation for this class was generated from the following files:
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Sun Feb 5 2023 04:14:16 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.