summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--common/mail/threadindexer.cpp5
-rw-r--r--common/typeindex.cpp12
-rw-r--r--common/typeindex.h9
3 files changed, 25 insertions, 1 deletions
diff --git a/common/mail/threadindexer.cpp b/common/mail/threadindexer.cpp
index ea2cf71..4171d85 100644
--- a/common/mail/threadindexer.cpp
+++ b/common/mail/threadindexer.cpp
@@ -71,7 +71,10 @@ void ThreadIndexer::modify(const ApplicationDomain::ApplicationDomainType &old,
71 71
72void ThreadIndexer::remove(const ApplicationDomain::ApplicationDomainType &entity) 72void ThreadIndexer::remove(const ApplicationDomain::ApplicationDomainType &entity)
73{ 73{
74 74 auto messageId = entity.getProperty(Mail::MessageId::name);
75 auto thread = index().secondaryLookup<Mail::MessageId, Mail::ThreadId>(messageId);
76 index().unindex<Mail::MessageId, Mail::ThreadId>(messageId.toByteArray(), thread.first(), transaction());
77 index().unindex<Mail::ThreadId, Mail::MessageId>(thread.first(), messageId.toByteArray(), transaction());
75} 78}
76 79
77QMap<QByteArray, int> ThreadIndexer::databases() 80QMap<QByteArray, int> ThreadIndexer::databases()
diff --git a/common/typeindex.cpp b/common/typeindex.cpp
index 113c209..5a19839 100644
--- a/common/typeindex.cpp
+++ b/common/typeindex.cpp
@@ -282,6 +282,18 @@ void TypeIndex::index<QString, QByteArray>(const QByteArray &leftName, const QBy
282} 282}
283 283
284template <> 284template <>
285void TypeIndex::unindex<QByteArray, QByteArray>(const QByteArray &leftName, const QByteArray &rightName, const QVariant &leftValue, const QVariant &rightValue, Sink::Storage::DataStore::Transaction &transaction)
286{
287 Index(indexName(leftName + rightName), transaction).remove(getByteArray(leftValue), getByteArray(rightValue));
288}
289
290template <>
291void TypeIndex::unindex<QString, QByteArray>(const QByteArray &leftName, const QByteArray &rightName, const QVariant &leftValue, const QVariant &rightValue, Sink::Storage::DataStore::Transaction &transaction)
292{
293 Index(indexName(leftName + rightName), transaction).remove(getByteArray(leftValue), getByteArray(rightValue));
294}
295
296template <>
285QVector<QByteArray> TypeIndex::secondaryLookup<QByteArray>(const QByteArray &leftName, const QByteArray &rightName, const QVariant &value) 297QVector<QByteArray> TypeIndex::secondaryLookup<QByteArray>(const QByteArray &leftName, const QByteArray &rightName, const QVariant &value)
286{ 298{
287 QVector<QByteArray> keys; 299 QVector<QByteArray> keys;
diff --git a/common/typeindex.h b/common/typeindex.h
index 1f216a7..890c3db 100644
--- a/common/typeindex.h
+++ b/common/typeindex.h
@@ -95,6 +95,15 @@ public:
95 template <typename LeftType, typename RightType> 95 template <typename LeftType, typename RightType>
96 void index(const QByteArray &leftName, const QByteArray &rightName, const QVariant &leftValue, const QVariant &rightValue, Sink::Storage::DataStore::Transaction &transaction); 96 void index(const QByteArray &leftName, const QByteArray &rightName, const QVariant &leftValue, const QVariant &rightValue, Sink::Storage::DataStore::Transaction &transaction);
97 97
98 template <typename Left, typename Right>
99 void unindex(const QVariant &leftValue, const QVariant &rightValue, Sink::Storage::DataStore::Transaction &transaction)
100 {
101 index<typename Left::Type, typename Right::Type>(Left::name, Right::name, leftValue, rightValue, transaction);
102 }
103
104 template <typename LeftType, typename RightType>
105 void unindex(const QByteArray &leftName, const QByteArray &rightName, const QVariant &leftValue, const QVariant &rightValue, Sink::Storage::DataStore::Transaction &transaction);
106
98 107
99private: 108private:
100 friend class Sink::Storage::EntityStore; 109 friend class Sink::Storage::EntityStore;