From 45a5bf6910db54f358409e7c407b8081cdd711a4 Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Tue, 16 Feb 2016 17:45:20 +0100 Subject: Added an index for mail sorting by date on folder queries --- common/domain/mail.cpp | 1 + tests/testimplementations.h | 45 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+) diff --git a/common/domain/mail.cpp b/common/domain/mail.cpp index 69c351c..29c72c2 100644 --- a/common/domain/mail.cpp +++ b/common/domain/mail.cpp @@ -51,6 +51,7 @@ static TypeIndex &getIndex() index->addProperty("subject"); index->addProperty("date"); index->addProperty("folder"); + index->addPropertyWithSorting("folder", "date"); } return *index; } diff --git a/tests/testimplementations.h b/tests/testimplementations.h index 785c408..234e99d 100644 --- a/tests/testimplementations.h +++ b/tests/testimplementations.h @@ -26,9 +26,12 @@ #include #include #include +#include //Replace with something different #include "event_generated.h" +#include "mail_generated.h" +#include "createentity_generated.h" class TestEventAdaptorFactory : public DomainTypeAdaptorFactory { @@ -41,6 +44,17 @@ public: virtual ~TestEventAdaptorFactory() {}; }; +class TestMailAdaptorFactory : public DomainTypeAdaptorFactory +{ +public: + TestMailAdaptorFactory() + : DomainTypeAdaptorFactory() + { + } + + virtual ~TestMailAdaptorFactory() {}; +}; + class TestResourceAccess : public Sink::ResourceAccessInterface { Q_OBJECT @@ -69,6 +83,20 @@ public: } }; +class TestMailResourceFacade : public Sink::GenericFacade +{ +public: + TestMailResourceFacade(const QByteArray &instanceIdentifier, const QSharedPointer resourceAccess) + : Sink::GenericFacade(instanceIdentifier, QSharedPointer::create(), resourceAccess) + { + + } + virtual ~TestMailResourceFacade() + { + + } +}; + class TestResource : public Sink::GenericResource { public: @@ -82,3 +110,20 @@ public: return KAsync::null(); } }; + +template +QByteArray createCommand(const DomainType &domainObject, DomainTypeAdaptorFactoryInterface &domainTypeAdaptorFactory) +{ + flatbuffers::FlatBufferBuilder entityFbb; + domainTypeAdaptorFactory.createBuffer(domainObject, entityFbb); + flatbuffers::FlatBufferBuilder fbb; + auto type = fbb.CreateString(Sink::ApplicationDomain::getTypeName().toStdString().data()); + auto delta = fbb.CreateVector(entityFbb.GetBufferPointer(), entityFbb.GetSize()); + Sink::Commands::CreateEntityBuilder builder(fbb); + builder.add_domainType(type); + builder.add_delta(delta); + auto location = builder.Finish(); + Sink::Commands::FinishCreateEntityBuffer(fbb, location); + return QByteArray(reinterpret_cast(fbb.GetBufferPointer()), fbb.GetSize()); +} + -- cgit v1.2.3