• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdelibs API Reference
  • KDE Home
  • Contact Us
 

Nepomuk-Core

  • sources
  • kde-4.12
  • kdelibs
  • nepomuk-core
  • libnepomukcore
  • query
queryserializer.cpp
Go to the documentation of this file.
1 /*
2  This file is part of the Nepomuk KDE project.
3  Copyright (C) 2008-2010 Sebastian Trueg <trueg@kde.org>
4 
5  This library is free software; you can redistribute it and/or
6  modify it under the terms of the GNU Library General Public
7  License version 2 as published by the Free Software Foundation.
8 
9  This library is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  Library General Public License for more details.
13 
14  You should have received a copy of the GNU Library General Public License
15  along with this library; see the file COPYING.LIB. If not, write to
16  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17  Boston, MA 02110-1301, USA.
18  */
19 
20 #include "queryserializer.h"
21 
22 #include "filequery.h"
23 #include "term.h"
24 #include "literalterm.h"
25 #include "resourceterm.h"
26 #include "andterm.h"
27 #include "orterm.h"
28 #include "negationterm.h"
29 #include "comparisonterm.h"
30 #include "comparisonterm_p.h"
31 #include "resourcetypeterm.h"
32 #include "optionalterm.h"
33 
34 #include "property.h"
35 #include "class.h"
36 
37 #include <Soprano/LiteralValue>
38 
39 #include <kurl.h>
40 #include <kdebug.h>
41 
42 #include <QtCore/QXmlStreamWriter>
43 
44 
45 using namespace Nepomuk2::Query;
46 
47 namespace {
48 
49  QString aggregateToString( Nepomuk2::Query::ComparisonTerm::AggregateFunction f )
50  {
51  switch( f ) {
52  case Nepomuk2::Query::ComparisonTerm::Count:
53  return QString::fromLatin1("count");
54  case Nepomuk2::Query::ComparisonTerm::DistinctCount:
55  return QString::fromLatin1("distinctcount");
56  case Nepomuk2::Query::ComparisonTerm::Max:
57  return QString::fromLatin1("max");
58  case Nepomuk2::Query::ComparisonTerm::Min:
59  return QString::fromLatin1("min");
60  case Nepomuk2::Query::ComparisonTerm::Sum:
61  return QString::fromLatin1("sum");
62  case Nepomuk2::Query::ComparisonTerm::DistinctSum:
63  return QString::fromLatin1("distinctsum");
64  case Nepomuk2::Query::ComparisonTerm::Average:
65  return QString::fromLatin1("avg");
66  case Nepomuk2::Query::ComparisonTerm::DistinctAverage:
67  return QString::fromLatin1("distinctavg");
68  default:
69  return QString();
70  }
71  }
72 
73  Nepomuk2::Query::ComparisonTerm::AggregateFunction stringToAggregate( const QStringRef& f )
74  {
75  if( f == QString::fromLatin1("count") )
76  return Nepomuk2::Query::ComparisonTerm::Count;
77  else if( f == QString::fromLatin1("distinctcount") )
78  return Nepomuk2::Query::ComparisonTerm::DistinctCount;
79  else if( f == QString::fromLatin1("max") )
80  return Nepomuk2::Query::ComparisonTerm::Max;
81  else if( f == QString::fromLatin1("min") )
82  return Nepomuk2::Query::ComparisonTerm::Min;
83  else if( f == QString::fromLatin1("sum") )
84  return Nepomuk2::Query::ComparisonTerm::Sum;
85  else if( f == QString::fromLatin1("distinctsum") )
86  return Nepomuk2::Query::ComparisonTerm::DistinctSum;
87  else if( f == QString::fromLatin1("avg") )
88  return Nepomuk2::Query::ComparisonTerm::Average;
89  else if( f == QString::fromLatin1("distinctavg") )
90  return Nepomuk2::Query::ComparisonTerm::DistinctAverage;
91  else
92  return Nepomuk2::Query::ComparisonTerm::NoAggregateFunction;
93  }
94 
95 
96  bool doSerializeTerm( QXmlStreamWriter& xml, const Nepomuk2::Query::Term& term )
97  {
98  switch(term.type()) {
99  case Term::Literal: {
100  xml.writeStartElement( QLatin1String("literal") );
101  const Soprano::LiteralValue value = term.toLiteralTerm().value();
102  if( value.isPlain() )
103  xml.writeAttribute( QLatin1String("lang"), value.language().toString() );
104  else
105  xml.writeAttribute( QLatin1String("datatype"), KUrl(value.dataTypeUri()).url() );
106  xml.writeCharacters( value.toString() );
107  xml.writeEndElement();
108  break;
109  }
110 
111  case Term::Resource:
112  xml.writeStartElement( QLatin1String("resource") );
113  xml.writeAttribute( QLatin1String("uri"), KUrl( term.toResourceTerm().resource().uri() ).url() );
114  xml.writeEndElement();
115  break;
116 
117  case Term::And:
118  xml.writeStartElement( QLatin1String("and") );
119  Q_FOREACH( const Term& myterm, term.toAndTerm().subTerms() ) {
120  doSerializeTerm( xml, myterm );
121  }
122  xml.writeEndElement();
123  break;
124 
125  case Term::Or:
126  xml.writeStartElement( QLatin1String("or") );
127  Q_FOREACH( const Term& myterm, term.toOrTerm().subTerms() ) {
128  doSerializeTerm( xml, myterm );
129  }
130  xml.writeEndElement();
131  break;
132 
133  case Term::Comparison: {
134  ComparisonTerm cTerm( term.toComparisonTerm() );
135 
136  xml.writeStartElement( QLatin1String("comparison") );
137 
138  if( cTerm.property().isValid() )
139  xml.writeAttribute( QLatin1String("property"), KUrl(cTerm.property().uri()).url() );
140  xml.writeAttribute( QLatin1String("comparator"), Nepomuk2::Query::comparatorToString(cTerm.comparator()) );
141  if( !cTerm.variableName().isEmpty() )
142  xml.writeAttribute( QLatin1String("varname"), cTerm.variableName() );
143  if( cTerm.aggregateFunction() != ComparisonTerm::NoAggregateFunction )
144  xml.writeAttribute( QLatin1String("aggregate"), aggregateToString(cTerm.aggregateFunction()) );
145  if( cTerm.sortWeight() != 0 ) {
146  xml.writeAttribute( QLatin1String("sortWeight"), QString::number(cTerm.sortWeight()) );
147  xml.writeAttribute( QLatin1String("sortOrder"), cTerm.sortOrder() == Qt::AscendingOrder ? QLatin1String("asc") : QLatin1String("desc") );
148  }
149  xml.writeAttribute( QLatin1String("inverted"), cTerm.isInverted() ? QLatin1String("true") : QLatin1String("false") );
150 
151  doSerializeTerm( xml, cTerm.subTerm() );
152 
153  xml.writeEndElement();
154  break;
155  }
156 
157  case Term::ResourceType:
158  xml.writeStartElement( QLatin1String("type") );
159  xml.writeAttribute( QLatin1String("uri"), KUrl( term.toResourceTypeTerm().type().uri() ).url() );
160  xml.writeEndElement();
161  break;
162 
163  case Term::Negation:
164  xml.writeStartElement( QLatin1String("not") );
165  doSerializeTerm( xml, term.toNegationTerm().subTerm() );
166  xml.writeEndElement();
167  break;
168 
169  case Term::Optional:
170  xml.writeStartElement( QLatin1String("optional") );
171  doSerializeTerm( xml, term.toOptionalTerm().subTerm() );
172  xml.writeEndElement();
173  break;
174 
175  default:
176  return false;
177  }
178 
179  return true;
180  }
181 
182 
183  Term doParseTerm( QXmlStreamReader& xml, bool* ok = 0 )
184  {
185  Q_ASSERT( xml.isStartElement() );
186 
187  if( xml.name() == QLatin1String("literal") ) {
188  if( ok )
189  *ok = true;
190  QXmlStreamAttributes attr = xml.attributes();
191  LiteralTerm term;
192  if( attr.hasAttribute( QLatin1String("datatype") ) )
193  term = LiteralTerm( Soprano::LiteralValue::fromString( xml.readElementText(), KUrl(attr.value( QLatin1String("datatype") ).toString()) ) );
194  else
195  term = LiteralTerm( Soprano::LiteralValue::createPlainLiteral( xml.readElementText(), attr.value( QLatin1String("lang") ).toString()) );
196  // no need to skip to next element due to usage of readElementText?
197  return term;
198  }
199 
200  else if( xml.name() == QLatin1String("resource") ) {
201  if( ok )
202  *ok = true;
203  ResourceTerm term( KUrl(xml.attributes().value( QLatin1String("uri") ).toString()) );
204  xml.readNextStartElement(); // skip to next element
205  return term;
206  }
207 
208  else if( xml.name() == QLatin1String("and") ) {
209  AndTerm term;
210  while( xml.readNextStartElement() ) {
211  term.addSubTerm( doParseTerm( xml, ok ) );
212  if( ok && !*ok )
213  return Term();
214  }
215  return term;
216  }
217 
218  else if( xml.name() == QLatin1String("or") ) {
219  OrTerm term;
220  while( xml.readNextStartElement() ) {
221  term.addSubTerm( doParseTerm( xml, ok ) );
222  if( ok && !*ok )
223  return Term();
224  }
225  return term;
226  }
227 
228  else if( xml.name() == QLatin1String("not") ) {
229  if( xml.readNextStartElement() ) {
230  Term term = doParseTerm( xml, ok );
231  if( ok && !*ok )
232  return Term();
233  xml.readNextStartElement(); // skip to next element
234  return NegationTerm::negateTerm(term);
235  }
236  else {
237  if( ok )
238  *ok = false;
239  return Term();
240  }
241  }
242 
243  else if( xml.name() == QLatin1String("optional") ) {
244  if( xml.readNextStartElement() ) {
245  Term term = doParseTerm( xml, ok );
246  if( ok && !*ok )
247  return Term();
248  xml.readNextStartElement(); // skip to next element
249  return OptionalTerm::optionalizeTerm(term);
250  }
251  else {
252  if( ok )
253  *ok = false;
254  return Term();
255  }
256  }
257 
258  else if( xml.name() == QLatin1String("type") ) {
259  if( ok )
260  *ok = true;
261  ResourceTypeTerm term( KUrl(xml.attributes().value( QLatin1String("uri") ).toString()) );
262  xml.readNextStartElement(); // skip to next element
263  return term;
264  }
265 
266  else if( xml.name() == QLatin1String("comparison") ) {
267  ComparisonTerm cTerm;
268 
269  QXmlStreamAttributes attr = xml.attributes();
270 
271  if( attr.hasAttribute( QLatin1String("property") ) )
272  cTerm.setProperty( KUrl(attr.value( QLatin1String("property")).toString()) );
273 
274  if( attr.hasAttribute( QLatin1String("comparator") ) )
275  cTerm.setComparator( Nepomuk2::Query::stringToComparator(attr.value( QLatin1String("comparator"))) );
276 
277  if( attr.hasAttribute( QLatin1String("varname") ) )
278  cTerm.setVariableName( attr.value( QLatin1String("varname")).toString() );
279 
280  if( attr.hasAttribute( QLatin1String("aggregate") ) )
281  cTerm.setAggregateFunction( stringToAggregate(attr.value( QLatin1String("aggregate"))) );
282 
283  if( attr.hasAttribute( QLatin1String("sortWeight") ) )
284  cTerm.setSortWeight( attr.value( QLatin1String("sortWeight")).toString().toInt(),
285  attr.value( QLatin1String("sortOrder")) == QLatin1String("desc") ? Qt::DescendingOrder : Qt::AscendingOrder );
286 
287  if( attr.hasAttribute( QLatin1String("inverted") ) )
288  cTerm.setInverted( attr.value( QLatin1String("inverted")) == QLatin1String("true") );
289 
290  if( xml.readNextStartElement() ) {
291  Term term = doParseTerm( xml, ok );
292  if( ok && !*ok )
293  return Term();
294  cTerm.setSubTerm(term);
295  xml.readNextStartElement(); // skip to next element
296  }
297 
298  if( ok )
299  *ok = true;
300  return cTerm;
301  }
302 
303  else {
304  kDebug() << "Unknown term type" << xml.name();
305  if( ok )
306  *ok = false;
307  return Term();
308  }
309  }
310 
311 
312  Query::QueryFlags parseFlags( const QString& s )
313  {
314  Query::QueryFlags flags = Query::NoQueryFlags;
315  QStringList sl = s.split( QLatin1String("|"), QString::SkipEmptyParts );
316  Q_FOREACH( const QString& sf, sl ) {
317  if( sf == QLatin1String("NoResultRestrictions") )
318  flags |= Query::NoResultRestrictions;
319  else if( sf == QLatin1String("WithFullTextExcerpt") )
320  flags |= Query::WithFullTextExcerpt;
321  else
322  kError() << "Unknown query flag:" << sf;
323  }
324  return flags;
325  }
326 
327  QString serializeFlags( Query::QueryFlags flags ) {
328  QStringList sl;
329  if( flags&Query::NoResultRestrictions )
330  sl << QLatin1String("NoResultRestrictions");
331  if( flags&Query::WithFullTextExcerpt )
332  sl << QLatin1String("WithFullTextExcerpt");
333  return sl.join( QLatin1String("|") );
334  }
335 
336  void readQueryAttributes( const QXmlStreamAttributes& attributes, Query& query )
337  {
338  if( attributes.hasAttribute( QLatin1String("limit") ) )
339  query.setLimit( attributes.value( QLatin1String("limit") ).toString().toInt() );
340  if( attributes.hasAttribute( QLatin1String("offset") ) )
341  query.setOffset( attributes.value( QLatin1String("offset") ).toString().toInt() );
342  if( attributes.hasAttribute( QLatin1String("fullTextScoring") ) )
343  query.setFullTextScoringEnabled( attributes.value( QLatin1String("fullTextScoring") ) == QLatin1String("true") );
344  if( attributes.hasAttribute( QLatin1String("fullTextScoringOrder") ) )
345  query.setFullTextScoringSortOrder( attributes.value( QLatin1String("fullTextScoringOrder") ) == QLatin1String("desc") ? Qt::DescendingOrder : Qt::AscendingOrder );
346  if( attributes.hasAttribute( QLatin1String("flags") ) )
347  query.setQueryFlags( parseFlags(attributes.value( QLatin1String("flags") ).toString() ) );
348  }
349 }
350 
351 
352 QString Nepomuk2::Query::serializeQuery( const Query& query )
353 {
354  QString s;
355  QXmlStreamWriter xml( &s );
356 
357  xml.writeStartDocument();
358 
359  if( query.isFileQuery() ) {
360  FileQuery fq( query );
361  xml.writeStartElement( QLatin1String("filequery") );
362  xml.writeAttribute( QLatin1String("queryFiles"), fq.fileMode()&FileQuery::QueryFiles ? QLatin1String("true") : QLatin1String("false") );
363  xml.writeAttribute( QLatin1String("queryFolders"), fq.fileMode()&FileQuery::QueryFolders ? QLatin1String("true") : QLatin1String("false") );
364  }
365  else {
366  xml.writeStartElement( QLatin1String("query") );
367  }
368 
369  xml.writeAttribute( QLatin1String("limit"), QString::number(query.limit()) );
370  xml.writeAttribute( QLatin1String("offset"), QString::number(query.offset()) );
371  xml.writeAttribute( QLatin1String("fullTextScoring"), query.fullTextScoringEnabled() ? QLatin1String("true") : QLatin1String("false") );
372  xml.writeAttribute( QLatin1String("fullTextScoringOrder"), query.fullTextScoringSortOrder() == Qt::AscendingOrder ? QLatin1String("asc") : QLatin1String("desc") );
373  xml.writeAttribute( QLatin1String("flags"), serializeFlags( query.queryFlags() ) );
374 
375  Q_FOREACH( const Query::RequestProperty& rp, query.requestProperties() ) {
376  xml.writeStartElement( QLatin1String("requestProperty") );
377  xml.writeAttribute( QLatin1String("uri"), KUrl(rp.property().uri()).url() );
378  xml.writeAttribute( QLatin1String("optional"), rp.optional() ? QLatin1String("true") : QLatin1String("false") );
379  xml.writeEndElement();
380  }
381 
382  if( query.isFileQuery() ) {
383  FileQuery fq( query );
384  const QHash<KUrl, bool> includeFolders = fq.allIncludeFolders();
385  for( QHash<KUrl, bool>::ConstIterator it = includeFolders.constBegin();
386  it != includeFolders.constEnd(); ++it ) {
387  xml.writeStartElement( QLatin1String("folder") );
388  xml.writeAttribute( QLatin1String("url"), it.key().url() );
389  xml.writeAttribute( QLatin1String("include"), QLatin1String("true") );
390  xml.writeAttribute( QLatin1String("recursive"), it.value() ? QLatin1String("true") : QLatin1String("false") );
391  xml.writeEndElement();
392  }
393  Q_FOREACH( const KUrl& url, fq.excludeFolders() ) {
394  xml.writeStartElement( QLatin1String("folder") );
395  xml.writeAttribute( QLatin1String("url"), url.url() );
396  xml.writeAttribute( QLatin1String("include"), QLatin1String("false") );
397  xml.writeEndElement();
398  }
399  }
400 
401  doSerializeTerm( xml, query.term() );
402 
403  // close query element
404  xml.writeEndElement();
405  xml.writeEndDocument();
406 
407  return s;
408 }
409 
410 
411 Query Nepomuk2::Query::parseQuery( const QString& s )
412 {
413  QXmlStreamReader xml( s );
414 
415  Query query;
416 
417  while( xml.readNextStartElement() ) {
418  if( xml.name() == QLatin1String("query") ) {
419  readQueryAttributes( xml.attributes(), query );
420  }
421  else if( xml.name() == QLatin1String("filequery") ) {
422  readQueryAttributes( xml.attributes(), query );
423 
424  FileQuery fileQuery(query);
425  FileQuery::FileMode mode;
426  if( xml.attributes().value(QLatin1String("queryFiles") ) == QLatin1String("true") )
427  mode |= FileQuery::QueryFiles;
428  if( xml.attributes().value(QLatin1String("queryFolders") ) == QLatin1String("true") )
429  mode |= FileQuery::QueryFolders;
430  fileQuery.setFileMode(mode);
431 
432  query = fileQuery;
433  }
434  else if( xml.name() == QLatin1String("requestProperty") ) {
435  query.addRequestProperty( Query::RequestProperty( KUrl(xml.attributes().value( QLatin1String("uri") ).toString()),
436  xml.attributes().value( QLatin1String("optional") ) == QLatin1String("true") ) );
437  xml.readNextStartElement(); // skip to next element
438  }
439  else if( xml.name() == QLatin1String("folder") ) {
440  if( !query.isFileQuery() ) {
441  kDebug() << "Folder tokens are only allowed in filequerys";
442  query = Query();
443  break;
444  }
445 
446  FileQuery fileQuery(query);
447  if( xml.attributes().value( QLatin1String("include") ) == QLatin1String("true") ) {
448  // for the recursive flag we use double negation since the default is true (even if the flag is not specified)
449  fileQuery.addIncludeFolder( KUrl( xml.attributes().value( QLatin1String("url") ).toString() ),
450  xml.attributes().value( QLatin1String("recursive") ) != QLatin1String("false") );
451  }
452  else {
453  fileQuery.addExcludeFolder( KUrl( xml.attributes().value( QLatin1String("url") ).toString() ) );
454  }
455  query = fileQuery;
456  xml.readNextStartElement(); // skip to next element
457  }
458  else {
459  bool termOk = false;
460  query.setTerm( doParseTerm( xml, &termOk ) );
461  if( !termOk ) {
462  break;
463  }
464  }
465  }
466 
467  return query;
468 }
469 
470 
471 QString Nepomuk2::Query::serializeTerm( const Term& term )
472 {
473  QString s;
474  QXmlStreamWriter xml( &s );
475 
476  // FIXME: should we really add the document details?
477  xml.writeStartDocument();
478  doSerializeTerm( xml, term );
479  xml.writeEndDocument();
480 
481  return s;
482 }
483 
484 
485 Term Nepomuk2::Query::parseTerm( const QString& s )
486 {
487  QXmlStreamReader xml( s );
488  if( xml.readNextStartElement() )
489  return doParseTerm( xml );
490  else
491  return Term();
492 
493 }
andterm.h
Nepomuk2::Query::ComparisonTerm::setComparator
void setComparator(Comparator)
Set the comparator.
Definition: comparisonterm.cpp:474
class.h
Nepomuk2::Query::Term::Comparison
A comparison.
Definition: term.h:113
Nepomuk2::Query::Term::toLiteralTerm
LiteralTerm toLiteralTerm() const
Interpret this term as a LiteralTerm.
Definition: term.cpp:211
Nepomuk2::Query::ComparisonTerm::setProperty
void setProperty(const Types::Property &)
Set the property for ComparisonTerm Terms.
Definition: comparisonterm.cpp:481
Nepomuk2::Query::AndTerm
Match resource that match all sub terms.
Definition: andterm.h:43
Nepomuk2::Query::FileQuery::addExcludeFolder
void addExcludeFolder(const KUrl &folder)
Add a folder to exclude from the search.
Definition: filequery.cpp:96
Nepomuk2::Query::serializeTerm
QString serializeTerm(const Term &term)
Definition: queryserializer.cpp:471
Nepomuk2::Query::Term::toOptionalTerm
OptionalTerm toOptionalTerm() const
Interpret this term as a OptionalTerm.
Definition: term.cpp:239
Nepomuk2::Query::ComparisonTerm::Average
Return the average value of all results instead of the results themselves.
Definition: comparisonterm.h:177
Nepomuk2::Query::Query::queryFlags
QueryFlags queryFlags() const
Get the query flags to configure this query.
Definition: query.cpp:359
resourceterm.h
Nepomuk2::Query::ResourceTerm::resource
Nepomuk2::Resource resource() const
The resource this term should match against.
Definition: resourceterm.cpp:104
Nepomuk2::Query::Term::Negation
A negation term inverts the meaning of its sub term.
Definition: term.h:127
Nepomuk2::Query::ComparisonTerm::setAggregateFunction
void setAggregateFunction(AggregateFunction function)
Set an aggregate function which changes the result.
Definition: comparisonterm.cpp:502
Nepomuk2::Types::Entity::uri
QUrl uri() const
The URI of the resource.
Definition: entity.cpp:175
Nepomuk2::Query::Term
The base class for all term types.
Definition: term.h:64
Nepomuk2::Query::SimpleTerm::setSubTerm
void setSubTerm(const Term &term)
Set the sub term to match against.
Definition: simpleterm.cpp:59
Nepomuk2::Query::ComparisonTerm::setSortWeight
void setSortWeight(int weight, Qt::SortOrder sortOrder=Qt::AscendingOrder)
Set the sort weight of this property.
Definition: comparisonterm.cpp:516
Nepomuk2::Query::serializeQuery
QString serializeQuery(const Query &query)
Definition: queryserializer.cpp:352
Nepomuk2::Query::ResourceTypeTerm
Matching resources by type.
Definition: resourcetypeterm.h:48
Nepomuk2::Query::NegationTerm::negateTerm
static Term negateTerm(const Term &term)
Negate term.
Definition: negationterm.cpp:101
Nepomuk2::Query::Query::term
Term term() const
The root term of the query.
Definition: query.cpp:293
QHash
Nepomuk2::Query::Query::requestProperties
QList< RequestProperty > requestProperties() const
Definition: query.cpp:377
Nepomuk2::Query::SimpleTerm::subTerm
Term subTerm() const
The sub term to match against.
Definition: simpleterm.cpp:52
negationterm.h
Nepomuk2::Query::GroupTerm::subTerms
QList< Term > subTerms() const
The sub terms that are combined in this group.
Definition: groupterm.cpp:94
Nepomuk2::Query::ComparisonTerm::AggregateFunction
AggregateFunction
Aggregate functions which can be applied to a comparison term to influence the value they return...
Definition: comparisonterm.h:125
Nepomuk2::Query::Term::And
Match all resources that match all sub terms.
Definition: term.h:98
Nepomuk2::Query::Query::setLimit
void setLimit(int)
Set the maximum number of results this query should yield.
Definition: query.cpp:317
Nepomuk2::Query::FileQuery::excludeFolders
KUrl::List excludeFolders() const
The list of exclude folders set via addExcludeFolder() and setExcludeFolders().
Definition: filequery.cpp:108
Nepomuk2::Query::FileQuery::QueryFiles
Definition: filequery.h:168
Nepomuk2::Query::FileQuery::QueryFolders
Definition: filequery.h:169
Nepomuk2::Query::Query::RequestProperty::optional
bool optional() const
Definition: query.cpp:226
Nepomuk2::Query::ResourceTypeTerm::type
Nepomuk2::Types::Class type() const
The type to match.
Definition: resourcetypeterm.cpp:94
Nepomuk2::Query::Query::offset
int offset() const
The first result that should be retrieved.
Definition: query.cpp:305
Nepomuk2::Query::Term::Optional
An optional term which marks its sub term as optional.
Definition: term.h:136
Nepomuk2::Query::FileQuery::allIncludeFolders
QHash< KUrl, bool > allIncludeFolders() const
The hash of include folders set via addIncludeFolder() and setIncludeFolders() including their recurs...
Definition: filequery.cpp:90
Nepomuk2::Query::Query::setTerm
void setTerm(const Term &)
Set the root term of the query.
Definition: query.cpp:311
Nepomuk2::Query::ComparisonTerm::NoAggregateFunction
Do not use any aggregate function.
Definition: comparisonterm.h:129
Nepomuk2::Query::Term::toComparisonTerm
ComparisonTerm toComparisonTerm() const
Interpret this term as a ComparisonTerm.
Definition: term.cpp:266
Nepomuk2::Query::Query::addRequestProperty
void addRequestProperty(const RequestProperty &property)
Add a property that should be reported with each search result.
Definition: query.cpp:365
Nepomuk2::Query::ComparisonTerm::Max
Return the maximum value of all results instead of the results themselves.
Definition: comparisonterm.h:150
Nepomuk2::Query::Term::toResourceTerm
ResourceTerm toResourceTerm() const
Interpret this term as a ResourceTerm.
Definition: term.cpp:221
Nepomuk2::Query::ComparisonTerm::DistinctAverage
The same as Average except that no two similar results are counted twice.
Definition: comparisonterm.h:183
Nepomuk2::Query::parseTerm
Term parseTerm(const QString &s)
Definition: queryserializer.cpp:485
queryserializer.h
Nepomuk2::Query::Term::toOrTerm
OrTerm toOrTerm() const
Interpret this term as a OrTerm.
Definition: term.cpp:257
Nepomuk2::Query::FileQuery
A Nepomuk desktop query specialized for file searches.
Definition: filequery.h:44
Nepomuk2::Query::ComparisonTerm
A term matching the value of a property.
Definition: comparisonterm.h:70
Nepomuk2::Query::Query
A Nepomuk desktop query.
Definition: query.h:76
Nepomuk2::Query::Query::RequestProperty
A request property can be added to a Query to retrieve additional information about the results...
Definition: query.h:287
Nepomuk2::Query::OrTerm
Match resource that match at least one of the sub terms.
Definition: orterm.h:43
Nepomuk2::Query::Query::setFullTextScoringEnabled
void setFullTextScoringEnabled(bool enabled)
Nepomuk supports scoring the results based on any full text matching used in the query (full text mat...
Definition: query.cpp:329
Nepomuk2::Query::Term::toResourceTypeTerm
ResourceTypeTerm toResourceTypeTerm() const
Interpret this term as a ResourceTypeTerm.
Definition: term.cpp:275
Nepomuk2::Query::Term::ResourceType
Matches all resources of a specific type.
Definition: term.h:120
Nepomuk2::Query::Query::RequestProperty::property
Nepomuk2::Types::Property property() const
Definition: query.cpp:221
Nepomuk2::Query::ComparisonTerm::DistinctCount
The same as Count except that no two similar results are counted twice.
Definition: comparisonterm.h:143
resourcetypeterm.h
Nepomuk2::Query::OptionalTerm::optionalizeTerm
static Term optionalizeTerm(const Term &term)
Mark term as optional.
Definition: optionalterm.cpp:59
Nepomuk2::Query::ComparisonTerm::Min
Return the minimum value of all results instead of the results themselves.
Definition: comparisonterm.h:157
Nepomuk2::Query::Query::setOffset
void setOffset(int offset)
The first result that should be retrieved.
Definition: query.cpp:323
Nepomuk2::Query::Query::isFileQuery
bool isFileQuery() const
Definition: query.cpp:281
comparisonterm.h
literalterm.h
Nepomuk2::Query::ComparisonTerm::Sum
Return the sum of all result values instead of the results themselves.
Definition: comparisonterm.h:164
Nepomuk2::Query::GroupTerm::addSubTerm
void addSubTerm(const Term &term)
Add a sub term to the list of terms that are combined in this group.
Definition: groupterm.cpp:108
Nepomuk2::Query::Term::toAndTerm
AndTerm toAndTerm() const
Interpret this term as a AndTerm.
Definition: term.cpp:248
Nepomuk2::Query::FileQuery::addIncludeFolder
void addIncludeFolder(const KUrl &folder)
Add a folder to include in the search.
Definition: filequery.cpp:57
Nepomuk2::Query::Term::Resource
A resource term matches one resource by URI.
Definition: term.h:91
Nepomuk2::Query::Query::setQueryFlags
void setQueryFlags(QueryFlags flags)
Set the query flags to configure this query.
Definition: query.cpp:353
Nepomuk2::Query::Query::fullTextScoringEnabled
bool fullTextScoringEnabled() const
Definition: query.cpp:341
orterm.h
optionalterm.h
term.h
Nepomuk2::Resource::uri
QUrl uri() const
The URI of the resource, uniquely identifying it.
Definition: resource.cpp:166
Nepomuk2::Query::ComparisonTerm::setVariableName
void setVariableName(const QString &name)
Set the variable name that is to be used for the variable to match to.
Definition: comparisonterm.cpp:488
Nepomuk2::Query::Query::fullTextScoringSortOrder
Qt::SortOrder fullTextScoringSortOrder() const
Definition: query.cpp:347
Nepomuk2::Query::ComparisonTerm::DistinctSum
The same as Sum except that no two similar results are added twice.
Definition: comparisonterm.h:170
Nepomuk2::Query::Term::type
Type type() const
Definition: term.cpp:84
Nepomuk2::Query::Query::limit
int limit() const
The maximum number of results that this query should yield.
Definition: query.cpp:299
Nepomuk2::Query::Term::Or
Match all resources that match one of the sub terms.
Definition: term.h:105
filequery.h
Nepomuk2::Query::Term::Literal
A literal term is the simplest form of Term.
Definition: term.h:84
Nepomuk2::Query::ComparisonTerm::Count
Count the number of matching results instead of returning the results themselves. ...
Definition: comparisonterm.h:137
Nepomuk2::Query::parseQuery
Query parseQuery(const QString &s)
Definition: queryserializer.cpp:411
Nepomuk2::Query::LiteralTerm
Match literal properties via full text.
Definition: literalterm.h:86
Nepomuk2::Query::Query::setFullTextScoringSortOrder
void setFullTextScoringSortOrder(Qt::SortOrder order)
Set the full text scoring sort order.
Definition: query.cpp:335
Nepomuk2::Query::ComparisonTerm::setInverted
void setInverted(bool invert)
Invert the comparison, i.e.
Definition: comparisonterm.cpp:545
Nepomuk2::Query::ResourceTerm
Matches exactly one resource.
Definition: resourceterm.h:52
Nepomuk2::Query::LiteralTerm::value
Soprano::LiteralValue value() const
The value this LiteralTerm should match to.
Definition: literalterm.cpp:262
Nepomuk2::Query::Term::toNegationTerm
NegationTerm toNegationTerm() const
Interpret this term as a NegationTerm.
Definition: term.cpp:230
Nepomuk2::Query::FileQuery::fileMode
FileMode fileMode() const
Definition: filequery.cpp:120
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:48:08 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

Nepomuk-Core

Skip menu "Nepomuk-Core"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Modules
  • Related Pages

kdelibs API Reference

Skip menu "kdelibs API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  • kjsembed
  •   WTF
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Nepomuk-Core
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal