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