• Skip to content
  • Skip to link menu
Brand

API Documentation

  1. KDE API Reference
  2. KDE PIM
  3. Akonadi
  • KDE Home
  • Contact Us

Quick Links

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

Class Picker

About

PIM Storage Framework

Maintainer
Daniel Vrátil
Supported platforms
Linux
Community
IRC: #akonadi on Freenode
Mailing list: kde-pim
Use with CMake
find_package(KF5AkonadiCore)
target_link_libraries(yourapp KF5::AkonadiCore)
Use with QMake
QT += AkonadiCore 
Clone
git clone git://anongit.kde.org/akonadi.git
Browse source
Akonadi on cgit.kde.org

Akonadi

  • View on LXR
  • Akonadi
  • AgentBase
  • Observer
Public Member Functions | List of all members
Akonadi::AgentBase::Observer Class Reference

#include <agentbase.h>

Inheritance diagram for Akonadi::AgentBase::Observer:
Inheritance graph
[legend]

Public Member Functions

 Observer ()
 
virtual ~Observer ()
 
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)
 

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.
Do not call the base implementation of reimplemented virtual methods! The default implementation disconnected themselves from the Akonadi::ChangeRecorder to enable internal optimizations for unused notifications.

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
qCDebug(AKONADIAGENTBASE_LOG) << "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
qCDebug(AKONADIAGENTBASE_LOG) << "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[email protected].kra[email protected][email protected][email protected]gmx.[email protected]at
Deprecated:
Use ObserverV2 instead

Definition at line 190 of file agentbase.h.

Constructor & Destructor Documentation

AgentBase::Observer::Observer ( )

Creates an observer instance.

Definition at line 75 of file agentbase.cpp.

AgentBase::Observer::~Observer ( )
virtual

Destroys the observer instance.

Definition at line 79 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
collectionThe newly added collection.
parentThe parent collection.

Definition at line 109 of file agentbase.cpp.

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

Reimplement to handle changes to existing collections.

Parameters
collectionThe changed collection.

Definition at line 118 of file agentbase.cpp.

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

Reimplement to handle deletion of collections.

Parameters
collectionThe deleted collection.

Definition at line 126 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
itemThe newly added item.
collectionThe collection item got added to.

Definition at line 83 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
itemThe changed item.
partIdentifiersThe identifiers of the item parts that has been changed.

Definition at line 92 of file agentbase.cpp.

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

Reimplement to handle deletion of items.

Parameters
itemThe deleted item.

Definition at line 101 of file agentbase.cpp.


The documentation for this class was generated from the following files:
  • agentbase.h
  • agentbase.cpp
This file is part of the KDE documentation.
Documentation copyright © 1996-2019 The KDE developers.
Generated on Sun Dec 15 2019 03:00:47 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

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