• Skip to content
  • Skip to link menu
KDE 4.2 API Reference
  • KDE API Reference
  • KDE-PIM Libraries
  • Sitemap
  • Contact Us
 

akonadi

Akonadi::AgentBase::Observer

Akonadi::AgentBase::Observer Class Reference

The interface for reacting on monitored or replayed changes. More...

#include <agentbase.h>

List of all members.


Public Member Functions

virtual void collectionAdded (const Akonadi::Collection &collection, const Akonadi::Collection &parent)
virtual void collectionChanged (const Akonadi::Collection &collection)
virtual void collectionRemoved (const Akonadi::Collection &collection)
virtual void itemAdded (const Akonadi::Item &item, const Akonadi::Collection &collection)
virtual void itemChanged (const Akonadi::Item &item, const QSet< QByteArray > &partIdentifiers)
virtual void itemRemoved (const Akonadi::Item &item)
 Observer ()
virtual ~Observer ()

Detailed Description

The interface for reacting on monitored or replayed changes.

The Observer provides an interface to react on monitored or replayed changes.

Since the this base class does only tell the change recorder that the change has been processed, an AgentBase subclass which wants to actually process the change needs to subclass Observer and reimplement the methods it is interested in.

Such an agent specific Observer implementation can either be done stand-alone, i.e. as a separate object, or by inheriting both AgentBase and AgentBase::Observer.

The observer implementation then has registered with the agent, so it can forward the incoming changes to the observer.

Note:
In the multiple inheritance approach the init() method automatically registers itself as the observer.
Example for stand-alone observer:
 class ExampleAgent : public AgentBase
 {
   public:
     ExampleAgent( const QString &id );

     ~ExampleAgent();

   private:
     AgentBase::Observer *mObserver;
 };

 class ExampleObserver : public AgentBase::Observer
 {
   protected:
     void itemChanged( const Item &item );
 };

 ExampleAgent::ExampleAgent( const QString &id )
   : AgentBase( id ), mObserver( 0 )
 {
   mObserver = new ExampleObserver();
   registerObserver( mObserver );
 }

 ExampleAgent::~ExampleAgent()
 {
   delete mObserver;
 }

 void ExampleObserver::itemChanged( const Item &item )
 {
   // do something with item
   kDebug() << "Item id=" << item.id();

   // let base implementation tell the change recorder that we
   // have processed the change
   AgentBase::Observer::itemChanged( item );
 }

Example for observer through multiple inheritance:

 class ExampleAgent : public AgentBase, public AgentBase::Observer
 {
   public:
     ExampleAgent( const QString &id );

   protected:
     void itemChanged( const Item &item );
 };

 ExampleAgent::ExampleAgent( const QString &id )
   : AgentBase( id )
 {
   // no need to create or register observer since
   // we are the observer and registration happens automatically
   // in init()
 }

 void ExampleAgent::itemChanged( const Item &item )
 {
   // do something with item
   kDebug() << "Item id=" << item.id();

   // let base implementation tell the change recorder that we
   // have processed the change
   AgentBase::Observer::itemChanged( item );
 }

Author:
Kevin Krammer <kevin.krammer@gmx.at>

Definition at line 157 of file agentbase.h.


Constructor & Destructor Documentation

AgentBase::Observer::Observer (  ) 

Creates an observer instance.

Definition at line 55 of file agentbase.cpp.

AgentBase::Observer::~Observer (  )  [virtual]

Destroys the observer instance.

Definition at line 59 of file agentbase.cpp.


Member Function Documentation

void AgentBase::Observer::collectionAdded ( const Akonadi::Collection &  collection,
const Akonadi::Collection &  parent 
) [virtual]

Reimplement to handle adding of new collections.

Parameters:
collection The newly added collection.
parent The parent collection.

Definition at line 89 of file agentbase.cpp.

void AgentBase::Observer::collectionChanged ( const Akonadi::Collection &  collection  )  [virtual]

Reimplement to handle changes to existing collections.

Parameters:
collection The changed collection.

Definition at line 98 of file agentbase.cpp.

void AgentBase::Observer::collectionRemoved ( const Akonadi::Collection &  collection  )  [virtual]

Reimplement to handle deletion of collections.

Parameters:
collection The deleted collection.

Definition at line 106 of file agentbase.cpp.

void AgentBase::Observer::itemAdded ( const Akonadi::Item &  item,
const Akonadi::Collection &  collection 
) [virtual]

Reimplement to handle adding of new items.

Parameters:
item The newly added item.
collection The collection item got added to.

Definition at line 63 of file agentbase.cpp.

void AgentBase::Observer::itemChanged ( const Akonadi::Item &  item,
const QSet< QByteArray > &  partIdentifiers 
) [virtual]

Reimplement to handle changes to existing items.

Parameters:
item The changed item.
partIdentifiers The identifiers of the item parts that has been changed.

Definition at line 72 of file agentbase.cpp.

void AgentBase::Observer::itemRemoved ( const Akonadi::Item &  item  )  [virtual]

Reimplement to handle deletion of items.

Parameters:
item The deleted item.

Definition at line 81 of file agentbase.cpp.


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

akonadi

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

KDE-PIM Libraries

Skip menu "KDE-PIM Libraries"
  • akonadi
  • kabc
  • kblog
  • kcal
  • kimap
  • kioslave
  •   imap4
  •   mbox
  • kldap
  • kmime
  • kpimidentities
  •   richtextbuilders
  • kpimutils
  • kresources
  • ktnef
  • kxmlrpcclient
  • mailtransport
  • qgpgme
  • syndication
  •   atom
  •   rdf
  •   rss2
Generated for KDE-PIM Libraries by doxygen 1.5.7.1
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