##// END OF EJS Templates
Add discard method for event
perrinel -
r1298:85d482a16060
parent child
Show More
@@ -48,8 +48,9 public:
48 48 void updateEventProduct(std::shared_ptr<DBEventProduct> eventProduct);
49 49 void removeEvent(std::shared_ptr<DBEvent> event);
50 50 // void trashEvent(std::shared_ptr<DBEvent> event);
51 // void restore(QUuid eventId);
51 // void restore(std::shared_ptr<DBEvent> event);
52 52 void saveEvent(std::shared_ptr<DBEvent> event);
53 void discardEvent(std::shared_ptr<DBEvent> event);
53 54 bool eventHasChanges(std::shared_ptr<DBEvent> event) const;
54 55
55 56 // Catalogue
@@ -191,6 +191,26 void CatalogueController::saveEvent(std::shared_ptr<DBEvent> event)
191 191 impl->m_EventKeysWithChanges.remove(impl->eventUniqueKey(event));
192 192 }
193 193
194 void CatalogueController::discardEvent(std::shared_ptr<DBEvent> event)
195 {
196 auto uniqIdPredicate = std::make_shared<ComparaisonPredicate>(
197 QString{"uniqId"}, event->getUniqId(), ComparaisonOperation::EQUALEQUAL);
198
199 auto repositoryPredicate = std::make_shared<ComparaisonPredicate>(
200 QString{"repository"}, impl->toSyncRepository(event->getRepository()),
201 ComparaisonOperation::EQUALEQUAL);
202
203 auto compCompoundPred = std::make_shared<CompoundPredicate>(CompoundOperation::AND);
204 compCompoundPred->AddRequestPredicate(uniqIdPredicate);
205 compCompoundPred->AddRequestPredicate(repositoryPredicate);
206
207
208 auto syncEvent = impl->m_CatalogueDao.getEvent(compCompoundPred);
209 impl->m_CatalogueDao.copyEvent(syncEvent, impl->toWorkRepository(event->getRepository()), true);
210 *event = syncEvent;
211 impl->m_EventKeysWithChanges.remove(impl->eventUniqueKey(event));
212 }
213
194 214 bool CatalogueController::eventHasChanges(std::shared_ptr<DBEvent> event) const
195 215 {
196 216 return impl->m_EventKeysWithChanges.contains(impl->eventUniqueKey(event));
@@ -297,8 +317,8 CatalogueController::eventsForMimeData(const QByteArray &mimeData) const
297 317
298 318 void CatalogueController::initialize()
299 319 {
300 qCDebug(LOG_CatalogueController())
301 << tr("CatalogueController init") << QThread::currentThread();
320 qCDebug(LOG_CatalogueController()) << tr("CatalogueController init")
321 << QThread::currentThread();
302 322
303 323 impl->m_CatalogueDao.initialize();
304 324 auto defaultRepositoryLocation
@@ -371,7 +371,11 void CatalogueEventsWidget::setEventChanges(const std::shared_ptr<DBEvent> &even
371 371 sqpApp->catalogueController().saveEvent(event);
372 372 setEventChanges(event, false);
373 373 },
374 [this, event]() { setEventChanges(event, false); });
374 [this, event]() {
375 sqpApp->catalogueController().discardEvent(event);
376 setEventChanges(event, false);
377 impl->m_Model->refreshEvent(event);
378 });
375 379 ui->treeView->setIndexWidget(validationIndex, widget);
376 380 }
377 381 }
@@ -315,10 +315,8 void CatalogueSideBarWidget::CatalogueSideBarWidgetPrivate::setHasChanges(bool v
315 315 if (value) {
316 316 if (!hasChanges(validationIndex, treeView)) {
317 317 auto widget = CatalogueExplorerHelper::buildValidationWidget(
318 treeView,
319 [this, validationIndex, treeView]() {
320 setHasChanges(false, validationIndex, treeView);
321 },
318 treeView, [this, validationIndex,
319 treeView]() { setHasChanges(false, validationIndex, treeView); },
322 320 [this, validationIndex, treeView]() {
323 321 setHasChanges(false, validationIndex, treeView);
324 322 });
General Comments 3
Under Review
author

Auto status change to "Under Review"

Approved
author

Status change > Approved

You need to be logged in to leave comments. Login now