@@ -3,9 +3,11 | |||||
3 |
|
3 | |||
4 | #include <Common/spimpl.h> |
|
4 | #include <Common/spimpl.h> | |
5 |
|
5 | |||
|
6 | class CatalogueExplorer; | |||
|
7 | ||||
6 | class CatalogueActionManager { |
|
8 | class CatalogueActionManager { | |
7 | public: |
|
9 | public: | |
8 | CatalogueActionManager(); |
|
10 | CatalogueActionManager(CatalogueExplorer *catalogueExplorer); | |
9 |
|
11 | |||
10 | void installSelectionZoneActions(); |
|
12 | void installSelectionZoneActions(); | |
11 |
|
13 |
@@ -32,11 +32,17 public: | |||||
32 |
|
32 | |||
33 | void setVisualizationWidget(VisualizationWidget *visualization); |
|
33 | void setVisualizationWidget(VisualizationWidget *visualization); | |
34 |
|
34 | |||
|
35 | void addEvent(const std::shared_ptr<DBEvent> &event); | |||
35 | void setEventChanges(const std::shared_ptr<DBEvent> &event, bool hasChanges); |
|
36 | void setEventChanges(const std::shared_ptr<DBEvent> &event, bool hasChanges); | |
36 |
|
37 | |||
|
38 | QVector<std::shared_ptr<DBCatalogue> > displayedCatalogues() const; | |||
|
39 | bool isAllEventsDisplayed() const; | |||
|
40 | bool isEventDisplayed(const std::shared_ptr<DBEvent> &event) const; | |||
|
41 | ||||
37 | public slots: |
|
42 | public slots: | |
38 | void populateWithCatalogues(const QVector<std::shared_ptr<DBCatalogue> > &catalogues); |
|
43 | void populateWithCatalogues(const QVector<std::shared_ptr<DBCatalogue> > &catalogues); | |
39 | void populateWithAllEvents(); |
|
44 | void populateWithAllEvents(); | |
|
45 | void refresh(); | |||
40 |
|
46 | |||
41 | private: |
|
47 | private: | |
42 | Ui::CatalogueEventsWidget *ui; |
|
48 | Ui::CatalogueEventsWidget *ui; |
@@ -8,6 +8,9 namespace Ui { | |||||
8 | class CatalogueExplorer; |
|
8 | class CatalogueExplorer; | |
9 | } |
|
9 | } | |
10 |
|
10 | |||
|
11 | class CatalogueEventsWidget; | |||
|
12 | class CatalogueSideBarWidget; | |||
|
13 | ||||
11 | class VisualizationWidget; |
|
14 | class VisualizationWidget; | |
12 |
|
15 | |||
13 | class CatalogueExplorer : public QDialog { |
|
16 | class CatalogueExplorer : public QDialog { | |
@@ -19,6 +22,9 public: | |||||
19 |
|
22 | |||
20 | void setVisualizationWidget(VisualizationWidget *visualization); |
|
23 | void setVisualizationWidget(VisualizationWidget *visualization); | |
21 |
|
24 | |||
|
25 | CatalogueEventsWidget &eventsWidget() const; | |||
|
26 | CatalogueSideBarWidget &sideBarWidget() const; | |||
|
27 | ||||
22 | private: |
|
28 | private: | |
23 | Ui::CatalogueExplorer *ui; |
|
29 | Ui::CatalogueExplorer *ui; | |
24 |
|
30 |
@@ -28,8 +28,11 public: | |||||
28 | explicit CatalogueSideBarWidget(QWidget *parent = 0); |
|
28 | explicit CatalogueSideBarWidget(QWidget *parent = 0); | |
29 | virtual ~CatalogueSideBarWidget(); |
|
29 | virtual ~CatalogueSideBarWidget(); | |
30 |
|
30 | |||
|
31 | void addCatalogue(const std::shared_ptr<DBCatalogue> &catalogue, const QString &repository); | |||
31 | void setCatalogueChanges(const std::shared_ptr<DBCatalogue> &catalogue, bool hasChanges); |
|
32 | void setCatalogueChanges(const std::shared_ptr<DBCatalogue> &catalogue, bool hasChanges); | |
32 |
|
33 | |||
|
34 | QVector<std::shared_ptr<DBCatalogue> > getCatalogues(const QString &repository) const; | |||
|
35 | ||||
33 | private: |
|
36 | private: | |
34 | Ui::CatalogueSideBarWidget *ui; |
|
37 | Ui::CatalogueSideBarWidget *ui; | |
35 |
|
38 |
@@ -15,7 +15,8 class CreateEventDialog : public QDialog { | |||||
15 | Q_OBJECT |
|
15 | Q_OBJECT | |
16 |
|
16 | |||
17 | public: |
|
17 | public: | |
18 | explicit CreateEventDialog(QWidget *parent = 0); |
|
18 | explicit CreateEventDialog(const QVector<std::shared_ptr<DBCatalogue> > &catalogues, | |
|
19 | QWidget *parent = 0); | |||
19 | virtual ~CreateEventDialog(); |
|
20 | virtual ~CreateEventDialog(); | |
20 |
|
21 | |||
21 | void hideCatalogueChoice(); |
|
22 | void hideCatalogueChoice(); |
@@ -7,6 +7,9 | |||||
7 | #include <Visualization/VisualizationGraphWidget.h> |
|
7 | #include <Visualization/VisualizationGraphWidget.h> | |
8 | #include <Visualization/VisualizationSelectionZoneItem.h> |
|
8 | #include <Visualization/VisualizationSelectionZoneItem.h> | |
9 |
|
9 | |||
|
10 | #include <Catalogue/CatalogueEventsWidget.h> | |||
|
11 | #include <Catalogue/CatalogueExplorer.h> | |||
|
12 | #include <Catalogue/CatalogueSideBarWidget.h> | |||
10 | #include <Catalogue/CreateEventDialog.h> |
|
13 | #include <Catalogue/CreateEventDialog.h> | |
11 |
|
14 | |||
12 | #include <DBCatalogue.h> |
|
15 | #include <DBCatalogue.h> | |
@@ -21,6 +24,14 | |||||
21 | #include <memory> |
|
24 | #include <memory> | |
22 |
|
25 | |||
23 | struct CatalogueActionManager::CatalogueActionManagerPrivate { |
|
26 | struct CatalogueActionManager::CatalogueActionManagerPrivate { | |
|
27 | ||||
|
28 | CatalogueExplorer *m_CatalogueExplorer = nullptr; | |||
|
29 | ||||
|
30 | CatalogueActionManagerPrivate(CatalogueExplorer *catalogueExplorer) | |||
|
31 | : m_CatalogueExplorer(catalogueExplorer) | |||
|
32 | { | |||
|
33 | } | |||
|
34 | ||||
24 | void createEventFromZones(const QString &eventName, |
|
35 | void createEventFromZones(const QString &eventName, | |
25 | const QVector<VisualizationSelectionZoneItem *> &zones, |
|
36 | const QVector<VisualizationSelectionZoneItem *> &zones, | |
26 | const std::shared_ptr<DBCatalogue> &catalogue = nullptr) |
|
37 | const std::shared_ptr<DBCatalogue> &catalogue = nullptr) | |
@@ -49,15 +60,25 struct CatalogueActionManager::CatalogueActionManagerPrivate { | |||||
49 |
|
60 | |||
50 | sqpApp->catalogueController().addEvent(event); |
|
61 | sqpApp->catalogueController().addEvent(event); | |
51 |
|
62 | |||
|
63 | ||||
52 | if (catalogue) { |
|
64 | if (catalogue) { | |
53 | // TODO |
|
65 | // TODO | |
54 | // catalogue->addEvent(event); |
|
66 | // catalogue->addEvent(event); | |
|
67 | m_CatalogueExplorer->sideBarWidget().setCatalogueChanges(catalogue, true); | |||
|
68 | if (m_CatalogueExplorer->eventsWidget().displayedCatalogues().contains(catalogue)) { | |||
|
69 | m_CatalogueExplorer->eventsWidget().addEvent(event); | |||
|
70 | m_CatalogueExplorer->eventsWidget().setEventChanges(event, true); | |||
|
71 | } | |||
|
72 | } | |||
|
73 | else if (m_CatalogueExplorer->eventsWidget().isAllEventsDisplayed()) { | |||
|
74 | m_CatalogueExplorer->eventsWidget().addEvent(event); | |||
|
75 | m_CatalogueExplorer->eventsWidget().setEventChanges(event, true); | |||
55 | } |
|
76 | } | |
56 | } |
|
77 | } | |
57 | }; |
|
78 | }; | |
58 |
|
79 | |||
59 | CatalogueActionManager::CatalogueActionManager() |
|
80 | CatalogueActionManager::CatalogueActionManager(CatalogueExplorer *catalogueExplorer) | |
60 | : impl{spimpl::make_unique_impl<CatalogueActionManagerPrivate>()} |
|
81 | : impl{spimpl::make_unique_impl<CatalogueActionManagerPrivate>(catalogueExplorer)} | |
61 | { |
|
82 | { | |
62 | } |
|
83 | } | |
63 |
|
84 | |||
@@ -82,7 +103,8 void CatalogueActionManager::installSelectionZoneActions() | |||||
82 |
|
103 | |||
83 | auto createEventAction = actionController.addSectionZoneAction( |
|
104 | auto createEventAction = actionController.addSectionZoneAction( | |
84 | {QObject::tr("Catalogues")}, QObject::tr("New Event..."), [this](auto zones) { |
|
105 | {QObject::tr("Catalogues")}, QObject::tr("New Event..."), [this](auto zones) { | |
85 |
CreateEventDialog dialog |
|
106 | CreateEventDialog dialog( | |
|
107 | impl->m_CatalogueExplorer->sideBarWidget().getCatalogues("Default")); | |||
86 | dialog.hideCatalogueChoice(); |
|
108 | dialog.hideCatalogueChoice(); | |
87 | if (dialog.exec() == QDialog::Accepted) { |
|
109 | if (dialog.exec() == QDialog::Accepted) { | |
88 | impl->createEventFromZones(dialog.eventName(), zones); |
|
110 | impl->createEventFromZones(dialog.eventName(), zones); | |
@@ -92,12 +114,16 void CatalogueActionManager::installSelectionZoneActions() | |||||
92 |
|
114 | |||
93 | auto createEventInCatalogueAction = actionController.addSectionZoneAction( |
|
115 | auto createEventInCatalogueAction = actionController.addSectionZoneAction( | |
94 | {QObject::tr("Catalogues")}, QObject::tr("New Event in Catalogue..."), [this](auto zones) { |
|
116 | {QObject::tr("Catalogues")}, QObject::tr("New Event in Catalogue..."), [this](auto zones) { | |
95 |
CreateEventDialog dialog |
|
117 | CreateEventDialog dialog( | |
|
118 | impl->m_CatalogueExplorer->sideBarWidget().getCatalogues("Default")); | |||
96 | if (dialog.exec() == QDialog::Accepted) { |
|
119 | if (dialog.exec() == QDialog::Accepted) { | |
97 | auto selectedCatalogue = dialog.selectedCatalogue(); |
|
120 | auto selectedCatalogue = dialog.selectedCatalogue(); | |
98 | if (!selectedCatalogue) { |
|
121 | if (!selectedCatalogue) { | |
99 | selectedCatalogue = std::make_shared<DBCatalogue>(); |
|
122 | selectedCatalogue = std::make_shared<DBCatalogue>(); | |
100 | selectedCatalogue->setName(dialog.catalogueName()); |
|
123 | selectedCatalogue->setName(dialog.catalogueName()); | |
|
124 | // sqpApp->catalogueController().addCatalogue(selectedCatalogue); TODO | |||
|
125 | impl->m_CatalogueExplorer->sideBarWidget().addCatalogue(selectedCatalogue, | |||
|
126 | "Default"); | |||
101 | } |
|
127 | } | |
102 |
|
128 | |||
103 | impl->createEventFromZones(dialog.eventName(), zones, selectedCatalogue); |
|
129 | impl->createEventFromZones(dialog.eventName(), zones, selectedCatalogue); |
@@ -25,6 +25,7 struct CatalogueEventsWidget::CatalogueEventsWidgetPrivate { | |||||
25 | CatalogueEventsModel *m_Model = nullptr; |
|
25 | CatalogueEventsModel *m_Model = nullptr; | |
26 | QStringList m_ZonesForTimeMode; |
|
26 | QStringList m_ZonesForTimeMode; | |
27 | QString m_ZoneForGraphMode; |
|
27 | QString m_ZoneForGraphMode; | |
|
28 | QVector<std::shared_ptr<DBCatalogue> > m_DisplayedCatalogues; | |||
28 |
|
29 | |||
29 | VisualizationWidget *m_VisualizationWidget = nullptr; |
|
30 | VisualizationWidget *m_VisualizationWidget = nullptr; | |
30 |
|
31 | |||
@@ -304,6 +305,11 void CatalogueEventsWidget::setVisualizationWidget(VisualizationWidget *visualiz | |||||
304 | impl->m_VisualizationWidget = visualization; |
|
305 | impl->m_VisualizationWidget = visualization; | |
305 | } |
|
306 | } | |
306 |
|
307 | |||
|
308 | void CatalogueEventsWidget::addEvent(const std::shared_ptr<DBEvent> &event) | |||
|
309 | { | |||
|
310 | impl->addEvent(event, ui->treeView); | |||
|
311 | } | |||
|
312 | ||||
307 | void CatalogueEventsWidget::setEventChanges(const std::shared_ptr<DBEvent> &event, bool hasChanges) |
|
313 | void CatalogueEventsWidget::setEventChanges(const std::shared_ptr<DBEvent> &event, bool hasChanges) | |
308 | { |
|
314 | { | |
309 | impl->m_Model->refreshEvent(event); |
|
315 | impl->m_Model->refreshEvent(event); | |
@@ -323,18 +329,35 void CatalogueEventsWidget::setEventChanges(const std::shared_ptr<DBEvent> &even | |||||
323 | [this, event]() { setEventChanges(event, false); }); |
|
329 | [this, event]() { setEventChanges(event, false); }); | |
324 | ui->treeView->setIndexWidget(validationIndex, widget); |
|
330 | ui->treeView->setIndexWidget(validationIndex, widget); | |
325 | } |
|
331 | } | |
|
332 | ||||
|
333 | impl->m_Model->setEventHasChanges(event, hasChanges); | |||
326 | } |
|
334 | } | |
327 | else { |
|
335 | else { | |
328 | // Note: the widget is destroyed |
|
336 | qCWarning(LOG_CatalogueEventsWidget()) | |
329 | ui->treeView->setIndexWidget(validationIndex, nullptr); |
|
337 | << "setEventChanges: the event is not displayed in the model."; | |
|
338 | } | |||
330 | } |
|
339 | } | |
331 |
|
340 | |||
332 | impl->m_Model->setEventHasChanges(event, hasChanges); |
|
341 | QVector<std::shared_ptr<DBCatalogue> > CatalogueEventsWidget::displayedCatalogues() const | |
|
342 | { | |||
|
343 | return impl->m_DisplayedCatalogues; | |||
|
344 | } | |||
|
345 | ||||
|
346 | bool CatalogueEventsWidget::isAllEventsDisplayed() const | |||
|
347 | { | |||
|
348 | return impl->m_DisplayedCatalogues.isEmpty(); | |||
|
349 | } | |||
|
350 | ||||
|
351 | bool CatalogueEventsWidget::isEventDisplayed(const std::shared_ptr<DBEvent> &event) const | |||
|
352 | { | |||
|
353 | return impl->m_Model->indexOf(event).isValid(); | |||
333 | } |
|
354 | } | |
334 |
|
355 | |||
335 | void CatalogueEventsWidget::populateWithCatalogues( |
|
356 | void CatalogueEventsWidget::populateWithCatalogues( | |
336 | const QVector<std::shared_ptr<DBCatalogue> > &catalogues) |
|
357 | const QVector<std::shared_ptr<DBCatalogue> > &catalogues) | |
337 | { |
|
358 | { | |
|
359 | impl->m_DisplayedCatalogues = catalogues; | |||
|
360 | ||||
338 | QSet<QUuid> eventIds; |
|
361 | QSet<QUuid> eventIds; | |
339 | QVector<std::shared_ptr<DBEvent> > events; |
|
362 | QVector<std::shared_ptr<DBEvent> > events; | |
340 |
|
363 | |||
@@ -353,6 +376,8 void CatalogueEventsWidget::populateWithCatalogues( | |||||
353 |
|
376 | |||
354 | void CatalogueEventsWidget::populateWithAllEvents() |
|
377 | void CatalogueEventsWidget::populateWithAllEvents() | |
355 | { |
|
378 | { | |
|
379 | impl->m_DisplayedCatalogues.clear(); | |||
|
380 | ||||
356 | auto allEvents = sqpApp->catalogueController().retrieveAllEvents(); |
|
381 | auto allEvents = sqpApp->catalogueController().retrieveAllEvents(); | |
357 |
|
382 | |||
358 | QVector<std::shared_ptr<DBEvent> > events; |
|
383 | QVector<std::shared_ptr<DBEvent> > events; | |
@@ -362,3 +387,13 void CatalogueEventsWidget::populateWithAllEvents() | |||||
362 |
|
387 | |||
363 | impl->setEvents(events, ui->treeView); |
|
388 | impl->setEvents(events, ui->treeView); | |
364 | } |
|
389 | } | |
|
390 | ||||
|
391 | void CatalogueEventsWidget::refresh() | |||
|
392 | { | |||
|
393 | if (impl->m_DisplayedCatalogues.isEmpty()) { | |||
|
394 | populateWithAllEvents(); | |||
|
395 | } | |||
|
396 | else { | |||
|
397 | populateWithCatalogues(impl->m_DisplayedCatalogues); | |||
|
398 | } | |||
|
399 | } |
@@ -11,12 +11,17 | |||||
11 |
|
11 | |||
12 | struct CatalogueExplorer::CatalogueExplorerPrivate { |
|
12 | struct CatalogueExplorer::CatalogueExplorerPrivate { | |
13 | CatalogueActionManager m_ActionManager; |
|
13 | CatalogueActionManager m_ActionManager; | |
|
14 | ||||
|
15 | CatalogueExplorerPrivate(CatalogueExplorer *catalogueExplorer) | |||
|
16 | : m_ActionManager(catalogueExplorer) | |||
|
17 | { | |||
|
18 | } | |||
14 | }; |
|
19 | }; | |
15 |
|
20 | |||
16 | CatalogueExplorer::CatalogueExplorer(QWidget *parent) |
|
21 | CatalogueExplorer::CatalogueExplorer(QWidget *parent) | |
17 | : QDialog(parent, Qt::Dialog | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint), |
|
22 | : QDialog(parent, Qt::Dialog | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint), | |
18 | ui(new Ui::CatalogueExplorer), |
|
23 | ui(new Ui::CatalogueExplorer), | |
19 | impl{spimpl::make_unique_impl<CatalogueExplorerPrivate>()} |
|
24 | impl{spimpl::make_unique_impl<CatalogueExplorerPrivate>(this)} | |
20 | { |
|
25 | { | |
21 | ui->setupUi(this); |
|
26 | ui->setupUi(this); | |
22 |
|
27 | |||
@@ -96,3 +101,13 void CatalogueExplorer::setVisualizationWidget(VisualizationWidget *visualizatio | |||||
96 | { |
|
101 | { | |
97 | ui->events->setVisualizationWidget(visualization); |
|
102 | ui->events->setVisualizationWidget(visualization); | |
98 | } |
|
103 | } | |
|
104 | ||||
|
105 | CatalogueEventsWidget &CatalogueExplorer::eventsWidget() const | |||
|
106 | { | |||
|
107 | return *ui->events; | |||
|
108 | } | |||
|
109 | ||||
|
110 | CatalogueSideBarWidget &CatalogueExplorer::sideBarWidget() const | |||
|
111 | { | |||
|
112 | return *ui->catalogues; | |||
|
113 | } |
@@ -154,6 +154,13 CatalogueSideBarWidget::~CatalogueSideBarWidget() | |||||
154 | delete ui; |
|
154 | delete ui; | |
155 | } |
|
155 | } | |
156 |
|
156 | |||
|
157 | void CatalogueSideBarWidget::addCatalogue(const std::shared_ptr<DBCatalogue> &catalogue, | |||
|
158 | const QString &repository) | |||
|
159 | { | |||
|
160 | auto repositoryItem = impl->getDatabaseItem(repository); | |||
|
161 | impl->addCatalogueItem(catalogue, impl->m_TreeModel->indexOf(repositoryItem)); | |||
|
162 | } | |||
|
163 | ||||
157 | void CatalogueSideBarWidget::setCatalogueChanges(const std::shared_ptr<DBCatalogue> &catalogue, |
|
164 | void CatalogueSideBarWidget::setCatalogueChanges(const std::shared_ptr<DBCatalogue> &catalogue, | |
158 | bool hasChanges) |
|
165 | bool hasChanges) | |
159 | { |
|
166 | { | |
@@ -164,6 +171,24 void CatalogueSideBarWidget::setCatalogueChanges(const std::shared_ptr<DBCatalog | |||||
164 | } |
|
171 | } | |
165 | } |
|
172 | } | |
166 |
|
173 | |||
|
174 | QVector<std::shared_ptr<DBCatalogue> > | |||
|
175 | CatalogueSideBarWidget::getCatalogues(const QString &repository) const | |||
|
176 | { | |||
|
177 | QVector<std::shared_ptr<DBCatalogue> > result; | |||
|
178 | auto repositoryItem = impl->getDatabaseItem(repository); | |||
|
179 | for (auto child : repositoryItem->children()) { | |||
|
180 | if (child->type() == CATALOGUE_ITEM_TYPE) { | |||
|
181 | auto catalogueItem = static_cast<CatalogueTreeItem *>(child); | |||
|
182 | result << catalogueItem->catalogue(); | |||
|
183 | } | |||
|
184 | else { | |||
|
185 | qCWarning(LOG_CatalogueSideBarWidget()) << "getCatalogues: invalid structure"; | |||
|
186 | } | |||
|
187 | } | |||
|
188 | ||||
|
189 | return result; | |||
|
190 | } | |||
|
191 | ||||
167 | void CatalogueSideBarWidget::onContextMenuRequested(const QPoint &pos) |
|
192 | void CatalogueSideBarWidget::onContextMenuRequested(const QPoint &pos) | |
168 | { |
|
193 | { | |
169 | QMenu menu{this}; |
|
194 | QMenu menu{this}; |
@@ -10,7 +10,8 struct CreateEventDialog::CreateEventDialogPrivate { | |||||
10 | QVector<std::shared_ptr<DBCatalogue> > m_DisplayedCatalogues; |
|
10 | QVector<std::shared_ptr<DBCatalogue> > m_DisplayedCatalogues; | |
11 | }; |
|
11 | }; | |
12 |
|
12 | |||
13 | CreateEventDialog::CreateEventDialog(QWidget *parent) |
|
13 | CreateEventDialog::CreateEventDialog(const QVector<std::shared_ptr<DBCatalogue> > &catalogues, | |
|
14 | QWidget *parent) | |||
14 | : QDialog(parent), |
|
15 | : QDialog(parent), | |
15 | ui(new Ui::CreateEventDialog), |
|
16 | ui(new Ui::CreateEventDialog), | |
16 | impl{spimpl::make_unique_impl<CreateEventDialogPrivate>()} |
|
17 | impl{spimpl::make_unique_impl<CreateEventDialogPrivate>()} | |
@@ -20,10 +21,9 CreateEventDialog::CreateEventDialog(QWidget *parent) | |||||
20 | connect(ui->buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept); |
|
21 | connect(ui->buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept); | |
21 | connect(ui->buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject); |
|
22 | connect(ui->buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject); | |
22 |
|
23 | |||
23 | auto catalogues = sqpApp->catalogueController().retrieveCatalogues(); |
|
24 | impl->m_DisplayedCatalogues = catalogues; | |
24 |
for (auto cat : |
|
25 | for (auto cat : impl->m_DisplayedCatalogues) { | |
25 | ui->cbCatalogue->addItem(cat->getName()); |
|
26 | ui->cbCatalogue->addItem(cat->getName()); | |
26 | impl->m_DisplayedCatalogues << cat; |
|
|||
27 | } |
|
27 | } | |
28 | } |
|
28 | } | |
29 |
|
29 |
General Comments 0
You need to be logged in to leave comments.
Login now