KDE 4.4 PyKDE API Reference
  • KDE's Python API
  • Overview
  • PyKDE Home
  • Sitemap
  • Contact Us
 

QueryServiceClient Class Reference

from PyKDE4.nepomuk import *

Inherits: QObject
Namespace: Nepomuk.Query.QueryServiceClient

Detailed Description

\class QueryServiceClient queryserviceclient.h Nepomuk/Query/QueryServiceClient

Convenience frontend to the %Nepomuk Query DBus Service

The QueryServiceClient provides an easy way to access the %Nepomuk Query Service without having to deal with any communication details. By default it monitors queries for changes.

Usage is simple: Create an instance of the client for each search you want to track. One instance may also be reused for subsequent queries if further updates of the persistent query are not necessary.

Author:
Sebastian Trueg <trueg@kde.org>

Since:
4.4


Signals

 entriesRemoved (, [QUrl] entries)
 finishedListing ()
 newEntries (, [Nepomuk.Query.Result] entries)

Methods

 __init__ (self, QObject parent=0)
bool blockingDesktopQuery (self, QString query)
bool blockingQuery (self, Nepomuk.Query.Query query)
bool blockingSparqlQuery (self, QString query, Nepomuk.Query.RequestPropertyMap requestPropertyMap=Nepomuk.Query.RequestPropertyMap())
 close (self)
bool desktopQuery (self, QString query)
 entriesRemoved (self, [QUrl] entries)
 finishedListing (self)
 newEntries (self, [Nepomuk.Query.Result] entries)
bool query (self, Nepomuk.Query.Query query)
bool serviceAvailable (self)
bool sparqlQuery (self, QString query, Nepomuk.Query.RequestPropertyMap requestPropertyMap=Nepomuk.Query.RequestPropertyMap())

Method Documentation

__init__ (  self,
QObject  parent=0
)

Create a new QueryServiceClient instance.

bool blockingDesktopQuery (  self,
QString  query
)

Parameters:
query  a desktop query string which can be parsed by QueryParser.

\sa desktopQuery(const QString&), close()

bool blockingQuery (  self,
Nepomuk.Query.Query  query
)

Start a query using the Nepomuk query service.

Results will be reported as with query(const QString&) but a local event loop will be started to block the method call until all results have been listed.

The client will be closed after the initial listing. Thus, changes to results will not be reported as it is the case with the non-blocking methods.

Parameters:
query  the query to perform.

Returns:
true if the query service was found and the query was started. false otherwise.

\sa query(const Query&), close()

bool blockingSparqlQuery (  self,
QString  query,
Nepomuk.Query.RequestPropertyMap  requestPropertyMap=Nepomuk.Query.RequestPropertyMap()
)

Parameters:
query  a SPARQL query which binds results to variable 'r'.

Parameters:
requestPropertyMap  An optional mapping of variable binding names in query to their corresponding properties. For details see sparqlQuery.

\sa sparqlQuery(const Query&)

close (   self )

Close the client, thus stop to monitor the query for changes. Without closing the client it will continue signalling changes to the results.

This will also make any blockingQuery return immediately.

bool desktopQuery (  self,
QString  query
)

Parameters:
query  a desktop query string which can be parsed by QueryParser.

entriesRemoved (  self,
[QUrl]  entries
)

Emitted if the search results changed when monitoring a query.

Parameters:
entries  A list of resource URIs identifying the resources that dropped out of the query results.

Signal syntax:
QObject.connect(source, SIGNAL("entriesRemoved(const QList&)"), target_slot)
finishedListing (   self )

Emitted when the initial listing has been finished, ie. if all results have been reported via newEntries. If no further updates are necessary the client should be closed now.

Signal syntax:
QObject.connect(source, SIGNAL("finishedListing()"), target_slot)
newEntries (  self,
[Nepomuk.Query.Result]  entries
)

Emitted for new search results. This signal is emitted both for the initial listing and for changes to the search.

Signal syntax:
QObject.connect(source, SIGNAL("newEntries(const QList&)"), target_slot)
bool query (  self,
Nepomuk.Query.Query  query
)

Start a query using the Nepomuk query service.

Results will be reported via newEntries. All results have been reported once finishedListing has been emitted.

Parameters:
query  the query to perform.

Returns:
true if the query service was found and the query was started. false otherwise.

bool serviceAvailable (   self )

Check if the Nepomuk query service is running.

Returns:
true if the Nepomuk query service is running and could be contacted via DBus, false otherwise

bool sparqlQuery (  self,
QString  query,
Nepomuk.Query.RequestPropertyMap  requestPropertyMap=Nepomuk.Query.RequestPropertyMap()
)

Parameters:
query  a SPARQL query which binds results to variable 'r'.

Parameters:
requestPropertyMap  An optional mapping of variable binding names in query to their corresponding properties. These bindings will then be reported via Result.requestProperties(). This map will be constructed automatically when using query(const Query&).

Example:

 QString query = "select ?r ?mtime where { ?r a nfo:FileDataObject . ?r nie:lastModified ?mtime . }";
 QueryServiceClient.RequestPropertyMap requestPropertyMap;
 requestPropertyMap.insert( "mtime", Vocabulary.NIE.lastModified() );
 sparqlQuery( query, requestPropertyMap );

This will report the resources themselves and their modification time in the result's request properties:

 void handleResult( const Query.Result& results ) {
     QDateTime lastModified = result.requestProperty( Vocabulary.NIE.lastModified() ).toDateTime();
     [...]

\sa Query.requestPropertyMap()

  • Full Index

Modules

  • akonadi
  • dnssd
  • kdecore
  • kdeui
  • khtml
  • kio
  • knewstuff
  • kparts
  • kutils
  • nepomuk
  • phonon
  • plasma
  • polkitqt
  • solid
  • soprano
This documentation is maintained by Simon Edwards.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal