#include <itemmonitor.h>

Inheritance diagram for Akonadi::ItemMonitor:

Public Member Functions

 ItemMonitor ()
virtual ~ItemMonitor ()
Item item () const
void setItem (const Item &item)

Protected Member Functions

ItemFetchScopefetchScope ()
virtual void itemChanged (const Item &item)
virtual void itemRemoved ()
void setFetchScope (const ItemFetchScope &fetchScope)

Detailed Description

A convenience class to monitor a single item for changes.

This class can be used as a base class for classes that want to show a single item to the user and keep track of status changes of the item without having to using a Monitor object themself.


// A label that shows the name of a contact item
class ContactLabel : public QLabel, public Akonadi::ItemMonitor
ContactLabel( QWidget *parent = nullptr )
: QLabel( parent )
setText( "No Name" );
virtual void itemChanged( const Akonadi::Item &item )
if ( item.mimeType() != "text/directory" )
const KContacts::Addressee addr = item.payload<KContacts::Addressee>();
setText( addr.fullName() );
virtual void itemRemoved()
setText( "No Name" );
ContactLabel *label = new ContactLabel( this );
const Akonadi::Item item = fetchJob->items().at(0);
label->setItem( item );
Tobias Koenig tokoe[email protected]@kde[email protected].org

Definition at line 68 of file itemmonitor.h.

Constructor & Destructor Documentation

ItemMonitor::ItemMonitor ( )

Creates a new item monitor.

Definition at line 15 of file itemmonitor.cpp.

ItemMonitor::~ItemMonitor ( )

Destroys the item monitor.

Definition at line 20 of file itemmonitor.cpp.

Member Function Documentation

ItemFetchScope & ItemMonitor::fetchScope ( )

Returns the item fetch scope.

Since this returns a reference it can be used to conveniently modify the current scope in-place, i.e. by calling a method on the returned reference without storing it in a local variable. See the ItemFetchScope documentation for an example.

a reference to the current item fetch scope
See also
setFetchScope() for replacing the current item fetch scope

Definition at line 68 of file itemmonitor.cpp.

Item ItemMonitor::item ( ) const

Returns the currently monitored item.

Definition at line 49 of file itemmonitor.cpp.

void ItemMonitor::itemChanged ( const Item &  item)

This method is called whenever the monitored item has changed.

itemThe changed item.

Definition at line 54 of file itemmonitor.cpp.

void ItemMonitor::itemRemoved ( )

This method is called whenever the monitored item has been removed.

Definition at line 59 of file itemmonitor.cpp.

void ItemMonitor::setFetchScope ( const ItemFetchScope fetchScope)

Sets the item fetch scope.

Controls how much of an item's data is fetched from the server, e.g. whether to fetch the full item payload or only meta data.

fetchScopeThe new scope for item fetch operations.
See also

Definition at line 63 of file itemmonitor.cpp.

void ItemMonitor::setItem ( const Item &  item)

Sets the item that shall be monitored.

Definition at line 25 of file itemmonitor.cpp.

The documentation for this class was generated from the following files:
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Wed Jan 20 2021 23:23:14 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.