@@ -0,0 +1,17 | |||
|
1 | #ifndef SCIQLOP_CATALOGUEACTIONMANAGER_H | |
|
2 | #define SCIQLOP_CATALOGUEACTIONMANAGER_H | |
|
3 | ||
|
4 | #include <Common/spimpl.h> | |
|
5 | ||
|
6 | class CatalogueActionManager { | |
|
7 | public: | |
|
8 | CatalogueActionManager(); | |
|
9 | ||
|
10 | void installSelectionZoneActions(); | |
|
11 | ||
|
12 | private: | |
|
13 | class CatalogueActionManagerPrivate; | |
|
14 | spimpl::unique_impl_ptr<CatalogueActionManagerPrivate> impl; | |
|
15 | }; | |
|
16 | ||
|
17 | #endif // SCIQLOP_CATALOGUEACTIONMANAGER_H |
@@ -0,0 +1,35 | |||
|
1 | #ifndef SCIQLOP_CREATEEVENTDIALOG_H | |
|
2 | #define SCIQLOP_CREATEEVENTDIALOG_H | |
|
3 | ||
|
4 | #include <Common/spimpl.h> | |
|
5 | #include <QDialog> | |
|
6 | #include <memory> | |
|
7 | ||
|
8 | namespace Ui { | |
|
9 | class CreateEventDialog; | |
|
10 | } | |
|
11 | ||
|
12 | class DBCatalogue; | |
|
13 | ||
|
14 | class CreateEventDialog : public QDialog { | |
|
15 | Q_OBJECT | |
|
16 | ||
|
17 | public: | |
|
18 | explicit CreateEventDialog(QWidget *parent = 0); | |
|
19 | virtual ~CreateEventDialog(); | |
|
20 | ||
|
21 | void hideCatalogueChoice(); | |
|
22 | ||
|
23 | QString eventName() const; | |
|
24 | ||
|
25 | std::shared_ptr<DBCatalogue> selectedCatalogue() const; | |
|
26 | QString catalogueName() const; | |
|
27 | ||
|
28 | private: | |
|
29 | Ui::CreateEventDialog *ui; | |
|
30 | ||
|
31 | class CreateEventDialogPrivate; | |
|
32 | spimpl::unique_impl_ptr<CreateEventDialogPrivate> impl; | |
|
33 | }; | |
|
34 | ||
|
35 | #endif // SCIQLOP_CREATEEVENTDIALOG_H |
@@ -0,0 +1,107 | |||
|
1 | #include "Catalogue/CatalogueActionManager.h" | |
|
2 | ||
|
3 | #include <Actions/ActionsGuiController.h> | |
|
4 | #include <Catalogue/CatalogueController.h> | |
|
5 | #include <SqpApplication.h> | |
|
6 | #include <Variable/Variable.h> | |
|
7 | #include <Visualization/VisualizationGraphWidget.h> | |
|
8 | #include <Visualization/VisualizationSelectionZoneItem.h> | |
|
9 | ||
|
10 | #include <Catalogue/CreateEventDialog.h> | |
|
11 | ||
|
12 | #include <DBCatalogue.h> | |
|
13 | #include <DBEvent.h> | |
|
14 | #include <DBEventProduct.h> | |
|
15 | ||
|
16 | #include <QBoxLayout> | |
|
17 | #include <QComboBox> | |
|
18 | #include <QDialog> | |
|
19 | #include <QDialogButtonBox> | |
|
20 | #include <QLineEdit> | |
|
21 | #include <memory> | |
|
22 | ||
|
23 | struct CatalogueActionManager::CatalogueActionManagerPrivate { | |
|
24 | void createEventFromZones(const QString &eventName, | |
|
25 | const QVector<VisualizationSelectionZoneItem *> &zones, | |
|
26 | const std::shared_ptr<DBCatalogue> &catalogue = nullptr) | |
|
27 | { | |
|
28 | auto event = std::make_shared<DBEvent>(); | |
|
29 | event->setName(eventName); | |
|
30 | ||
|
31 | std::list<DBEventProduct> productList; | |
|
32 | for (auto zone : zones) { | |
|
33 | auto graph = zone->parentGraphWidget(); | |
|
34 | for (auto var : graph->variables()) { | |
|
35 | auto eventProduct = std::make_shared<DBEventProduct>(); | |
|
36 | eventProduct->setEvent(*event); | |
|
37 | ||
|
38 | auto zoneRange = zone->range(); | |
|
39 | eventProduct->setTStart(zoneRange.m_TStart); | |
|
40 | eventProduct->setTEnd(zoneRange.m_TEnd); | |
|
41 | ||
|
42 | eventProduct->setProductId(var->metadata().value("id", "TODO").toString()); // todo | |
|
43 | ||
|
44 | productList.push_back(*eventProduct); | |
|
45 | } | |
|
46 | } | |
|
47 | ||
|
48 | event->setEventProducts(productList); | |
|
49 | ||
|
50 | // TODO | |
|
51 | if (catalogue) { | |
|
52 | // catalogue->addEvent(event); | |
|
53 | } | |
|
54 | else { | |
|
55 | } | |
|
56 | } | |
|
57 | }; | |
|
58 | ||
|
59 | CatalogueActionManager::CatalogueActionManager() | |
|
60 | : impl{spimpl::make_unique_impl<CatalogueActionManagerPrivate>()} | |
|
61 | { | |
|
62 | } | |
|
63 | ||
|
64 | void CatalogueActionManager::installSelectionZoneActions() | |
|
65 | { | |
|
66 | auto &actionController = sqpApp->actionsGuiController(); | |
|
67 | ||
|
68 | auto createEventEnableFuntion = [](auto zones) { | |
|
69 | QSet<VisualizationGraphWidget *> usedGraphs; | |
|
70 | for (auto zone : zones) { | |
|
71 | auto graph = zone->parentGraphWidget(); | |
|
72 | if (!usedGraphs.contains(graph)) { | |
|
73 | usedGraphs.insert(graph); | |
|
74 | } | |
|
75 | else { | |
|
76 | return false; | |
|
77 | } | |
|
78 | } | |
|
79 | ||
|
80 | return true; | |
|
81 | }; | |
|
82 | ||
|
83 | auto createEventAction = actionController.addSectionZoneAction( | |
|
84 | {QObject::tr("Catalogues")}, QObject::tr("New Event..."), [this](auto zones) { | |
|
85 | CreateEventDialog dialog; | |
|
86 | dialog.hideCatalogueChoice(); | |
|
87 | if (dialog.exec() == QDialog::Accepted) { | |
|
88 | impl->createEventFromZones(dialog.eventName(), zones); | |
|
89 | } | |
|
90 | }); | |
|
91 | createEventAction->setEnableFunction(createEventEnableFuntion); | |
|
92 | ||
|
93 | auto createEventInCatalogueAction = actionController.addSectionZoneAction( | |
|
94 | {QObject::tr("Catalogues")}, QObject::tr("New Event in Catalogue..."), [this](auto zones) { | |
|
95 | CreateEventDialog dialog; | |
|
96 | if (dialog.exec() == QDialog::Accepted) { | |
|
97 | auto selectedCatalogue = dialog.selectedCatalogue(); | |
|
98 | if (!selectedCatalogue) { | |
|
99 | selectedCatalogue = std::make_shared<DBCatalogue>(); | |
|
100 | selectedCatalogue->setName(dialog.catalogueName()); | |
|
101 | } | |
|
102 | ||
|
103 | impl->createEventFromZones(dialog.eventName(), zones, selectedCatalogue); | |
|
104 | } | |
|
105 | }); | |
|
106 | createEventInCatalogueAction->setEnableFunction(createEventEnableFuntion); | |
|
107 | } |
@@ -0,0 +1,59 | |||
|
1 | #include "Catalogue/CreateEventDialog.h" | |
|
2 | #include "ui_CreateEventDialog.h" | |
|
3 | ||
|
4 | #include <Catalogue/CatalogueController.h> | |
|
5 | #include <SqpApplication.h> | |
|
6 | ||
|
7 | #include <DBCatalogue.h> | |
|
8 | ||
|
9 | struct CreateEventDialog::CreateEventDialogPrivate { | |
|
10 | QVector<std::shared_ptr<DBCatalogue> > m_DisplayedCatalogues; | |
|
11 | }; | |
|
12 | ||
|
13 | CreateEventDialog::CreateEventDialog(QWidget *parent) | |
|
14 | : QDialog(parent), | |
|
15 | ui(new Ui::CreateEventDialog), | |
|
16 | impl{spimpl::make_unique_impl<CreateEventDialogPrivate>()} | |
|
17 | { | |
|
18 | ui->setupUi(this); | |
|
19 | ||
|
20 | connect(ui->buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept); | |
|
21 | connect(ui->buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject); | |
|
22 | ||
|
23 | auto catalogues = sqpApp->catalogueController().getCatalogues("Default"); | |
|
24 | for (auto cat : catalogues) { | |
|
25 | ui->cbCatalogue->addItem(cat->getName()); | |
|
26 | impl->m_DisplayedCatalogues << cat; | |
|
27 | } | |
|
28 | } | |
|
29 | ||
|
30 | CreateEventDialog::~CreateEventDialog() | |
|
31 | { | |
|
32 | delete ui; | |
|
33 | } | |
|
34 | ||
|
35 | void CreateEventDialog::hideCatalogueChoice() | |
|
36 | { | |
|
37 | ui->cbCatalogue->hide(); | |
|
38 | ui->lblCatalogue->hide(); | |
|
39 | } | |
|
40 | ||
|
41 | QString CreateEventDialog::eventName() const | |
|
42 | { | |
|
43 | return ui->leEvent->text(); | |
|
44 | } | |
|
45 | ||
|
46 | std::shared_ptr<DBCatalogue> CreateEventDialog::selectedCatalogue() const | |
|
47 | { | |
|
48 | auto catalogue = impl->m_DisplayedCatalogues.value(ui->cbCatalogue->currentIndex()); | |
|
49 | if (!catalogue || catalogue->getName() != catalogueName()) { | |
|
50 | return nullptr; | |
|
51 | } | |
|
52 | ||
|
53 | return catalogue; | |
|
54 | } | |
|
55 | ||
|
56 | QString CreateEventDialog::catalogueName() const | |
|
57 | { | |
|
58 | return ui->cbCatalogue->currentText(); | |
|
59 | } |
@@ -0,0 +1,55 | |||
|
1 | <?xml version="1.0" encoding="UTF-8"?> | |
|
2 | <ui version="4.0"> | |
|
3 | <class>CreateEventDialog</class> | |
|
4 | <widget class="QDialog" name="CreateEventDialog"> | |
|
5 | <property name="geometry"> | |
|
6 | <rect> | |
|
7 | <x>0</x> | |
|
8 | <y>0</y> | |
|
9 | <width>324</width> | |
|
10 | <height>93</height> | |
|
11 | </rect> | |
|
12 | </property> | |
|
13 | <property name="windowTitle"> | |
|
14 | <string>New Event</string> | |
|
15 | </property> | |
|
16 | <layout class="QGridLayout" name="gridLayout"> | |
|
17 | <item row="0" column="0"> | |
|
18 | <widget class="QLabel" name="label"> | |
|
19 | <property name="text"> | |
|
20 | <string>Event Name</string> | |
|
21 | </property> | |
|
22 | </widget> | |
|
23 | </item> | |
|
24 | <item row="0" column="1"> | |
|
25 | <widget class="QLineEdit" name="leEvent"/> | |
|
26 | </item> | |
|
27 | <item row="1" column="0"> | |
|
28 | <widget class="QLabel" name="lblCatalogue"> | |
|
29 | <property name="text"> | |
|
30 | <string>Catalogue</string> | |
|
31 | </property> | |
|
32 | </widget> | |
|
33 | </item> | |
|
34 | <item row="1" column="1"> | |
|
35 | <widget class="QComboBox" name="cbCatalogue"> | |
|
36 | <property name="editable"> | |
|
37 | <bool>true</bool> | |
|
38 | </property> | |
|
39 | <property name="insertPolicy"> | |
|
40 | <enum>QComboBox::NoInsert</enum> | |
|
41 | </property> | |
|
42 | </widget> | |
|
43 | </item> | |
|
44 | <item row="2" column="0" colspan="2"> | |
|
45 | <widget class="QDialogButtonBox" name="buttonBox"> | |
|
46 | <property name="standardButtons"> | |
|
47 | <set>QDialogButtonBox::Ok</set> | |
|
48 | </property> | |
|
49 | </widget> | |
|
50 | </item> | |
|
51 | </layout> | |
|
52 | </widget> | |
|
53 | <resources/> | |
|
54 | <connections/> | |
|
55 | </ui> |
@@ -26,7 +26,8 gui_moc_headers = [ | |||
|
26 | 26 | 'include/Catalogue/CatalogueEventsWidget.h', |
|
27 | 27 | 'include/Catalogue/CatalogueSideBarWidget.h', |
|
28 | 28 | 'include/Catalogue/CatalogueInspectorWidget.h', |
|
29 | 'include/Catalogue/CatalogueEventsModel.h' | |
|
29 | 'include/Catalogue/CatalogueEventsModel.h', | |
|
30 | 'include/Catalogue/CreateEventDialog.ui' | |
|
30 | 31 | ] |
|
31 | 32 | |
|
32 | 33 | gui_ui_files = [ |
@@ -47,7 +48,8 gui_ui_files = [ | |||
|
47 | 48 | 'ui/Catalogue/CatalogueExplorer.ui', |
|
48 | 49 | 'ui/Catalogue/CatalogueEventsWidget.ui', |
|
49 | 50 | 'ui/Catalogue/CatalogueSideBarWidget.ui', |
|
50 | 'ui/Catalogue/CatalogueInspectorWidget.ui' | |
|
51 | 'ui/Catalogue/CatalogueInspectorWidget.ui', | |
|
52 | 'ui/Catalogue/CreateEventDialog.ui' | |
|
51 | 53 | ] |
|
52 | 54 | |
|
53 | 55 | gui_qresources = ['resources/sqpguiresources.qrc'] |
@@ -118,7 +120,9 gui_sources = [ | |||
|
118 | 120 | 'src/Catalogue/CatalogueInspectorWidget.cpp', |
|
119 | 121 | 'src/Catalogue/CatalogueTreeWidgetItem.cpp', |
|
120 | 122 | 'src/Catalogue/CatalogueEventsModel.cpp', |
|
121 | 'src/Catalogue/CatalogueExplorerHelper.cpp' | |
|
123 | 'src/Catalogue/CatalogueExplorerHelper.cpp', | |
|
124 | 'src/Catalogue/CatalogueActionManager.cpp', | |
|
125 | 'src/Catalogue/CreateEventDialog.cpp' | |
|
122 | 126 | ] |
|
123 | 127 | |
|
124 | 128 | gui_inc = include_directories(['include']) |
@@ -1,12 +1,14 | |||
|
1 | 1 | #include "Catalogue/CatalogueExplorer.h" |
|
2 | 2 | #include "ui_CatalogueExplorer.h" |
|
3 | 3 | |
|
4 | #include <Catalogue/CatalogueActionManager.h> | |
|
4 | 5 | #include <Visualization/VisualizationWidget.h> |
|
5 | 6 | |
|
6 | 7 | #include <DBCatalogue.h> |
|
7 | 8 | #include <DBEvent.h> |
|
8 | 9 | |
|
9 | 10 | struct CatalogueExplorer::CatalogueExplorerPrivate { |
|
11 | CatalogueActionManager m_ActionManager; | |
|
10 | 12 | }; |
|
11 | 13 | |
|
12 | 14 | CatalogueExplorer::CatalogueExplorer(QWidget *parent) |
@@ -16,6 +18,8 CatalogueExplorer::CatalogueExplorer(QWidget *parent) | |||
|
16 | 18 | { |
|
17 | 19 | ui->setupUi(this); |
|
18 | 20 | |
|
21 | impl->m_ActionManager.installSelectionZoneActions(); | |
|
22 | ||
|
19 | 23 | connect(ui->catalogues, &CatalogueSideBarWidget::catalogueSelected, [this](auto catalogues) { |
|
20 | 24 | if (catalogues.count() == 1) { |
|
21 | 25 | ui->inspector->setCatalogue(catalogues.first()); |
General Comments 0
You need to be logged in to leave comments.
Login now