##// END OF EJS Templates
Rework event creation menus without popup dialog
trabillard -
r1326:04c34c9f216f
parent child
Show More
@@ -28,7 +28,6 gui_moc_headers = [
28 28 'include/Catalogue/CatalogueSideBarWidget.h',
29 29 'include/Catalogue/CatalogueInspectorWidget.h',
30 30 'include/Catalogue/CatalogueEventsModel.h',
31 'include/Catalogue/CreateEventDialog.h',
32 31 'include/Catalogue/CatalogueTreeModel.h'
33 32 ]
34 33
@@ -50,8 +49,7 gui_ui_files = [
50 49 'ui/Catalogue/CatalogueExplorer.ui',
51 50 'ui/Catalogue/CatalogueEventsWidget.ui',
52 51 'ui/Catalogue/CatalogueSideBarWidget.ui',
53 'ui/Catalogue/CatalogueInspectorWidget.ui',
54 'ui/Catalogue/CreateEventDialog.ui'
52 'ui/Catalogue/CatalogueInspectorWidget.ui'
55 53 ]
56 54
57 55 gui_qresources = ['resources/sqpguiresources.qrc']
@@ -126,7 +124,6 gui_sources = [
126 124 'src/Catalogue/CatalogueEventsModel.cpp',
127 125 'src/Catalogue/CatalogueExplorerHelper.cpp',
128 126 'src/Catalogue/CatalogueActionManager.cpp',
129 'src/Catalogue/CreateEventDialog.cpp',
130 127 'src/Catalogue/CatalogueTreeModel.cpp'
131 128 ]
132 129
@@ -11,7 +11,6
11 11 #include <Catalogue/CatalogueEventsWidget.h>
12 12 #include <Catalogue/CatalogueExplorer.h>
13 13 #include <Catalogue/CatalogueSideBarWidget.h>
14 #include <Catalogue/CreateEventDialog.h>
15 14
16 15 #include <CatalogueDao.h>
17 16 #include <DBCatalogue.h>
@@ -25,6 +24,12
25 24 #include <QLineEdit>
26 25 #include <memory>
27 26
27 const auto CATALOGUE_MENU_NAME = QObject::tr("Catalogues");
28 const auto CATALOGUE_CREATE_EVENT_MENU_NAME = QObject::tr("New Event");
29
30 const auto DEFAULT_EVENT_NAME = QObject::tr("New Event");
31 const auto DEFAULT_CATALOGUE_NAME = QObject::tr("New Catalogue");
32
28 33 struct CatalogueActionManager::CatalogueActionManagerPrivate {
29 34
30 35 CatalogueExplorer *m_CatalogueExplorer = nullptr;
@@ -113,33 +118,36 void CatalogueActionManager::installSelectionZoneActions()
113 118 return true;
114 119 };
115 120
121
116 122 auto createEventAction = actionController.addSectionZoneAction(
117 {QObject::tr("Catalogues")}, QObject::tr("New Event..."), [this](auto zones) {
118 CreateEventDialog dialog(
119 impl->m_CatalogueExplorer->sideBarWidget().getCatalogues(REPOSITORY_DEFAULT));
120 dialog.hideCatalogueChoice();
121 if (dialog.exec() == QDialog::Accepted) {
122 impl->createEventFromZones(dialog.eventName(), zones);
123 }
124 });
123 {CATALOGUE_MENU_NAME, CATALOGUE_CREATE_EVENT_MENU_NAME}, QObject::tr("Without Catalogue"),
124 [this](auto zones) { impl->createEventFromZones(DEFAULT_EVENT_NAME, zones); });
125 125 createEventAction->setEnableFunction(createEventEnableFuntion);
126 126
127 auto createEventInCatalogueAction = actionController.addSectionZoneAction(
128 {QObject::tr("Catalogues")}, QObject::tr("New Event in Catalogue..."), [this](auto zones) {
129 CreateEventDialog dialog(
130 impl->m_CatalogueExplorer->sideBarWidget().getCatalogues(REPOSITORY_DEFAULT));
131 if (dialog.exec() == QDialog::Accepted) {
132 auto selectedCatalogue = dialog.selectedCatalogue();
133 if (!selectedCatalogue) {
134 selectedCatalogue = std::make_shared<DBCatalogue>();
135 selectedCatalogue->setName(dialog.catalogueName());
136 sqpApp->catalogueController().addCatalogue(selectedCatalogue);
137 impl->m_CatalogueExplorer->sideBarWidget().addCatalogue(selectedCatalogue,
138 REPOSITORY_DEFAULT);
139 }
127 auto createEventInNewCatalogueAction = actionController.addSectionZoneAction(
128 {CATALOGUE_MENU_NAME, CATALOGUE_CREATE_EVENT_MENU_NAME}, QObject::tr("In New Catalogue"),
129 [this](auto zones) {
140 130
141 impl->createEventFromZones(dialog.eventName(), zones, selectedCatalogue);
142 }
131 auto newCatalogue = std::make_shared<DBCatalogue>();
132 newCatalogue->setName(DEFAULT_CATALOGUE_NAME);
133 sqpApp->catalogueController().addCatalogue(newCatalogue);
134 impl->m_CatalogueExplorer->sideBarWidget().addCatalogue(newCatalogue,
135 REPOSITORY_DEFAULT);
136
137 impl->createEventFromZones(DEFAULT_EVENT_NAME, zones, newCatalogue);
143 138 });
144 createEventInCatalogueAction->setEnableFunction(createEventEnableFuntion);
139 createEventInNewCatalogueAction->setEnableFunction(createEventEnableFuntion);
140
141
142 auto allCatalogues
143 = impl->m_CatalogueExplorer->sideBarWidget().getCatalogues(REPOSITORY_DEFAULT);
144 for (auto catalogue : allCatalogues) {
145 auto catalogueName = catalogue->getName();
146 auto createEventInCatalogueAction = actionController.addSectionZoneAction(
147 {CATALOGUE_MENU_NAME, CATALOGUE_CREATE_EVENT_MENU_NAME},
148 QObject::tr("In ").append(catalogueName), [this, catalogue](auto zones) {
149 impl->createEventFromZones(DEFAULT_EVENT_NAME, zones, catalogue);
150 });
151 createEventInCatalogueAction->setEnableFunction(createEventEnableFuntion);
152 }
145 153 }
1 NO CONTENT: file was removed
1 NO CONTENT: file was removed
1 NO CONTENT: file was removed
General Comments 0
You need to be logged in to leave comments. Login now