delay a few things on startup, such as setting the visibility mode, which ensures...
[personal-kdebase.git] / runtime / nepomuk / libnepomukquery / query.h
blob3aee568574ffc450e629df4a3d74100d38cf7188
1 /*
2 This file is part of the Nepomuk KDE project.
3 Copyright (C) 2008 Sebastian Trueg <trueg@kde.org>
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.
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.
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.
20 #ifndef _NEPOMUK_SEARCH_QUERY_H_
21 #define _NEPOMUK_SEARCH_QUERY_H_
23 #include <QtCore/QSharedDataPointer>
24 #include <QtCore/QList>
25 #include <QtCore/QPair>
26 #include <QtCore/QDebug>
28 #include <nepomuk/nepomuk_export.h>
30 class QUrl;
32 namespace Nepomuk {
33 namespace Search {
35 class Term;
37 /**
38 * \class Query query.h nepomuk/query.h
40 * \brief A Nepomuk desktop query.
42 * A query can either be based on Term or a more complex
43 * SPARQL query.
45 * \author Sebastian Trueg <trueg@kde.org>
47 class NEPOMUK_EXPORT Query
49 public:
50 enum Type {
51 InvalidQuery,
52 PlainQuery,
53 SPARQLQuery
56 /**
57 * Create an empty invalid query object.
59 Query();
61 /**
62 * Create a query of type PlainQuery based on
63 * \a term.
65 Query( const Term& term );
67 /**
68 * Create a SPARQL query. The query has to have one select variable called "?r"
70 explicit Query( const QString& sparqlQuery );
72 /**
73 * Copy constructor.
75 Query( const Query& );
77 /**
78 * Destructor
80 ~Query();
82 /**
83 * Assignment operator
85 Query& operator=( const Query& );
87 Type type() const;
88 Term term() const;
89 QString sparqlQuery() const;
90 int limit() const;
92 void setTerm( const Term& );
93 void setSparqlQuery( const QString& );
94 void setLimit( int );
96 /**
97 * Add a property that should be reported with each search result.
98 * \param property The requested property.
99 * \param optional If \p true the property is optional, meaning it can
100 * be empty ins earch results.
102 void addRequestProperty( const QUrl& property, bool optional = true );
103 void clearRequestProperties();
105 typedef QPair<QUrl, bool> RequestProperty;
107 QList<RequestProperty> requestProperties() const;
109 bool operator==( const Query& ) const;
111 private:
112 class Private;
113 QSharedDataPointer<Private> d;
116 NEPOMUK_EXPORT uint qHash( const Nepomuk::Search::Query& );
120 NEPOMUK_EXPORT QDebug operator<<( QDebug, const Nepomuk::Search::Query& );
122 #endif