##// END OF EJS Templates
Zone actions to create a new event
trabillard -
r1163:800f227572ac
parent child
Show More
@@ -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>
@@ -1,139 +1,143
1 1 qxorm_dep = dependency('QxOrm', required : true, fallback:['QxOrm','qxorm_dep'])
2 2 catalogueapi_dep = dependency('CatalogueAPI', required : true, fallback:['CatalogueAPI','CatalogueAPI_dep'])
3 3
4 4 gui_moc_headers = [
5 5 'include/DataSource/DataSourceWidget.h',
6 6 'include/Settings/SqpSettingsDialog.h',
7 7 'include/Settings/SqpSettingsGeneralWidget.h',
8 8 'include/SidePane/SqpSidePane.h',
9 9 'include/SqpApplication.h',
10 10 'include/DragAndDrop/DragDropScroller.h',
11 11 'include/DragAndDrop/DragDropTabSwitcher.h',
12 12 'include/TimeWidget/TimeWidget.h',
13 13 'include/Variable/VariableInspectorWidget.h',
14 14 'include/Variable/RenameVariableDialog.h',
15 15 'include/Visualization/qcustomplot.h',
16 16 'include/Visualization/VisualizationGraphWidget.h',
17 17 'include/Visualization/VisualizationTabWidget.h',
18 18 'include/Visualization/VisualizationWidget.h',
19 19 'include/Visualization/VisualizationZoneWidget.h',
20 20 'include/Visualization/VisualizationDragDropContainer.h',
21 21 'include/Visualization/VisualizationDragWidget.h',
22 22 'include/Visualization/ColorScaleEditor.h',
23 23 'include/Actions/SelectionZoneAction.h',
24 24 'include/Visualization/VisualizationMultiZoneSelectionDialog.h',
25 25 'include/Catalogue/CatalogueExplorer.h',
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 = [
33 34 'ui/DataSource/DataSourceWidget.ui',
34 35 'ui/Settings/SqpSettingsDialog.ui',
35 36 'ui/Settings/SqpSettingsGeneralWidget.ui',
36 37 'ui/SidePane/SqpSidePane.ui',
37 38 'ui/TimeWidget/TimeWidget.ui',
38 39 'ui/Variable/VariableInspectorWidget.ui',
39 40 'ui/Variable/RenameVariableDialog.ui',
40 41 'ui/Variable/VariableMenuHeaderWidget.ui',
41 42 'ui/Visualization/VisualizationGraphWidget.ui',
42 43 'ui/Visualization/VisualizationTabWidget.ui',
43 44 'ui/Visualization/VisualizationWidget.ui',
44 45 'ui/Visualization/VisualizationZoneWidget.ui',
45 46 'ui/Visualization/ColorScaleEditor.ui',
46 47 'ui/Visualization/VisualizationMultiZoneSelectionDialog.ui',
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']
54 56
55 57 rcc_gen = generator(rcc,
56 58 output : 'qrc_@BASENAME@.cpp',
57 59 arguments : [
58 60 '--output',
59 61 '@OUTPUT@',
60 62 '@INPUT@',
61 63 '@EXTRA_ARGS@'])
62 64
63 65 rcc_files = rcc_gen.process(gui_qresources, extra_args : ['-name', 'sqpguiresources'])
64 66
65 67 gui_moc_files = qt5.preprocess(moc_headers : gui_moc_headers,
66 68 ui_files : gui_ui_files)
67 69
68 70 gui_sources = [
69 71 'src/SqpApplication.cpp',
70 72 'src/DragAndDrop/DragDropGuiController.cpp',
71 73 'src/DragAndDrop/DragDropScroller.cpp',
72 74 'src/DragAndDrop/DragDropTabSwitcher.cpp',
73 75 'src/Common/ColorUtils.cpp',
74 76 'src/Common/VisualizationDef.cpp',
75 77 'src/DataSource/DataSourceTreeWidgetItem.cpp',
76 78 'src/DataSource/DataSourceTreeWidgetHelper.cpp',
77 79 'src/DataSource/DataSourceWidget.cpp',
78 80 'src/DataSource/DataSourceTreeWidget.cpp',
79 81 'src/Settings/SqpSettingsDialog.cpp',
80 82 'src/Settings/SqpSettingsGeneralWidget.cpp',
81 83 'src/SidePane/SqpSidePane.cpp',
82 84 'src/TimeWidget/TimeWidget.cpp',
83 85 'src/Variable/VariableInspectorWidget.cpp',
84 86 'src/Variable/VariableInspectorTableView.cpp',
85 87 'src/Variable/VariableMenuHeaderWidget.cpp',
86 88 'src/Variable/RenameVariableDialog.cpp',
87 89 'src/Visualization/VisualizationGraphHelper.cpp',
88 90 'src/Visualization/VisualizationGraphRenderingDelegate.cpp',
89 91 'src/Visualization/VisualizationGraphWidget.cpp',
90 92 'src/Visualization/VisualizationTabWidget.cpp',
91 93 'src/Visualization/VisualizationWidget.cpp',
92 94 'src/Visualization/VisualizationZoneWidget.cpp',
93 95 'src/Visualization/qcustomplot.cpp',
94 96 'src/Visualization/QCustomPlotSynchronizer.cpp',
95 97 'src/Visualization/operations/FindVariableOperation.cpp',
96 98 'src/Visualization/operations/GenerateVariableMenuOperation.cpp',
97 99 'src/Visualization/operations/MenuBuilder.cpp',
98 100 'src/Visualization/operations/RemoveVariableOperation.cpp',
99 101 'src/Visualization/operations/RescaleAxeOperation.cpp',
100 102 'src/Visualization/VisualizationDragDropContainer.cpp',
101 103 'src/Visualization/VisualizationDragWidget.cpp',
102 104 'src/Visualization/AxisRenderingUtils.cpp',
103 105 'src/Visualization/PlottablesRenderingUtils.cpp',
104 106 'src/Visualization/MacScrollBarStyle.cpp',
105 107 'src/Visualization/VisualizationCursorItem.cpp',
106 108 'src/Visualization/ColorScaleEditor.cpp',
107 109 'src/Visualization/SqpColorScale.cpp',
108 110 'src/Visualization/QCPColorMapIterator.cpp',
109 111 'src/Visualization/VisualizationSelectionZoneItem.cpp',
110 112 'src/Visualization/VisualizationSelectionZoneManager.cpp',
111 113 'src/Actions/SelectionZoneAction.cpp',
112 114 'src/Actions/ActionsGuiController.cpp',
113 115 'src/Visualization/VisualizationActionManager.cpp',
114 116 'src/Visualization/VisualizationMultiZoneSelectionDialog.cpp',
115 117 'src/Catalogue/CatalogueExplorer.cpp',
116 118 'src/Catalogue/CatalogueEventsWidget.cpp',
117 119 'src/Catalogue/CatalogueSideBarWidget.cpp',
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'])
125 129
126 130 sciqlop_gui_lib = library('sciqlopgui',
127 131 gui_sources,
128 132 gui_moc_files,
129 133 rcc_files,
130 134 include_directories : [gui_inc],
131 135 dependencies : [ qt5printsupport, qt5gui, qt5widgets, qt5svg, sciqlop_core, catalogueapi_dep],
132 136 install : true
133 137 )
134 138
135 139 sciqlop_gui = declare_dependency(link_with : sciqlop_gui_lib,
136 140 include_directories : gui_inc,
137 141 dependencies : [qt5printsupport, qt5gui, qt5widgets, qt5svg, sciqlop_core, catalogueapi_dep])
138 142
139 143
@@ -1,85 +1,89
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)
13 15 : QDialog(parent, Qt::Dialog | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint),
14 16 ui(new Ui::CatalogueExplorer),
15 17 impl{spimpl::make_unique_impl<CatalogueExplorerPrivate>()}
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());
22 26 }
23 27 else {
24 28 ui->inspector->showPage(CatalogueInspectorWidget::Page::Empty);
25 29 }
26 30
27 31 ui->events->populateWithCatalogues(catalogues);
28 32 });
29 33
30 34 connect(ui->catalogues, &CatalogueSideBarWidget::databaseSelected, [this](auto databases) {
31 35 ui->inspector->showPage(CatalogueInspectorWidget::Page::Empty);
32 36 });
33 37
34 38 connect(ui->catalogues, &CatalogueSideBarWidget::trashSelected,
35 39 [this]() { ui->inspector->showPage(CatalogueInspectorWidget::Page::Empty); });
36 40
37 41 connect(ui->catalogues, &CatalogueSideBarWidget::allEventsSelected, [this]() {
38 42 ui->inspector->showPage(CatalogueInspectorWidget::Page::Empty);
39 43 ui->events->populateWithAllEvents();
40 44 });
41 45
42 46 connect(ui->catalogues, &CatalogueSideBarWidget::selectionCleared,
43 47 [this]() { ui->inspector->showPage(CatalogueInspectorWidget::Page::Empty); });
44 48
45 49 connect(ui->events, &CatalogueEventsWidget::eventsSelected, [this](auto events) {
46 50 if (events.count() == 1) {
47 51 ui->inspector->setEvent(events.first());
48 52 }
49 53 else {
50 54 ui->inspector->showPage(CatalogueInspectorWidget::Page::Empty);
51 55 }
52 56 });
53 57
54 58 connect(ui->events, &CatalogueEventsWidget::eventProductsSelected, [this](auto eventProducts) {
55 59 if (eventProducts.count() == 1) {
56 60 ui->inspector->setEventProduct(eventProducts.first().first,
57 61 eventProducts.first().second);
58 62 }
59 63 else {
60 64 ui->inspector->showPage(CatalogueInspectorWidget::Page::Empty);
61 65 }
62 66 });
63 67
64 68 connect(ui->events, &CatalogueEventsWidget::selectionCleared,
65 69 [this]() { ui->inspector->showPage(CatalogueInspectorWidget::Page::Empty); });
66 70
67 71 connect(ui->inspector, &CatalogueInspectorWidget::catalogueUpdated,
68 72 [this](auto catalogue) { ui->catalogues->setCatalogueChanges(catalogue, true); });
69 73
70 74 connect(ui->inspector, &CatalogueInspectorWidget::eventUpdated,
71 75 [this](auto event) { ui->events->setEventChanges(event, true); });
72 76
73 77 connect(ui->inspector, &CatalogueInspectorWidget::eventProductUpdated,
74 78 [this](auto event, auto eventProduct) { ui->events->setEventChanges(event, true); });
75 79 }
76 80
77 81 CatalogueExplorer::~CatalogueExplorer()
78 82 {
79 83 delete ui;
80 84 }
81 85
82 86 void CatalogueExplorer::setVisualizationWidget(VisualizationWidget *visualization)
83 87 {
84 88 ui->events->setVisualizationWidget(visualization);
85 89 }
General Comments 0
You need to be logged in to leave comments. Login now