Akonadi::AgentBase::Observer Class

class Akonadi::AgentBase::Observer

Public 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

* \short 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. * *

Note: 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.krammer@gmx.at> * * @deprecated Use ObserverV2 instead

Member Function Documentation

Observer::Observer()

Creates an observer instance.

[virtual noexcept] Observer::~Observer()

Destroys the observer instance.

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

Reimplement to handle adding of new collections. collection The newly added collection. parent The parent collection.

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

Reimplement to handle changes to existing collections. collection The changed collection.

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

Reimplement to handle deletion of collections. collection The deleted collection.

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

Reimplement to handle adding of new items. item The newly added item. collection The collection \p item got added to.

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

Reimplement to handle changes to existing items. item The changed item. partIdentifiers The identifiers of the item parts that has been changed.

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

Reimplement to handle deletion of items. item The deleted item.