##// END OF EJS Templates
Link with selection zone on event creation
trabillard -
r1294:eede5e75e31f
parent child
Show More
@@ -12,6 +12,10 class CatalogueEventsWidget;
12 class CatalogueSideBarWidget;
12 class CatalogueSideBarWidget;
13
13
14 class VisualizationWidget;
14 class VisualizationWidget;
15 class VisualizationSelectionZoneItem;
16
17 class DBEvent;
18
15
19
16 class CatalogueExplorer : public QDialog {
20 class CatalogueExplorer : public QDialog {
17 Q_OBJECT
21 Q_OBJECT
@@ -25,6 +29,10 public:
25 CatalogueEventsWidget &eventsWidget() const;
29 CatalogueEventsWidget &eventsWidget() const;
26 CatalogueSideBarWidget &sideBarWidget() const;
30 CatalogueSideBarWidget &sideBarWidget() const;
27
31
32 void clearSelectionZones();
33 void addSelectionZoneItem(const std::shared_ptr<DBEvent> &event, const QString &productId,
34 VisualizationSelectionZoneItem *selectionZone);
35
28 private:
36 private:
29 Ui::CatalogueExplorer *ui;
37 Ui::CatalogueExplorer *ui;
30
38
@@ -48,14 +48,18 struct CatalogueActionManager::CatalogueActionManagerPrivate {
48 auto eventProduct = std::make_shared<DBEventProduct>();
48 auto eventProduct = std::make_shared<DBEventProduct>();
49 eventProduct->setEvent(*event);
49 eventProduct->setEvent(*event);
50
50
51 auto productId
52 = var->metadata().value(DataSourceItem::ID_DATA_KEY, "UnknownID").toString();
53
51 auto zoneRange = zone->range();
54 auto zoneRange = zone->range();
52 eventProduct->setTStart(zoneRange.m_TStart);
55 eventProduct->setTStart(zoneRange.m_TStart);
53 eventProduct->setTEnd(zoneRange.m_TEnd);
56 eventProduct->setTEnd(zoneRange.m_TEnd);
54
57
55 eventProduct->setProductId(
58 eventProduct->setProductId(productId);
56 var->metadata().value(DataSourceItem::ID_DATA_KEY, "UnknownID").toString());
57
59
58 productList.push_back(*eventProduct);
60 productList.push_back(*eventProduct);
61
62 m_CatalogueExplorer->addSelectionZoneItem(event, productId, zone);
59 }
63 }
60 }
64 }
61
65
@@ -19,6 +19,8 struct CatalogueExplorer::CatalogueExplorerPrivate {
19 std::unordered_map<std::shared_ptr<DBEvent>, QVector<VisualizationSelectionZoneItem *> >
19 std::unordered_map<std::shared_ptr<DBEvent>, QVector<VisualizationSelectionZoneItem *> >
20 m_SelectionZonesPerEvents;
20 m_SelectionZonesPerEvents;
21
21
22 QMetaObject::Connection m_Conn;
23
22 CatalogueExplorerPrivate(CatalogueExplorer *catalogueExplorer)
24 CatalogueExplorerPrivate(CatalogueExplorer *catalogueExplorer)
23 : m_ActionManager(catalogueExplorer)
25 : m_ActionManager(catalogueExplorer)
24 {
26 {
@@ -100,22 +102,7 CatalogueExplorer::CatalogueExplorer(QWidget *parent)
100 // Manage Selection Zones associated to events
102 // Manage Selection Zones associated to events
101 connect(ui->events, &CatalogueEventsWidget::selectionZoneAdded,
103 connect(ui->events, &CatalogueEventsWidget::selectionZoneAdded,
102 [this](auto event, auto productId, auto zone) {
104 [this](auto event, auto productId, auto zone) {
103 impl->m_SelectionZonesPerEvents[event] << zone;
105 this->addSelectionZoneItem(event, productId, zone);
104 connect(zone, &VisualizationSelectionZoneItem::rangeEdited,
105 [event, productId, this](auto range) {
106 auto productList = event->getEventProducts();
107 for (auto &product : productList) {
108 if (product.getProductId() == productId) {
109 product.setTStart(range.m_TStart);
110 product.setTEnd(range.m_TEnd);
111 }
112 }
113 event->setEventProducts(productList);
114 sqpApp->catalogueController().updateEvent(event);
115 ui->events->refreshEvent(event);
116 ui->events->setEventChanges(event, true);
117 ui->inspector->refresh();
118 });
119 });
106 });
120
107
121 connect(ui->events, &CatalogueEventsWidget::eventsRemoved, [this](auto events) {
108 connect(ui->events, &CatalogueEventsWidget::eventsRemoved, [this](auto events) {
@@ -152,6 +139,7 CatalogueExplorer::CatalogueExplorer(QWidget *parent)
152
139
153 CatalogueExplorer::~CatalogueExplorer()
140 CatalogueExplorer::~CatalogueExplorer()
154 {
141 {
142 disconnect(impl->m_Conn);
155 delete ui;
143 delete ui;
156 }
144 }
157
145
@@ -169,3 +157,37 CatalogueSideBarWidget &CatalogueExplorer::sideBarWidget() const
169 {
157 {
170 return *ui->catalogues;
158 return *ui->catalogues;
171 }
159 }
160
161 void CatalogueExplorer::clearSelectionZones()
162 {
163 impl->m_SelectionZonesPerEvents.clear();
164 }
165
166 void CatalogueExplorer::addSelectionZoneItem(const std::shared_ptr<DBEvent> &event,
167 const QString &productId,
168 VisualizationSelectionZoneItem *selectionZone)
169 {
170 impl->m_SelectionZonesPerEvents[event] << selectionZone;
171 connect(selectionZone, &VisualizationSelectionZoneItem::rangeEdited,
172 [event, productId, this](auto range) {
173 auto productList = event->getEventProducts();
174 for (auto &product : productList) {
175 if (product.getProductId() == productId) {
176 product.setTStart(range.m_TStart);
177 product.setTEnd(range.m_TEnd);
178 }
179 }
180 event->setEventProducts(productList);
181 sqpApp->catalogueController().updateEvent(event);
182 ui->events->refreshEvent(event);
183 ui->events->setEventChanges(event, true);
184 ui->inspector->refresh();
185 });
186
187 impl->m_Conn = connect(selectionZone, &VisualizationSelectionZoneItem::destroyed,
188 [event, selectionZone, this]() {
189 if (!impl->m_SelectionZonesPerEvents.empty()) {
190 impl->m_SelectionZonesPerEvents[event].removeAll(selectionZone);
191 }
192 });
193 }
General Comments 0
You need to be logged in to leave comments. Login now