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

Plasma

  • Plasma
  • DataContainer
Public Slots | Signals | Public Member Functions | Protected Slots | Protected Member Functions | List of all members
Plasma::DataContainer Class Reference

#include <Plasma/DataContainer>

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

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 ()
 
void timerEvent (QTimerEvent *event)
 

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 retrieval 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

Plasma::DataContainer::DataContainer ( QObject *  parent = 0)
explicit

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

Definition at line 30 of file datacontainer.cpp.

Plasma::DataContainer::~DataContainer ( )
virtual

Definition at line 36 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 290 of file datacontainer.cpp.

void Plasma::DataContainer::checkUsage ( )
protectedslot

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

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

Returns the data for this DataContainer.

Definition at line 41 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 264 of file datacontainer.cpp.

void Plasma::DataContainer::forceImmediateUpdate ( )
slot

Forces immediate update signals to all visualizations.

Since
4.4

Definition at line 304 of file datacontainer.cpp.

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

Definition at line 172 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 157 of file datacontainer.cpp.

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

Definition at line 162 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 68 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 46 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 167 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 323 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 147 of file datacontainer.cpp.

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

Definition at line 335 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 316 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 80 of file datacontainer.cpp.


The documentation for this class was generated from the following files:
  • datacontainer.h
  • datacontainer.cpp
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:48:35 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

Plasma

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

kdelibs API Reference

Skip menu "kdelibs API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  • kjsembed
  •   WTF
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Nepomuk-Core
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal