From 90a8d33f7c17c802730fd9b978db0e32d28a7dff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Nicole?= Date: Sun, 6 May 2018 17:42:37 +0200 Subject: Implement Todo entity type Summary: Some notes: - Needed to specialize some flatbuffers related functions for serializing QStringList and int - Removed useless qWarnings in caldav test - Rename EventSynchronizer -> CalDAVSynchronizer since it also synchronizes Calendars and Todos (and more to come!) Reviewers: cmollekopf Tags: #sink Differential Revision: https://phabricator.kde.org/D12695 --- common/domain/applicationdomaintype.cpp | 13 ++++++++++++ common/domain/applicationdomaintype.h | 17 ++++++++++++++++ common/domain/applicationdomaintype_p.h | 2 ++ common/domain/propertyregistry.cpp | 6 ++++++ common/domain/todo.fbs | 18 +++++++++++++++++ common/domain/typeimplementations.cpp | 35 +++++++++++++++++++++++++++++++++ common/domain/typeimplementations.h | 12 +++++++++++ 7 files changed, 103 insertions(+) create mode 100644 common/domain/todo.fbs (limited to 'common/domain') diff --git a/common/domain/applicationdomaintype.cpp b/common/domain/applicationdomaintype.cpp index 78d46ee..b1469e1 100644 --- a/common/domain/applicationdomaintype.cpp +++ b/common/domain/applicationdomaintype.cpp @@ -132,6 +132,19 @@ SINK_REGISTER_PROPERTY(Event, EndTime); SINK_REGISTER_PROPERTY(Event, Ical); SINK_REGISTER_PROPERTY(Event, Calendar); +SINK_REGISTER_ENTITY(Todo); +SINK_REGISTER_PROPERTY(Todo, Uid); +SINK_REGISTER_PROPERTY(Todo, Summary); +SINK_REGISTER_PROPERTY(Todo, Description); +SINK_REGISTER_PROPERTY(Todo, CompletedDate); +SINK_REGISTER_PROPERTY(Todo, DueDate); +SINK_REGISTER_PROPERTY(Todo, StartDate); +SINK_REGISTER_PROPERTY(Todo, Status); +SINK_REGISTER_PROPERTY(Todo, Priority); +SINK_REGISTER_PROPERTY(Todo, Categories); +SINK_REGISTER_PROPERTY(Todo, Ical); +SINK_REGISTER_PROPERTY(Todo, Calendar); + SINK_REGISTER_ENTITY(Calendar); SINK_REGISTER_PROPERTY(Calendar, Name); diff --git a/common/domain/applicationdomaintype.h b/common/domain/applicationdomaintype.h index 39e66ab..93de8f5 100644 --- a/common/domain/applicationdomaintype.h +++ b/common/domain/applicationdomaintype.h @@ -407,6 +407,17 @@ struct SINK_EXPORT Event : public Entity { struct SINK_EXPORT Todo : public Entity { SINK_ENTITY(Todo, todo); + SINK_EXTRACTED_PROPERTY(QString, Uid, uid); + SINK_EXTRACTED_PROPERTY(QString, Summary, summary); + SINK_EXTRACTED_PROPERTY(QString, Description, description); + SINK_EXTRACTED_PROPERTY(QDateTime, CompletedDate, completedDate); + SINK_EXTRACTED_PROPERTY(QDateTime, DueDate, dueDate); + SINK_EXTRACTED_PROPERTY(QDateTime, StartDate, startDate); + SINK_EXTRACTED_PROPERTY(QString, Status, status); + SINK_EXTRACTED_PROPERTY(int, Priority, priority); + SINK_EXTRACTED_PROPERTY(QStringList, Categories, categories); + SINK_PROPERTY(QByteArray, Ical, ical); + SINK_REFERENCE_PROPERTY(Calendar, Calendar, calendar); }; struct SINK_EXPORT Folder : public Entity { @@ -506,6 +517,11 @@ namespace Event { static constexpr const char *calendar = "calendar"; static constexpr const char *storage = "event.storage"; }; +namespace Todo { + static constexpr const char *todo = "todo"; + static constexpr const char *calendar = "calendar"; + static constexpr const char *storage = "todo.storage"; +}; }; namespace SpecialPurpose { @@ -558,6 +574,7 @@ class SINK_EXPORT TypeImplementation; REGISTER_TYPE(Sink::ApplicationDomain::Contact) \ REGISTER_TYPE(Sink::ApplicationDomain::Addressbook) \ REGISTER_TYPE(Sink::ApplicationDomain::Event) \ + REGISTER_TYPE(Sink::ApplicationDomain::Todo) \ REGISTER_TYPE(Sink::ApplicationDomain::Calendar) \ REGISTER_TYPE(Sink::ApplicationDomain::Mail) \ REGISTER_TYPE(Sink::ApplicationDomain::Folder) \ diff --git a/common/domain/applicationdomaintype_p.h b/common/domain/applicationdomaintype_p.h index 734ac3e..248f6f0 100644 --- a/common/domain/applicationdomaintype_p.h +++ b/common/domain/applicationdomaintype_p.h @@ -38,6 +38,8 @@ struct TypeHelper { return Func{}(std::forward(args...)); } else if (type == Sink::ApplicationDomain::getTypeName()) { return Func{}(std::forward(args...)); + } else if (type == Sink::ApplicationDomain::getTypeName()) { + return Func{}(std::forward(args...)); } else if (type == Sink::ApplicationDomain::getTypeName()) { return Func{}(std::forward(args...)); } else if (type == Sink::ApplicationDomain::getTypeName()) { diff --git a/common/domain/propertyregistry.cpp b/common/domain/propertyregistry.cpp index d929d68..00bbb1d 100644 --- a/common/domain/propertyregistry.cpp +++ b/common/domain/propertyregistry.cpp @@ -74,6 +74,12 @@ QVariant parseString>(const QString &s) return QVariant::fromValue(result); } +template <> +QVariant parseString(const QString &s) +{ + return s.split(','); +} + template <> QVariant parseString(const QString &s) { diff --git a/common/domain/todo.fbs b/common/domain/todo.fbs new file mode 100644 index 0000000..b448cae --- /dev/null +++ b/common/domain/todo.fbs @@ -0,0 +1,18 @@ +namespace Sink.ApplicationDomain.Buffer; + +table Todo { + uid:string; + summary:string; + description:string; + completedDate:string; + dueDate:string; + startDate:string; + status:string; + priority:int; + categories:[string]; + ical:string; + calendar:string; +} + +root_type Todo; +file_identifier "AKFB"; diff --git a/common/domain/typeimplementations.cpp b/common/domain/typeimplementations.cpp index 615c8e8..b584138 100644 --- a/common/domain/typeimplementations.cpp +++ b/common/domain/typeimplementations.cpp @@ -67,6 +67,10 @@ typedef IndexConfig > EventIndexConfig; +typedef IndexConfig + > TodoIndexConfig; + typedef IndexConfig > CalendarIndexConfig; @@ -218,6 +222,37 @@ void TypeImplementation::configure(IndexPropertyMapper &) } +void TypeImplementation::configure(TypeIndex &index) +{ + TodoIndexConfig::configure(index); +} + +QMap TypeImplementation::typeDatabases() +{ + return merge(QMap{{QByteArray{Todo::name} + ".main", 0}}, TodoIndexConfig::databases()); +} + +void TypeImplementation::configure(PropertyMapper &propertyMapper) +{ + SINK_REGISTER_SERIALIZER(propertyMapper, Todo, Uid, uid); + SINK_REGISTER_SERIALIZER(propertyMapper, Todo, Summary, summary); + SINK_REGISTER_SERIALIZER(propertyMapper, Todo, Description, description); + SINK_REGISTER_SERIALIZER(propertyMapper, Todo, CompletedDate, completedDate); + SINK_REGISTER_SERIALIZER(propertyMapper, Todo, DueDate, dueDate); + SINK_REGISTER_SERIALIZER(propertyMapper, Todo, StartDate, startDate); + SINK_REGISTER_SERIALIZER(propertyMapper, Todo, Status, status); + SINK_REGISTER_SERIALIZER(propertyMapper, Todo, Priority, priority); + SINK_REGISTER_SERIALIZER(propertyMapper, Todo, Categories, categories); + SINK_REGISTER_SERIALIZER(propertyMapper, Todo, Ical, ical); + SINK_REGISTER_SERIALIZER(propertyMapper, Todo, Calendar, calendar); +} + +void TypeImplementation::configure(IndexPropertyMapper &) +{ + +} + + void TypeImplementation::configure(TypeIndex &index) { CalendarIndexConfig::configure(index); diff --git a/common/domain/typeimplementations.h b/common/domain/typeimplementations.h index 672e83a..5c6ba14 100644 --- a/common/domain/typeimplementations.h +++ b/common/domain/typeimplementations.h @@ -24,6 +24,7 @@ #include "mail_generated.h" #include "folder_generated.h" #include "event_generated.h" +#include "todo_generated.h" #include "calendar_generated.h" #include "contact_generated.h" #include "addressbook_generated.h" @@ -96,6 +97,17 @@ public: static QMap typeDatabases(); }; +template<> +class SINK_EXPORT TypeImplementation { +public: + typedef Sink::ApplicationDomain::Buffer::Todo Buffer; + typedef Sink::ApplicationDomain::Buffer::TodoBuilder BufferBuilder; + static void configure(TypeIndex &); + static void configure(PropertyMapper &); + static void configure(IndexPropertyMapper &indexPropertyMapper); + static QMap typeDatabases(); +}; + template<> class SINK_EXPORT TypeImplementation { public: -- cgit v1.2.3