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