• Skip to content
  • Skip to link menu
KDE 4.2 API Reference
  • KDE API Reference
  • API Reference
  • Sitemap
  • Contact Us
 

NepomukDaemons

searchthread.h

Go to the documentation of this file.
00001 /*
00002    This file is part of the Nepomuk KDE project.
00003    Copyright (C) 2007 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_SEARCH_THREAD_H_
00021 #define _NEPOMUK_SEARCH_THREAD_H_
00022 
00023 #include <QtCore/QThread>
00024 #include <QtCore/QHash>
00025 #include <QtCore/QUrl>
00026 #include <QtCore/QPair>
00027 
00028 #include "query.h"
00029 #include "term.h"
00030 #include "result.h"
00031 
00032 
00033 
00034 namespace Soprano {
00035     class QueryResultIterator;
00036 }
00037 
00038 namespace Nepomuk {
00039     namespace Search {
00040 
00041         class SearchNode
00042         {
00043         public:
00044             enum Type {
00045                 Unknown,
00046                 Lucene,
00047                 Sparql
00048             };
00049 
00050             SearchNode( const Term& t, Type tt = Unknown, const QList<SearchNode>& sub = QList<SearchNode>() )
00051                 : term(t),
00052                 type(tt),
00053                 subNodes(sub) {
00054             }
00055             
00056             Term term;
00057             Type type;
00058             QList<SearchNode> subNodes;
00059         };
00060 
00061         class SearchThread : public QThread
00062         {
00063             Q_OBJECT
00064 
00065         public:
00066             SearchThread( QObject* parent = 0 );
00067             ~SearchThread();
00068 
00072             void query( const Query& query, double cutOffScore );
00073             void cancel();
00074 
00075             double cutOffScore() const { return m_cutOffScore; }
00076 
00077         signals:
00078             void newResult( const Nepomuk::Search::Result& result );
00079 
00080         protected:
00081             void run();
00082 
00083         private:
00093             Nepomuk::Search::Term resolveFields( const Term& term );
00094 
00104             Nepomuk::Search::Term resolveValues( const Term& term );
00105 
00109             Nepomuk::Search::Term optimize( const Term& term );
00110 
00115             SearchNode splitLuceneSparql( const Term& term );
00116 
00117             QList<QUrl> matchFieldName( const QString& field );
00118             QHash<QUrl, Result> search( const SearchNode& node, double baseScore, bool reportResults = false );
00119             QHash<QUrl, Result> andSearch( const QList<SearchNode>& terms, double baseScore, bool reportResults = false );
00120             QHash<QUrl, Result> orSearch( const QList<SearchNode>& terms, double baseScore, bool reportResults = false );
00121             QHash<QUrl, Nepomuk::Search::Result> sparqlQuery( const QString& query, double baseScore, bool reportResults );
00122             QHash<QUrl, Nepomuk::Search::Result> luceneQuery( const QString& query, double baseScore, bool reportResults );
00123 
00124             QString buildRequestPropertyVariableList() const;
00125             QString buildRequestPropertyPatterns() const;
00126             Nepomuk::Search::Result extractResult( const Soprano::QueryResultIterator& it ) const;
00127             void fetchRequestPropertiesForResource( Result& uri );
00128 
00129             QString createSparqlQuery( const SearchNode& node );
00130 
00131             Query m_searchTerm;
00132             double m_cutOffScore;
00133 
00134             // status
00135             int m_numResults;
00136             bool m_canceled;
00137         };
00138     }
00139 }
00140 
00141 #endif

NepomukDaemons

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

API Reference

Skip menu "API Reference"
  • KCMShell
  • KNotify
  • KStyles
  • Nepomuk Daemons
Generated for API Reference by doxygen 1.5.7
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