summaryrefslogtreecommitdiffstats
path: root/src/client/qjsondbwatcher.cpp
diff options
context:
space:
mode:
authorDenis Dzyubenko <[email protected]>2012-04-11 15:59:00 +0200
committerDenis Dzyubenko <[email protected]>2012-04-11 16:54:46 +0200
commit6b7df60a752422b1f6ff07bb2682c21e18a43985 (patch)
tree3e56bd3f4ee34a228777d00ff328ef1c53cb1df1 /src/client/qjsondbwatcher.cpp
parent20549eedb5b5e852c0e384cd76bfbff14168dbda (diff)
parent7ef36e3c5a88560eb4e3a81c2c9f14059739108b (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/client/qjsondbwatcher.cpp')
-rw-r--r--src/client/qjsondbwatcher.cpp23
1 files changed, 14 insertions, 9 deletions
diff --git a/src/client/qjsondbwatcher.cpp b/src/client/qjsondbwatcher.cpp
index e99f7bd..2d39abd 100644
--- a/src/client/qjsondbwatcher.cpp
+++ b/src/client/qjsondbwatcher.cpp
@@ -44,7 +44,6 @@
#include "qjsondbconnection_p.h"
#include <QUuid>
-#include <QDebug>
QT_BEGIN_NAMESPACE_JSONDB
@@ -84,8 +83,6 @@ QJsonDbNotification::QJsonDbNotification(const QJsonObject &object, QJsonDbWatch
longer matches the watcher query string, and the object contains
the property \c{_deleted} with value \c{true}.
- \li If the action() is QJsonDbWatcher::StateChanged, the object is empty.
-
\endlist
\sa QJsonDbObject
@@ -115,7 +112,7 @@ quint32 QJsonDbNotification::stateNumber() const
QJsonDbWatcherPrivate::QJsonDbWatcherPrivate(QJsonDbWatcher *q)
: q_ptr(q), status(QJsonDbWatcher::Inactive),
- actions(QJsonDbWatcher::All), initialStateNumber(0), lastStateNumber(0)
+ actions(QJsonDbWatcher::All), initialStateNumber(QJsonDbWatcherPrivate::UnspecifiedInitialStateNumber), lastStateNumber(0)
{
uuid = QUuid::createUuid().toString();
}
@@ -176,7 +173,6 @@ QJsonDbWatcherPrivate::QJsonDbWatcherPrivate(QJsonDbWatcher *q)
\value Created Watches for objects to start matching the given query string.
\value Updated Watches for modifications of objects matching the given query.
\value Removed Watches for objects that stop matching the given query string.
- \value StateChanged Watches for database state changes.
\value All A convenience value that specifies to watch for all possible actions.
*/
/*!
@@ -339,6 +335,8 @@ quint32 QJsonDbWatcher::initialStateNumber() const
This property contains valid data only after watcher was successfully
activated (i.e. the watcher state was changed to QJsonDbWatcher::Active).
+ The lastStateNumber will be changed after receiving all notifications for that state number.
+
\sa lastStateNumberChanged(), status
*/
quint32 QJsonDbWatcher::lastStateNumber() const
@@ -400,7 +398,7 @@ void QJsonDbWatcherPrivate::_q_onError(QtJsonDb::QJsonDbRequest::ErrorCode code,
{
Q_Q(QJsonDbWatcher);
Q_UNUSED(code);
- QJsonDbWatcher::ErrorCode error = QJsonDbWatcher::InvalidQuery; // ### TODO:
+ QJsonDbWatcher::ErrorCode error = static_cast<QJsonDbWatcher::ErrorCode>(code);
emit q->error(error, message);
}
@@ -410,13 +408,20 @@ void QJsonDbWatcherPrivate::handleNotification(quint32 stateNumber, QJsonDbWatch
if (!actions.testFlag(action))
return;
Q_ASSERT(!object.isEmpty());
+ if (initialStateNumber == static_cast<quint32>(QJsonDbWatcherPrivate::UnspecifiedInitialStateNumber))
+ initialStateNumber = stateNumber;
+ QJsonDbNotification n(object, action, stateNumber);
+ notifications.append(n);
+ emit q->notificationsAvailable(notifications.size());
+}
+
+void QJsonDbWatcherPrivate::handleStateChange(quint32 stateNumber)
+{
+ Q_Q(QJsonDbWatcher);
if (stateNumber != lastStateNumber) {
lastStateNumber = stateNumber;
emit q->lastStateNumberChanged(stateNumber);
}
- QJsonDbNotification n(object, action, stateNumber);
- notifications.append(n);
- emit q->notificationsAvailable(notifications.size());
}
/*!