• 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
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 _NEPOMUK2_QUERY_QUERY_H_
21 #define _NEPOMUK2_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 "nepomuk_export.h"
33 
34 class QTextStream;
35 
36 namespace Nepomuk2 {
37  namespace Query {
38 
39  class Term;
40  class QueryPrivate;
41  class FileQuery;
42 
47  typedef QHash<QString, Nepomuk2::Types::Property> RequestPropertyMap;
48 
76  class NEPOMUK_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 
252  WithFullTextExcerpt = 0x2
253  };
254  Q_DECLARE_FLAGS( QueryFlags, QueryFlag )
255 
256 
263  void setQueryFlags( QueryFlags flags );
264 
272  QueryFlags queryFlags() const;
273 
287  class NEPOMUK_EXPORT RequestProperty {
288  public:
295  RequestProperty( const Nepomuk2::Types::Property& property,
296  bool optional = true );
297 
301  RequestProperty( const RequestProperty& );
302 
306  ~RequestProperty();
307 
311  RequestProperty& operator=( const RequestProperty& );
312 
318  bool operator==( const RequestProperty& other ) const;
319 
323  Nepomuk2::Types::Property property() const;
324 
328  bool optional() const;
329 
330  private:
331  class Private;
332  QSharedDataPointer<Private> d;
333  };
334 
345  void addRequestProperty( const RequestProperty& property );
346 
357  void setRequestProperties( const QList<RequestProperty>& properties );
358 
363  QList<RequestProperty> requestProperties() const;
364 
368  enum SparqlFlag {
372  NoFlags = 0x0,
373 
379  CreateCountQuery = 0x1,
380 
386  HandleInverseProperties = 0x2,
387 
394  CreateAskQuery = 0x4
395  };
396  Q_DECLARE_FLAGS( SparqlFlags, SparqlFlag )
397 
398 
422  QString toSparqlQuery( SparqlFlags flags = NoFlags ) const;
423 
437  KUrl toSearchUrl( SparqlFlags flags = NoFlags ) const;
438 
460  KUrl toSearchUrl( const QString& customTitle, SparqlFlags flags = NoFlags ) const;
461 
468  RequestPropertyMap requestPropertyMap() const;
469 
475  bool operator==( const Query& query ) const;
476 
484  bool operator!=( const Query& query ) const;
485 
497  Query optimized() const;
498 
508  QString toString() const;
509 
519  static Query fromString( const QString& queryString );
520 
533  static Query fromQueryUrl( const KUrl& url );
534 
546  static QString sparqlFromQueryUrl( const KUrl& url );
547 
560  static QString titleFromQueryUrl( const KUrl& url );
561 
562  protected:
564  QSharedDataPointer<QueryPrivate> d;
566  };
567 
576  NEPOMUK_EXPORT Query operator&&( const Query& query, const Term& term );
577 
586  NEPOMUK_EXPORT Query operator||( const Query& query, const Term& term );
587 
596  NEPOMUK_EXPORT Query operator!( const Query& query );
597 
598  NEPOMUK_EXPORT uint qHash( const Nepomuk2::Query::Query& );
599  }
600 }
601 
602 Q_DECLARE_OPERATORS_FOR_FLAGS( Nepomuk2::Query::Query::SparqlFlags )
603 Q_DECLARE_OPERATORS_FOR_FLAGS( Nepomuk2::Query::Query::QueryFlags )
604 
605 NEPOMUK_EXPORT QDebug operator<<( QDebug, const Nepomuk2::Query::Query& );
606 
607 #endif
Nepomuk2::Query::Term
The base class for all term types.
Definition: term.h:64
Nepomuk2::Query::Query::QueryFlag
QueryFlag
A set of flags that influence the result of the query.
Definition: query.h:233
QHash
Nepomuk2::Query::qHash
uint qHash(const Nepomuk2::Query::Query &)
Definition: query.cpp:738
Nepomuk2::Query::RequestPropertyMap
QHash< QString, Nepomuk2::Types::Property > RequestPropertyMap
Convinience definition for request property mappings as used in QueryServiceClient::sparqlQuery() and...
Definition: query.h:41
Nepomuk2::Query::FileQuery
A Nepomuk desktop query specialized for file searches.
Definition: filequery.h:44
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::Types::Property
A property is a resource of type rdf:Property which relates a domain with a range.
Definition: libnepomukcore/types/property.h:52
Nepomuk2::Query::Query::SparqlFlag
SparqlFlag
Aditional flags modifying the behaviour of toSparqlQuery() and toSearchUrl().
Definition: query.h:368
nepomuk_export.h
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