ItemMonitor Class Reference
from PyKDE4.akonadi import *
Namespace: Akonadi
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 = 0 ) : QLabel( parent ) { setText( "No Name" ); } protected: virtual void itemChanged( const Akonadi.Item &item ) { if ( item.mimeType() != "text/directory" ) return; const KABC.Addressee addr = item.payload<KABC.Addressee>(); setText( addr.fullName() ); } virtual void itemRemoved() { setText( "No Name" ); } }; ... ContactLabel *label = new ContactLabel( this ); const Akonadi.Item item = fetchJob->items().first(); label->setItem( item );
Methods | |
__init__ (self) | |
Akonadi.ItemFetchScope | fetchScope (self) |
Akonadi.Item | item (self) |
itemChanged (self, Akonadi.Item item) | |
itemRemoved (self) | |
setFetchScope (self, Akonadi.ItemFetchScope fetchScope) | |
setItem (self, Akonadi.Item item) |
Method Documentation
__init__ | ( | self ) |
Creates a new item monitor.
Akonadi.ItemFetchScope fetchScope | ( | self ) |
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
Akonadi.Item item | ( | self ) |
Returns the currently monitored item.
itemChanged | ( | self, | ||
Akonadi.Item | item | |||
) |
This method is called whenever the monitored item has changed.
- Parameters:
-
item The changed item.
itemRemoved | ( | self ) |
This method is called whenever the monitored item has been removed.
setFetchScope | ( | self, | ||
Akonadi.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.
- Parameters:
-
fetchScope The new scope for item fetch operations.
- See also:
- fetchScope()
setItem | ( | self, | ||
Akonadi.Item | item | |||
) |
Sets the item that shall be monitored.