Akonadi.ItemFetchJob

KDE 4.9 PyKDE API Reference

- KDE's Python API

# ItemFetchJob Class Reference

`from PyKDE4.akonadi import *`

Inherits: Akonadi.Job → KCompositeJob → KJob → QObject
Namespace: Akonadi

## Detailed Description

Job that fetches items from the Akonadi storage.

This class is used to fetch items from the Akonadi storage. Which parts of the items (e.g. headers only, attachments or all) can be specified by the ItemFetchScope.

Note that ItemFetchJob does not refresh the Akonadi storage from the backend; this is unnecessary due to the fact that backend updates automatically trigger an update to the Akonadi database whenever they occur (unless the resource is offline).

Note that items can not be created in the root collection (Collection.root()) and therefore can not be fetched from there either. That is - an item fetch in the root collection will yield an empty list.

Example:

     // Fetch all items with full payload from a collection

     const Collection collection = getCollection();

     Akonadi.ItemFetchJob *job = new Akonadi.ItemFetchJob( collection );
     connect( job, SIGNAL( result( KJob* ) ), SLOT( jobFinished( KJob* ) ) );
     job->fetchScope().fetchFullPayload();

     ...

     MyClass.jobFinished( KJob *job )
     {
       if ( job->error() ) {
         qDebug() << "Error occurred";
         return;
       }

       Akonadi.ItemFetchJob *fetchJob = qobject_cast<Akonadi.ItemFetchJob*>( job );

       const Akonadi.Item.List items = fetchJob->items();
       foreach ( const Akonadi.Item &item, items ) {
         qDebug() << "Item ID:" << item.id();
       }
     }

Author:
  Volker Krause <vkrause@kde.org>

## Signals
| itemsReceived ([Akonadi.Item] items)
## Methods
| __init__ (self, Akonadi.Collection collection, QObject parent=0)
| __init__ (self, Akonadi.Item item, QObject parent=0)
| __init__ (self, [Akonadi.Item] items, QObject parent=0)
| doHandleResponse (self, QByteArray tag, QByteArray data)
| doStart (self)
Akonadi.ItemFetchScope | fetchScope (self)
[Akonadi.Item] | items (self)
| setCollection (self, Akonadi.Collection collection)
| setFetchScope (self, Akonadi.ItemFetchScope fetchScope)

## Signal Documentation

itemsReceived | ( | [Akonadi.Item] | items
| ) |  |  |

This signal is emitted whenever new items have been fetched completely.

Note:
  This is an optimization; instead of waiting for the end of the job and calling items(), you can connect to this signal and get the items incrementally.

Parameters:

  | items | The fetched items.

Signal syntax:
  `QObject.connect(source, SIGNAL("itemsReceived(const Akonadi::Item::List&)"), target_slot)`

## Method Documentation

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

Creates a new item fetch job that retrieves all items inside the given collection.

Parameters:

  | collection | The parent collection to fetch all items from.
  | parent | The parent object.

__init__ | ( | self, |
|  | Akonadi.Item | item,
|  | QObject | parent=0
| ) |  |  |

Creates a new item fetch job that retrieves the specified item. If the item has a uid set, this is used to identify the item on the Akonadi server. If only a remote identifier is available, that is used. However, as remote identifiers are not necessarily globally unique, you need to specify the resource and/or collection to search in in that case, using setCollection() or Akonadi.ResourceSelectJob.

Parameters:

  | item | The item to fetch.
  | parent | The parent object.

__init__ | ( | self, |
|  | [Akonadi.Item] | items,
|  | QObject | parent=0
| ) |  |  |

Convenience ctor equivalent to ItemFetchJob( const Item.List &items, QObject *parent = 0 )

Since:
  4.8

doHandleResponse | ( | self, |
|  | QByteArray | tag,
|  | QByteArray | data
| ) |  |  |

doStart | ( |  | self ) |

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 fetched item.

Note:
  The items are invalid before the result( KJob* ) signal has been emitted or if an error occurred.

setCollection | ( | self, |
|  | Akonadi.Collection | collection
| ) |  |  |

Specifies the collection the item is in. This is only required when retrieving an item based on its remote id which might not be unique globally.

See also:
  Akonadi.ResourceSelectJob

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

Since:
  4.4