Akonadi.RecursiveItemFetchJob

KDE 4.9 PyKDE API Reference

- KDE's Python API

# RecursiveItemFetchJob Class Reference

`from PyKDE4.akonadi import *`

Inherits: KJob → QObject
Namespace: Akonadi

## Detailed Description

Job that fetches all items of a collection recursive.

This job takes a collection as argument and returns a list of all items that are part of the passed collection and its child collections. The items to fetch can be filtered by mime types and the parts of the items that shall be fetched can be specified via an ItemFetchScope.

Example:

     // Assume the following Akonadi storage tree structure:
     //
     // Root Collection
     // |
     // +- Contacts
     // |  |
     // |  +- Private
     // |  |
     // |  `- Business
     // |
     // `- Events
     //
     // Collection 'Contacts' has the ID 15, then the following code
     // returns all contact items from 'Contacts', 'Private' and 'Business'.

     const Akonadi.Collection contactsCollection( 15 );
     const QStringList mimeTypes = QStringList() << KABC.Addressee.mimeType();

     Akonadi.RecursiveItemFetchJob *job = new Akonadi.RecursiveItemFetchJob( contactsCollection, mimeTypes );
     job->fetchScope().fetchFullPayload();
     connect( job, SIGNAL( result( KJob* ) ), this, SLOT( fetchResult( KJob* ) ) );

     job->start();

     ...

     MyClass.fetchResult( KJob *job )
     {
       Akonadi.RecursiveItemFetchJob *fetchJob = qobject_cast<Akonadi.RecursiveItemFetchJob*>( job );
       const Akonadi.Item.List items = fetchJob->items();
       // do something with the items
     }

Author:
  Tobias Koenig <tokoe@kde.org>

Since:
  4.6

## Methods
| __init__ (self, Akonadi.Collection collection, QStringList mimeTypes, QObject parent=0)
Akonadi.ItemFetchScope | fetchScope (self)
[Akonadi.Item] | items (self)
| setFetchScope (self, Akonadi.ItemFetchScope fetchScope)
| start (self)

## Method Documentation

__init__ | ( | self, |
|  | Akonadi.Collection | collection,
|  | QStringList | mimeTypes,
|  | QObject | parent=0
| ) |  |  |

Creates a new recursive item fetch job.

Parameters:

  | collection | The collection that shall be fetched recursive.
  | mimeTypes | The list of mime types that will be used for filtering.
  | parent | The parent object.

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] items | ( |  | self ) |

Returns the list of fetched items.

setFetchScope | ( | self, |
|  | Akonadi.ItemFetchScope | fetchScope
| ) |  |  |

Sets the item fetch scope.

The ItemFetchScope 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()

start | ( |  | self ) |

Starts the recursive item fetch job.