##// END OF EJS Templates
Link with selection zone on event creation
trabillard -
r1294:eede5e75e31f
parent child
Show More
@@ -1,35 +1,43
1 #ifndef SCIQLOP_CATALOGUEEXPLORER_H
1 #ifndef SCIQLOP_CATALOGUEEXPLORER_H
2 #define SCIQLOP_CATALOGUEEXPLORER_H
2 #define SCIQLOP_CATALOGUEEXPLORER_H
3
3
4 #include <Common/spimpl.h>
4 #include <Common/spimpl.h>
5 #include <QDialog>
5 #include <QDialog>
6
6
7 namespace Ui {
7 namespace Ui {
8 class CatalogueExplorer;
8 class CatalogueExplorer;
9 }
9 }
10
10
11 class CatalogueEventsWidget;
11 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
18
22
19 public:
23 public:
20 explicit CatalogueExplorer(QWidget *parent = 0);
24 explicit CatalogueExplorer(QWidget *parent = 0);
21 virtual ~CatalogueExplorer();
25 virtual ~CatalogueExplorer();
22
26
23 void setVisualizationWidget(VisualizationWidget *visualization);
27 void setVisualizationWidget(VisualizationWidget *visualization);
24
28
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
31 class CatalogueExplorerPrivate;
39 class CatalogueExplorerPrivate;
32 spimpl::unique_impl_ptr<CatalogueExplorerPrivate> impl;
40 spimpl::unique_impl_ptr<CatalogueExplorerPrivate> impl;
33 };
41 };
34
42
35 #endif // SCIQLOP_CATALOGUEEXPLORER_H
43 #endif // SCIQLOP_CATALOGUEEXPLORER_H
@@ -1,143 +1,147
1 #include "Catalogue/CatalogueActionManager.h"
1 #include "Catalogue/CatalogueActionManager.h"
2
2
3 #include <Actions/ActionsGuiController.h>
3 #include <Actions/ActionsGuiController.h>
4 #include <Catalogue/CatalogueController.h>
4 #include <Catalogue/CatalogueController.h>
5 #include <DataSource/DataSourceItem.h>
5 #include <DataSource/DataSourceItem.h>
6 #include <SqpApplication.h>
6 #include <SqpApplication.h>
7 #include <Variable/Variable.h>
7 #include <Variable/Variable.h>
8 #include <Visualization/VisualizationGraphWidget.h>
8 #include <Visualization/VisualizationGraphWidget.h>
9 #include <Visualization/VisualizationSelectionZoneItem.h>
9 #include <Visualization/VisualizationSelectionZoneItem.h>
10
10
11 #include <Catalogue/CatalogueEventsWidget.h>
11 #include <Catalogue/CatalogueEventsWidget.h>
12 #include <Catalogue/CatalogueExplorer.h>
12 #include <Catalogue/CatalogueExplorer.h>
13 #include <Catalogue/CatalogueSideBarWidget.h>
13 #include <Catalogue/CatalogueSideBarWidget.h>
14 #include <Catalogue/CreateEventDialog.h>
14 #include <Catalogue/CreateEventDialog.h>
15
15
16 #include <CatalogueDao.h>
16 #include <CatalogueDao.h>
17 #include <DBCatalogue.h>
17 #include <DBCatalogue.h>
18 #include <DBEvent.h>
18 #include <DBEvent.h>
19 #include <DBEventProduct.h>
19 #include <DBEventProduct.h>
20
20
21 #include <QBoxLayout>
21 #include <QBoxLayout>
22 #include <QComboBox>
22 #include <QComboBox>
23 #include <QDialog>
23 #include <QDialog>
24 #include <QDialogButtonBox>
24 #include <QDialogButtonBox>
25 #include <QLineEdit>
25 #include <QLineEdit>
26 #include <memory>
26 #include <memory>
27
27
28 struct CatalogueActionManager::CatalogueActionManagerPrivate {
28 struct CatalogueActionManager::CatalogueActionManagerPrivate {
29
29
30 CatalogueExplorer *m_CatalogueExplorer = nullptr;
30 CatalogueExplorer *m_CatalogueExplorer = nullptr;
31
31
32 CatalogueActionManagerPrivate(CatalogueExplorer *catalogueExplorer)
32 CatalogueActionManagerPrivate(CatalogueExplorer *catalogueExplorer)
33 : m_CatalogueExplorer(catalogueExplorer)
33 : m_CatalogueExplorer(catalogueExplorer)
34 {
34 {
35 }
35 }
36
36
37 void createEventFromZones(const QString &eventName,
37 void createEventFromZones(const QString &eventName,
38 const QVector<VisualizationSelectionZoneItem *> &zones,
38 const QVector<VisualizationSelectionZoneItem *> &zones,
39 const std::shared_ptr<DBCatalogue> &catalogue = nullptr)
39 const std::shared_ptr<DBCatalogue> &catalogue = nullptr)
40 {
40 {
41 auto event = std::make_shared<DBEvent>();
41 auto event = std::make_shared<DBEvent>();
42 event->setName(eventName);
42 event->setName(eventName);
43
43
44 std::list<DBEventProduct> productList;
44 std::list<DBEventProduct> productList;
45 for (auto zone : zones) {
45 for (auto zone : zones) {
46 auto graph = zone->parentGraphWidget();
46 auto graph = zone->parentGraphWidget();
47 for (auto var : graph->variables()) {
47 for (auto var : graph->variables()) {
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
62 event->setEventProducts(productList);
66 event->setEventProducts(productList);
63
67
64 sqpApp->catalogueController().addEvent(event);
68 sqpApp->catalogueController().addEvent(event);
65
69
66
70
67 if (catalogue) {
71 if (catalogue) {
68 // TODO
72 // TODO
69 // catalogue->addEvent(event);
73 // catalogue->addEvent(event);
70 m_CatalogueExplorer->sideBarWidget().setCatalogueChanges(catalogue, true);
74 m_CatalogueExplorer->sideBarWidget().setCatalogueChanges(catalogue, true);
71 if (m_CatalogueExplorer->eventsWidget().displayedCatalogues().contains(catalogue)) {
75 if (m_CatalogueExplorer->eventsWidget().displayedCatalogues().contains(catalogue)) {
72 m_CatalogueExplorer->eventsWidget().addEvent(event);
76 m_CatalogueExplorer->eventsWidget().addEvent(event);
73 m_CatalogueExplorer->eventsWidget().setEventChanges(event, true);
77 m_CatalogueExplorer->eventsWidget().setEventChanges(event, true);
74 }
78 }
75 }
79 }
76 else if (m_CatalogueExplorer->eventsWidget().isAllEventsDisplayed()) {
80 else if (m_CatalogueExplorer->eventsWidget().isAllEventsDisplayed()) {
77 m_CatalogueExplorer->eventsWidget().addEvent(event);
81 m_CatalogueExplorer->eventsWidget().addEvent(event);
78 m_CatalogueExplorer->eventsWidget().setEventChanges(event, true);
82 m_CatalogueExplorer->eventsWidget().setEventChanges(event, true);
79 }
83 }
80 }
84 }
81 };
85 };
82
86
83 CatalogueActionManager::CatalogueActionManager(CatalogueExplorer *catalogueExplorer)
87 CatalogueActionManager::CatalogueActionManager(CatalogueExplorer *catalogueExplorer)
84 : impl{spimpl::make_unique_impl<CatalogueActionManagerPrivate>(catalogueExplorer)}
88 : impl{spimpl::make_unique_impl<CatalogueActionManagerPrivate>(catalogueExplorer)}
85 {
89 {
86 }
90 }
87
91
88 void CatalogueActionManager::installSelectionZoneActions()
92 void CatalogueActionManager::installSelectionZoneActions()
89 {
93 {
90 auto &actionController = sqpApp->actionsGuiController();
94 auto &actionController = sqpApp->actionsGuiController();
91
95
92 auto createEventEnableFuntion = [](auto zones) {
96 auto createEventEnableFuntion = [](auto zones) {
93
97
94 // Checks that all variables in the zones doesn't refer to the same product
98 // Checks that all variables in the zones doesn't refer to the same product
95 QSet<QString> usedDatasource;
99 QSet<QString> usedDatasource;
96 for (auto zone : zones) {
100 for (auto zone : zones) {
97 auto graph = zone->parentGraphWidget();
101 auto graph = zone->parentGraphWidget();
98 auto variables = graph->variables();
102 auto variables = graph->variables();
99
103
100 for (auto var : variables) {
104 for (auto var : variables) {
101 auto datasourceId = var->metadata().value(DataSourceItem::ID_DATA_KEY).toString();
105 auto datasourceId = var->metadata().value(DataSourceItem::ID_DATA_KEY).toString();
102 if (!usedDatasource.contains(datasourceId)) {
106 if (!usedDatasource.contains(datasourceId)) {
103 usedDatasource.insert(datasourceId);
107 usedDatasource.insert(datasourceId);
104 }
108 }
105 else {
109 else {
106 return false;
110 return false;
107 }
111 }
108 }
112 }
109 }
113 }
110
114
111 return true;
115 return true;
112 };
116 };
113
117
114 auto createEventAction = actionController.addSectionZoneAction(
118 auto createEventAction = actionController.addSectionZoneAction(
115 {QObject::tr("Catalogues")}, QObject::tr("New Event..."), [this](auto zones) {
119 {QObject::tr("Catalogues")}, QObject::tr("New Event..."), [this](auto zones) {
116 CreateEventDialog dialog(
120 CreateEventDialog dialog(
117 impl->m_CatalogueExplorer->sideBarWidget().getCatalogues(REPOSITORY_DEFAULT));
121 impl->m_CatalogueExplorer->sideBarWidget().getCatalogues(REPOSITORY_DEFAULT));
118 dialog.hideCatalogueChoice();
122 dialog.hideCatalogueChoice();
119 if (dialog.exec() == QDialog::Accepted) {
123 if (dialog.exec() == QDialog::Accepted) {
120 impl->createEventFromZones(dialog.eventName(), zones);
124 impl->createEventFromZones(dialog.eventName(), zones);
121 }
125 }
122 });
126 });
123 createEventAction->setEnableFunction(createEventEnableFuntion);
127 createEventAction->setEnableFunction(createEventEnableFuntion);
124
128
125 auto createEventInCatalogueAction = actionController.addSectionZoneAction(
129 auto createEventInCatalogueAction = actionController.addSectionZoneAction(
126 {QObject::tr("Catalogues")}, QObject::tr("New Event in Catalogue..."), [this](auto zones) {
130 {QObject::tr("Catalogues")}, QObject::tr("New Event in Catalogue..."), [this](auto zones) {
127 CreateEventDialog dialog(
131 CreateEventDialog dialog(
128 impl->m_CatalogueExplorer->sideBarWidget().getCatalogues(REPOSITORY_DEFAULT));
132 impl->m_CatalogueExplorer->sideBarWidget().getCatalogues(REPOSITORY_DEFAULT));
129 if (dialog.exec() == QDialog::Accepted) {
133 if (dialog.exec() == QDialog::Accepted) {
130 auto selectedCatalogue = dialog.selectedCatalogue();
134 auto selectedCatalogue = dialog.selectedCatalogue();
131 if (!selectedCatalogue) {
135 if (!selectedCatalogue) {
132 selectedCatalogue = std::make_shared<DBCatalogue>();
136 selectedCatalogue = std::make_shared<DBCatalogue>();
133 selectedCatalogue->setName(dialog.catalogueName());
137 selectedCatalogue->setName(dialog.catalogueName());
134 // sqpApp->catalogueController().addCatalogue(selectedCatalogue); TODO
138 // sqpApp->catalogueController().addCatalogue(selectedCatalogue); TODO
135 impl->m_CatalogueExplorer->sideBarWidget().addCatalogue(selectedCatalogue,
139 impl->m_CatalogueExplorer->sideBarWidget().addCatalogue(selectedCatalogue,
136 REPOSITORY_DEFAULT);
140 REPOSITORY_DEFAULT);
137 }
141 }
138
142
139 impl->createEventFromZones(dialog.eventName(), zones, selectedCatalogue);
143 impl->createEventFromZones(dialog.eventName(), zones, selectedCatalogue);
140 }
144 }
141 });
145 });
142 createEventInCatalogueAction->setEnableFunction(createEventEnableFuntion);
146 createEventInCatalogueAction->setEnableFunction(createEventEnableFuntion);
143 }
147 }
@@ -1,171 +1,193
1 #include "Catalogue/CatalogueExplorer.h"
1 #include "Catalogue/CatalogueExplorer.h"
2 #include "ui_CatalogueExplorer.h"
2 #include "ui_CatalogueExplorer.h"
3
3
4 #include <Catalogue/CatalogueActionManager.h>
4 #include <Catalogue/CatalogueActionManager.h>
5 #include <Catalogue/CatalogueController.h>
5 #include <Catalogue/CatalogueController.h>
6 #include <SqpApplication.h>
6 #include <SqpApplication.h>
7 #include <Visualization/VisualizationGraphWidget.h>
7 #include <Visualization/VisualizationGraphWidget.h>
8 #include <Visualization/VisualizationSelectionZoneItem.h>
8 #include <Visualization/VisualizationSelectionZoneItem.h>
9 #include <Visualization/VisualizationWidget.h>
9 #include <Visualization/VisualizationWidget.h>
10
10
11 #include <DBCatalogue.h>
11 #include <DBCatalogue.h>
12 #include <DBEvent.h>
12 #include <DBEvent.h>
13 #include <DBEventProduct.h>
13 #include <DBEventProduct.h>
14
14
15 #include <unordered_map>
15 #include <unordered_map>
16
16
17 struct CatalogueExplorer::CatalogueExplorerPrivate {
17 struct CatalogueExplorer::CatalogueExplorerPrivate {
18 CatalogueActionManager m_ActionManager;
18 CatalogueActionManager m_ActionManager;
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 {
25 }
27 }
26 };
28 };
27
29
28 CatalogueExplorer::CatalogueExplorer(QWidget *parent)
30 CatalogueExplorer::CatalogueExplorer(QWidget *parent)
29 : QDialog(parent, Qt::Dialog | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint),
31 : QDialog(parent, Qt::Dialog | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint),
30 ui(new Ui::CatalogueExplorer),
32 ui(new Ui::CatalogueExplorer),
31 impl{spimpl::make_unique_impl<CatalogueExplorerPrivate>(this)}
33 impl{spimpl::make_unique_impl<CatalogueExplorerPrivate>(this)}
32 {
34 {
33 ui->setupUi(this);
35 ui->setupUi(this);
34
36
35 impl->m_ActionManager.installSelectionZoneActions();
37 impl->m_ActionManager.installSelectionZoneActions();
36
38
37 // Updates events and inspector when something is selected in the catalogue widget
39 // Updates events and inspector when something is selected in the catalogue widget
38 connect(ui->catalogues, &CatalogueSideBarWidget::catalogueSelected, [this](auto catalogues) {
40 connect(ui->catalogues, &CatalogueSideBarWidget::catalogueSelected, [this](auto catalogues) {
39 if (catalogues.count() == 1) {
41 if (catalogues.count() == 1) {
40 ui->inspector->setCatalogue(catalogues.first());
42 ui->inspector->setCatalogue(catalogues.first());
41 }
43 }
42 else {
44 else {
43 ui->inspector->showPage(CatalogueInspectorWidget::Page::Empty);
45 ui->inspector->showPage(CatalogueInspectorWidget::Page::Empty);
44 }
46 }
45
47
46 ui->events->populateWithCatalogues(catalogues);
48 ui->events->populateWithCatalogues(catalogues);
47 });
49 });
48
50
49 connect(ui->catalogues, &CatalogueSideBarWidget::databaseSelected, [this](auto databases) {
51 connect(ui->catalogues, &CatalogueSideBarWidget::databaseSelected, [this](auto databases) {
50 ui->inspector->showPage(CatalogueInspectorWidget::Page::Empty);
52 ui->inspector->showPage(CatalogueInspectorWidget::Page::Empty);
51 });
53 });
52
54
53 connect(ui->catalogues, &CatalogueSideBarWidget::trashSelected, [this]() {
55 connect(ui->catalogues, &CatalogueSideBarWidget::trashSelected, [this]() {
54 ui->inspector->showPage(CatalogueInspectorWidget::Page::Empty);
56 ui->inspector->showPage(CatalogueInspectorWidget::Page::Empty);
55 ui->events->clear();
57 ui->events->clear();
56 });
58 });
57
59
58 connect(ui->catalogues, &CatalogueSideBarWidget::allEventsSelected, [this]() {
60 connect(ui->catalogues, &CatalogueSideBarWidget::allEventsSelected, [this]() {
59 ui->inspector->showPage(CatalogueInspectorWidget::Page::Empty);
61 ui->inspector->showPage(CatalogueInspectorWidget::Page::Empty);
60 ui->events->populateWithAllEvents();
62 ui->events->populateWithAllEvents();
61 });
63 });
62
64
63 connect(ui->catalogues, &CatalogueSideBarWidget::databaseSelected, [this](auto databaseList) {
65 connect(ui->catalogues, &CatalogueSideBarWidget::databaseSelected, [this](auto databaseList) {
64 QVector<std::shared_ptr<DBCatalogue> > catalogueList;
66 QVector<std::shared_ptr<DBCatalogue> > catalogueList;
65 for (auto database : databaseList) {
67 for (auto database : databaseList) {
66 catalogueList.append(ui->catalogues->getCatalogues(database));
68 catalogueList.append(ui->catalogues->getCatalogues(database));
67 }
69 }
68 ui->events->populateWithCatalogues(catalogueList);
70 ui->events->populateWithCatalogues(catalogueList);
69 ui->inspector->showPage(CatalogueInspectorWidget::Page::Empty);
71 ui->inspector->showPage(CatalogueInspectorWidget::Page::Empty);
70 });
72 });
71
73
72 connect(ui->catalogues, &CatalogueSideBarWidget::selectionCleared, [this]() {
74 connect(ui->catalogues, &CatalogueSideBarWidget::selectionCleared, [this]() {
73 ui->inspector->showPage(CatalogueInspectorWidget::Page::Empty);
75 ui->inspector->showPage(CatalogueInspectorWidget::Page::Empty);
74 ui->events->clear();
76 ui->events->clear();
75 });
77 });
76
78
77 // Updates the inspectot when something is selected in the events
79 // Updates the inspectot when something is selected in the events
78 connect(ui->events, &CatalogueEventsWidget::eventsSelected, [this](auto events) {
80 connect(ui->events, &CatalogueEventsWidget::eventsSelected, [this](auto events) {
79 if (events.count() == 1) {
81 if (events.count() == 1) {
80 ui->inspector->setEvent(events.first());
82 ui->inspector->setEvent(events.first());
81 }
83 }
82 else {
84 else {
83 ui->inspector->showPage(CatalogueInspectorWidget::Page::Empty);
85 ui->inspector->showPage(CatalogueInspectorWidget::Page::Empty);
84 }
86 }
85 });
87 });
86
88
87 connect(ui->events, &CatalogueEventsWidget::eventProductsSelected, [this](auto eventProducts) {
89 connect(ui->events, &CatalogueEventsWidget::eventProductsSelected, [this](auto eventProducts) {
88 if (eventProducts.count() == 1) {
90 if (eventProducts.count() == 1) {
89 ui->inspector->setEventProduct(eventProducts.first().first,
91 ui->inspector->setEventProduct(eventProducts.first().first,
90 eventProducts.first().second);
92 eventProducts.first().second);
91 }
93 }
92 else {
94 else {
93 ui->inspector->showPage(CatalogueInspectorWidget::Page::Empty);
95 ui->inspector->showPage(CatalogueInspectorWidget::Page::Empty);
94 }
96 }
95 });
97 });
96
98
97 connect(ui->events, &CatalogueEventsWidget::selectionCleared,
99 connect(ui->events, &CatalogueEventsWidget::selectionCleared,
98 [this]() { ui->inspector->showPage(CatalogueInspectorWidget::Page::Empty); });
100 [this]() { ui->inspector->showPage(CatalogueInspectorWidget::Page::Empty); });
99
101
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) {
122 for (auto event : events) {
109 for (auto event : events) {
123 auto associatedSelectionZonesIt = impl->m_SelectionZonesPerEvents.find(event);
110 auto associatedSelectionZonesIt = impl->m_SelectionZonesPerEvents.find(event);
124 if (associatedSelectionZonesIt != impl->m_SelectionZonesPerEvents.cend()) {
111 if (associatedSelectionZonesIt != impl->m_SelectionZonesPerEvents.cend()) {
125 for (auto selectionZone : associatedSelectionZonesIt->second) {
112 for (auto selectionZone : associatedSelectionZonesIt->second) {
126 auto parentGraph = selectionZone->parentGraphWidget();
113 auto parentGraph = selectionZone->parentGraphWidget();
127 parentGraph->removeSelectionZone(selectionZone);
114 parentGraph->removeSelectionZone(selectionZone);
128 }
115 }
129
116
130 impl->m_SelectionZonesPerEvents.erase(event);
117 impl->m_SelectionZonesPerEvents.erase(event);
131 }
118 }
132 }
119 }
133 });
120 });
134
121
135 // Updates changes from the inspector
122 // Updates changes from the inspector
136 connect(ui->inspector, &CatalogueInspectorWidget::catalogueUpdated, [this](auto catalogue) {
123 connect(ui->inspector, &CatalogueInspectorWidget::catalogueUpdated, [this](auto catalogue) {
137 sqpApp->catalogueController().updateCatalogue(catalogue);
124 sqpApp->catalogueController().updateCatalogue(catalogue);
138 ui->catalogues->setCatalogueChanges(catalogue, true);
125 ui->catalogues->setCatalogueChanges(catalogue, true);
139 });
126 });
140
127
141 connect(ui->inspector, &CatalogueInspectorWidget::eventUpdated, [this](auto event) {
128 connect(ui->inspector, &CatalogueInspectorWidget::eventUpdated, [this](auto event) {
142 sqpApp->catalogueController().updateEvent(event);
129 sqpApp->catalogueController().updateEvent(event);
143 ui->events->setEventChanges(event, true);
130 ui->events->setEventChanges(event, true);
144 });
131 });
145
132
146 connect(ui->inspector, &CatalogueInspectorWidget::eventProductUpdated,
133 connect(ui->inspector, &CatalogueInspectorWidget::eventProductUpdated,
147 [this](auto event, auto eventProduct) {
134 [this](auto event, auto eventProduct) {
148 sqpApp->catalogueController().updateEventProduct(eventProduct);
135 sqpApp->catalogueController().updateEventProduct(eventProduct);
149 ui->events->setEventChanges(event, true);
136 ui->events->setEventChanges(event, true);
150 });
137 });
151 }
138 }
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
158 void CatalogueExplorer::setVisualizationWidget(VisualizationWidget *visualization)
146 void CatalogueExplorer::setVisualizationWidget(VisualizationWidget *visualization)
159 {
147 {
160 ui->events->setVisualizationWidget(visualization);
148 ui->events->setVisualizationWidget(visualization);
161 }
149 }
162
150
163 CatalogueEventsWidget &CatalogueExplorer::eventsWidget() const
151 CatalogueEventsWidget &CatalogueExplorer::eventsWidget() const
164 {
152 {
165 return *ui->events;
153 return *ui->events;
166 }
154 }
167
155
168 CatalogueSideBarWidget &CatalogueExplorer::sideBarWidget() const
156 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