akonadi
Akonadi::ItemFetchJob Class Reference
Job that fetches items from the Akonadi storage. More...
#include <itemfetchjob.h>

Signals | |
void | itemsReceived (const Akonadi::Item::List &items) |
Public Member Functions | |
ItemFetchJob (const Collection &collection, QObject *parent=0) | |
ItemFetchJob (const Item &item, QObject *parent=0) | |
ItemFetchJob (const Item::List &items, QObject *parent=0) | |
virtual | ~ItemFetchJob () |
ItemFetchScope & | fetchScope () |
Item::List | items () const |
void | setCollection (const Collection &collection) |
void | setFetchScope (const ItemFetchScope &fetchScope) |
void | setFetchScope (ItemFetchScope &fetchScope) |
Protected Member Functions | |
virtual void | doHandleResponse (const QByteArray &tag, const QByteArray &data) |
virtual void | doStart () |
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.
Example:
// Fetch all items with full payload from the root collection Akonadi::ItemFetchJob *job = new Akonadi::ItemFetchJob( Akonadi::Collection::root() ); 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(); } }
Definition at line 69 of file itemfetchjob.h.
Constructor & Destructor Documentation
Akonadi::ItemFetchJob::ItemFetchJob | ( | const Collection & | collection, | |
QObject * | parent = 0 | |||
) | [explicit] |
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.
Akonadi::ItemFetchJob::ItemFetchJob | ( | const Item & | item, | |
QObject * | parent = 0 | |||
) | [explicit] |
Creates a new item fetch job that retrieves the specified item.
If the item has an uid set, this is used to identify the item on the Akonadi server. If only a remote identifier is available, that one is used. However, as remote identifier 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.
Akonadi::ItemFetchJob::ItemFetchJob | ( | const Item::List & | items, | |
QObject * | parent = 0 | |||
) | [explicit] |
Creates a new item fetch job that retrieves the specified items.
If the items have an uid set, this is used to identify the item on the Akonadi server. If only a remote identifier is available, that one is used. However, as remote identifier 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:
-
items The items to fetch. parent The parent object.
- Since:
- 4.4
virtual Akonadi::ItemFetchJob::~ItemFetchJob | ( | ) | [virtual] |
Destroys the item fetch job.
Member Function Documentation
virtual void Akonadi::ItemFetchJob::doHandleResponse | ( | const QByteArray & | tag, | |
const QByteArray & | data | |||
) | [protected, virtual] |
This method should be reimplemented in the concrete jobs in case you want to handle incoming data.
It will be called on received data from the backend. The default implementation does nothing.
- Parameters:
-
tag The tag of the corresponding command, empty if this is an untagged response. data The received data.
Reimplemented from Akonadi::Job.
virtual void Akonadi::ItemFetchJob::doStart | ( | ) | [protected, virtual] |
This method must be reimplemented in the concrete jobs.
It will be called after the job has been started and a connection to the Akonadi backend has been established.
Implements Akonadi::Job.
ItemFetchScope& Akonadi::ItemFetchJob::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.
- Returns:
- a reference to the current item fetch scope
- See also:
- setFetchScope() for replacing the current item fetch scope
Item::List Akonadi::ItemFetchJob::items | ( | ) | const |
Returns the fetched item.
- Note:
- The items are invalid before the result( KJob* ) signal has been emitted or if an error occurred.
void Akonadi::ItemFetchJob::itemsReceived | ( | const Akonadi::Item::List & | items | ) | [signal] |
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.
void Akonadi::ItemFetchJob::setCollection | ( | const 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
void Akonadi::ItemFetchJob::setFetchScope | ( | const 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
void Akonadi::ItemFetchJob::setFetchScope | ( | 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()
The documentation for this class was generated from the following file: