From e1430017eb60976610f4963cd770116a4a486c2e Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Thu, 23 Mar 2017 14:02:15 +0100 Subject: New properties --- common/domain/applicationdomaintype.cpp | 5 +++++ common/domain/applicationdomaintype.h | 18 +++++++++++++++++- common/domain/contact.fbs | 9 ++++++++- common/domain/propertyregistry.cpp | 18 ++++++++++++++++++ common/domain/propertyregistry.h | 3 +++ 5 files changed, 51 insertions(+), 2 deletions(-) (limited to 'common/domain') diff --git a/common/domain/applicationdomaintype.cpp b/common/domain/applicationdomaintype.cpp index 413fb7c..c9cef3f 100644 --- a/common/domain/applicationdomaintype.cpp +++ b/common/domain/applicationdomaintype.cpp @@ -95,15 +95,20 @@ SINK_REGISTER_PROPERTY(Folder, Icon); SINK_REGISTER_PROPERTY(Folder, SpecialPurpose); SINK_REGISTER_PROPERTY(Folder, Enabled); SINK_REGISTER_PROPERTY(Folder, Parent); +SINK_REGISTER_PROPERTY(Folder, Count); +SINK_REGISTER_PROPERTY(Folder, FullContentAvailable); SINK_REGISTER_PROPERTY(Contact, Uid); SINK_REGISTER_PROPERTY(Contact, Fn); +SINK_REGISTER_PROPERTY(Contact, Firstname); +SINK_REGISTER_PROPERTY(Contact, Lastname); SINK_REGISTER_PROPERTY(Contact, Emails); SINK_REGISTER_PROPERTY(Contact, Vcard); SINK_REGISTER_PROPERTY(Contact, Addressbook); SINK_REGISTER_PROPERTY(Addressbook, Name); SINK_REGISTER_PROPERTY(Addressbook, Parent); +SINK_REGISTER_PROPERTY(Addressbook, LastUpdated); static const int foo = [] { QMetaType::registerEqualsComparator(); diff --git a/common/domain/applicationdomaintype.h b/common/domain/applicationdomaintype.h index ae8e6bc..74b747d 100644 --- a/common/domain/applicationdomaintype.h +++ b/common/domain/applicationdomaintype.h @@ -328,13 +328,25 @@ struct SINK_EXPORT Addressbook : public Entity { SINK_ENTITY(Addressbook); SINK_REFERENCE_PROPERTY(Addressbook, Parent, parent); SINK_PROPERTY(QString, Name, name); + SINK_EXTRACTED_PROPERTY(QDateTime, LastUpdated, lastUpdated); }; struct SINK_EXPORT Contact : public Entity { + struct SINK_EXPORT Email { + enum Type { + Undefined, + Work, + Home + }; + Type type; + QString email; + }; SINK_ENTITY(Contact); SINK_PROPERTY(QString, Uid, uid); SINK_PROPERTY(QString, Fn, fn); - SINK_PROPERTY(QByteArrayList, Emails, emails); + SINK_PROPERTY(QString, Firstname, firstname); + SINK_PROPERTY(QString, Lastname, lastname); + SINK_PROPERTY(QList, Emails, emails); SINK_PROPERTY(QByteArray, Vcard, vcard); SINK_REFERENCE_PROPERTY(Addressbook, Addressbook, addressbook); }; @@ -362,6 +374,9 @@ struct SINK_EXPORT Folder : public Entity { SINK_PROPERTY(QByteArray, Icon, icon); SINK_PROPERTY(QByteArrayList, SpecialPurpose, specialpurpose); SINK_PROPERTY(bool, Enabled, enabled); + SINK_EXTRACTED_PROPERTY(QDateTime, LastUpdated, lastUpdated); + SINK_EXTRACTED_PROPERTY(int, Count, count); + SINK_EXTRACTED_PROPERTY(bool, FullContentAvailable, fullContentAvailable); }; struct SINK_EXPORT Mail : public Entity { @@ -552,6 +567,7 @@ Q_DECLARE_METATYPE(Sink::ApplicationDomain::ApplicationDomainType::Ptr) Q_DECLARE_METATYPE(Sink::ApplicationDomain::Entity) Q_DECLARE_METATYPE(Sink::ApplicationDomain::Entity::Ptr) Q_DECLARE_METATYPE(Sink::ApplicationDomain::Mail::Contact) +Q_DECLARE_METATYPE(Sink::ApplicationDomain::Contact::Email) Q_DECLARE_METATYPE(Sink::ApplicationDomain::Error) Q_DECLARE_METATYPE(Sink::ApplicationDomain::Progress) Q_DECLARE_METATYPE(Sink::ApplicationDomain::BLOB) diff --git a/common/domain/contact.fbs b/common/domain/contact.fbs index 7d7f797..d941d5a 100644 --- a/common/domain/contact.fbs +++ b/common/domain/contact.fbs @@ -1,10 +1,17 @@ namespace Sink.ApplicationDomain.Buffer; +table ContactEmail { + type: int; + email: string; +} + table Contact { uid:string; fn:string; + firstname:string; + lastname:string; addressbook:string; - emails: [string]; + emails: [ContactEmail]; vcard: string; } diff --git a/common/domain/propertyregistry.cpp b/common/domain/propertyregistry.cpp index 2208193..7b9b61a 100644 --- a/common/domain/propertyregistry.cpp +++ b/common/domain/propertyregistry.cpp @@ -63,6 +63,17 @@ QVariant parseString(const QString &s) return QVariant::fromValue(false); } +template <> +QVariant parseString(const QString &s) +{ + bool ok = false; + auto n = s.toInt(&ok); + if (ok) { + return QVariant::fromValue(n); + } + return {}; +} + template <> QVariant parseString>(const QString &s) { @@ -92,6 +103,13 @@ QVariant parseString>(const QStrin return QVariant{}; } +template <> +QVariant parseString>(const QString &s) +{ + Q_ASSERT(false); + return QVariant{}; +} + PropertyRegistry &PropertyRegistry::instance() { static PropertyRegistry instance; diff --git a/common/domain/propertyregistry.h b/common/domain/propertyregistry.h index 16df23b..758c10d 100644 --- a/common/domain/propertyregistry.h +++ b/common/domain/propertyregistry.h @@ -48,6 +48,9 @@ QVariant parseString(const QString &s); template <> QVariant parseString(const QString &s); +template <> +QVariant parseString(const QString &s); + template <> QVariant parseString>(const QString &s); -- cgit v1.2.3