blob: ff7e51adb0c71fba6288fca43b2f1a61c7d4bb44 (
plain) (
blame)
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
|
#include "db/asyncqueryrunner.h"
#include "db/sqlquery.h"
#include "db/db.h"
#include <QDebug>
AsyncQueryRunner::AsyncQueryRunner(const QString &query, const QVariant& args, Db::Flags flags)
: query(query), args(args), flags(flags)
{
init();
}
void AsyncQueryRunner::init()
{
setAutoDelete(false);
}
void AsyncQueryRunner::run()
{
if (!db || !db->isValid())
{
qCritical() << "No Db or invalid Db defined in AsyncQueryRunner!";
emit finished(this);
}
SqlQueryPtr res;
if (args.userType() == QVariant::List)
{
res = db->exec(query, args.toList(), flags);
}
else if (args.userType() == QVariant::Hash)
{
res = db->exec(query, args.toHash(), flags);
}
else
{
qCritical() << "Invalid argument type in AsyncQueryRunner::run():" << args.userType();
}
results = SqlQueryPtr(res);
emit finished(this);
}
SqlQueryPtr AsyncQueryRunner::getResults()
{
return results;
}
void AsyncQueryRunner::setDb(Db *db)
{
this->db = db;
}
void AsyncQueryRunner::setAsyncId(quint32 id)
{
asyncId = id;
}
quint32 AsyncQueryRunner::getAsyncId()
{
return asyncId;
}
|