Auto status change to "Under Review"
@@ -3,9 +3,11 | |||
|
3 | 3 | |
|
4 | 4 | #include <Common/spimpl.h> |
|
5 | 5 | |
|
6 | class CatalogueExplorer; | |
|
7 | ||
|
6 | 8 | class CatalogueActionManager { |
|
7 | 9 | public: |
|
8 | CatalogueActionManager(); | |
|
10 | CatalogueActionManager(CatalogueExplorer *catalogueExplorer); | |
|
9 | 11 | |
|
10 | 12 | void installSelectionZoneActions(); |
|
11 | 13 |
@@ -32,11 +32,17 public: | |||
|
32 | 32 | |
|
33 | 33 | void setVisualizationWidget(VisualizationWidget *visualization); |
|
34 | 34 | |
|
35 | void addEvent(const std::shared_ptr<DBEvent> &event); | |
|
35 | 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 | 42 | public slots: |
|
38 | 43 | void populateWithCatalogues(const QVector<std::shared_ptr<DBCatalogue> > &catalogues); |
|
39 | 44 | void populateWithAllEvents(); |
|
45 | void refresh(); | |
|
40 | 46 | |
|
41 | 47 | private: |
|
42 | 48 | Ui::CatalogueEventsWidget *ui; |
@@ -8,6 +8,9 namespace Ui { | |||
|
8 | 8 | class CatalogueExplorer; |
|
9 | 9 | } |
|
10 | 10 | |
|
11 | class CatalogueEventsWidget; | |
|
12 | class CatalogueSideBarWidget; | |
|
13 | ||
|
11 | 14 | class VisualizationWidget; |
|
12 | 15 | |
|
13 | 16 | class CatalogueExplorer : public QDialog { |
@@ -19,6 +22,9 public: | |||
|
19 | 22 | |
|
20 | 23 | void setVisualizationWidget(VisualizationWidget *visualization); |
|
21 | 24 | |
|
25 | CatalogueEventsWidget &eventsWidget() const; | |
|
26 | CatalogueSideBarWidget &sideBarWidget() const; | |
|
27 | ||
|
22 | 28 | private: |
|
23 | 29 | Ui::CatalogueExplorer *ui; |
|
24 | 30 |
@@ -28,8 +28,11 public: | |||
|
28 | 28 | explicit CatalogueSideBarWidget(QWidget *parent = 0); |
|
29 | 29 | virtual ~CatalogueSideBarWidget(); |
|
30 | 30 | |
|
31 | void addCatalogue(const std::shared_ptr<DBCatalogue> &catalogue, const QString &repository); | |
|
31 | 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 | 36 | private: |
|
34 | 37 | Ui::CatalogueSideBarWidget *ui; |
|
35 | 38 |
@@ -15,7 +15,8 class CreateEventDialog : public QDialog { | |||
|
15 | 15 | Q_OBJECT |
|
16 | 16 | |
|
17 | 17 | public: |
|
18 | explicit CreateEventDialog(QWidget *parent = 0); | |
|
18 | explicit CreateEventDialog(const QVector<std::shared_ptr<DBCatalogue> > &catalogues, | |
|
19 | QWidget *parent = 0); | |
|
19 | 20 | virtual ~CreateEventDialog(); |
|
20 | 21 | |
|
21 | 22 | void hideCatalogueChoice(); |
@@ -7,6 +7,9 | |||
|
7 | 7 | #include <Visualization/VisualizationGraphWidget.h> |
|
8 | 8 | #include <Visualization/VisualizationSelectionZoneItem.h> |
|
9 | 9 | |
|
10 | #include <Catalogue/CatalogueEventsWidget.h> | |
|
11 | #include <Catalogue/CatalogueExplorer.h> | |
|
12 | #include <Catalogue/CatalogueSideBarWidget.h> | |
|
10 | 13 | #include <Catalogue/CreateEventDialog.h> |
|
11 | 14 | |
|
12 | 15 | #include <DBCatalogue.h> |
@@ -21,6 +24,14 | |||
|
21 | 24 | #include <memory> |
|
22 | 25 | |
|
23 | 26 | struct CatalogueActionManager::CatalogueActionManagerPrivate { |
|
27 | ||
|
28 | CatalogueExplorer *m_CatalogueExplorer = nullptr; | |
|
29 | ||
|
30 | CatalogueActionManagerPrivate(CatalogueExplorer *catalogueExplorer) | |
|
31 | : m_CatalogueExplorer(catalogueExplorer) | |
|
32 | { | |
|
33 | } | |
|
34 | ||
|
24 | 35 | void createEventFromZones(const QString &eventName, |
|
25 | 36 | const QVector<VisualizationSelectionZoneItem *> &zones, |
|
26 | 37 | const std::shared_ptr<DBCatalogue> &catalogue = nullptr) |
@@ -49,15 +60,25 struct CatalogueActionManager::CatalogueActionManagerPrivate { | |||
|
49 | 60 | |
|
50 | 61 | sqpApp->catalogueController().addEvent(event); |
|
51 | 62 | |
|
63 | ||
|
52 | 64 | if (catalogue) { |
|
53 | 65 | // TODO |
|
54 | 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() | |
|
60 | : impl{spimpl::make_unique_impl<CatalogueActionManagerPrivate>()} | |
|
80 | CatalogueActionManager::CatalogueActionManager(CatalogueExplorer *catalogueExplorer) | |
|
81 | : impl{spimpl::make_unique_impl<CatalogueActionManagerPrivate>(catalogueExplorer)} | |
|
61 | 82 | { |
|
62 | 83 | } |
|
63 | 84 | |
@@ -82,7 +103,8 void CatalogueActionManager::installSelectionZoneActions() | |||
|
82 | 103 | |
|
83 | 104 | auto createEventAction = actionController.addSectionZoneAction( |
|
84 | 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 | 108 | dialog.hideCatalogueChoice(); |
|
87 | 109 | if (dialog.exec() == QDialog::Accepted) { |
|
88 | 110 | impl->createEventFromZones(dialog.eventName(), zones); |
@@ -92,12 +114,16 void CatalogueActionManager::installSelectionZoneActions() | |||
|
92 | 114 | |
|
93 | 115 | auto createEventInCatalogueAction = actionController.addSectionZoneAction( |
|
94 | 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 | 119 | if (dialog.exec() == QDialog::Accepted) { |
|
97 | 120 | auto selectedCatalogue = dialog.selectedCatalogue(); |
|
98 | 121 | if (!selectedCatalogue) { |
|
99 | 122 | selectedCatalogue = std::make_shared<DBCatalogue>(); |
|
100 | 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 | 129 | impl->createEventFromZones(dialog.eventName(), zones, selectedCatalogue); |
@@ -25,6 +25,7 struct CatalogueEventsWidget::CatalogueEventsWidgetPrivate { | |||
|
25 | 25 | CatalogueEventsModel *m_Model = nullptr; |
|
26 | 26 | QStringList m_ZonesForTimeMode; |
|
27 | 27 | QString m_ZoneForGraphMode; |
|
28 | QVector<std::shared_ptr<DBCatalogue> > m_DisplayedCatalogues; | |
|
28 | 29 | |
|
29 | 30 | VisualizationWidget *m_VisualizationWidget = nullptr; |
|
30 | 31 | |
@@ -304,6 +305,11 void CatalogueEventsWidget::setVisualizationWidget(VisualizationWidget *visualiz | |||
|
304 | 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 | 313 | void CatalogueEventsWidget::setEventChanges(const std::shared_ptr<DBEvent> &event, bool hasChanges) |
|
308 | 314 | { |
|
309 | 315 | impl->m_Model->refreshEvent(event); |
@@ -323,18 +329,35 void CatalogueEventsWidget::setEventChanges(const std::shared_ptr<DBEvent> &even | |||
|
323 | 329 | [this, event]() { setEventChanges(event, false); }); |
|
324 | 330 | ui->treeView->setIndexWidget(validationIndex, widget); |
|
325 | 331 | } |
|
332 | ||
|
333 | impl->m_Model->setEventHasChanges(event, hasChanges); | |
|
326 | 334 | } |
|
327 | 335 | else { |
|
328 | // Note: the widget is destroyed | |
|
329 | ui->treeView->setIndexWidget(validationIndex, nullptr); | |
|
336 | qCWarning(LOG_CatalogueEventsWidget()) | |
|
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 | 356 | void CatalogueEventsWidget::populateWithCatalogues( |
|
336 | 357 | const QVector<std::shared_ptr<DBCatalogue> > &catalogues) |
|
337 | 358 | { |
|
359 | impl->m_DisplayedCatalogues = catalogues; | |
|
360 | ||
|
338 | 361 | QSet<QUuid> eventIds; |
|
339 | 362 | QVector<std::shared_ptr<DBEvent> > events; |
|
340 | 363 | |
@@ -353,6 +376,8 void CatalogueEventsWidget::populateWithCatalogues( | |||
|
353 | 376 | |
|
354 | 377 | void CatalogueEventsWidget::populateWithAllEvents() |
|
355 | 378 | { |
|
379 | impl->m_DisplayedCatalogues.clear(); | |
|
380 | ||
|
356 | 381 | auto allEvents = sqpApp->catalogueController().retrieveAllEvents(); |
|
357 | 382 | |
|
358 | 383 | QVector<std::shared_ptr<DBEvent> > events; |
@@ -362,3 +387,13 void CatalogueEventsWidget::populateWithAllEvents() | |||
|
362 | 387 | |
|
363 | 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 | 12 | struct CatalogueExplorer::CatalogueExplorerPrivate { |
|
13 | 13 | CatalogueActionManager m_ActionManager; |
|
14 | ||
|
15 | CatalogueExplorerPrivate(CatalogueExplorer *catalogueExplorer) | |
|
16 | : m_ActionManager(catalogueExplorer) | |
|
17 | { | |
|
18 | } | |
|
14 | 19 | }; |
|
15 | 20 | |
|
16 | 21 | CatalogueExplorer::CatalogueExplorer(QWidget *parent) |
|
17 | 22 | : QDialog(parent, Qt::Dialog | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint), |
|
18 | 23 | ui(new Ui::CatalogueExplorer), |
|
19 | impl{spimpl::make_unique_impl<CatalogueExplorerPrivate>()} | |
|
24 | impl{spimpl::make_unique_impl<CatalogueExplorerPrivate>(this)} | |
|
20 | 25 | { |
|
21 | 26 | ui->setupUi(this); |
|
22 | 27 | |
@@ -96,3 +101,13 void CatalogueExplorer::setVisualizationWidget(VisualizationWidget *visualizatio | |||
|
96 | 101 | { |
|
97 | 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 | 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 | 164 | void CatalogueSideBarWidget::setCatalogueChanges(const std::shared_ptr<DBCatalogue> &catalogue, |
|
158 | 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 | 192 | void CatalogueSideBarWidget::onContextMenuRequested(const QPoint &pos) |
|
168 | 193 | { |
|
169 | 194 | QMenu menu{this}; |
@@ -10,7 +10,8 struct CreateEventDialog::CreateEventDialogPrivate { | |||
|
10 | 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 | 15 | : QDialog(parent), |
|
15 | 16 | ui(new Ui::CreateEventDialog), |
|
16 | 17 | impl{spimpl::make_unique_impl<CreateEventDialogPrivate>()} |
@@ -20,10 +21,9 CreateEventDialog::CreateEventDialog(QWidget *parent) | |||
|
20 | 21 | connect(ui->buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept); |
|
21 | 22 | connect(ui->buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject); |
|
22 | 23 | |
|
23 | auto catalogues = sqpApp->catalogueController().retrieveCatalogues(); | |
|
24 |
for (auto cat : |
|
|
24 | impl->m_DisplayedCatalogues = catalogues; | |
|
25 | for (auto cat : impl->m_DisplayedCatalogues) { | |
|
25 | 26 | ui->cbCatalogue->addItem(cat->getName()); |
|
26 | impl->m_DisplayedCatalogues << cat; | |
|
27 | 27 | } |
|
28 | 28 | } |
|
29 | 29 |
General Comments 3
Status change > Approved
You need to be logged in to leave comments.
Login now