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

Nepomuk

query.h

Go to the documentation of this file.
00001 /*
00002    This file is part of the Nepomuk KDE project.
00003    Copyright (C) 2008-2010 Sebastian Trueg <trueg@kde.org>
00004 
00005    This library is free software; you can redistribute it and/or
00006    modify it under the terms of the GNU Library General Public
00007    License version 2 as published by the Free Software Foundation.
00008 
00009    This library is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY; without even the implied warranty of
00011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012    Library General Public License for more details.
00013 
00014    You should have received a copy of the GNU Library General Public License
00015    along with this library; see the file COPYING.LIB.  If not, write to
00016    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00017    Boston, MA 02110-1301, USA.
00018  */
00019 
00020 #ifndef _NEPOMUK_QUERY_QUERY_H_
00021 #define _NEPOMUK_QUERY_QUERY_H_
00022 
00023 #include <QtCore/QSharedDataPointer>
00024 #include <QtCore/QList>
00025 #include <QtCore/QPair>
00026 #include <QtCore/QDebug>
00027 
00028 #include <kurl.h>
00029 
00030 #include "property.h"
00031 
00032 #include "nepomukquery_export.h"
00033 
00034 class QTextStream;
00035 
00036 namespace Nepomuk {
00037     namespace Query {
00038 
00039         class Term;
00040         class QueryPrivate;
00041         class FileQuery;
00042 
00047         typedef QHash<QString, Nepomuk::Types::Property> RequestPropertyMap;
00048 
00076         class NEPOMUKQUERY_EXPORT Query
00077         {
00078         public:
00082             Query();
00083 
00087             explicit Query( const Term& term );
00088 
00092             Query( const Query& );
00093 
00097             ~Query();
00098 
00102             Query& operator=( const Query& );
00103 
00111             Query& operator=( const Term& term );
00112 
00117             bool isValid() const;
00118 
00127             bool isFileQuery() const;
00128 
00134             FileQuery toFileQuery() const;
00135 
00142             Term term() const;
00143 
00149             int limit() const;
00150 
00158             int offset() const;
00159 
00165             void setTerm( const Term& );
00166 
00173             void setLimit( int );
00174 
00181             void setOffset( int offset );
00182 
00196             void setFullTextScoringEnabled( bool enabled );
00197 
00208             void setFullTextScoringSortOrder( Qt::SortOrder order );
00209 
00217             bool fullTextScoringEnabled() const;
00218 
00224             Qt::SortOrder fullTextScoringSortOrder() const;
00225 
00233             enum QueryFlag {
00237                 NoQueryFlags = 0x0,
00238 
00245                 NoResultRestrictions = 0x1,
00246 
00253                 WithoutFullTextExcerpt = 0x2
00254             };
00255             Q_DECLARE_FLAGS( QueryFlags, QueryFlag )
00256 
00257             
00264             void setQueryFlags( QueryFlags flags );
00265 
00273             QueryFlags queryFlags() const;
00274 
00288             class NEPOMUKQUERY_EXPORT RequestProperty {
00289             public:
00296                 RequestProperty( const Nepomuk::Types::Property& property,
00297                                  bool optional = true );
00298 
00302                 RequestProperty( const RequestProperty& );
00303 
00307                 ~RequestProperty();
00308 
00312                 RequestProperty& operator=( const RequestProperty& );
00313 
00319                 bool operator==( const RequestProperty& other ) const;
00320 
00324                 Nepomuk::Types::Property property() const;
00325 
00329                 bool optional() const;
00330 
00331             private:
00332                 class Private;
00333                 QSharedDataPointer<Private> d;
00334             };
00335 
00346             void addRequestProperty( const RequestProperty& property );
00347 
00358             void setRequestProperties( const QList<RequestProperty>& properties );
00359 
00364             QList<RequestProperty> requestProperties() const;
00365 
00369             enum SparqlFlag {
00373                 NoFlags = 0x0,
00374 
00380                 CreateCountQuery = 0x1,
00381 
00387                 HandleInverseProperties = 0x2,
00388 
00395                 CreateAskQuery = 0x4
00396             };
00397             Q_DECLARE_FLAGS( SparqlFlags, SparqlFlag )
00398 
00399             
00423             QString toSparqlQuery( SparqlFlags flags = NoFlags ) const;
00424 
00438             KUrl toSearchUrl( SparqlFlags flags = NoFlags ) const;
00439 
00461             KUrl toSearchUrl( const QString& customTitle, SparqlFlags flags = NoFlags ) const;
00462 
00469             RequestPropertyMap requestPropertyMap() const;
00470 
00476             bool operator==( const Query& query ) const;
00477 
00485             bool operator!=( const Query& query ) const;
00486 
00498             Query optimized() const;
00499 
00509             QString toString() const;
00510 
00520             static Query fromString( const QString& queryString );
00521 
00534             static Query fromQueryUrl( const KUrl& url );
00535 
00547             static QString sparqlFromQueryUrl( const KUrl& url );
00548 
00561             static QString titleFromQueryUrl( const KUrl& url );
00562 
00563         protected:
00565             QSharedDataPointer<QueryPrivate> d;
00567         };
00568 
00577         NEPOMUKQUERY_EXPORT Query operator&&( const Query& query, const Term& term );
00578 
00587         NEPOMUKQUERY_EXPORT Query operator||( const Query& query, const Term& term );
00588 
00597         NEPOMUKQUERY_EXPORT Query operator!( const Query& query );
00598 
00599         NEPOMUKQUERY_EXPORT uint qHash( const Nepomuk::Query::Query& );
00600     }
00601 }
00602 
00603 Q_DECLARE_OPERATORS_FOR_FLAGS( Nepomuk::Query::Query::SparqlFlags )
00604 Q_DECLARE_OPERATORS_FOR_FLAGS( Nepomuk::Query::Query::QueryFlags )
00605 
00606 NEPOMUKQUERY_EXPORT QDebug operator<<( QDebug, const Nepomuk::Query::Query& );
00607 
00608 #endif

Nepomuk

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

kdelibs

Skip menu "kdelibs"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • Kate
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.7.3
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal