diff options
author | Denis Dzyubenko <[email protected]> | 2012-04-11 15:59:00 +0200 |
---|---|---|
committer | Denis Dzyubenko <[email protected]> | 2012-04-11 16:54:46 +0200 |
commit | 6b7df60a752422b1f6ff07bb2682c21e18a43985 (patch) | |
tree | 3e56bd3f4ee34a228777d00ff328ef1c53cb1df1 /src/imports/jsondb/jsondbqueryobject.cpp | |
parent | 20549eedb5b5e852c0e384cd76bfbff14168dbda (diff) | |
parent | 7ef36e3c5a88560eb4e3a81c2c9f14059739108b (diff) |
Merge remote-tracking branch 'gerrit/master' into hbtreehbtree
Conflicts:
src/daemon/daemon.pri
src/daemon/jsondbview.cpp
src/partition/jsondbindex.cpp
src/partition/jsondbindex.h
src/partition/jsondbindexquery.h
src/partition/jsondbmanagedbtree.cpp
src/partition/jsondbmanagedbtree.h
src/partition/jsondbmanagedbtreetxn.cpp
src/partition/jsondbmanagedbtreetxn.h
src/partition/jsondbobjecttable.cpp
src/partition/jsondbobjecttable.h
src/partition/jsondbpartition.cpp
src/partition/jsondbpartition.h
tests/auto/auto.pro
tests/auto/partition/testpartition.cpp
tests/benchmarks/benchmarks.pro
Change-Id: I963adefd6d32fca9b3537981306b67538c759034
Diffstat (limited to 'src/imports/jsondb/jsondbqueryobject.cpp')
-rw-r--r-- | src/imports/jsondb/jsondbqueryobject.cpp | 60 |
1 files changed, 29 insertions, 31 deletions
diff --git a/src/imports/jsondb/jsondbqueryobject.cpp b/src/imports/jsondb/jsondbqueryobject.cpp index b42daaa..ac00e69 100644 --- a/src/imports/jsondb/jsondbqueryobject.cpp +++ b/src/imports/jsondb/jsondbqueryobject.cpp @@ -38,10 +38,11 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ -#include "jsondb-global.h" #include "jsondbqueryobject.h" #include "jsondbpartition.h" -#include "private/jsondb-strings_p.h" +#include "jsondatabase.h" +#include <private/qjsondbstrings_p.h> +#include <jsondbmodelutils.h> #include <qdebug.h> QT_BEGIN_NAMESPACE_JSONDB @@ -84,7 +85,6 @@ JsonDbQueryObject::JsonDbQueryObject(QObject *parent) , queryLimit(-1) , partitionObject(0) , defaultPartitionObject(0) - , jsondbQuery(0) , errorCode(0) , objectStatus(JsonDbQueryObject::Null) { @@ -94,8 +94,8 @@ JsonDbQueryObject::~JsonDbQueryObject() { if (defaultPartitionObject) delete defaultPartitionObject; - if (jsondbQuery) - delete jsondbQuery; + if (readRequest) + delete readRequest; } @@ -145,8 +145,8 @@ void JsonDbQueryObject::setPartition(JsonDbPartition *newPartition) */ quint32 JsonDbQueryObject::stateNumber() const { - if (jsondbQuery) - return jsondbQuery->stateNumber(); + if (readRequest) + return readRequest->stateNumber(); return 0; } @@ -240,8 +240,8 @@ void JsonDbQueryObject::setBindings(const QVariantMap &newBindings) QVariantList JsonDbQueryObject::takeResults() { QVariantList list; - if (jsondbQuery) { - list = jsondbQuery->takeResults(); + if (readRequest) { + list = qjsonobject_list_to_qvariantlist(readRequest->takeResults()); } return list; } @@ -329,32 +329,29 @@ int JsonDbQueryObject::start() return -1; } - if (jsondbQuery) { - delete jsondbQuery; + if (readRequest) { + delete readRequest; } - jsondbQuery = partitionObject->jsonDb.query(); - jsondbQuery->setQuery(queryString); - jsondbQuery->setQueryLimit(queryLimit); - jsondbQuery->setQueryOffset(0); - jsondbQuery->setPartition(partitionObject->name()); + QJsonDbReadRequest *request = new QJsonDbReadRequest; + request->setQuery(queryString); + request->setQueryLimit(queryLimit); + request->setPartition(partitionObject->name()); QVariantMap::ConstIterator i = queryBindings.constBegin(); while (i != queryBindings.constEnd()) { - jsondbQuery->bindValue(i.key(), i.value()); + request->bindValue(i.key(), QJsonValue::fromVariant(i.value())); ++i; } - connect(jsondbQuery, SIGNAL(resultsReady(int)), - this, SIGNAL(resultsReady(int))); - connect(jsondbQuery, SIGNAL(finished()), - this, SLOT(setReadyStatus())); - connect(jsondbQuery, SIGNAL(finished()), - this, SIGNAL(finished())); - connect(jsondbQuery, SIGNAL(error(QtAddOn::JsonDb::JsonDbError::ErrorCode,QString)), - this, SLOT(setError(QtAddOn::JsonDb::JsonDbError::ErrorCode,QString))); - - jsondbQuery->start(); + connect(request, SIGNAL(resultsAvailable(int)), this, SIGNAL(resultsReady(int))); + connect(request, SIGNAL(finished()), this, SLOT(setReadyStatus())); + connect(request, SIGNAL(finished()), this, SIGNAL(finished())); + connect(request, SIGNAL(error(QtJsonDb::QJsonDbRequest::ErrorCode,QString)), + this, SLOT(setError(QtJsonDb::QJsonDbRequest::ErrorCode,QString))); + objectStatus = JsonDbQueryObject::Loading; emit statusChanged(objectStatus); - return jsondbQuery->requestId(); + JsonDatabase::sharedConnection().send(request); + readRequest = request; + return request->property("requestId").toInt(); } @@ -405,16 +402,17 @@ void JsonDbQueryObject::setReadyStatus() emit statusChanged(objectStatus); } -void JsonDbQueryObject::setError(QtAddOn::JsonDb::JsonDbError::ErrorCode code, const QString& message) +void JsonDbQueryObject::setError(QtJsonDb::QJsonDbRequest::ErrorCode code, const QString & message) { int oldErrorCode = errorCode; errorCode = code; errorString = message; - if (objectStatus != JsonDbQueryObject::Error) { + bool changed = (objectStatus != JsonDbQueryObject::Error); + if (changed) { objectStatus = JsonDbQueryObject::Error; emit statusChanged(objectStatus); } - if (oldErrorCode != errorCode) { + if (oldErrorCode != errorCode || changed) { emit errorChanged(error()); } } |