##// END OF EJS Templates
Add init of DisplayedEvent. Add save on EventProduct modif
perrinel -
r1281:6aa3d9aeb6d5
parent child
Show More
@@ -81,7 +81,10 CatalogueExplorer::CatalogueExplorer(QWidget *parent)
81 });
81 });
82
82
83 connect(ui->inspector, &CatalogueInspectorWidget::eventProductUpdated,
83 connect(ui->inspector, &CatalogueInspectorWidget::eventProductUpdated,
84 [this](auto event, auto eventProduct) { ui->events->setEventChanges(event, true); });
84 [this](auto event, auto eventProduct) {
85 sqpApp->catalogueController().updateEventProduct(eventProduct);
86 ui->events->setEventChanges(event, true);
87 });
85 }
88 }
86
89
87 CatalogueExplorer::~CatalogueExplorer()
90 CatalogueExplorer::~CatalogueExplorer()
@@ -78,8 +78,18 void CatalogueInspectorWidget::CatalogueInspectorWidgetPrivate::connectEventUpda
78
78
79 connect(ui->leEventProduct, &QLineEdit::editingFinished, [ui, inspector, this]() {
79 connect(ui->leEventProduct, &QLineEdit::editingFinished, [ui, inspector, this]() {
80 if (ui->leEventProduct->text() != m_DisplayedEventProduct->getProductId()) {
80 if (ui->leEventProduct->text() != m_DisplayedEventProduct->getProductId()) {
81 auto oldProductId = m_DisplayedEventProduct->getProductId();
81 m_DisplayedEventProduct->setProductId(ui->leEventProduct->text());
82 m_DisplayedEventProduct->setProductId(ui->leEventProduct->text());
82 emit inspector->eventProductUpdated(m_DisplayedEvent, m_DisplayedEventProduct);
83
84 auto eventProducts = m_DisplayedEvent->getEventProducts();
85 for (auto &eventProduct : eventProducts) {
86 if (eventProduct.getProductId() == oldProductId) {
87 eventProduct.setProductId(m_DisplayedEventProduct->getProductId());
88 }
89 }
90 m_DisplayedEvent->setEventProducts(eventProducts);
91
92 emit inspector->eventUpdated(m_DisplayedEvent);
83 }
93 }
84 });
94 });
85
95
@@ -87,7 +97,16 void CatalogueInspectorWidget::CatalogueInspectorWidgetPrivate::connectEventUpda
87 auto time = DateUtils::secondsSinceEpoch(ui->dateTimeEventTStart->dateTime());
97 auto time = DateUtils::secondsSinceEpoch(ui->dateTimeEventTStart->dateTime());
88 if (time != m_DisplayedEventProduct->getTStart()) {
98 if (time != m_DisplayedEventProduct->getTStart()) {
89 m_DisplayedEventProduct->setTStart(time);
99 m_DisplayedEventProduct->setTStart(time);
90 emit inspector->eventProductUpdated(m_DisplayedEvent, m_DisplayedEventProduct);
100
101 auto eventProducts = m_DisplayedEvent->getEventProducts();
102 for (auto &eventProduct : eventProducts) {
103 if (eventProduct.getProductId() == m_DisplayedEventProduct->getProductId()) {
104 eventProduct.setTStart(m_DisplayedEventProduct->getTStart());
105 }
106 }
107 m_DisplayedEvent->setEventProducts(eventProducts);
108
109 emit inspector->eventUpdated(m_DisplayedEvent);
91 }
110 }
92 });
111 });
93
112
@@ -95,7 +114,16 void CatalogueInspectorWidget::CatalogueInspectorWidgetPrivate::connectEventUpda
95 auto time = DateUtils::secondsSinceEpoch(ui->dateTimeEventTEnd->dateTime());
114 auto time = DateUtils::secondsSinceEpoch(ui->dateTimeEventTEnd->dateTime());
96 if (time != m_DisplayedEventProduct->getTEnd()) {
115 if (time != m_DisplayedEventProduct->getTEnd()) {
97 m_DisplayedEventProduct->setTEnd(time);
116 m_DisplayedEventProduct->setTEnd(time);
98 emit inspector->eventProductUpdated(m_DisplayedEvent, m_DisplayedEventProduct);
117
118 auto eventProducts = m_DisplayedEvent->getEventProducts();
119 for (auto &eventProduct : eventProducts) {
120 if (eventProduct.getProductId() == m_DisplayedEventProduct->getProductId()) {
121 eventProduct.setTEnd(m_DisplayedEventProduct->getTEnd());
122 }
123 }
124 m_DisplayedEvent->setEventProducts(eventProducts);
125
126 emit inspector->eventUpdated(m_DisplayedEvent);
99 }
127 }
100 });
128 });
101 }
129 }
@@ -145,6 +173,8 void CatalogueInspectorWidget::setEvent(const std::shared_ptr<DBEvent> &event)
145 void CatalogueInspectorWidget::setEventProduct(const std::shared_ptr<DBEvent> &event,
173 void CatalogueInspectorWidget::setEventProduct(const std::shared_ptr<DBEvent> &event,
146 const std::shared_ptr<DBEventProduct> &eventProduct)
174 const std::shared_ptr<DBEventProduct> &eventProduct)
147 {
175 {
176
177 impl->m_DisplayedEvent = event;
148 impl->m_DisplayedEventProduct = eventProduct;
178 impl->m_DisplayedEventProduct = eventProduct;
149
179
150 blockSignals(true);
180 blockSignals(true);
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