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

Nepomuk

  • sources
  • kde-4.12
  • kdelibs
  • nepomuk
  • query
query.h
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 #ifndef _NEPOMUK_QUERY_QUERY_H_
21 #define _NEPOMUK_QUERY_QUERY_H_
22 
23 #include <QtCore/QSharedDataPointer>
24 #include <QtCore/QList>
25 #include <QtCore/QPair>
26 #include <QtCore/QDebug>
27 
28 #include <kurl.h>
29 
30 #include "property.h"
31 
32 #include "nepomukquery_export.h"
33 
34 class QTextStream;
35 
36 namespace Nepomuk {
37  namespace Query {
38 
39  class Term;
40  class QueryPrivate;
41  class FileQuery;
42 
47  typedef QHash<QString, Nepomuk::Types::Property> RequestPropertyMap;
48 
76  class NEPOMUKQUERY_EXPORT Query
77  {
78  public:
82  Query();
83 
87  explicit Query( const Term& term );
88 
92  Query( const Query& );
93 
97  ~Query();
98 
102  Query& operator=( const Query& );
103 
111  Query& operator=( const Term& term );
112 
117  bool isValid() const;
118 
127  bool isFileQuery() const;
128 
134  FileQuery toFileQuery() const;
135 
142  Term term() const;
143 
149  int limit() const;
150 
158  int offset() const;
159 
165  void setTerm( const Term& );
166 
173  void setLimit( int );
174 
181  void setOffset( int offset );
182 
196  void setFullTextScoringEnabled( bool enabled );
197 
208  void setFullTextScoringSortOrder( Qt::SortOrder order );
209 
217  bool fullTextScoringEnabled() const;
218 
224  Qt::SortOrder fullTextScoringSortOrder() const;
225 
233  enum QueryFlag {
237  NoQueryFlags = 0x0,
238 
245  NoResultRestrictions = 0x1,
246 
253  WithoutFullTextExcerpt = 0x2
254  };
255  Q_DECLARE_FLAGS( QueryFlags, QueryFlag )
256 
257 
264  void setQueryFlags( QueryFlags flags );
265 
273  QueryFlags queryFlags() const;
274 
288  class NEPOMUKQUERY_EXPORT RequestProperty {
289  public:
296  RequestProperty( const Nepomuk::Types::Property& property,
297  bool optional = true );
298 
302  RequestProperty( const RequestProperty& );
303 
307  ~RequestProperty();
308 
312  RequestProperty& operator=( const RequestProperty& );
313 
319  bool operator==( const RequestProperty& other ) const;
320 
324  Nepomuk::Types::Property property() const;
325 
329  bool optional() const;
330 
331  private:
332  class Private;
333  QSharedDataPointer<Private> d;
334  };
335 
346  void addRequestProperty( const RequestProperty& property );
347 
358  void setRequestProperties( const QList<RequestProperty>& properties );
359 
364  QList<RequestProperty> requestProperties() const;
365 
369  enum SparqlFlag {
373  NoFlags = 0x0,
374 
380  CreateCountQuery = 0x1,
381 
387  HandleInverseProperties = 0x2,
388 
395  CreateAskQuery = 0x4
396  };
397  Q_DECLARE_FLAGS( SparqlFlags, SparqlFlag )
398 
399 
423  QString toSparqlQuery( SparqlFlags flags = NoFlags ) const;
424 
438  KUrl toSearchUrl( SparqlFlags flags = NoFlags ) const;
439 
461  KUrl toSearchUrl( const QString& customTitle, SparqlFlags flags = NoFlags ) const;
462 
469  RequestPropertyMap requestPropertyMap() const;
470 
476  bool operator==( const Query& query ) const;
477 
485  bool operator!=( const Query& query ) const;
486 
498  Query optimized() const;
499 
509  QString toString() const;
510 
520  static Query fromString( const QString& queryString );
521 
534  static Query fromQueryUrl( const KUrl& url );
535 
547  static QString sparqlFromQueryUrl( const KUrl& url );
548 
561  static QString titleFromQueryUrl( const KUrl& url );
562 
563  protected:
565  QSharedDataPointer<QueryPrivate> d;
567  };
568 
577  NEPOMUKQUERY_EXPORT Query operator&&( const Query& query, const Term& term );
578 
587  NEPOMUKQUERY_EXPORT Query operator||( const Query& query, const Term& term );
588 
597  NEPOMUKQUERY_EXPORT Query operator!( const Query& query );
598 
599  NEPOMUKQUERY_EXPORT uint qHash( const Nepomuk::Query::Query& );
600  }
601 }
602 
603 Q_DECLARE_OPERATORS_FOR_FLAGS( Nepomuk::Query::Query::SparqlFlags )
604 Q_DECLARE_OPERATORS_FOR_FLAGS( Nepomuk::Query::Query::QueryFlags )
605 
606 NEPOMUKQUERY_EXPORT QDebug operator<<( QDebug, const Nepomuk::Query::Query& );
607 
608 #endif
Nepomuk::Query::Query::QueryFlag
QueryFlag
A set of flags that influence the result of the query.
Definition: query.h:233
Nepomuk::Query::RequestPropertyMap
QHash< QString, Nepomuk::Types::Property > RequestPropertyMap
Convinience definition for request property mappings as used in QueryServiceClient::sparqlQuery() and...
Definition: query.h:41
Nepomuk::Query::Query
A Nepomuk desktop query.
Definition: query.h:76
property.h
Nepomuk::Types::Property
A property is a resource of type rdf:Property which relates a domain with a range.
Definition: property.h:52
Nepomuk::Query::Term
The base class for all term types.
Definition: term.h:64
Nepomuk::Query::FileQuery
A Nepomuk desktop query specialized for file searches.
Definition: filequery.h:44
nepomukquery_export.h
Nepomuk::Query::Query::SparqlFlag
SparqlFlag
Aditional flags modifying the behaviour of toSparqlQuery() and toSearchUrl().
Definition: query.h:369
Nepomuk::Query::Query::RequestProperty
A request property can be added to a Query to retrieve additional information about the results...
Definition: query.h:288
Nepomuk::Query::qHash
uint qHash(const Nepomuk::Query::Query &)
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:48:27 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

Nepomuk

Skip menu "Nepomuk"
  • 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