Merge lp:~renatofilho/qtorganizer5-eds/fix-1295180 into lp:qtorganizer5-eds
- fix-1295180
- Merge into trunk
Proposed by
Renato Araujo Oliveira Filho
Status: | Merged | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Approved by: | Bill Filler | ||||||||||||
Approved revision: | 45 | ||||||||||||
Merged at revision: | 47 | ||||||||||||
Proposed branch: | lp:~renatofilho/qtorganizer5-eds/fix-1295180 | ||||||||||||
Merge into: | lp:qtorganizer5-eds | ||||||||||||
Diff against target: |
570 lines (+275/-84) 7 files modified
qorganizer/qorganizer-eds-engine.cpp (+60/-14) qorganizer/qorganizer-eds-engine.h (+2/-0) qorganizer/qorganizer-eds-savecollectionrequestdata.cpp (+121/-56) qorganizer/qorganizer-eds-savecollectionrequestdata.h (+16/-5) qorganizer/qorganizer-eds-source-registry.cpp (+30/-3) qorganizer/qorganizer-eds-source-registry.h (+8/-3) tests/unittest/collections-test.cpp (+38/-3) |
||||||||||||
To merge this branch: | bzr merge lp:~renatofilho/qtorganizer5-eds/fix-1295180 | ||||||||||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Bill Filler (community) | Approve | ||
PS Jenkins bot | continuous-integration | Approve | |
Review via email: mp+212218@code.launchpad.net |
Commit message
Implemented support to save changes on collections.
Export eds collection color into QOrganizerColle
Export eds collection type into QOrganizerColle
Export eds collection selected or not into QOrganizerColle
Description of the change
To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : | # |
review:
Approve
(continuous-integration)
Revision history for this message
Kunal Parmar (pkunal-parmar) wrote : | # |
Works great for Calendar usecase
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'qorganizer/qorganizer-eds-engine.cpp' |
2 | --- qorganizer/qorganizer-eds-engine.cpp 2014-03-06 21:31:03 +0000 |
3 | +++ qorganizer/qorganizer-eds-engine.cpp 2014-03-21 18:07:57 +0000 |
4 | @@ -745,11 +745,16 @@ |
5 | return d->m_sourceRegistry->defaultCollection(); |
6 | } |
7 | |
8 | -QOrganizerCollection QOrganizerEDSEngine::collection(const QOrganizerCollectionId& collectionId, QOrganizerManager::Error* error) |
9 | +QOrganizerCollection QOrganizerEDSEngine::collection(const QOrganizerCollectionId& collectionId, |
10 | + QOrganizerManager::Error* error) |
11 | { |
12 | qDebug() << Q_FUNC_INFO; |
13 | - *error = QOrganizerManager::DoesNotExistError; |
14 | - return QOrganizerCollection(); |
15 | + QOrganizerCollection collection = d->m_sourceRegistry->collection(collectionId.toString()); |
16 | + if (collection.id().isNull() && error) { |
17 | + *error = QOrganizerManager::DoesNotExistError; |
18 | + } |
19 | + |
20 | + return collection; |
21 | } |
22 | |
23 | QList<QOrganizerCollection> QOrganizerEDSEngine::collections(QOrganizerManager::Error* error) |
24 | @@ -803,14 +808,19 @@ |
25 | } |
26 | |
27 | ESourceRegistry *registry = d->m_sourceRegistry->object(); |
28 | - g_object_ref(registry); |
29 | - |
30 | SaveCollectionRequestData *requestData = new SaveCollectionRequestData(this, req); |
31 | - e_source_registry_create_sources(registry, |
32 | - requestData->sources(), |
33 | - requestData->cancellable(), |
34 | - (GAsyncReadyCallback) QOrganizerEDSEngine::saveCollectionAsyncCommited, |
35 | - requestData); |
36 | + requestData->setRegistry(registry); |
37 | + |
38 | + if (requestData->prepareToCreate()) { |
39 | + e_source_registry_create_sources(registry, |
40 | + requestData->sourcesToCreate(), |
41 | + requestData->cancellable(), |
42 | + (GAsyncReadyCallback) QOrganizerEDSEngine::saveCollectionAsyncCommited, |
43 | + requestData); |
44 | + } else { |
45 | + requestData->prepareToUpdate(); |
46 | + saveCollectionUpdateAsyncStart(requestData); |
47 | + } |
48 | } |
49 | |
50 | void QOrganizerEDSEngine::saveCollectionAsyncCommited(ESourceRegistry *registry, |
51 | @@ -826,12 +836,48 @@ |
52 | qWarning() << "Fail to create sources:" << gError->message; |
53 | g_error_free(gError); |
54 | data->finish(QOrganizerManager::InvalidCollectionError); |
55 | + delete data; |
56 | + } else { |
57 | + data->commitSourceCreated(); |
58 | + data->prepareToUpdate(); |
59 | + saveCollectionUpdateAsyncStart(data); |
60 | + } |
61 | +} |
62 | + |
63 | +void QOrganizerEDSEngine::saveCollectionUpdateAsyncStart(SaveCollectionRequestData *data) |
64 | +{ |
65 | + ESource *source = data->nextSourceToUpdate(); |
66 | + if (source) { |
67 | + e_source_registry_commit_source(data->registry(), |
68 | + source, |
69 | + data->cancellable(), |
70 | + (GAsyncReadyCallback) QOrganizerEDSEngine::saveCollectionUpdateAsynCommited, |
71 | + data); |
72 | } else { |
73 | data->finish(); |
74 | - } |
75 | - |
76 | - delete data; |
77 | - g_object_unref(registry); |
78 | + delete data; |
79 | + } |
80 | +} |
81 | + |
82 | +void QOrganizerEDSEngine::saveCollectionUpdateAsynCommited(ESourceRegistry *registry, |
83 | + GAsyncResult *res, |
84 | + SaveCollectionRequestData *data) |
85 | +{ |
86 | + GError *gError = 0; |
87 | + ESource *currentSource = data->nextSourceToUpdate(); |
88 | + |
89 | + e_source_registry_commit_source_finish(registry, res, &gError); |
90 | + QCoreApplication::processEvents(); |
91 | + |
92 | + if (gError) { |
93 | + qWarning() << "Fail to update collection" << gError->message; |
94 | + g_error_free(gError); |
95 | + data->commitSourceUpdated(currentSource, QOrganizerManager::InvalidCollectionError); |
96 | + } else { |
97 | + data->commitSourceUpdated(currentSource); |
98 | + } |
99 | + |
100 | + saveCollectionUpdateAsyncStart(data); |
101 | } |
102 | |
103 | bool QOrganizerEDSEngine::removeCollection(const QOrganizerCollectionId& collectionId, QOrganizerManager::Error* error) |
104 | |
105 | === modified file 'qorganizer/qorganizer-eds-engine.h' |
106 | --- qorganizer/qorganizer-eds-engine.h 2014-02-25 17:12:32 +0000 |
107 | +++ qorganizer/qorganizer-eds-engine.h 2014-03-21 18:07:57 +0000 |
108 | @@ -229,7 +229,9 @@ |
109 | static void removeItemsAsyncStart(RemoveRequestData *data); |
110 | |
111 | void saveCollectionAsync(QtOrganizer::QOrganizerCollectionSaveRequest *req); |
112 | + static void saveCollectionUpdateAsyncStart(SaveCollectionRequestData *data); |
113 | static void saveCollectionAsyncCommited(ESourceRegistry *registry, GAsyncResult *res, SaveCollectionRequestData *data); |
114 | + static void saveCollectionUpdateAsynCommited(ESourceRegistry *registry, GAsyncResult *res, SaveCollectionRequestData *data); |
115 | |
116 | void removeCollectionAsync(QtOrganizer::QOrganizerCollectionRemoveRequest *req); |
117 | static void removeCollectionAsyncStart(GObject *sourceObject, GAsyncResult *res, RemoveCollectionRequestData *data); |
118 | |
119 | === modified file 'qorganizer/qorganizer-eds-savecollectionrequestdata.cpp' |
120 | --- qorganizer/qorganizer-eds-savecollectionrequestdata.cpp 2014-02-25 17:00:58 +0000 |
121 | +++ qorganizer/qorganizer-eds-savecollectionrequestdata.cpp 2014-03-21 18:07:57 +0000 |
122 | @@ -28,75 +28,121 @@ |
123 | |
124 | using namespace QtOrganizer; |
125 | |
126 | -#define COLLECTION_CALLENDAR_TYPE_METADATA "collection-type" |
127 | - |
128 | SaveCollectionRequestData::SaveCollectionRequestData(QOrganizerEDSEngine *engine, |
129 | QtOrganizer::QOrganizerAbstractRequest *req) |
130 | : RequestData(engine, req), |
131 | - m_sources(0) |
132 | + m_currentSources(0), |
133 | + m_registry(0) |
134 | { |
135 | parseCollections(); |
136 | } |
137 | |
138 | SaveCollectionRequestData::~SaveCollectionRequestData() |
139 | { |
140 | - if (m_sources) { |
141 | - g_list_free_full(m_sources, g_object_unref); |
142 | - m_sources = 0; |
143 | + if (m_registry) { |
144 | + g_object_unref(m_registry); |
145 | + m_registry = 0; |
146 | + } |
147 | + |
148 | + if (m_currentSources) { |
149 | + g_list_free_full(m_currentSources, g_object_unref); |
150 | + m_currentSources = 0; |
151 | } |
152 | } |
153 | |
154 | void SaveCollectionRequestData::finish(QtOrganizer::QOrganizerManager::Error error) |
155 | { |
156 | - if (error == QOrganizerManager::NoError) { |
157 | - GList *i = g_list_first(m_sources); |
158 | - |
159 | - for(; i != 0; i = i->next) { |
160 | - ESource *source = E_SOURCE(i->data); |
161 | - QOrganizerCollection collection = parent()->d->m_sourceRegistry->insert(source); |
162 | - m_results.append(collection); |
163 | - } |
164 | - } else { |
165 | - qDebug() << "save collection error" << error; |
166 | - } |
167 | - |
168 | QOrganizerManagerEngine::updateCollectionSaveRequest(request<QOrganizerCollectionSaveRequest>(), |
169 | - m_results, |
170 | + m_results.values(), |
171 | error, |
172 | m_errorMap, |
173 | QOrganizerAbstractRequest::FinishedState); |
174 | |
175 | - QList<QOrganizerCollectionId> added; |
176 | - Q_FOREACH(const QOrganizerCollection &col, m_results) { |
177 | - added.append(col.id()); |
178 | - } |
179 | - |
180 | - QOrganizerCollectionChangeSet cs; |
181 | - cs.insertAddedCollections(added); |
182 | - emitChangeset(&cs); |
183 | -} |
184 | - |
185 | -GList *SaveCollectionRequestData::sources() const |
186 | -{ |
187 | - return m_sources; |
188 | -} |
189 | - |
190 | -QList<QOrganizerCollection> SaveCollectionRequestData::results() const |
191 | -{ |
192 | - return m_results; |
193 | + emitChangeset(&m_changeSet); |
194 | + m_changeSet.clearAll(); |
195 | +} |
196 | + |
197 | +void SaveCollectionRequestData::commitSourceCreated() |
198 | +{ |
199 | + GList *i = g_list_first(m_currentSources); |
200 | + |
201 | + for(; i != 0; i = i->next) { |
202 | + ESource *source = E_SOURCE(i->data); |
203 | + QOrganizerCollection collection = parent()->d->m_sourceRegistry->insert(source); |
204 | + m_results.insert(m_sources.key(source), collection); |
205 | + m_changeSet.insertAddedCollection(collection.id()); |
206 | + } |
207 | +} |
208 | + |
209 | +void SaveCollectionRequestData::commitSourceUpdated(ESource *source, |
210 | + QOrganizerManager::Error error) |
211 | +{ |
212 | + int index = m_sourcesToUpdate.firstKey(); |
213 | + m_sourcesToUpdate.remove(index); |
214 | + |
215 | + if (error == QOrganizerManager::NoError) { |
216 | + QOrganizerEDSCollectionEngineId *id; |
217 | + QOrganizerCollection collection = SourceRegistry::parseSource(source, &id); |
218 | + m_results.insert(index, collection); |
219 | + m_changeSet.insertChangedCollection(collection.id()); |
220 | + } else { |
221 | + m_errorMap.insert(index, error); |
222 | + } |
223 | +} |
224 | + |
225 | +ESource *SaveCollectionRequestData::nextSourceToUpdate() |
226 | +{ |
227 | + if (m_sourcesToUpdate.size() > 0) { |
228 | + return m_sourcesToUpdate.first(); |
229 | + } else { |
230 | + return 0; |
231 | + } |
232 | +} |
233 | + |
234 | +bool SaveCollectionRequestData::prepareToCreate() |
235 | +{ |
236 | + Q_FOREACH(ESource *source, m_sourcesToCreate.values()) { |
237 | + m_currentSources = g_list_append(m_currentSources, source); |
238 | + } |
239 | + return (g_list_length(m_currentSources) > 0); |
240 | +} |
241 | + |
242 | +bool SaveCollectionRequestData::prepareToUpdate() |
243 | +{ |
244 | + return (m_sourcesToUpdate.size() > 0); |
245 | +} |
246 | + |
247 | +void SaveCollectionRequestData::setRegistry(ESourceRegistry *registry) |
248 | +{ |
249 | + if (m_registry) { |
250 | + g_object_unref(m_registry); |
251 | + m_registry = 0; |
252 | + } |
253 | + if (registry) { |
254 | + m_registry = registry; |
255 | + g_object_ref(m_registry); |
256 | + } |
257 | +} |
258 | + |
259 | +ESourceRegistry *SaveCollectionRequestData::registry() const |
260 | +{ |
261 | + return m_registry; |
262 | +} |
263 | + |
264 | +GList *SaveCollectionRequestData::sourcesToCreate() const |
265 | +{ |
266 | + return m_currentSources; |
267 | } |
268 | |
269 | void SaveCollectionRequestData::parseCollections() |
270 | { |
271 | - if (m_sources) { |
272 | - g_list_free_full(m_sources, g_object_unref); |
273 | - m_sources = 0; |
274 | - } |
275 | - |
276 | + m_sources.clear(); |
277 | m_errorMap.clear(); |
278 | + |
279 | int index = 0; |
280 | Q_FOREACH(const QOrganizerCollection &collection, request<QOrganizerCollectionSaveRequest>()->collections()) { |
281 | ESource *source = 0; |
282 | + bool isNew = true; |
283 | if (collection.id().isNull()) { |
284 | GError *gError = 0; |
285 | source = e_source_new(0, 0, &gError); |
286 | @@ -106,16 +152,12 @@ |
287 | g_error_free(gError); |
288 | Q_ASSERT(false); |
289 | } |
290 | + e_source_set_parent(source, "local-stub"); |
291 | } else { |
292 | - qDebug() << "Collection update not implemented"; |
293 | - Q_ASSERT(false); |
294 | + source = m_parent->d->m_sourceRegistry->source(collection.id().toString()); |
295 | + isNew = false; |
296 | } |
297 | |
298 | - e_source_set_parent(source, "local-stub"); |
299 | - QString name = collection.metaData(QOrganizerCollection::KeyName).toString(); |
300 | - e_source_set_display_name(source, name.toUtf8().data()); |
301 | - |
302 | - |
303 | QVariant callendarType = collection.extendedMetaData(COLLECTION_CALLENDAR_TYPE_METADATA); |
304 | ESourceBackend *extCalendar = 0; |
305 | |
306 | @@ -127,15 +169,38 @@ |
307 | extCalendar = E_SOURCE_BACKEND(e_source_get_extension(source, E_SOURCE_EXTENSION_CALENDAR)); |
308 | } |
309 | |
310 | - if (extCalendar) { |
311 | - e_source_backend_set_backend_name(extCalendar, "local"); |
312 | - } else { |
313 | - qWarning() << "Fail to get source callendar"; |
314 | + |
315 | + if (source) { |
316 | + if (isNew) { |
317 | + if (extCalendar) { |
318 | + e_source_backend_set_backend_name(extCalendar, "local"); |
319 | + } else { |
320 | + qWarning() << "Fail to get source callendar"; |
321 | + } |
322 | + } |
323 | + |
324 | + // update name |
325 | + QString name = collection.metaData(QOrganizerCollection::KeyName).toString(); |
326 | + e_source_set_display_name(source, name.toUtf8().data()); |
327 | + |
328 | + // update color |
329 | + QString color = collection.metaData(QOrganizerCollection::KeyColor).toString(); |
330 | + e_source_selectable_set_color(E_SOURCE_SELECTABLE(extCalendar), color.toUtf8().data()); |
331 | + |
332 | + // update selected |
333 | + bool selected = collection.extendedMetaData(COLLECTION_SELECTED_METADATA).toBool(); |
334 | + e_source_selectable_set_selected(E_SOURCE_SELECTABLE(extCalendar), selected); |
335 | + |
336 | + m_sources.insert(index, source); |
337 | + if (isNew) { |
338 | + m_sourcesToCreate.insert(index, source); |
339 | + } else { |
340 | + m_sourcesToUpdate.insert(index, source); |
341 | + } |
342 | + index++; |
343 | } |
344 | - m_sources = g_list_append(m_sources, source); |
345 | - index++; |
346 | } |
347 | |
348 | - qDebug() << "Request with" << g_list_length(m_sources) << "sources"; |
349 | + qDebug() << "Request with" << m_sources.size() << "sources"; |
350 | } |
351 | |
352 | |
353 | === modified file 'qorganizer/qorganizer-eds-savecollectionrequestdata.h' |
354 | --- qorganizer/qorganizer-eds-savecollectionrequestdata.h 2013-12-01 15:01:34 +0000 |
355 | +++ qorganizer/qorganizer-eds-savecollectionrequestdata.h 2014-03-21 18:07:57 +0000 |
356 | @@ -30,15 +30,26 @@ |
357 | |
358 | void finish(QtOrganizer::QOrganizerManager::Error error = QtOrganizer::QOrganizerManager::NoError); |
359 | bool isNew(int index) const; |
360 | + bool prepareToCreate(); |
361 | + bool prepareToUpdate(); |
362 | + void setRegistry(ESourceRegistry *registry); |
363 | + ESourceRegistry *registry() const; |
364 | |
365 | - GList *sources() const; |
366 | - QList<QtOrganizer::QOrganizerCollection> results() const; |
367 | - void commit(QtOrganizer::QOrganizerManager::Error error = QtOrganizer::QOrganizerManager::NoError); |
368 | + GList *sourcesToCreate() const; |
369 | + void commitSourceCreated(); |
370 | + void commitSourceUpdated(ESource *source, QtOrganizer::QOrganizerManager::Error error = QtOrganizer::QOrganizerManager::NoError); |
371 | + ESource *nextSourceToUpdate(); |
372 | |
373 | private: |
374 | + GList *m_currentSources; |
375 | + ESourceRegistry *m_registry; |
376 | + |
377 | QMap<int, QtOrganizer::QOrganizerManager::Error> m_errorMap; |
378 | - QList<QtOrganizer::QOrganizerCollection> m_results; |
379 | - GList *m_sources; |
380 | + QMap<int, QtOrganizer::QOrganizerCollection> m_results; |
381 | + QMap<int, ESource*> m_sources; |
382 | + QMap<int, ESource*> m_sourcesToCreate; |
383 | + QMap<int, ESource*> m_sourcesToUpdate; |
384 | + QtOrganizer::QOrganizerCollectionChangeSet m_changeSet; |
385 | |
386 | void parseCollections(); |
387 | |
388 | |
389 | === modified file 'qorganizer/qorganizer-eds-source-registry.cpp' |
390 | --- qorganizer/qorganizer-eds-source-registry.cpp 2014-02-25 17:00:58 +0000 |
391 | +++ qorganizer/qorganizer-eds-source-registry.cpp 2014-03-21 18:07:57 +0000 |
392 | @@ -103,6 +103,11 @@ |
393 | return m_defaultCollection; |
394 | } |
395 | |
396 | +QOrganizerCollection SourceRegistry::collection(const QString &collectionId) const |
397 | +{ |
398 | + return m_collections.value(collectionId); |
399 | +} |
400 | + |
401 | QList<QOrganizerCollection> SourceRegistry::collections() const |
402 | { |
403 | return m_collections.values(); |
404 | @@ -276,7 +281,6 @@ |
405 | ESource *source, |
406 | SourceRegistry *self) |
407 | { |
408 | -#if 0 |
409 | qDebug() << Q_FUNC_INFO << (void*) self; |
410 | Q_UNUSED(registry); |
411 | QString collectionId = self->findCollection(source); |
412 | @@ -287,7 +291,6 @@ |
413 | } else { |
414 | qWarning() << "Source changed not found"; |
415 | } |
416 | -#endif |
417 | } |
418 | |
419 | void SourceRegistry::onSourceRemoved(ESourceRegistry *registry, |
420 | @@ -302,8 +305,32 @@ |
421 | void SourceRegistry::updateCollection(QOrganizerCollection *collection, |
422 | ESource *source) |
423 | { |
424 | - qDebug() << Q_FUNC_INFO << (void*) this; |
425 | //TODO get metadata (color, etc..) |
426 | collection->setMetaData(QOrganizerCollection::KeyName, |
427 | QString::fromUtf8(e_source_get_display_name(source))); |
428 | + |
429 | + // name |
430 | + collection->setMetaData(QOrganizerCollection::KeyName, |
431 | + QString::fromUtf8(e_source_get_display_name(source))); |
432 | + |
433 | + // extension |
434 | + ESourceBackend *extCalendar; |
435 | + if (e_source_has_extension(source, E_SOURCE_EXTENSION_TASK_LIST)) { |
436 | + extCalendar = E_SOURCE_BACKEND(e_source_get_extension(source, E_SOURCE_EXTENSION_TASK_LIST)); |
437 | + collection->setExtendedMetaData(COLLECTION_CALLENDAR_TYPE_METADATA, E_SOURCE_EXTENSION_TASK_LIST); |
438 | + } else if (e_source_has_extension(source, E_SOURCE_EXTENSION_MEMO_LIST)) { |
439 | + extCalendar = E_SOURCE_BACKEND(e_source_get_extension(source, E_SOURCE_EXTENSION_MEMO_LIST)); |
440 | + collection->setExtendedMetaData(COLLECTION_CALLENDAR_TYPE_METADATA, E_SOURCE_EXTENSION_MEMO_LIST); |
441 | + } else { |
442 | + extCalendar = E_SOURCE_BACKEND(e_source_get_extension(source, E_SOURCE_EXTENSION_CALENDAR)); |
443 | + collection->setExtendedMetaData(COLLECTION_CALLENDAR_TYPE_METADATA, E_SOURCE_EXTENSION_CALENDAR); |
444 | + } |
445 | + |
446 | + // color |
447 | + const gchar *color = e_source_selectable_get_color(E_SOURCE_SELECTABLE(extCalendar)); |
448 | + collection->setMetaData(QOrganizerCollection::KeyColor, QString::fromUtf8(color)); |
449 | + |
450 | + // selected |
451 | + bool selected = (e_source_selectable_get_selected(E_SOURCE_SELECTABLE(extCalendar)) == TRUE); |
452 | + collection->setExtendedMetaData(COLLECTION_SELECTED_METADATA, selected); |
453 | } |
454 | |
455 | === modified file 'qorganizer/qorganizer-eds-source-registry.h' |
456 | --- qorganizer/qorganizer-eds-source-registry.h 2013-12-03 18:45:04 +0000 |
457 | +++ qorganizer/qorganizer-eds-source-registry.h 2014-03-21 18:07:57 +0000 |
458 | @@ -28,6 +28,9 @@ |
459 | |
460 | #include "qorganizer-eds-collection-engineid.h" |
461 | |
462 | +#define COLLECTION_CALLENDAR_TYPE_METADATA "collection-type" |
463 | +#define COLLECTION_SELECTED_METADATA "collection-selected" |
464 | + |
465 | class SourceRegistry : public QObject |
466 | { |
467 | Q_OBJECT |
468 | @@ -38,6 +41,7 @@ |
469 | ESourceRegistry *object() const; |
470 | void load(); |
471 | QtOrganizer::QOrganizerCollection defaultCollection() const; |
472 | + QtOrganizer::QOrganizerCollection collection(const QString &collectionId) const; |
473 | QList<QtOrganizer::QOrganizerCollection> collections() const; |
474 | QStringList collectionsIds() const; |
475 | QList<QOrganizerEDSCollectionEngineId*> collectionsEngineIds() const; |
476 | @@ -50,6 +54,9 @@ |
477 | EClient *client(const QString &collectionId); |
478 | void clear(); |
479 | |
480 | + static QtOrganizer::QOrganizerCollection parseSource(ESource *source, |
481 | + QOrganizerEDSCollectionEngineId **edsId); |
482 | + |
483 | Q_SIGNALS: |
484 | void sourceAdded(const QString &collectionId); |
485 | void sourceRemoved(const QString &collectionId); |
486 | @@ -72,9 +79,7 @@ |
487 | |
488 | QString findCollection(ESource *source) const; |
489 | QtOrganizer::QOrganizerCollection registerSource(ESource *source); |
490 | - void updateCollection(QtOrganizer::QOrganizerCollection *collection, ESource *source); |
491 | - QtOrganizer::QOrganizerCollection parseSource(ESource *source, |
492 | - QOrganizerEDSCollectionEngineId **edsId); |
493 | + static void updateCollection(QtOrganizer::QOrganizerCollection *collection, ESource *source); |
494 | |
495 | |
496 | // glib callback |
497 | |
498 | === modified file 'tests/unittest/collections-test.cpp' |
499 | --- tests/unittest/collections-test.cpp 2014-02-20 19:22:19 +0000 |
500 | +++ tests/unittest/collections-test.cpp 2014-03-21 18:07:57 +0000 |
501 | @@ -62,6 +62,7 @@ |
502 | QOrganizerCollection collection; |
503 | QtOrganizer::QOrganizerManager::Error error; |
504 | collection.setMetaData(QOrganizerCollection::KeyName, defaultCollectionName); |
505 | + collection.setMetaData(QOrganizerCollection::KeyColor, QStringLiteral("red")); |
506 | |
507 | QList<QOrganizerCollection> collections = m_engineRead->collections(&error); |
508 | int initalCollectionCount = collections.count(); |
509 | @@ -73,9 +74,43 @@ |
510 | collections = m_engineWrite->collections(&error); |
511 | QCOMPARE(collections.count(), initalCollectionCount + 1); |
512 | |
513 | - // wait some time for the changes to propagate |
514 | collections = m_engineRead->collections(&error); |
515 | QCOMPARE(collections.count(), initalCollectionCount + 1); |
516 | + |
517 | + // Check if data was correct saved |
518 | + QOrganizerCollection newCollection = m_engineRead->collection(collection.id(), &error); |
519 | + QCOMPARE(error, QOrganizerManager::NoError); |
520 | + QCOMPARE(newCollection.metaData(QOrganizerCollection::KeyName).toString(), defaultCollectionName); |
521 | + QCOMPARE(newCollection.metaData(QOrganizerCollection::KeyColor).toString(), QStringLiteral("red")); |
522 | + QCOMPARE(newCollection.extendedMetaData("collection-type").toString(), QStringLiteral("Calendar")); |
523 | + QCOMPARE(newCollection.extendedMetaData("collection-selected").toBool(), false); |
524 | + } |
525 | + |
526 | + void testUpdateCollection() |
527 | + { |
528 | + QOrganizerCollection collection; |
529 | + QtOrganizer::QOrganizerManager::Error error; |
530 | + collection.setMetaData(QOrganizerCollection::KeyName, defaultCollectionName); |
531 | + collection.setMetaData(QOrganizerCollection::KeyColor, "red"); |
532 | + |
533 | + QVERIFY(m_engineWrite->saveCollection(&collection, &error)); |
534 | + QCOMPARE(error, QOrganizerManager::NoError); |
535 | + QVERIFY(!collection.id().isNull()); |
536 | + |
537 | + // update the collection |
538 | + QSignalSpy updateCollection(m_engineWrite, SIGNAL(collectionsChanged(QList<QOrganizerCollectionId>))); |
539 | + collection.setMetaData(QOrganizerCollection::KeyColor, "blue"); |
540 | + collection.setExtendedMetaData("collection-selected", true); |
541 | + QVERIFY(m_engineWrite->saveCollection(&collection, &error)); |
542 | + QCOMPARE(error, QOrganizerManager::NoError); |
543 | + QTRY_COMPARE(updateCollection.count(), 1); |
544 | + |
545 | + // Check if the collection was stored correct |
546 | + QOrganizerCollection newCollection = m_engineRead->collection(collection.id(), &error); |
547 | + QCOMPARE(error, QOrganizerManager::NoError); |
548 | + QCOMPARE(newCollection.metaData(QOrganizerCollection::KeyName).toString(), defaultCollectionName); |
549 | + QCOMPARE(newCollection.metaData(QOrganizerCollection::KeyColor).toString(), QStringLiteral("blue")); |
550 | + QCOMPARE(newCollection.extendedMetaData("collection-selected").toBool(), true); |
551 | } |
552 | |
553 | void testRemoveCollection() |
554 | @@ -117,7 +152,7 @@ |
555 | QVERIFY(!collection.id().isNull()); |
556 | |
557 | //verify signal |
558 | - QCOMPARE(createdCollection.count(), 1); |
559 | + QTRY_COMPARE(createdCollection.count(), 1); |
560 | QList<QVariant> args = createdCollection.takeFirst(); |
561 | QCOMPARE(args.count(), 1); |
562 | |
563 | @@ -159,7 +194,7 @@ |
564 | appendToRemove(items[0].id()); |
565 | |
566 | //verify signal |
567 | - QCOMPARE(createdItem.count(), 1); |
568 | + QTRY_COMPARE(createdItem.count(), 1); |
569 | QList<QVariant> args = createdItem.takeFirst(); |
570 | QCOMPARE(args.count(), 1); |
571 |
PASSED: Continuous integration, rev:45 jenkins. qa.ubuntu. com/job/ qtorganizer5- eds-ci/ 121/ jenkins. qa.ubuntu. com/job/ qtorganizer5- eds-trusty- amd64-ci/ 110 jenkins. qa.ubuntu. com/job/ qtorganizer5- eds-trusty- armhf-ci/ 108 jenkins. qa.ubuntu. com/job/ qtorganizer5- eds-trusty- armhf-ci/ 108/artifact/ work/output/ *zip*/output. zip jenkins. qa.ubuntu. com/job/ qtorganizer5- eds-trusty- i386-ci/ 108
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild: s-jenkins. ubuntu- ci:8080/ job/qtorganizer 5-eds-ci/ 121/rebuild
http://