Changeset View
Changeset View
Standalone View
Standalone View
src/akonadi/akonaditaskrepository.cpp
Show First 20 Lines • Show All 139 Lines • ▼ Show 20 Line(s) | 137 | { | |||
---|---|---|---|---|---|
140 | 140 | | |||
141 | auto compositeJob = new CompositeJob(); | 141 | auto compositeJob = new CompositeJob(); | ||
142 | ItemFetchJobInterface *fetchItemJob = m_storage->fetchItem(item); | 142 | ItemFetchJobInterface *fetchItemJob = m_storage->fetchItem(item); | ||
143 | compositeJob->install(fetchItemJob->kjob(), [fetchItemJob, compositeJob, this] { | 143 | compositeJob->install(fetchItemJob->kjob(), [fetchItemJob, compositeJob, this] { | ||
144 | if (fetchItemJob->kjob()->error() != KJob::NoError) | 144 | if (fetchItemJob->kjob()->error() != KJob::NoError) | ||
145 | return; | 145 | return; | ||
146 | 146 | | |||
147 | Q_ASSERT(fetchItemJob->items().size() == 1); | 147 | Q_ASSERT(fetchItemJob->items().size() == 1); | ||
148 | auto item = fetchItemJob->items().first(); | 148 | auto item = fetchItemJob->items().at(0); | ||
149 | 149 | | |||
150 | ItemFetchJobInterface *fetchCollectionItemsJob = m_storage->fetchItems(item.parentCollection()); | 150 | ItemFetchJobInterface *fetchCollectionItemsJob = m_storage->fetchItems(item.parentCollection()); | ||
151 | compositeJob->install(fetchCollectionItemsJob->kjob(), [fetchCollectionItemsJob, item, compositeJob, this] { | 151 | compositeJob->install(fetchCollectionItemsJob->kjob(), [fetchCollectionItemsJob, item, compositeJob, this] { | ||
152 | if (fetchCollectionItemsJob->kjob()->error() != KJob::NoError) | 152 | if (fetchCollectionItemsJob->kjob()->error() != KJob::NoError) | ||
153 | return; | 153 | return; | ||
154 | 154 | | |||
155 | Item::List childItems = m_serializer->filterDescendantItems(fetchCollectionItemsJob->items(), item); | 155 | Item::List childItems = m_serializer->filterDescendantItems(fetchCollectionItemsJob->items(), item); | ||
156 | childItems << item; | 156 | childItems << item; | ||
Show All 13 Lines | 168 | { | |||
170 | 170 | | |||
171 | auto job = new CompositeJob(); | 171 | auto job = new CompositeJob(); | ||
172 | auto fetchJob = m_storage->fetchItem(item); | 172 | auto fetchJob = m_storage->fetchItem(item); | ||
173 | job->install(fetchJob->kjob(), [fetchJob, job, this] { | 173 | job->install(fetchJob->kjob(), [fetchJob, job, this] { | ||
174 | if (fetchJob->kjob()->error() != KJob::NoError) | 174 | if (fetchJob->kjob()->error() != KJob::NoError) | ||
175 | return; | 175 | return; | ||
176 | 176 | | |||
177 | Q_ASSERT(fetchJob->items().size() == 1); | 177 | Q_ASSERT(fetchJob->items().size() == 1); | ||
178 | auto item = fetchJob->items().first(); | 178 | auto item = fetchJob->items().at(0); | ||
179 | m_serializer->promoteItemToProject(item); | 179 | m_serializer->promoteItemToProject(item); | ||
180 | 180 | | |||
181 | auto updateJob = m_storage->updateItem(item); | 181 | auto updateJob = m_storage->updateItem(item); | ||
182 | job->addSubjob(updateJob); | 182 | job->addSubjob(updateJob); | ||
183 | updateJob->start(); | 183 | updateJob->start(); | ||
184 | }); | 184 | }); | ||
185 | return job; | 185 | return job; | ||
186 | } | 186 | } | ||
187 | 187 | | |||
188 | KJob *TaskRepository::associate(Domain::Task::Ptr parent, Domain::Task::Ptr child) | 188 | KJob *TaskRepository::associate(Domain::Task::Ptr parent, Domain::Task::Ptr child) | ||
189 | { | 189 | { | ||
190 | auto childItem = m_serializer->createItemFromTask(child); | 190 | auto childItem = m_serializer->createItemFromTask(child); | ||
191 | 191 | | |||
192 | auto job = new CompositeJob(); | 192 | auto job = new CompositeJob(); | ||
193 | ItemFetchJobInterface *fetchItemJob = m_storage->fetchItem(childItem); | 193 | ItemFetchJobInterface *fetchItemJob = m_storage->fetchItem(childItem); | ||
194 | job->install(fetchItemJob->kjob(), [fetchItemJob, child, parent, job, this] { | 194 | job->install(fetchItemJob->kjob(), [fetchItemJob, child, parent, job, this] { | ||
195 | if (fetchItemJob->kjob()->error() != KJob::NoError) | 195 | if (fetchItemJob->kjob()->error() != KJob::NoError) | ||
196 | return; | 196 | return; | ||
197 | 197 | | |||
198 | Q_ASSERT(fetchItemJob->items().size() == 1); | 198 | Q_ASSERT(fetchItemJob->items().size() == 1); | ||
199 | auto childItem = fetchItemJob->items().first(); | 199 | auto childItem = fetchItemJob->items().at(0); | ||
200 | m_serializer->updateItemParent(childItem, parent); | 200 | m_serializer->updateItemParent(childItem, parent); | ||
201 | 201 | | |||
202 | // Check collections to know if we need to move child | 202 | // Check collections to know if we need to move child | ||
203 | auto partialParentItem = m_serializer->createItemFromTask(parent); | 203 | auto partialParentItem = m_serializer->createItemFromTask(parent); | ||
204 | ItemFetchJobInterface *fetchParentItemJob = m_storage->fetchItems(partialParentItem.parentCollection()); | 204 | ItemFetchJobInterface *fetchParentItemJob = m_storage->fetchItems(partialParentItem.parentCollection()); | ||
205 | job->install(fetchParentItemJob->kjob(), [child, parent, fetchParentItemJob, partialParentItem, childItem, job, this] { | 205 | job->install(fetchParentItemJob->kjob(), [child, parent, fetchParentItemJob, partialParentItem, childItem, job, this] { | ||
206 | if (fetchParentItemJob->kjob()->error() != KJob::NoError) | 206 | if (fetchParentItemJob->kjob()->error() != KJob::NoError) | ||
207 | return; | 207 | return; | ||
▲ Show 20 Lines • Show All 59 Lines • ▼ Show 20 Line(s) | 266 | { | |||
267 | auto job = new CompositeJob(); | 267 | auto job = new CompositeJob(); | ||
268 | auto childItem = m_serializer->createItemFromTask(child); | 268 | auto childItem = m_serializer->createItemFromTask(child); | ||
269 | ItemFetchJobInterface *fetchItemJob = m_storage->fetchItem(childItem); | 269 | ItemFetchJobInterface *fetchItemJob = m_storage->fetchItem(childItem); | ||
270 | job->install(fetchItemJob->kjob(), [fetchItemJob, job, this] { | 270 | job->install(fetchItemJob->kjob(), [fetchItemJob, job, this] { | ||
271 | if (fetchItemJob->kjob()->error() != KJob::NoError) | 271 | if (fetchItemJob->kjob()->error() != KJob::NoError) | ||
272 | return; | 272 | return; | ||
273 | 273 | | |||
274 | Q_ASSERT(fetchItemJob->items().size() == 1); | 274 | Q_ASSERT(fetchItemJob->items().size() == 1); | ||
275 | auto childItem = fetchItemJob->items().first(); | 275 | auto childItem = fetchItemJob->items().at(0); | ||
276 | 276 | | |||
277 | m_serializer->removeItemParent(childItem); | 277 | m_serializer->removeItemParent(childItem); | ||
278 | 278 | | |||
279 | auto updateJob = m_storage->updateItem(childItem); | 279 | auto updateJob = m_storage->updateItem(childItem); | ||
280 | job->addSubjob(updateJob); | 280 | job->addSubjob(updateJob); | ||
281 | updateJob->start(); | 281 | updateJob->start(); | ||
282 | }); | 282 | }); | ||
283 | 283 | | |||
284 | return job; | 284 | return job; | ||
285 | } | 285 | } | ||
286 | 286 | | |||
287 | KJob *TaskRepository::dissociateAll(Domain::Task::Ptr child) | 287 | KJob *TaskRepository::dissociateAll(Domain::Task::Ptr child) | ||
288 | { | 288 | { | ||
289 | auto job = new CompositeJob(); | 289 | auto job = new CompositeJob(); | ||
290 | auto childItem = m_serializer->createItemFromTask(child); | 290 | auto childItem = m_serializer->createItemFromTask(child); | ||
291 | ItemFetchJobInterface *fetchItemJob = m_storage->fetchItem(childItem); | 291 | ItemFetchJobInterface *fetchItemJob = m_storage->fetchItem(childItem); | ||
292 | job->install(fetchItemJob->kjob(), [fetchItemJob, job, this] { | 292 | job->install(fetchItemJob->kjob(), [fetchItemJob, job, this] { | ||
293 | if (fetchItemJob->kjob()->error() != KJob::NoError) | 293 | if (fetchItemJob->kjob()->error() != KJob::NoError) | ||
294 | return; | 294 | return; | ||
295 | 295 | | |||
296 | Q_ASSERT(fetchItemJob->items().size() == 1); | 296 | Q_ASSERT(fetchItemJob->items().size() == 1); | ||
297 | auto childItem = fetchItemJob->items().first(); | 297 | auto childItem = fetchItemJob->items().at(0); | ||
298 | 298 | | |||
299 | m_serializer->removeItemParent(childItem); | 299 | m_serializer->removeItemParent(childItem); | ||
300 | m_serializer->clearItem(&childItem); | 300 | m_serializer->clearItem(&childItem); | ||
301 | 301 | | |||
302 | auto updateJob = m_storage->updateItem(childItem); | 302 | auto updateJob = m_storage->updateItem(childItem); | ||
303 | job->addSubjob(updateJob); | 303 | job->addSubjob(updateJob); | ||
304 | updateJob->start(); | 304 | updateJob->start(); | ||
305 | }); | 305 | }); | ||
Show All 19 Lines |