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

Query Class Reference

from PyKDE4.nepomuk import *

Subclasses: Nepomuk.Query.FileQuery
Namespace: Nepomuk.Query.Query

Detailed Description

\class Query query.h Nepomuk/Query/Query

A Nepomuk desktop query.

A Query consists or a combination of Terms that can be optionally restricted via a limit (setLimit()) or folder filters (setIncludeFolders() and setExcludeFolders()).

Additionally setRequestProperties() allows to retrieve additional information about the results.

Queries can be easily converted to SPARQL via the toSparqlQuery() method or to search URLs ready for KIO.DirLister using toSearchUrl().

The typical usage of a Query instance would be QueryServiceClient.query(). However one can also use toSparqlQuery() to convert it into a SPARQL query string and use that string in QueryServiceClient.sparqlQuery() or even directly in Soprano.Model.executeQuery() via ResourceManager.instance()->mainModel() or in a custom Model.

\sa QueryParser

Author:
Sebastian Trueg <trueg@kde.org>

Since:
4.4


Enumerations

SparqlFlag { NoFlags, CreateCountQuery, HandleInverseProperties }

Methods

 __init__ (self)
 __init__ (self, Nepomuk.Query.Term term)
 __init__ (self, Nepomuk.Query.Query a0)
 addRequestProperty (self, Nepomuk.Query.Query.RequestProperty property)
bool isValid (self)
int limit (self)
bool operator == (self, Nepomuk.Query.Query query)
[Nepomuk.Query.Query.RequestProperty] requestProperties (self)
Nepomuk.Query.RequestPropertyMap requestPropertyMap (self)
 setLimit (self, int a0)
 setRequestProperties (self, [Nepomuk.Query.Query.RequestProperty] properties)
 setTerm (self, Nepomuk.Query.Term a0)
Nepomuk.Query.Term term (self)
KUrl toSearchUrl (self, Nepomuk.Query.Query.SparqlFlags flags=Nepomuk.Query.Query.SparqlFlag.NoFlags)
QString toSparqlQuery (self, Nepomuk.Query.Query.SparqlFlags flags=Nepomuk.Query.Query.SparqlFlag.NoFlags)

Method Documentation

__init__ (   self )

Copy constructor.

__init__ (  self,
Nepomuk.Query.Term  term
)

Create a query of type PlainQuery based on term.

__init__ (  self,
Nepomuk.Query.Query  a0
)

Copy constructor.

addRequestProperty (  self,
Nepomuk.Query.Query.RequestProperty  property
)

Add a property that should be reported with each search result.

Parameters:
property  The requested property.

\sa setRequestProperties, requestProperties

bool isValid (   self )

Returns:
true if the query is valid, i.e. it has a valid term().

int limit (   self )

The maximum number of results that this query should yield.

\sa setLimit

bool operator == (  self,
Nepomuk.Query.Query  query
)

Comparison operator.

Returns:
true if this query is equal to query.

[Nepomuk.Query.Query.RequestProperty] requestProperties (   self )

Returns:
The list of RequestProperty instances set via addRequestProperty and setRequestProperties.

Nepomuk.Query.RequestPropertyMap requestPropertyMap (   self )

Build a request property map as used in QueryServiceClient.sparqlQuery() from the request properties set via addRequestProperty() and setRequestProperties().

Be aware that in most situations it is much simpler to use QueryServiceClient.query().

setLimit (  self,
int  a0
)

Set the maximum number of results this query should yield.

\sa limit

setRequestProperties (  self,
[Nepomuk.Query.Query.RequestProperty]  properties
)

Set the properties that should be reported with each search result.

Parameters:
properties  The requested properties.

\sa addRequestProperty, requestProperties

setTerm (  self,
Nepomuk.Query.Term  a0
)

Set the root term of the query.

\sa term

Nepomuk.Query.Term term (   self )

The root term of the query. This can be any type of term.

\sa setTerm

KUrl toSearchUrl (  self,
Nepomuk.Query.Query.SparqlFlags  flags=Nepomuk.Query.Query.SparqlFlag.NoFlags
)

Convert the query into a URL which can be listed using KIO.DirLister. The URL will use the nepomuksearch:/ KIO protocol to handle the listing of search results.

This is the perfect method for listing results in file managers or file dialogs.

Parameters:
flags  Optional flags to change the query. Query.CreateCountQuery is not supported and will silently be dropped from flags.

Returns:
A URL which will list a virtual folder containing all search results from this query or an invalid URL in case this query is invalid.

\sa toSparqlQuery(), SparqlFlag

QString toSparqlQuery (  self,
Nepomuk.Query.Query.SparqlFlags  flags=Nepomuk.Query.Query.SparqlFlag.NoFlags
)

Convert the query into a SPARQL query which can be used with the Nepomuk query service or directly in Soprano.Model.executeQuery.

The resulting query will bind the results to variable 'r'. Request properties will be bound to variables 'reqProp1' through 'reqPropN'.

Warning:
The SPARQL queries created by this method contain SPARQL extensions from Virtuoso and will not work with other RDF storage solutions!

Parameters:
flags  Optional flags to change the query.

Returns:
The SPARQL representation of this query or an empty string if the query could not be converted (invalid query.)

\sa toSearchUrl(), SparqlFlag


Enumeration Documentation

SparqlFlag

Aditional flags modifying the behaviour of toSparqlQuery() and toSearchUrl().

Enumerator:
NoFlags = 0x0
CreateCountQuery = 0x1
HandleInverseProperties = 0x2

  • 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