From 3410ca3f15c07d6f19f1165b50ef4f1a42599164 Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Mon, 16 Jul 2018 13:29:59 +0200 Subject: Deal with modifications to filtered entities --- common/datastorequery.cpp | 6 ++++-- tests/querytest.cpp | 8 ++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/common/datastorequery.cpp b/common/datastorequery.cpp index 4c25710..aca4bb1 100644 --- a/common/datastorequery.cpp +++ b/common/datastorequery.cpp @@ -359,9 +359,12 @@ public: //Redo the reduction to find new aggregated values auto selectionResult = reduceOnValue(reductionValue); + //If mSelectedValues did not contain the value, oldSelectionResult will be empty.(Happens if entites have been filtered) auto oldSelectionResult = mSelectedValues.take(reductionValueBa); SinkTraceCtx(mDatastore->mLogCtx) << "Old selection result: " << oldSelectionResult << " New selection result: " << selectionResult.selection; - if (oldSelectionResult == selectionResult.selection) { + if (selectionResult.selection.isEmpty() && oldSelectionResult.isEmpty()) { + //Nothing to do, the item was filtered before, and still is. + } else if (oldSelectionResult == selectionResult.selection) { mSelectedValues.insert(reductionValueBa, selectionResult.selection); Q_ASSERT(!selectionResult.selection.isEmpty()); readEntity(selectionResult.selection, [&](const Sink::ApplicationDomain::ApplicationDomainType &entity, Sink::Operation) { @@ -369,7 +372,6 @@ public: }); } else { //remove old result - //If mSelectedValues did not containthe value, oldSelectionResult will be empty.(Happens if entites have been filtered) if (!oldSelectionResult.isEmpty()) { readEntity(oldSelectionResult, [&](const Sink::ApplicationDomain::ApplicationDomainType &entity, Sink::Operation) { callback({entity, Sink::Operation_Removal}); diff --git a/tests/querytest.cpp b/tests/querytest.cpp index 5abe6d0..98bf5a0 100644 --- a/tests/querytest.cpp +++ b/tests/querytest.cpp @@ -1039,6 +1039,10 @@ private slots: mail.setExtractedMessageId("aggregatedId"); mail.setFolder(folder2); VERIFYEXEC(Sink::Store::create(mail)); + + //Ensure that we can deal with a modification to the filtered message + mail.setUnread(true); + VERIFYEXEC(Sink::Store::modify(mail)); } VERIFYEXEC(Sink::ResourceControl::flushMessageQueue("sink.dummy.instance1")); @@ -1050,6 +1054,10 @@ private slots: mail.setExtractedMessageId("aggregatedId"); mail.setFolder(folder1); VERIFYEXEC(Sink::Store::create(mail)); + + //Ensure that we can deal with a modification to the filtered message + mail.setUnread(true); + VERIFYEXEC(Sink::Store::modify(mail)); } VERIFYEXEC(Sink::ResourceControl::flushMessageQueue("sink.dummy.instance1")); QTRY_COMPARE(model->rowCount(), 1); -- cgit v1.2.3