diff options
author | Minijackson <minijackson@riseup.net> | 2018-08-21 14:01:03 +0200 |
---|---|---|
committer | Minijackson <minijackson@riseup.net> | 2018-08-21 14:04:57 +0200 |
commit | 258fb05e00e1fc03a227630d8e4def6d691158de (patch) | |
tree | 4cd77c4b7f7dae2af7800ef48b62483a8b0df55e /common/domain/typeimplementations.cpp | |
parent | 191730c624aae5fa7831fe900b98624b2ac1f1d7 (diff) | |
download | sink-258fb05e00e1fc03a227630d8e4def6d691158de.tar.gz sink-258fb05e00e1fc03a227630d8e4def6d691158de.zip |
Factor typeDatabases implementations for different entity types
Diffstat (limited to 'common/domain/typeimplementations.cpp')
-rw-r--r-- | common/domain/typeimplementations.cpp | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/common/domain/typeimplementations.cpp b/common/domain/typeimplementations.cpp index f969072..6e14501 100644 --- a/common/domain/typeimplementations.cpp +++ b/common/domain/typeimplementations.cpp | |||
@@ -80,7 +80,11 @@ typedef IndexConfig<Calendar, | |||
80 | ValueIndex<Calendar::Name> | 80 | ValueIndex<Calendar::Name> |
81 | > CalendarIndexConfig; | 81 | > CalendarIndexConfig; |
82 | 82 | ||
83 | 83 | template <typename EntityType, typename EntityIndexConfig> | |
84 | QMap<QByteArray, int> defaultTypeDatabases() | ||
85 | { | ||
86 | return merge(QMap<QByteArray, int>{{QByteArray{EntityType::name} + ".main", Storage::IntegerKeys}}, EntityIndexConfig::databases()); | ||
87 | } | ||
84 | 88 | ||
85 | void TypeImplementation<Mail>::configure(TypeIndex &index) | 89 | void TypeImplementation<Mail>::configure(TypeIndex &index) |
86 | { | 90 | { |
@@ -89,7 +93,7 @@ void TypeImplementation<Mail>::configure(TypeIndex &index) | |||
89 | 93 | ||
90 | QMap<QByteArray, int> TypeImplementation<Mail>::typeDatabases() | 94 | QMap<QByteArray, int> TypeImplementation<Mail>::typeDatabases() |
91 | { | 95 | { |
92 | return merge(QMap<QByteArray, int>{{QByteArray{Mail::name} + ".main", Storage::IntegerKeys}}, MailIndexConfig::databases()); | 96 | return defaultTypeDatabases<Mail, MailIndexConfig>(); |
93 | } | 97 | } |
94 | 98 | ||
95 | void TypeImplementation<Mail>::configure(IndexPropertyMapper &indexPropertyMapper) | 99 | void TypeImplementation<Mail>::configure(IndexPropertyMapper &indexPropertyMapper) |
@@ -132,7 +136,7 @@ void TypeImplementation<Folder>::configure(TypeIndex &index) | |||
132 | 136 | ||
133 | QMap<QByteArray, int> TypeImplementation<Folder>::typeDatabases() | 137 | QMap<QByteArray, int> TypeImplementation<Folder>::typeDatabases() |
134 | { | 138 | { |
135 | return merge(QMap<QByteArray, int>{{QByteArray{Folder::name} + ".main", Storage::IntegerKeys}}, FolderIndexConfig::databases()); | 139 | return defaultTypeDatabases<Folder, FolderIndexConfig>(); |
136 | } | 140 | } |
137 | 141 | ||
138 | void TypeImplementation<Folder>::configure(PropertyMapper &propertyMapper) | 142 | void TypeImplementation<Folder>::configure(PropertyMapper &propertyMapper) |
@@ -157,7 +161,7 @@ void TypeImplementation<Contact>::configure(TypeIndex &index) | |||
157 | 161 | ||
158 | QMap<QByteArray, int> TypeImplementation<Contact>::typeDatabases() | 162 | QMap<QByteArray, int> TypeImplementation<Contact>::typeDatabases() |
159 | { | 163 | { |
160 | return merge(QMap<QByteArray, int>{{QByteArray{Contact::name} + ".main", Storage::IntegerKeys}}, ContactIndexConfig::databases()); | 164 | return defaultTypeDatabases<Contact, ContactIndexConfig>(); |
161 | } | 165 | } |
162 | 166 | ||
163 | void TypeImplementation<Contact>::configure(PropertyMapper &propertyMapper) | 167 | void TypeImplementation<Contact>::configure(PropertyMapper &propertyMapper) |
@@ -185,7 +189,7 @@ void TypeImplementation<Addressbook>::configure(TypeIndex &index) | |||
185 | 189 | ||
186 | QMap<QByteArray, int> TypeImplementation<Addressbook>::typeDatabases() | 190 | QMap<QByteArray, int> TypeImplementation<Addressbook>::typeDatabases() |
187 | { | 191 | { |
188 | return merge(QMap<QByteArray, int>{{QByteArray{Addressbook::name} + ".main", Storage::IntegerKeys}}, AddressbookIndexConfig::databases()); | 192 | return defaultTypeDatabases<Addressbook, AddressbookIndexConfig>(); |
189 | } | 193 | } |
190 | 194 | ||
191 | void TypeImplementation<Addressbook>::configure(PropertyMapper &propertyMapper) | 195 | void TypeImplementation<Addressbook>::configure(PropertyMapper &propertyMapper) |
@@ -207,7 +211,7 @@ void TypeImplementation<Event>::configure(TypeIndex &index) | |||
207 | 211 | ||
208 | QMap<QByteArray, int> TypeImplementation<Event>::typeDatabases() | 212 | QMap<QByteArray, int> TypeImplementation<Event>::typeDatabases() |
209 | { | 213 | { |
210 | return merge(QMap<QByteArray, int>{{QByteArray{Event::name} + ".main", Storage::IntegerKeys}}, EventIndexConfig::databases()); | 214 | return defaultTypeDatabases<Event, EventIndexConfig>(); |
211 | } | 215 | } |
212 | 216 | ||
213 | void TypeImplementation<Event>::configure(PropertyMapper &propertyMapper) | 217 | void TypeImplementation<Event>::configure(PropertyMapper &propertyMapper) |
@@ -235,7 +239,7 @@ void TypeImplementation<Todo>::configure(TypeIndex &index) | |||
235 | 239 | ||
236 | QMap<QByteArray, int> TypeImplementation<Todo>::typeDatabases() | 240 | QMap<QByteArray, int> TypeImplementation<Todo>::typeDatabases() |
237 | { | 241 | { |
238 | return merge(QMap<QByteArray, int>{{QByteArray{Todo::name} + ".main", Storage::IntegerKeys}}, TodoIndexConfig::databases()); | 242 | return defaultTypeDatabases<Todo, TodoIndexConfig>(); |
239 | } | 243 | } |
240 | 244 | ||
241 | void TypeImplementation<Todo>::configure(PropertyMapper &propertyMapper) | 245 | void TypeImplementation<Todo>::configure(PropertyMapper &propertyMapper) |
@@ -266,7 +270,7 @@ void TypeImplementation<Calendar>::configure(TypeIndex &index) | |||
266 | 270 | ||
267 | QMap<QByteArray, int> TypeImplementation<Calendar>::typeDatabases() | 271 | QMap<QByteArray, int> TypeImplementation<Calendar>::typeDatabases() |
268 | { | 272 | { |
269 | return merge(QMap<QByteArray, int>{{QByteArray{Calendar::name} + ".main", Storage::IntegerKeys}}, CalendarIndexConfig::databases()); | 273 | return defaultTypeDatabases<Calendar, CalendarIndexConfig>(); |
270 | } | 274 | } |
271 | 275 | ||
272 | void TypeImplementation<Calendar>::configure(PropertyMapper &propertyMapper) | 276 | void TypeImplementation<Calendar>::configure(PropertyMapper &propertyMapper) |