From 516d38bd7bca5562ebb7b21b96a5dd62152ee52e Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Thu, 9 Feb 2017 14:06:17 +0100 Subject: Cleaner index syntax, don't index messageid twice --- common/domain/mail.cpp | 14 ++++++-------- common/typeindex.cpp | 13 +++++++++++++ common/typeindex.h | 6 ++++++ 3 files changed, 25 insertions(+), 8 deletions(-) (limited to 'common') diff --git a/common/domain/mail.cpp b/common/domain/mail.cpp index f9a20d7..9f120cc 100644 --- a/common/domain/mail.cpp +++ b/common/domain/mail.cpp @@ -36,17 +36,15 @@ using namespace Sink::ApplicationDomain; void TypeImplementation::configure(TypeIndex &index) { - index.addProperty(Mail::Uid::name); - index.addProperty(Mail::Sender::name); + index.addProperty(); + // index.addProperty(); /* index.addProperty(Mail::SenderName::name); */ /* index->addProperty(Mail::Subject::name); */ /* index->addFulltextProperty(Mail::Subject::name); */ - index.addProperty(Mail::Date::name); - index.addProperty(Mail::Folder::name); - index.addPropertyWithSorting(Mail::Folder::name, Mail::Date::name); - index.addProperty(Mail::MessageId::name); - index.addProperty(Mail::ParentMessageId::name); - + index.addProperty(); + index.addProperty(); + index.addPropertyWithSorting(); + index.addProperty(); index.addProperty(); index.addSecondaryPropertyIndexer(); diff --git a/common/typeindex.cpp b/common/typeindex.cpp index 077bfa1..a65c676 100644 --- a/common/typeindex.cpp +++ b/common/typeindex.cpp @@ -102,6 +102,12 @@ void TypeIndex::addProperty(const QByteArray &property) mProperties << property; } +template <> +void TypeIndex::addProperty(const QByteArray &property) +{ + addProperty(property); +} + template <> void TypeIndex::addPropertyWithSorting(const QByteArray &property, const QByteArray &sortProperty) { @@ -114,8 +120,15 @@ void TypeIndex::addPropertyWithSorting(const QByteArray & mSortedProperties.insert(property, sortProperty); } +template <> +void TypeIndex::addPropertyWithSorting(const QByteArray &property, const QByteArray &sortProperty) +{ + addPropertyWithSorting(property, sortProperty); +} + void TypeIndex::add(const QByteArray &identifier, const Sink::ApplicationDomain::ApplicationDomainType &entity, Sink::Storage::DataStore::Transaction &transaction) { + SinkTrace() << "add " << identifier; for (const auto &property : mProperties) { const auto value = entity.getProperty(property); auto indexer = mIndexer.value(property); diff --git a/common/typeindex.h b/common/typeindex.h index 626959e..7ff2029 100644 --- a/common/typeindex.h +++ b/common/typeindex.h @@ -41,6 +41,12 @@ public: template void addPropertyWithSorting(const QByteArray &property, const QByteArray &sortProperty); + template + void addPropertyWithSorting() + { + addPropertyWithSorting(T::name, S::name); + } + template void addProperty() { -- cgit v1.2.3