##// END OF EJS Templates
Discard an added event remove it now.
perrinel -
r1321:fba51a5eef20
parent child
Show More
@@ -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
@@ -184,8 +184,27 void CatalogueController::addEvent(std::shared_ptr<DBEvent> event)
184 impl->m_CatalogueDao.updateEvent(eventTemp);
184 impl->m_CatalogueDao.updateEvent(eventTemp);
185 }
185 }
186
186
187 <<<<<<< Upstream, based on feature/CatalogueDevelop2
187 auto uniqueId = impl->eventUniqueKey(event);
188 auto uniqueId = impl->eventUniqueKey(event);
188 impl->m_EventKeysWithChanges.insert(uniqueId);
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 void CatalogueController::saveEvent(std::shared_ptr<DBEvent> event)
210 void CatalogueController::saveEvent(std::shared_ptr<DBEvent> event)
@@ -194,7 +213,7 void CatalogueController::saveEvent(std::shared_ptr<DBEvent> event)
194 impl->m_EventKeysWithChanges.remove(impl->eventUniqueKey(event));
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 auto uniqIdPredicate = std::make_shared<ComparaisonPredicate>(
218 auto uniqIdPredicate = std::make_shared<ComparaisonPredicate>(
200 QString{"uniqId"}, event->getUniqId(), ComparaisonOperation::EQUALEQUAL);
219 QString{"uniqId"}, event->getUniqId(), ComparaisonOperation::EQUALEQUAL);
@@ -218,12 +237,22 void CatalogueController::discardEvent(std::shared_ptr<DBEvent> event)
218
237
219
238
220 auto syncEvent = impl->m_CatalogueDao.getEvent(syncPred);
239 auto syncEvent = impl->m_CatalogueDao.getEvent(syncPred);
221 impl->m_CatalogueDao.copyEvent(syncEvent, impl->toWorkRepository(event->getRepository()), true);
240 if (!syncEvent.getUniqId().isNull()) {
241 removed = false;
242 impl->m_CatalogueDao.copyEvent(syncEvent, impl->toWorkRepository(event->getRepository()),
243 true);
222
244
223 auto workEvent = impl->m_CatalogueDao.getEvent(workPred);
245 auto workEvent = impl->m_CatalogueDao.getEvent(workPred);
224 *event = workEvent;
246 *event = workEvent;
225 impl->m_EventKeysWithChanges.remove(impl->eventUniqueKey(event));
247 impl->m_EventKeysWithChanges.remove(impl->eventUniqueKey(event));
226 }
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 }
255 }
227
256
228 bool CatalogueController::eventHasChanges(std::shared_ptr<DBEvent> event) const
257 bool CatalogueController::eventHasChanges(std::shared_ptr<DBEvent> event) const
229 {
258 {
@@ -358,9 +358,15 void CatalogueEventsWidget::setEventChanges(const std::shared_ptr<DBEvent> &even
358 setEventChanges(event, false);
358 setEventChanges(event, false);
359 },
359 },
360 [this, event]() {
360 [this, event]() {
361 sqpApp->catalogueController().discardEvent(event);
361 bool removed = false;
362 sqpApp->catalogueController().discardEvent(event, removed);
363 if (removed) {
364 impl->m_Model->removeEvent(event);
365 }
366 else {
362 setEventChanges(event, false);
367 setEventChanges(event, false);
363 impl->m_Model->refreshEvent(event, true);
368 impl->m_Model->refreshEvent(event, true);
369 }
364 emitSelection();
370 emitSelection();
365 });
371 });
366 ui->treeView->setIndexWidget(validationIndex, widget);
372 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