summaryrefslogtreecommitdiffstats
path: root/common/domain/typeimplementations.cpp
diff options
context:
space:
mode:
authorMinijackson <minijackson@riseup.net>2018-08-21 14:01:03 +0200
committerMinijackson <minijackson@riseup.net>2018-08-21 14:01:03 +0200
commitd96628e0e9d9d017cf838ac37ce66e1a461ee2ae (patch)
tree8a88f2dfb884e26f90f6ccc1aa8a5af3b1e933eb /common/domain/typeimplementations.cpp
parentdd13089146d32bdc4e0306d63922537112d40304 (diff)
downloadsink-d96628e0e9d9d017cf838ac37ce66e1a461ee2ae.tar.gz
sink-d96628e0e9d9d017cf838ac37ce66e1a461ee2ae.zip
Factor typeDatabases implementations for different entity types
Diffstat (limited to 'common/domain/typeimplementations.cpp')
-rw-r--r--common/domain/typeimplementations.cpp20
1 files changed, 12 insertions, 8 deletions
diff --git a/common/domain/typeimplementations.cpp b/common/domain/typeimplementations.cpp
index d6b5b76..c74701d 100644
--- a/common/domain/typeimplementations.cpp
+++ b/common/domain/typeimplementations.cpp
@@ -77,7 +77,11 @@ typedef IndexConfig<Calendar,
77 ValueIndex<Calendar::Name> 77 ValueIndex<Calendar::Name>
78 > CalendarIndexConfig; 78 > CalendarIndexConfig;
79 79
80 80template <typename EntityType, typename EntityIndexConfig>
81QMap<QByteArray, int> defaultTypeDatabases()
82{
83 return merge(QMap<QByteArray, int>{{QByteArray{EntityType::name} + ".main", Storage::IntegerKeys}}, EntityIndexConfig::databases());
84}
81 85
82void TypeImplementation<Mail>::configure(TypeIndex &index) 86void TypeImplementation<Mail>::configure(TypeIndex &index)
83{ 87{
@@ -86,7 +90,7 @@ void TypeImplementation<Mail>::configure(TypeIndex &index)
86 90
87QMap<QByteArray, int> TypeImplementation<Mail>::typeDatabases() 91QMap<QByteArray, int> TypeImplementation<Mail>::typeDatabases()
88{ 92{
89 return merge(QMap<QByteArray, int>{{QByteArray{Mail::name} + ".main", Storage::IntegerKeys}}, MailIndexConfig::databases()); 93 return defaultTypeDatabases<Mail, MailIndexConfig>();
90} 94}
91 95
92void TypeImplementation<Mail>::configure(IndexPropertyMapper &indexPropertyMapper) 96void TypeImplementation<Mail>::configure(IndexPropertyMapper &indexPropertyMapper)
@@ -129,7 +133,7 @@ void TypeImplementation<Folder>::configure(TypeIndex &index)
129 133
130QMap<QByteArray, int> TypeImplementation<Folder>::typeDatabases() 134QMap<QByteArray, int> TypeImplementation<Folder>::typeDatabases()
131{ 135{
132 return merge(QMap<QByteArray, int>{{QByteArray{Folder::name} + ".main", Storage::IntegerKeys}}, FolderIndexConfig::databases()); 136 return defaultTypeDatabases<Folder, FolderIndexConfig>();
133} 137}
134 138
135void TypeImplementation<Folder>::configure(PropertyMapper &propertyMapper) 139void TypeImplementation<Folder>::configure(PropertyMapper &propertyMapper)
@@ -154,7 +158,7 @@ void TypeImplementation<Contact>::configure(TypeIndex &index)
154 158
155QMap<QByteArray, int> TypeImplementation<Contact>::typeDatabases() 159QMap<QByteArray, int> TypeImplementation<Contact>::typeDatabases()
156{ 160{
157 return merge(QMap<QByteArray, int>{{QByteArray{Contact::name} + ".main", Storage::IntegerKeys}}, ContactIndexConfig::databases()); 161 return defaultTypeDatabases<Contact, ContactIndexConfig>();
158} 162}
159 163
160void TypeImplementation<Contact>::configure(PropertyMapper &propertyMapper) 164void TypeImplementation<Contact>::configure(PropertyMapper &propertyMapper)
@@ -182,7 +186,7 @@ void TypeImplementation<Addressbook>::configure(TypeIndex &index)
182 186
183QMap<QByteArray, int> TypeImplementation<Addressbook>::typeDatabases() 187QMap<QByteArray, int> TypeImplementation<Addressbook>::typeDatabases()
184{ 188{
185 return merge(QMap<QByteArray, int>{{QByteArray{Addressbook::name} + ".main", Storage::IntegerKeys}}, AddressbookIndexConfig::databases()); 189 return defaultTypeDatabases<Addressbook, AddressbookIndexConfig>();
186} 190}
187 191
188void TypeImplementation<Addressbook>::configure(PropertyMapper &propertyMapper) 192void TypeImplementation<Addressbook>::configure(PropertyMapper &propertyMapper)
@@ -204,7 +208,7 @@ void TypeImplementation<Event>::configure(TypeIndex &index)
204 208
205QMap<QByteArray, int> TypeImplementation<Event>::typeDatabases() 209QMap<QByteArray, int> TypeImplementation<Event>::typeDatabases()
206{ 210{
207 return merge(QMap<QByteArray, int>{{QByteArray{Event::name} + ".main", Storage::IntegerKeys}}, EventIndexConfig::databases()); 211 return defaultTypeDatabases<Event, EventIndexConfig>();
208} 212}
209 213
210void TypeImplementation<Event>::configure(PropertyMapper &propertyMapper) 214void TypeImplementation<Event>::configure(PropertyMapper &propertyMapper)
@@ -232,7 +236,7 @@ void TypeImplementation<Todo>::configure(TypeIndex &index)
232 236
233QMap<QByteArray, int> TypeImplementation<Todo>::typeDatabases() 237QMap<QByteArray, int> TypeImplementation<Todo>::typeDatabases()
234{ 238{
235 return merge(QMap<QByteArray, int>{{QByteArray{Todo::name} + ".main", Storage::IntegerKeys}}, TodoIndexConfig::databases()); 239 return defaultTypeDatabases<Todo, TodoIndexConfig>();
236} 240}
237 241
238void TypeImplementation<Todo>::configure(PropertyMapper &propertyMapper) 242void TypeImplementation<Todo>::configure(PropertyMapper &propertyMapper)
@@ -263,7 +267,7 @@ void TypeImplementation<Calendar>::configure(TypeIndex &index)
263 267
264QMap<QByteArray, int> TypeImplementation<Calendar>::typeDatabases() 268QMap<QByteArray, int> TypeImplementation<Calendar>::typeDatabases()
265{ 269{
266 return merge(QMap<QByteArray, int>{{QByteArray{Calendar::name} + ".main", Storage::IntegerKeys}}, CalendarIndexConfig::databases()); 270 return defaultTypeDatabases<Calendar, CalendarIndexConfig>();
267} 271}
268 272
269void TypeImplementation<Calendar>::configure(PropertyMapper &propertyMapper) 273void TypeImplementation<Calendar>::configure(PropertyMapper &propertyMapper)