Changeset View
Changeset View
Standalone View
Standalone View
src/akonadi/akonadiprojectrepository.cpp
Show First 20 Lines • Show All 70 Lines • ▼ Show 20 Line(s) | 64 | { | |||
---|---|---|---|---|---|
71 | 71 | | |||
72 | auto job = new Utils::CompositeJob(); | 72 | auto job = new Utils::CompositeJob(); | ||
73 | ItemFetchJobInterface *fetchItemJob = m_storage->fetchItem(childItem); | 73 | ItemFetchJobInterface *fetchItemJob = m_storage->fetchItem(childItem); | ||
74 | job->install(fetchItemJob->kjob(), [fetchItemJob, parent, child, job, this] { | 74 | job->install(fetchItemJob->kjob(), [fetchItemJob, parent, child, job, this] { | ||
75 | if (fetchItemJob->kjob()->error() != KJob::NoError) | 75 | if (fetchItemJob->kjob()->error() != KJob::NoError) | ||
76 | return; | 76 | return; | ||
77 | 77 | | |||
78 | Q_ASSERT(fetchItemJob->items().size() == 1); | 78 | Q_ASSERT(fetchItemJob->items().size() == 1); | ||
79 | auto childItem = fetchItemJob->items().first(); | 79 | auto childItem = fetchItemJob->items().at(0); | ||
80 | m_serializer->updateItemProject(childItem, parent); | 80 | m_serializer->updateItemProject(childItem, parent); | ||
81 | 81 | | |||
82 | // Check collections to know if we need to move child | 82 | // Check collections to know if we need to move child | ||
83 | auto parentItem = m_serializer->createItemFromProject(parent); | 83 | auto parentItem = m_serializer->createItemFromProject(parent); | ||
84 | ItemFetchJobInterface *fetchParentItemJob = m_storage->fetchItem(parentItem); | 84 | ItemFetchJobInterface *fetchParentItemJob = m_storage->fetchItem(parentItem); | ||
85 | job->install(fetchParentItemJob->kjob(), [fetchParentItemJob, child, childItem, job, this] { | 85 | job->install(fetchParentItemJob->kjob(), [fetchParentItemJob, child, childItem, job, this] { | ||
86 | if (fetchParentItemJob->kjob()->error() != KJob::NoError) | 86 | if (fetchParentItemJob->kjob()->error() != KJob::NoError) | ||
87 | return; | 87 | return; | ||
88 | 88 | | |||
89 | Q_ASSERT(fetchParentItemJob->items().size() == 1); | 89 | Q_ASSERT(fetchParentItemJob->items().size() == 1); | ||
90 | auto parentItem = fetchParentItemJob->items().first(); | 90 | auto parentItem = fetchParentItemJob->items().at(0); | ||
91 | 91 | | |||
92 | const int itemCollectionId = childItem.parentCollection().id(); | 92 | const int itemCollectionId = childItem.parentCollection().id(); | ||
93 | const int parentCollectionId = parentItem.parentCollection().id(); | 93 | const int parentCollectionId = parentItem.parentCollection().id(); | ||
94 | 94 | | |||
95 | if (child.objectCast<Domain::Task>() | 95 | if (child.objectCast<Domain::Task>() | ||
96 | && itemCollectionId != parentCollectionId) { | 96 | && itemCollectionId != parentCollectionId) { | ||
97 | ItemFetchJobInterface *fetchChildrenItemJob = m_storage->fetchItems(childItem.parentCollection()); | 97 | ItemFetchJobInterface *fetchChildrenItemJob = m_storage->fetchItems(childItem.parentCollection()); | ||
98 | job->install(fetchChildrenItemJob->kjob(), [fetchChildrenItemJob, childItem, parentItem, job, this] { | 98 | job->install(fetchChildrenItemJob->kjob(), [fetchChildrenItemJob, childItem, parentItem, job, this] { | ||
Show All 32 Lines | 123 | { | |||
131 | Q_ASSERT(childItem.isValid()); | 131 | Q_ASSERT(childItem.isValid()); | ||
132 | 132 | | |||
133 | ItemFetchJobInterface *fetchItemJob = m_storage->fetchItem(childItem); | 133 | ItemFetchJobInterface *fetchItemJob = m_storage->fetchItem(childItem); | ||
134 | job->install(fetchItemJob->kjob(), [fetchItemJob, job, this] { | 134 | job->install(fetchItemJob->kjob(), [fetchItemJob, job, this] { | ||
135 | if (fetchItemJob->kjob()->error() != KJob::NoError) | 135 | if (fetchItemJob->kjob()->error() != KJob::NoError) | ||
136 | return; | 136 | return; | ||
137 | 137 | | |||
138 | Q_ASSERT(fetchItemJob->items().size() == 1); | 138 | Q_ASSERT(fetchItemJob->items().size() == 1); | ||
139 | auto childItem = fetchItemJob->items().first(); | 139 | auto childItem = fetchItemJob->items().at(0); | ||
140 | 140 | | |||
141 | m_serializer->removeItemParent(childItem); | 141 | m_serializer->removeItemParent(childItem); | ||
142 | 142 | | |||
143 | auto updateJob = m_storage->updateItem(childItem); | 143 | auto updateJob = m_storage->updateItem(childItem); | ||
144 | job->addSubjob(updateJob); | 144 | job->addSubjob(updateJob); | ||
145 | updateJob->start(); | 145 | updateJob->start(); | ||
146 | }); | 146 | }); | ||
147 | 147 | | |||
148 | return job; | 148 | return job; | ||
149 | } | 149 | } |