• 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
countqueryrunnable.cpp
Go to the documentation of this file.
1 /*
2  Copyright (c) 2010 Sebastian Trueg <trueg@kde.org>
3 
4  This program is free software; you can redistribute it and/or
5  modify it under the terms of the GNU General Public License as
6  published by the Free Software Foundation; either version 2 of
7  the License or (at your option) version 3 or any later version
8  accepted by the membership of KDE e.V. (or its successor approved
9  by the membership of KDE e.V.), which shall act as a proxy
10  defined in Section 14 of version 3 of the license.
11 
12  This program is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU General Public License for more details.
16 
17  You should have received a copy of the GNU General Public License
18  along with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20 
21 #include "countqueryrunnable.h"
22 #include "folder.h"
23 
24 #include "query/query.h"
25 
26 #include <Soprano/QueryResultIterator>
27 #include <Soprano/Node>
28 #include <Soprano/LiteralValue>
29 #include <Soprano/Model>
30 
31 #include <KDebug>
32 
33 #include <QtCore/QMutexLocker>
34 #include <QtCore/QTime>
35 
36 Nepomuk2::Query::CountQueryRunnable::CountQueryRunnable( Soprano::Model* model, const Nepomuk2::Query::Query& query )
37  : QRunnable(),
38  m_model( model ),
39  m_cancelled( false )
40 {
41  m_countQuery = query.toSparqlQuery( Query::CreateCountQuery );
42  kDebug();
43 }
44 
45 
46 Nepomuk2::Query::CountQueryRunnable::~CountQueryRunnable()
47 {
48 }
49 
50 
51 void Nepomuk2::Query::CountQueryRunnable::cancel()
52 {
53  m_cancelled = true;
54 }
55 
56 
57 void Nepomuk2::Query::CountQueryRunnable::run()
58 {
59  int count = -1;
60 
61 #ifndef NDEBUG
62  QTime time;
63  time.start();
64 #endif
65 
66  Soprano::QueryResultIterator it = m_model->executeQuery( m_countQuery, Soprano::Query::QueryLanguageSparql );
67  if( it.next() && !m_cancelled ) {
68  count = it.binding( 0 ).literal().toInt();
69  }
70  kDebug() << "Count:" << count;
71 
72 #ifndef NDEBUG
73  kDebug() << "Count Query Time:" << time.elapsed()/1000.0 << "seconds";
74 #endif
75 
76  if( !m_cancelled )
77  emit countQueryFinished( count );
78 }
Nepomuk2::Query::Query::toSparqlQuery
QString toSparqlQuery(SparqlFlags flags=NoFlags) const
Convert the query into a SPARQL query which can be used with the Nepomuk query service or directly in...
Definition: query.cpp:409
Nepomuk2::Query::Query::CreateCountQuery
Create a SPARQL count query which will return the number of results rather than the results themselve...
Definition: query.h:379
QRunnable
query.h
Nepomuk2::Query::CountQueryRunnable::run
void run()
Definition: countqueryrunnable.cpp:57
Nepomuk2::Query::CountQueryRunnable::~CountQueryRunnable
~CountQueryRunnable()
Definition: countqueryrunnable.cpp:46
Nepomuk2::Query::CountQueryRunnable::CountQueryRunnable
CountQueryRunnable(Soprano::Model *model, const Query &query)
Definition: countqueryrunnable.cpp:36
Nepomuk2::Query::Query
A Nepomuk desktop query.
Definition: query.h:76
countqueryrunnable.h
folder.h
Nepomuk2::Query::CountQueryRunnable::cancel
void cancel()
Cancel the search and detach it from the folder.
Definition: countqueryrunnable.cpp:51
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