• Skip to content
  • Skip to link menu
KDE 4.6 API Reference
  • KDE API Reference
  • kdelibs
  • KDE Home
  • Contact Us
 

Plasma

  • Plasma
  • DataContainer
Public Slots | Signals | Public Member Functions | Protected Slots | Protected Member Functions

Plasma::DataContainer Class Reference

A set of data exported via a DataEngine. More...

#include <Plasma/DataContainer>

Inheritance diagram for Plasma::DataContainer:
Inheritance graph
[legend]

List of all members.

Public Slots

void disconnectVisualization (QObject *visualization)
void forceImmediateUpdate ()

Signals

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

Public Member Functions

 DataContainer (QObject *parent=0)
virtual ~DataContainer ()
void connectVisualization (QObject *visualization, uint pollingInterval, Plasma::IntervalAlignment alignment)
const DataEngine::Data data () const
DataEngine * getDataEngine ()
bool isStorageEnabled () const
bool needsToBeStored () const
void removeAllData ()
void setData (const QString &key, const QVariant &value)
void setNeedsToBeStored (bool store)
void setStorageEnabled (bool store)
bool visualizationIsConnected (QObject *visualization) const

Protected Slots

void checkUsage ()

Protected Member Functions

void checkForUpdate ()
void setNeedsUpdate (bool update=true)
uint timeSinceLastUpdate () const

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 retreival for a source, since all notifications are done via signals rather than virtual methods.

Definition at line 63 of file datacontainer.h.


Constructor & Destructor Documentation

builddir build BUILD kdelibs plasma datacontainer cpp Plasma::DataContainer::DataContainer ( QObject *  parent = 0) [explicit]

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

Definition at line 31 of file datacontainer.cpp.

Plasma::DataContainer::~DataContainer ( ) [virtual]

Definition at line 37 of file datacontainer.cpp.


Member Function Documentation

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
void Plasma::DataContainer::checkForUpdate ( ) [protected]

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

Definition at line 324 of file datacontainer.cpp.

void Plasma::DataContainer::checkUsage ( ) [protected, slot]

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.

Definition at line 362 of file datacontainer.cpp.

void Plasma::DataContainer::connectVisualization ( QObject *  visualization,
uint  pollingInterval,
Plasma::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 86 of file datacontainer.cpp.

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

Returns the data for this DataContainer.

Definition at line 42 of file datacontainer.cpp.

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
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 298 of file datacontainer.cpp.

void Plasma::DataContainer::forceImmediateUpdate ( ) [slot]

Forces immediate update signals to all visualizations.

Since:
4.4

Definition at line 338 of file datacontainer.cpp.

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

Definition at line 173 of file datacontainer.cpp.

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

Definition at line 158 of file datacontainer.cpp.

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

Definition at line 163 of file datacontainer.cpp.

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 69 of file datacontainer.cpp.

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 47 of file datacontainer.cpp.

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 168 of file datacontainer.cpp.

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 357 of file datacontainer.cpp.

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 148 of file datacontainer.cpp.

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 350 of file datacontainer.cpp.

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.
bool Plasma::DataContainer::visualizationIsConnected ( QObject *  visualization) const
Returns:
true if the visualization is currently connected

Definition at line 81 of file datacontainer.cpp.


The documentation for this class was generated from the following files:
  • datacontainer.h
  • datacontainer.cpp

Plasma

Skip menu "Plasma"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

kdelibs

Skip menu "kdelibs"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • Kate
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.7.3
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal