summaryrefslogtreecommitdiffstats
path: root/common/domain/applicationdomaintype.h
diff options
context:
space:
mode:
Diffstat (limited to 'common/domain/applicationdomaintype.h')
-rw-r--r--common/domain/applicationdomaintype.h94
1 files changed, 76 insertions, 18 deletions
diff --git a/common/domain/applicationdomaintype.h b/common/domain/applicationdomaintype.h
index eadad00..4eec4a3 100644
--- a/common/domain/applicationdomaintype.h
+++ b/common/domain/applicationdomaintype.h
@@ -23,12 +23,56 @@
23#include <QSharedPointer> 23#include <QSharedPointer>
24#include <QVariant> 24#include <QVariant>
25#include <QByteArray> 25#include <QByteArray>
26#include <QDateTime>
26#include <QDebug> 27#include <QDebug>
27#include <QUuid> 28#include <QUuid>
28#include "bufferadaptor.h" 29#include "bufferadaptor.h"
29 30
30namespace Sink { 31#define SINK_ENTITY(TYPE) \
32 typedef QSharedPointer<TYPE> Ptr; \
33 using Entity::Entity; \
34 virtual ~TYPE(); \
35
36
37#define SINK_PROPERTY(TYPE, NAME, LOWERCASENAME) \
38 struct NAME { \
39 static constexpr const char *name = #LOWERCASENAME; \
40 typedef TYPE Type; \
41 }; \
42 void set##NAME(const TYPE &value) { setProperty(NAME::name, QVariant::fromValue(value)); } \
43 TYPE get##NAME() const { return getProperty(NAME::name).value<TYPE>(); } \
44
45
46#define SINK_EXTRACTED_PROPERTY(TYPE, NAME, LOWERCASENAME) \
47 struct NAME { \
48 static constexpr const char *name = #LOWERCASENAME; \
49 typedef TYPE Type; \
50 }; \
51 void setExtracted##NAME(const TYPE &value) { setProperty(NAME::name, QVariant::fromValue(value)); } \
52 TYPE get##NAME() const { return getProperty(NAME::name).value<TYPE>(); } \
53
54
55#define SINK_BLOB_PROPERTY(NAME, LOWERCASENAME) \
56 struct NAME { \
57 static constexpr const char *name = #LOWERCASENAME; \
58 typedef QString Type; \
59 }; \
60 void set##NAME(const QByteArray &value) { setBlobProperty(NAME::name, value); } \
61 void set##NAME##Path(const QString &path) { setProperty(NAME::name, QVariant::fromValue(path)); } \
62 QByteArray get##NAME() const { return getBlobProperty(NAME::name); } \
63 QString get##NAME##Path() const { return getProperty(NAME::name).value<QString>(); } \
64
65#define SINK_REFERENCE_PROPERTY(TYPE, NAME, LOWERCASENAME) \
66 struct NAME { \
67 static constexpr const char *name = #LOWERCASENAME; \
68 typedef QByteArray Type; \
69 }; \
70 void set##NAME(const ApplicationDomain::TYPE &value) { setProperty(NAME::name, value); } \
71 void set##NAME(const QByteArray &value) { setProperty(NAME::name, QVariant::fromValue(value)); } \
72 QByteArray get##NAME() const { return getProperty(NAME::name).value<QByteArray>(); } \
73
31 74
75namespace Sink {
32namespace ApplicationDomain { 76namespace ApplicationDomain {
33 77
34/** 78/**
@@ -128,33 +172,41 @@ struct SINK_EXPORT Entity : public ApplicationDomainType {
128}; 172};
129 173
130struct SINK_EXPORT Event : public Entity { 174struct SINK_EXPORT Event : public Entity {
131 typedef QSharedPointer<Event> Ptr; 175 SINK_ENTITY(Event);
132 using Entity::Entity; 176 SINK_PROPERTY(QString, Uid, uid);
133 virtual ~Event(); 177 SINK_PROPERTY(QString, Summary, summary);
178 SINK_PROPERTY(QString, Description, description);
179 SINK_PROPERTY(QByteArray, Attachment, attachment);
134}; 180};
135 181
136struct SINK_EXPORT Todo : public Entity { 182struct SINK_EXPORT Todo : public Entity {
137 typedef QSharedPointer<Todo> Ptr; 183 SINK_ENTITY(Todo);
138 using Entity::Entity;
139 virtual ~Todo();
140}; 184};
141 185
142struct SINK_EXPORT Calendar : public Entity { 186struct SINK_EXPORT Calendar : public Entity {
143 typedef QSharedPointer<Calendar> Ptr; 187 SINK_ENTITY(Calendar);
144 using Entity::Entity;
145 virtual ~Calendar();
146}; 188};
147 189
148struct SINK_EXPORT Mail : public Entity { 190struct SINK_EXPORT Folder : public Entity {
149 typedef QSharedPointer<Mail> Ptr; 191 SINK_ENTITY(Folder);
150 using Entity::Entity; 192 SINK_REFERENCE_PROPERTY(Folder, Parent, parent);
151 virtual ~Mail(); 193 SINK_PROPERTY(QString, Name, name);
194 SINK_PROPERTY(QByteArray, Icon, icon);
195 SINK_PROPERTY(QByteArrayList, SpecialPurpose, specialpurpose);
152}; 196};
153 197
154struct SINK_EXPORT Folder : public Entity { 198struct SINK_EXPORT Mail : public Entity {
155 typedef QSharedPointer<Folder> Ptr; 199 SINK_ENTITY(Mail);
156 using Entity::Entity; 200 SINK_PROPERTY(QString, Uid, uid);
157 virtual ~Folder(); 201 SINK_EXTRACTED_PROPERTY(QString, Sender, sender);
202 SINK_EXTRACTED_PROPERTY(QString, SenderName, senderName);
203 SINK_EXTRACTED_PROPERTY(QString, Subject, subject);
204 SINK_EXTRACTED_PROPERTY(QDateTime, Date, date);
205 SINK_PROPERTY(bool, Unread, unread);
206 SINK_PROPERTY(bool, Important, important);
207 SINK_REFERENCE_PROPERTY(Folder, Folder, folder);
208 SINK_BLOB_PROPERTY(MimeMessage, mimeMessage);
209 SINK_PROPERTY(bool, Draft, draft);
158}; 210};
159 211
160/** 212/**
@@ -235,6 +287,12 @@ class SINK_EXPORT TypeImplementation;
235} 287}
236} 288}
237 289
290#undef SINK_ENTITY
291#undef SINK_PROPERTY
292#undef SINK_EXTRACTED_PROPERTY
293#undef SINK_BLOB_PROPERTY
294#undef SINK_REFERENCE_PROPERTY
295
238Q_DECLARE_METATYPE(Sink::ApplicationDomain::ApplicationDomainType) 296Q_DECLARE_METATYPE(Sink::ApplicationDomain::ApplicationDomainType)
239Q_DECLARE_METATYPE(Sink::ApplicationDomain::ApplicationDomainType::Ptr) 297Q_DECLARE_METATYPE(Sink::ApplicationDomain::ApplicationDomainType::Ptr)
240Q_DECLARE_METATYPE(Sink::ApplicationDomain::Entity) 298Q_DECLARE_METATYPE(Sink::ApplicationDomain::Entity)