@@ -49,7 +49,7 public: | |||
|
49 | 49 | // void trashEvent(std::shared_ptr<DBEvent> event); |
|
50 | 50 | // void restore(std::shared_ptr<DBEvent> event); |
|
51 | 51 | void saveEvent(std::shared_ptr<DBEvent> event); |
|
52 | void discardEvent(std::shared_ptr<DBEvent> event); | |
|
52 | void discardEvent(std::shared_ptr<DBEvent> event, bool &removed); | |
|
53 | 53 | bool eventHasChanges(std::shared_ptr<DBEvent> event) const; |
|
54 | 54 | |
|
55 | 55 | // Catalogue |
@@ -184,8 +184,27 void CatalogueController::addEvent(std::shared_ptr<DBEvent> event) | |||
|
184 | 184 | impl->m_CatalogueDao.updateEvent(eventTemp); |
|
185 | 185 | } |
|
186 | 186 | |
|
187 | <<<<<<< Upstream, based on feature/CatalogueDevelop2 | |
|
187 | 188 | auto uniqueId = impl->eventUniqueKey(event); |
|
188 | 189 | impl->m_EventKeysWithChanges.insert(uniqueId); |
|
190 | ======= | |
|
191 | ||
|
192 | // update event parameter | |
|
193 | auto uniqIdPredicate = std::make_shared<ComparaisonPredicate>( | |
|
194 | QString{"uniqId"}, event->getUniqId(), ComparaisonOperation::EQUALEQUAL); | |
|
195 | ||
|
196 | auto workRepositoryPredicate = std::make_shared<ComparaisonPredicate>( | |
|
197 | QString{"repository"}, impl->toWorkRepository(event->getRepository()), | |
|
198 | ComparaisonOperation::EQUALEQUAL); | |
|
199 | ||
|
200 | auto workPred = std::make_shared<CompoundPredicate>(CompoundOperation::AND); | |
|
201 | workPred->AddRequestPredicate(uniqIdPredicate); | |
|
202 | workPred->AddRequestPredicate(workRepositoryPredicate); | |
|
203 | ||
|
204 | ||
|
205 | auto workEvent = impl->m_CatalogueDao.getEvent(workPred); | |
|
206 | *event = workEvent; | |
|
207 | >>>>>>> 575bb1a Discard an added event remove it now. | |
|
189 | 208 | } |
|
190 | 209 | |
|
191 | 210 | void CatalogueController::saveEvent(std::shared_ptr<DBEvent> event) |
@@ -194,7 +213,7 void CatalogueController::saveEvent(std::shared_ptr<DBEvent> event) | |||
|
194 | 213 | impl->m_EventKeysWithChanges.remove(impl->eventUniqueKey(event)); |
|
195 | 214 | } |
|
196 | 215 | |
|
197 | void CatalogueController::discardEvent(std::shared_ptr<DBEvent> event) | |
|
216 | void CatalogueController::discardEvent(std::shared_ptr<DBEvent> event, bool &removed) | |
|
198 | 217 | { |
|
199 | 218 | auto uniqIdPredicate = std::make_shared<ComparaisonPredicate>( |
|
200 | 219 | QString{"uniqId"}, event->getUniqId(), ComparaisonOperation::EQUALEQUAL); |
@@ -218,11 +237,21 void CatalogueController::discardEvent(std::shared_ptr<DBEvent> event) | |||
|
218 | 237 | |
|
219 | 238 | |
|
220 | 239 | auto syncEvent = impl->m_CatalogueDao.getEvent(syncPred); |
|
221 | impl->m_CatalogueDao.copyEvent(syncEvent, impl->toWorkRepository(event->getRepository()), true); | |
|
222 | ||
|
223 | auto workEvent = impl->m_CatalogueDao.getEvent(workPred); | |
|
224 | *event = workEvent; | |
|
225 | impl->m_EventKeysWithChanges.remove(impl->eventUniqueKey(event)); | |
|
240 | if (!syncEvent.getUniqId().isNull()) { | |
|
241 | removed = false; | |
|
242 | impl->m_CatalogueDao.copyEvent(syncEvent, impl->toWorkRepository(event->getRepository()), | |
|
243 | true); | |
|
244 | ||
|
245 | auto workEvent = impl->m_CatalogueDao.getEvent(workPred); | |
|
246 | *event = workEvent; | |
|
247 | impl->m_EventKeysWithChanges.remove(impl->eventUniqueKey(event)); | |
|
248 | } | |
|
249 | else { | |
|
250 | removed = true; | |
|
251 | // Since the element wasn't in sync repository. Discard it means remove it | |
|
252 | event->setRepository(impl->toWorkRepository(event->getRepository())); | |
|
253 | impl->m_CatalogueDao.removeEvent(*event); | |
|
254 | } | |
|
226 | 255 | } |
|
227 | 256 | |
|
228 | 257 | bool CatalogueController::eventHasChanges(std::shared_ptr<DBEvent> event) const |
@@ -358,9 +358,15 void CatalogueEventsWidget::setEventChanges(const std::shared_ptr<DBEvent> &even | |||
|
358 | 358 | setEventChanges(event, false); |
|
359 | 359 | }, |
|
360 | 360 | [this, event]() { |
|
361 | sqpApp->catalogueController().discardEvent(event); | |
|
362 |
setEvent |
|
|
363 | impl->m_Model->refreshEvent(event, true); | |
|
361 | bool removed = false; | |
|
362 | sqpApp->catalogueController().discardEvent(event, removed); | |
|
363 | if (removed) { | |
|
364 | impl->m_Model->removeEvent(event); | |
|
365 | } | |
|
366 | else { | |
|
367 | setEventChanges(event, false); | |
|
368 | impl->m_Model->refreshEvent(event, true); | |
|
369 | } | |
|
364 | 370 | emitSelection(); |
|
365 | 371 | }); |
|
366 | 372 | ui->treeView->setIndexWidget(validationIndex, widget); |
@@ -64,7 +64,7 void CatalogueInspectorWidget::CatalogueInspectorWidgetPrivate::connectEventUpda | |||
|
64 | 64 | }); |
|
65 | 65 | |
|
66 | 66 | connect(ui->leEventTags, &QLineEdit::editingFinished, [ui, inspector, this]() { |
|
67 | auto tags = ui->leEventTags->text().split(QRegExp("\\s+")); | |
|
67 | auto tags = ui->leEventTags->text().split(QRegExp("\\s+"), QString::SkipEmptyParts); | |
|
68 | 68 | std::list<QString> tagNames; |
|
69 | 69 | for (auto tag : tags) { |
|
70 | 70 | tagNames.push_back(tag); |
General Comments 0
You need to be logged in to leave comments.
Login now