Plasma5Support::DataContainer
Signals | |
void | becameUnused (const QString &source) |
void | dataUpdated (const QString &source, const Plasma5Support::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, Plasma5Support::Types::IntervalAlignment alignment) |
const DataEngine::Data | data () const |
DataEngine * | getDataEngine () |
bool | isStorageEnabled () const |
bool | isUsed () const |
QAbstractItemModel * | model () |
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) | |
QBindable< QString > | bindableObjectName () |
bool | blockSignals (bool block) |
const QObjectList & | children () 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 () const const |
void | dumpObjectTree () const const |
QList< QByteArray > | dynamicPropertyNames () const const |
virtual bool | event (QEvent *e) |
virtual bool | eventFilter (QObject *watched, QEvent *event) |
T | findChild (const QString &name, 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 |
QList< T > | findChildren (Qt::FindChildOptions options) const const |
bool | inherits (const char *className) const const |
void | installEventFilter (QObject *filterObj) |
bool | isQuickItemType () const const |
bool | isWidgetType () const const |
bool | isWindowType () const const |
void | killTimer (int id) |
virtual const QMetaObject * | metaObject () const const |
void | moveToThread (QThread *targetThread) |
QString | objectName () const const |
void | objectNameChanged (const QString &objectName) |
QObject * | parent () const const |
QVariant | property (const char *name) const const |
Q_CLASSINFO (Name, Value) | |
Q_EMIT Q_EMIT | |
Q_ENUM (...) | |
Q_ENUM_NS (...) | |
Q_ENUMS (...) | |
Q_FLAG (...) | |
Q_FLAG_NS (...) | |
Q_FLAGS (...) | |
Q_GADGET Q_GADGET | |
Q_GADGET_EXPORT (EXPORT_MACRO) | |
Q_INTERFACES (...) | |
Q_INVOKABLE Q_INVOKABLE | |
Q_MOC_INCLUDE Q_MOC_INCLUDE | |
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 | |
T | qobject_cast (const QObject *object) |
T | 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 | setObjectName (QAnyStringView name) |
void | setParent (QObject *parent) |
bool | setProperty (const char *name, const QVariant &value) |
bool | setProperty (const char *name, QVariant &&value) |
bool | signalsBlocked () const const |
int | startTimer (int interval, Qt::TimerType timerType) |
int | startTimer (std::chrono::milliseconds interval, Qt::TimerType timerType) |
QThread * | thread () 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 |
QObject * | sender () const const |
int | senderSignalIndex () const const |
virtual void | timerEvent (QTimerEvent *event) |
Additional Inherited Members | |
Public Types inherited from QObject | |
typedef | QObjectList |
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) |
Detailed Description
A set of data exported via a DataEngine.
Plasma5Support::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()
|
explicit |
Constructs a default DataContainer that has no name or data associated with it.
Definition at line 19 of file datacontainer.cpp.
◆ ~DataContainer()
|
override |
Definition at line 25 of file datacontainer.cpp.
Member Function Documentation
◆ becameUnused
|
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
-
source the name of the source that became unused
◆ checkForUpdate()
|
protected |
Checks whether any data has changed and, if so, emits dataUpdated().
Definition at line 339 of file datacontainer.cpp.
◆ connectVisualization()
void Plasma5Support::DataContainer::connectVisualization | ( | QObject * | visualization, |
uint | pollingInterval, | ||
Plasma5Support::Types::IntervalAlignment | alignment ) |
Connects an object to this DataContainer.
May be called repeatedly for the same visualization without side effects
- Parameters
-
visualization the object to connect to this DataContainer pollingInterval the time in milliseconds between updates alignment the clock position to align updates to
Definition at line 94 of file datacontainer.cpp.
◆ data()
const DataEngine::Data Plasma5Support::DataContainer::data | ( | ) | const |
Returns the data for this DataContainer.
Definition at line 30 of file datacontainer.cpp.
◆ dataUpdated
|
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
-
source the objectName() of the DataContainer (and hence the name of the source) that updated its data data the updated data
◆ disconnectVisualization
|
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 296 of file datacontainer.cpp.
◆ forceImmediateUpdate
|
slot |
Forces immediate update signals to all visualizations.
- Since
- 4.4
Definition at line 355 of file datacontainer.cpp.
◆ getDataEngine()
DataEngine * Plasma5Support::DataContainer::getDataEngine | ( | ) |
- Returns
- the DataEngine that the DataContainer is a child of.
Definition at line 206 of file datacontainer.cpp.
◆ isStorageEnabled()
bool Plasma5Support::DataContainer::isStorageEnabled | ( | ) | const |
- Returns
- true if the data container has been marked for storage
- Since
- 4.6
Definition at line 191 of file datacontainer.cpp.
◆ isUsed()
bool Plasma5Support::DataContainer::isUsed | ( | ) | const |
- Returns
- true if one or more visualizations is connected to this DataContainer
Definition at line 377 of file datacontainer.cpp.
◆ model()
QAbstractItemModel * Plasma5Support::DataContainer::model | ( | ) |
- Returns
- the model owned by this DataSource
Definition at line 72 of file datacontainer.cpp.
◆ modelChanged
|
signal |
A new model has been associated to this source, visualizations can safely use it as long they are connected to this source.
- Parameters
-
source the objectName() of the DataContainer (and hence the name of the source) that owns the model model the QAbstractItemModel instance
◆ needsToBeStored()
bool Plasma5Support::DataContainer::needsToBeStored | ( | ) | const |
- Returns
- true if the data container has been updated, but not stored
Definition at line 196 of file datacontainer.cpp.
◆ removeAllData()
void Plasma5Support::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()
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
-
key a string used as the key for the data value a 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 Plasma5Support::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
-
model the model that will be associated with this DataContainer
Definition at line 57 of file datacontainer.cpp.
◆ setNeedsToBeStored()
void Plasma5Support::DataContainer::setNeedsToBeStored | ( | bool | store | ) |
sets that the data container needs to be stored or not.
- Parameters
-
whether the data container needs to be stored
Definition at line 201 of file datacontainer.cpp.
◆ setNeedsUpdate()
|
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 372 of file datacontainer.cpp.
◆ setStorageEnabled()
void Plasma5Support::DataContainer::setStorageEnabled | ( | bool | store | ) |
sets this data container to be automatically stored.
- Parameters
-
whether this data container should be stored
- Since
- 4.6
Definition at line 183 of file datacontainer.cpp.
◆ timerEvent
|
overrideprotectedslot |
- Reimplemented from superclass. from QObject
Definition at line 389 of file datacontainer.cpp.
◆ timeSinceLastUpdate()
|
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 367 of file datacontainer.cpp.
◆ updateRequested
|
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
-
source the datacontainer the update was requested for. Useful for classes that update the data for several containers.
◆ visualizationIsConnected()
bool Plasma5Support::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:
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 16:59:38 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.