Akonadi::ItemMonitor

Search for usage in LXR

#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.

Example:

// A label that shows the name of a contact item
class ContactLabel : public QLabel, public Akonadi::ItemMonitor
{
public:
ContactLabel( QWidget *parent = nullptr )
{
setText( "No Name" );
}
protected:
virtual void itemChanged( const Akonadi::Item &item )
{
if ( item.mimeType() != "text/directory" )
return;
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 );
A convenience class to monitor a single item for changes.
Definition itemmonitor.h:70
Item item() const
Returns the currently monitored item.
virtual void itemRemoved()
This method is called whenever the monitored item has been removed.
virtual void itemChanged(const Item &item)
This method is called whenever the monitored item has changed.
Represents a PIM item stored in Akonadi storage.
Definition item.h:100
QString mimeType() const
Returns the mime type of the item.
Definition item.cpp:326
T payload() const
Returns the payload object of this PIM item.
Definition item.h:754
QString label(StandardShortcut id)
void setText(const QString &)
QObject * parent() const const
Author
Tobias Koenig tokoe.nosp@m.@kde.nosp@m..org

Definition at line 69 of file itemmonitor.h.

Constructor & Destructor Documentation

◆ ItemMonitor()

ItemMonitor::ItemMonitor ( )

Creates a new item monitor.

Definition at line 14 of file itemmonitor.cpp.

◆ ~ItemMonitor()

ItemMonitor::~ItemMonitor ( )
virtualdefault

Destroys the item monitor.

Member Function Documentation

◆ fetchScope()

ItemFetchScope & ItemMonitor::fetchScope ( )
protected

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.

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

Definition at line 66 of file itemmonitor.cpp.

◆ item()

Item ItemMonitor::item ( ) const

Returns the currently monitored item.

Definition at line 47 of file itemmonitor.cpp.

◆ itemChanged()

void ItemMonitor::itemChanged ( const Item & item)
protectedvirtual

This method is called whenever the monitored item has changed.

Parameters
itemThe changed item.

Definition at line 52 of file itemmonitor.cpp.

◆ itemRemoved()

void ItemMonitor::itemRemoved ( )
protectedvirtual

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

Definition at line 57 of file itemmonitor.cpp.

◆ setFetchScope()

void ItemMonitor::setFetchScope ( const ItemFetchScope & fetchScope)
protected

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.

Parameters
fetchScopeThe new scope for item fetch operations.
See also
fetchScope()

Definition at line 61 of file itemmonitor.cpp.

◆ setItem()

void ItemMonitor::setItem ( const Item & item)

Sets the item that shall be monitored.

Definition at line 21 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-2024 The KDE developers.
Generated on Sat Dec 21 2024 17:01:42 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.