• 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
  • services
  • storage
  • query
searchrunnable.cpp
Go to the documentation of this file.
1 /*
2  This file is part of the Nepomuk KDE project.
3  Copyright (C) 2007-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 #include "searchrunnable.h"
21 #include "folder.h"
22 
23 #include "resourcemanager.h"
24 #include "resource.h"
25 #include "resultiterator.h"
26 
27 #include <Soprano/Version>
28 #include <Soprano/Model>
29 #include <Soprano/QueryResultIterator>
30 #include <Soprano/Node>
31 #include <Soprano/Statement>
32 #include <Soprano/LiteralValue>
33 #include <Soprano/StatementIterator>
34 #include <Soprano/Vocabulary/RDF>
35 #include <Soprano/Vocabulary/RDFS>
36 #include <Soprano/Vocabulary/NRL>
37 #include <Soprano/Vocabulary/NAO>
38 #include <Soprano/Vocabulary/XMLSchema>
39 #include <Soprano/Vocabulary/OWL>
40 #include <Soprano/Vocabulary/Xesam>
41 #include "nfo.h"
42 
43 #include <KDebug>
44 #include <KDateTime>
45 #include <KRandom>
46 
47 #include <QtCore/QTime>
48 #include <QtCore/QRegExp>
49 #include <QtCore/QLatin1String>
50 #include <QtCore/QStringList>
51 
52 
53 Nepomuk2::Query::SearchRunnable::SearchRunnable( Soprano::Model* model, const QString& sparqlQuery, const Nepomuk2::Query::RequestPropertyMap& map )
54  : QRunnable(),
55  m_model( model ),
56  m_sparqlQuery( sparqlQuery ),
57  m_requestPropertyMap( map ),
58  m_cancelled( false )
59 {
60 }
61 
62 
63 Nepomuk2::Query::SearchRunnable::~SearchRunnable()
64 {
65 }
66 
67 
68 void Nepomuk2::Query::SearchRunnable::cancel()
69 {
70  m_cancelled = true;
71 }
72 
73 
74 void Nepomuk2::Query::SearchRunnable::run()
75 {
76  kDebug() << m_sparqlQuery;
77 
78 #ifndef NDEBUG
79  QTime time;
80  time.start();
81 #endif
82 
83  ResultIterator hits( m_sparqlQuery, m_requestPropertyMap );
84  while ( !m_cancelled && hits.next() ) {
85  Result result = hits.result();
86 
87  kDebug() << "Found result:" << result.resource().uri() << result.score();
88  emit newResult( result );
89  }
90 
91 #ifndef NDEBUG
92  kDebug() << "Query Time:" << time.elapsed()/1000.0 << "seconds";
93 #endif
94 
95  emit listingFinished();
96 }
Nepomuk2::Query::ResultIterator::next
bool next()
Get the next result.
Definition: resultiterator.cpp:100
Nepomuk2::Query::SearchRunnable::run
void run()
Definition: searchrunnable.cpp:74
Nepomuk2::Query::ResultIterator::result
Result result() const
Definition: resultiterator.cpp:115
Nepomuk2::Query::SearchRunnable::SearchRunnable
SearchRunnable(Soprano::Model *model, const QString &sparqlQuery, const RequestPropertyMap &map)
Definition: searchrunnable.cpp:53
Nepomuk2::Query::ResultIterator
A class to iterate over Nepomuk query results.
Definition: resultiterator.h:45
Nepomuk2::Query::SearchRunnable::~SearchRunnable
~SearchRunnable()
Definition: searchrunnable.cpp:63
QRunnable
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
resource.h
Nepomuk2::Query::SearchRunnable::cancel
void cancel()
Cancel the search and detach it from the folder.
Definition: searchrunnable.cpp:68
resourcemanager.h
resultiterator.h
folder.h
Nepomuk2::Query::Result
A single search result.
Definition: result.h:57
Nepomuk2::Query::Result::resource
Resource resource() const
The result resource.
Definition: result.cpp:81
Nepomuk2::Resource::uri
QUrl uri() const
The URI of the resource, uniquely identifying it.
Definition: resource.cpp:166
Nepomuk2::Query::Result::score
double score() const
The score of the result.
Definition: result.cpp:75
searchrunnable.h
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:48:09 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