diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2018-07-16 13:29:59 +0200 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2018-07-16 13:29:59 +0200 |
commit | 3410ca3f15c07d6f19f1165b50ef4f1a42599164 (patch) | |
tree | bf5b1575696682b8c85e9ae522c6e4339e3e93a1 | |
parent | 4b0b2abf9c9b2d57f79388064ccc95888c1cb039 (diff) | |
download | sink-3410ca3f15c07d6f19f1165b50ef4f1a42599164.tar.gz sink-3410ca3f15c07d6f19f1165b50ef4f1a42599164.zip |
Deal with modifications to filtered entities
-rw-r--r-- | common/datastorequery.cpp | 6 | ||||
-rw-r--r-- | 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: | |||
359 | //Redo the reduction to find new aggregated values | 359 | //Redo the reduction to find new aggregated values |
360 | auto selectionResult = reduceOnValue(reductionValue); | 360 | auto selectionResult = reduceOnValue(reductionValue); |
361 | 361 | ||
362 | //If mSelectedValues did not contain the value, oldSelectionResult will be empty.(Happens if entites have been filtered) | ||
362 | auto oldSelectionResult = mSelectedValues.take(reductionValueBa); | 363 | auto oldSelectionResult = mSelectedValues.take(reductionValueBa); |
363 | SinkTraceCtx(mDatastore->mLogCtx) << "Old selection result: " << oldSelectionResult << " New selection result: " << selectionResult.selection; | 364 | SinkTraceCtx(mDatastore->mLogCtx) << "Old selection result: " << oldSelectionResult << " New selection result: " << selectionResult.selection; |
364 | if (oldSelectionResult == selectionResult.selection) { | 365 | if (selectionResult.selection.isEmpty() && oldSelectionResult.isEmpty()) { |
366 | //Nothing to do, the item was filtered before, and still is. | ||
367 | } else if (oldSelectionResult == selectionResult.selection) { | ||
365 | mSelectedValues.insert(reductionValueBa, selectionResult.selection); | 368 | mSelectedValues.insert(reductionValueBa, selectionResult.selection); |
366 | Q_ASSERT(!selectionResult.selection.isEmpty()); | 369 | Q_ASSERT(!selectionResult.selection.isEmpty()); |
367 | readEntity(selectionResult.selection, [&](const Sink::ApplicationDomain::ApplicationDomainType &entity, Sink::Operation) { | 370 | readEntity(selectionResult.selection, [&](const Sink::ApplicationDomain::ApplicationDomainType &entity, Sink::Operation) { |
@@ -369,7 +372,6 @@ public: | |||
369 | }); | 372 | }); |
370 | } else { | 373 | } else { |
371 | //remove old result | 374 | //remove old result |
372 | //If mSelectedValues did not containthe value, oldSelectionResult will be empty.(Happens if entites have been filtered) | ||
373 | if (!oldSelectionResult.isEmpty()) { | 375 | if (!oldSelectionResult.isEmpty()) { |
374 | readEntity(oldSelectionResult, [&](const Sink::ApplicationDomain::ApplicationDomainType &entity, Sink::Operation) { | 376 | readEntity(oldSelectionResult, [&](const Sink::ApplicationDomain::ApplicationDomainType &entity, Sink::Operation) { |
375 | callback({entity, Sink::Operation_Removal}); | 377 | 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: | |||
1039 | mail.setExtractedMessageId("aggregatedId"); | 1039 | mail.setExtractedMessageId("aggregatedId"); |
1040 | mail.setFolder(folder2); | 1040 | mail.setFolder(folder2); |
1041 | VERIFYEXEC(Sink::Store::create(mail)); | 1041 | VERIFYEXEC(Sink::Store::create(mail)); |
1042 | |||
1043 | //Ensure that we can deal with a modification to the filtered message | ||
1044 | mail.setUnread(true); | ||
1045 | VERIFYEXEC(Sink::Store::modify(mail)); | ||
1042 | } | 1046 | } |
1043 | 1047 | ||
1044 | VERIFYEXEC(Sink::ResourceControl::flushMessageQueue("sink.dummy.instance1")); | 1048 | VERIFYEXEC(Sink::ResourceControl::flushMessageQueue("sink.dummy.instance1")); |
@@ -1050,6 +1054,10 @@ private slots: | |||
1050 | mail.setExtractedMessageId("aggregatedId"); | 1054 | mail.setExtractedMessageId("aggregatedId"); |
1051 | mail.setFolder(folder1); | 1055 | mail.setFolder(folder1); |
1052 | VERIFYEXEC(Sink::Store::create(mail)); | 1056 | VERIFYEXEC(Sink::Store::create(mail)); |
1057 | |||
1058 | //Ensure that we can deal with a modification to the filtered message | ||
1059 | mail.setUnread(true); | ||
1060 | VERIFYEXEC(Sink::Store::modify(mail)); | ||
1053 | } | 1061 | } |
1054 | VERIFYEXEC(Sink::ResourceControl::flushMessageQueue("sink.dummy.instance1")); | 1062 | VERIFYEXEC(Sink::ResourceControl::flushMessageQueue("sink.dummy.instance1")); |
1055 | QTRY_COMPARE(model->rowCount(), 1); | 1063 | QTRY_COMPARE(model->rowCount(), 1); |