##// END OF EJS Templates
Link with selection zone on event creation
trabillard -
r1348:eede5e75e31f
parent child
Show More
@@ -12,6 +12,10 class CatalogueEventsWidget;
12 12 class CatalogueSideBarWidget;
13 13
14 14 class VisualizationWidget;
15 class VisualizationSelectionZoneItem;
16
17 class DBEvent;
18
15 19
16 20 class CatalogueExplorer : public QDialog {
17 21 Q_OBJECT
@@ -25,6 +29,10 public:
25 29 CatalogueEventsWidget &eventsWidget() const;
26 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 36 private:
29 37 Ui::CatalogueExplorer *ui;
30 38
@@ -48,14 +48,18 struct CatalogueActionManager::CatalogueActionManagerPrivate {
48 48 auto eventProduct = std::make_shared<DBEventProduct>();
49 49 eventProduct->setEvent(*event);
50 50
51 auto productId
52 = var->metadata().value(DataSourceItem::ID_DATA_KEY, "UnknownID").toString();
53
51 54 auto zoneRange = zone->range();
52 55 eventProduct->setTStart(zoneRange.m_TStart);
53 56 eventProduct->setTEnd(zoneRange.m_TEnd);
54 57
55 eventProduct->setProductId(
56 var->metadata().value(DataSourceItem::ID_DATA_KEY, "UnknownID").toString());
58 eventProduct->setProductId(productId);
57 59
58 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 19 std::unordered_map<std::shared_ptr<DBEvent>, QVector<VisualizationSelectionZoneItem *> >
20 20 m_SelectionZonesPerEvents;
21 21
22 QMetaObject::Connection m_Conn;
23
22 24 CatalogueExplorerPrivate(CatalogueExplorer *catalogueExplorer)
23 25 : m_ActionManager(catalogueExplorer)
24 26 {
@@ -100,22 +102,7 CatalogueExplorer::CatalogueExplorer(QWidget *parent)
100 102 // Manage Selection Zones associated to events
101 103 connect(ui->events, &CatalogueEventsWidget::selectionZoneAdded,
102 104 [this](auto event, auto productId, auto zone) {
103 impl->m_SelectionZonesPerEvents[event] << 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 });
105 this->addSelectionZoneItem(event, productId, zone);
119 106 });
120 107
121 108 connect(ui->events, &CatalogueEventsWidget::eventsRemoved, [this](auto events) {
@@ -152,6 +139,7 CatalogueExplorer::CatalogueExplorer(QWidget *parent)
152 139
153 140 CatalogueExplorer::~CatalogueExplorer()
154 141 {
142 disconnect(impl->m_Conn);
155 143 delete ui;
156 144 }
157 145
@@ -169,3 +157,37 CatalogueSideBarWidget &CatalogueExplorer::sideBarWidget() const
169 157 {
170 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