KDE 4.7 PyKDE API Reference

- KDE's Python API

# ItemSearchJob Class Reference

`from PyKDE4.akonadi import *`

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

## Detailed Description

Job that searches for items in the Akonadi storage.

This job searches for items that match a given search query and returns the list of matching item.

Attention: Since this is an ordinary SPARQL query, potentially the whole Nepomuk store is searched, which can be very slow. Therefore, you should create SPARQL queries that only search for items that Akonadi fed into Nepomuk. This can be done by limiting the results to statements that contain the predicate with the akonadiItemIdUri() URI. This limits the search result to to Nepomuk resources that were added by the Akonadi Nepomuk feeders.

     const QString query = "..."; // some sparql query

     Akonadi.ItemSearchJob *job = new Akonadi.ItemSearchJob( query );
     job->fetchScope().fetchFullPayload();
     connect( job, SIGNAL( result( KJob* ) ), this, SLOT( searchResult( KJob* ) ) );

     ...

     MyClass.searchResult( KJob *job )
     {
       Akonadi.ItemSearchJob *searchJob = qobject_cast<Akonadi.ItemSearchJob*>( job );
       const Akonadi.Item.List items = searchJob->items();
       foreach ( const Akonadi.Item &item, items ) {
         // extract the payload and do further stuff
       }
     }

Author:
  Tobias Koenig <tokoe@kde.org>

Since:
  4.4

## Signals

| itemsReceived ([Akonadi.Item] items)

## Methods

| __init__ (self, QString query, QObject parent=0)
| doHandleResponse (self, QByteArray tag, QByteArray data)
| doStart (self)
Akonadi.ItemFetchScope | fetchScope (self)
[Akonadi.Item] | items (self)
| setFetchScope (self, Akonadi.ItemFetchScope fetchScope)
| setQuery (self, QString query)

## Static Methods

QUrl | akonadiItemIdUri ()

## Signal Documentation

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

This signal is emitted whenever new matching 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 matching items.

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

## Method Documentation

__init__ | ( | self, |
|  | QString | query,
|  | QObject | parent=0
| ) |  |  |

Creates an item search job.

Parameters:

  | query | The search query in SPARQL format.
  | parent | The parent object.

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 items that matched the search query.

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

Sets the item fetch scope.

The ItemFetchScope controls how much of an matching 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()

setQuery | ( | self, |
|  | QString | query
| ) |  |  |

Sets the search query in SPARQL format.

## Static Method Documentation

QUrl akonadiItemIdUri | ( |  | ) |

Returns an URI that represents a predicate that is always added to the Nepomuk resource by the Akonadi Nepomuk feeders.

The statement containing this predicate has the Akonadi Item ID of the resource as string as the object, and the Nepomuk resource, e.g. a PersonContact, as the subject.

Always limit your searches to statements that contain this URI as predicate.

Since:
  4.4.3