-
Notifications
You must be signed in to change notification settings - Fork 0
/
querythread.h
67 lines (50 loc) · 1.92 KB
/
querythread.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#ifndef QUERYTHREAD_H
#define QUERYTHREAD_H
#include <QThread>
#include <QPair>
typedef QPair<QString, QString> QStringPair;
namespace Soprano
{
class Model;
}
/*! Thread class that executes queries (and performs some utility functions)
*/
class QueryThread : public QThread
{
Q_OBJECT
public:
enum QueryMode{ SingleQuery, SingleQueryPairs, IncrementalQuery };
QueryThread(QObject *parent);
/** Runs the query:
- for SingleQuery: extracts the first two bindings
- for IncrementalQuery: extracts the binding corresponding to varName
*/
void run();
/** Sets the query to be run on the RDF repository with the run() function
*/
void setQuery(QString query, QString varName = QString(), QueryMode queryMode = QueryThread::SingleQuery);
/** SYNCHRONOUS utility function.
Returns query results of a simple SELECT query
query - the query to run
freeVar - the variable to get bindings for
*/
static QStringList queryResults( QString query, QString freeVar );
/** SYNCHRONOUS utility function.
Counts the query results of a simple SELECT query
*/
static int countQueryResults( QString query );
signals:
void queryDone(QList<QStringPair>);
void queryDone(QStringList);
void resultFound(QString item);
private:
void singleQuery();//fires results at the end - you need to have supplied the conditions and the free var to get bindings for
void singleQueryPairs();//fires pair at the end - you need to have supplied the conditions and the free var to get bindings for
void incrementalQuery();//fires each result item in turn - you need to have supplied the conditions and the free var to get bindings for
static Soprano::Model* nepomukMainModel();
static bool caseInsensitiveLessThan(const QStringPair &s1, const QStringPair &s2);
QString m_query;
QString m_varName;
QueryMode m_queryMode;
};
#endif // QUERYTHREAD_H