From 6adf9a4734f15a2c0fa199897f76ded4659b83b7 Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Thu, 4 May 2017 11:40:24 +0200 Subject: Added progress notification --- common/synchronizer.cpp | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'common/synchronizer.cpp') diff --git a/common/synchronizer.cpp b/common/synchronizer.cpp index 3e7bd30..58e5e7a 100644 --- a/common/synchronizer.cpp +++ b/common/synchronizer.cpp @@ -304,9 +304,21 @@ void Synchronizer::emitNotification(Notification::NoticationType type, int code, emit notify(n); } +void Synchronizer::emitProgressNotification(Notification::NoticationType type, int progress, int total, const QByteArray &id, const QByteArrayList &entities) +{ + Sink::Notification n; + n.id = id; + n.type = type; + n.progress = progress; + n.total = total; + n.entities = entities; + emit notify(n); +} + void Synchronizer::reportProgress(int progress, int total) { SinkLogCtx(mLogCtx) << "Progress: " << progress << " out of " << total; + emitProgressNotification(Notification::Progress, progress, total, mCurrentRequest.requestId, mCurrentRequest.applicableEntities); } void Synchronizer::setStatusFromResult(const KAsync::Error &error, const QString &s, const QByteArray &requestId) @@ -465,13 +477,15 @@ KAsync::Job Synchronizer::processSyncQueue() if (request.requestType == Synchronizer::SyncRequest::Synchronization) { setBusy(true, "Synchronization has started.", request.requestId); } else if (request.requestType == Synchronizer::SyncRequest::ChangeReplay) { - setBusy(true, "ChangeReplay has started.", "changereplay"); + setBusy(true, "ChangeReplay has started.", request.requestId); } + mCurrentRequest = request; }) .then(processRequest(request)) .then([this, request](const KAsync::Error &error) { SinkTraceCtx(mLogCtx) << "Sync request processed"; setBusy(false, {}, request.requestId); + mCurrentRequest = {}; mEntityStore->abortTransaction(); mSyncTransaction.abort(); mMessageQueue->commit(); @@ -516,7 +530,7 @@ void Synchronizer::revisionChanged() return; } } - mSyncRequestQueue << Synchronizer::SyncRequest{Synchronizer::SyncRequest::ChangeReplay}; + mSyncRequestQueue << Synchronizer::SyncRequest{Synchronizer::SyncRequest::ChangeReplay, "changereplay"}; processSyncQueue().exec(); } -- cgit v1.2.3