diff --git a/gui/include/Catalogue/CreateEventDialog.h b/gui/include/Catalogue/CreateEventDialog.h deleted file mode 100644 index 9e85fa4..0000000 --- a/gui/include/Catalogue/CreateEventDialog.h +++ /dev/null @@ -1,36 +0,0 @@ -#ifndef SCIQLOP_CREATEEVENTDIALOG_H -#define SCIQLOP_CREATEEVENTDIALOG_H - -#include -#include -#include - -namespace Ui { -class CreateEventDialog; -} - -class DBCatalogue; - -class CreateEventDialog : public QDialog { - Q_OBJECT - -public: - explicit CreateEventDialog(const QVector > &catalogues, - QWidget *parent = 0); - virtual ~CreateEventDialog(); - - void hideCatalogueChoice(); - - QString eventName() const; - - std::shared_ptr selectedCatalogue() const; - QString catalogueName() const; - -private: - Ui::CreateEventDialog *ui; - - class CreateEventDialogPrivate; - spimpl::unique_impl_ptr impl; -}; - -#endif // SCIQLOP_CREATEEVENTDIALOG_H diff --git a/gui/meson.build b/gui/meson.build index 1a81c55..31ccb6b 100644 --- a/gui/meson.build +++ b/gui/meson.build @@ -28,7 +28,6 @@ gui_moc_headers = [ 'include/Catalogue/CatalogueSideBarWidget.h', 'include/Catalogue/CatalogueInspectorWidget.h', 'include/Catalogue/CatalogueEventsModel.h', - 'include/Catalogue/CreateEventDialog.h', 'include/Catalogue/CatalogueTreeModel.h' ] @@ -50,8 +49,7 @@ gui_ui_files = [ 'ui/Catalogue/CatalogueExplorer.ui', 'ui/Catalogue/CatalogueEventsWidget.ui', 'ui/Catalogue/CatalogueSideBarWidget.ui', - 'ui/Catalogue/CatalogueInspectorWidget.ui', - 'ui/Catalogue/CreateEventDialog.ui' + 'ui/Catalogue/CatalogueInspectorWidget.ui' ] gui_qresources = ['resources/sqpguiresources.qrc'] @@ -126,7 +124,6 @@ gui_sources = [ 'src/Catalogue/CatalogueEventsModel.cpp', 'src/Catalogue/CatalogueExplorerHelper.cpp', 'src/Catalogue/CatalogueActionManager.cpp', - 'src/Catalogue/CreateEventDialog.cpp', 'src/Catalogue/CatalogueTreeModel.cpp' ] diff --git a/gui/src/Catalogue/CatalogueActionManager.cpp b/gui/src/Catalogue/CatalogueActionManager.cpp index f1b865f..652bebd 100644 --- a/gui/src/Catalogue/CatalogueActionManager.cpp +++ b/gui/src/Catalogue/CatalogueActionManager.cpp @@ -11,7 +11,6 @@ #include #include #include -#include #include #include @@ -25,6 +24,12 @@ #include #include +const auto CATALOGUE_MENU_NAME = QObject::tr("Catalogues"); +const auto CATALOGUE_CREATE_EVENT_MENU_NAME = QObject::tr("New Event"); + +const auto DEFAULT_EVENT_NAME = QObject::tr("New Event"); +const auto DEFAULT_CATALOGUE_NAME = QObject::tr("New Catalogue"); + struct CatalogueActionManager::CatalogueActionManagerPrivate { CatalogueExplorer *m_CatalogueExplorer = nullptr; @@ -113,33 +118,36 @@ void CatalogueActionManager::installSelectionZoneActions() return true; }; + auto createEventAction = actionController.addSectionZoneAction( - {QObject::tr("Catalogues")}, QObject::tr("New Event..."), [this](auto zones) { - CreateEventDialog dialog( - impl->m_CatalogueExplorer->sideBarWidget().getCatalogues(REPOSITORY_DEFAULT)); - dialog.hideCatalogueChoice(); - if (dialog.exec() == QDialog::Accepted) { - impl->createEventFromZones(dialog.eventName(), zones); - } - }); + {CATALOGUE_MENU_NAME, CATALOGUE_CREATE_EVENT_MENU_NAME}, QObject::tr("Without Catalogue"), + [this](auto zones) { impl->createEventFromZones(DEFAULT_EVENT_NAME, zones); }); createEventAction->setEnableFunction(createEventEnableFuntion); - auto createEventInCatalogueAction = actionController.addSectionZoneAction( - {QObject::tr("Catalogues")}, QObject::tr("New Event in Catalogue..."), [this](auto zones) { - CreateEventDialog dialog( - impl->m_CatalogueExplorer->sideBarWidget().getCatalogues(REPOSITORY_DEFAULT)); - if (dialog.exec() == QDialog::Accepted) { - auto selectedCatalogue = dialog.selectedCatalogue(); - if (!selectedCatalogue) { - selectedCatalogue = std::make_shared(); - selectedCatalogue->setName(dialog.catalogueName()); - sqpApp->catalogueController().addCatalogue(selectedCatalogue); - impl->m_CatalogueExplorer->sideBarWidget().addCatalogue(selectedCatalogue, - REPOSITORY_DEFAULT); - } + auto createEventInNewCatalogueAction = actionController.addSectionZoneAction( + {CATALOGUE_MENU_NAME, CATALOGUE_CREATE_EVENT_MENU_NAME}, QObject::tr("In New Catalogue"), + [this](auto zones) { - impl->createEventFromZones(dialog.eventName(), zones, selectedCatalogue); - } + auto newCatalogue = std::make_shared(); + newCatalogue->setName(DEFAULT_CATALOGUE_NAME); + sqpApp->catalogueController().addCatalogue(newCatalogue); + impl->m_CatalogueExplorer->sideBarWidget().addCatalogue(newCatalogue, + REPOSITORY_DEFAULT); + + impl->createEventFromZones(DEFAULT_EVENT_NAME, zones, newCatalogue); }); - createEventInCatalogueAction->setEnableFunction(createEventEnableFuntion); + createEventInNewCatalogueAction->setEnableFunction(createEventEnableFuntion); + + + auto allCatalogues + = impl->m_CatalogueExplorer->sideBarWidget().getCatalogues(REPOSITORY_DEFAULT); + for (auto catalogue : allCatalogues) { + auto catalogueName = catalogue->getName(); + auto createEventInCatalogueAction = actionController.addSectionZoneAction( + {CATALOGUE_MENU_NAME, CATALOGUE_CREATE_EVENT_MENU_NAME}, + QObject::tr("In ").append(catalogueName), [this, catalogue](auto zones) { + impl->createEventFromZones(DEFAULT_EVENT_NAME, zones, catalogue); + }); + createEventInCatalogueAction->setEnableFunction(createEventEnableFuntion); + } } diff --git a/gui/src/Catalogue/CreateEventDialog.cpp b/gui/src/Catalogue/CreateEventDialog.cpp deleted file mode 100644 index 2dd6249..0000000 --- a/gui/src/Catalogue/CreateEventDialog.cpp +++ /dev/null @@ -1,59 +0,0 @@ -#include "Catalogue/CreateEventDialog.h" -#include "ui_CreateEventDialog.h" - -#include -#include - -#include - -struct CreateEventDialog::CreateEventDialogPrivate { - QVector > m_DisplayedCatalogues; -}; - -CreateEventDialog::CreateEventDialog(const QVector > &catalogues, - QWidget *parent) - : QDialog(parent), - ui(new Ui::CreateEventDialog), - impl{spimpl::make_unique_impl()} -{ - ui->setupUi(this); - - connect(ui->buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept); - connect(ui->buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject); - - impl->m_DisplayedCatalogues = catalogues; - for (auto cat : impl->m_DisplayedCatalogues) { - ui->cbCatalogue->addItem(cat->getName()); - } -} - -CreateEventDialog::~CreateEventDialog() -{ - delete ui; -} - -void CreateEventDialog::hideCatalogueChoice() -{ - ui->cbCatalogue->hide(); - ui->lblCatalogue->hide(); -} - -QString CreateEventDialog::eventName() const -{ - return ui->leEvent->text(); -} - -std::shared_ptr CreateEventDialog::selectedCatalogue() const -{ - auto catalogue = impl->m_DisplayedCatalogues.value(ui->cbCatalogue->currentIndex()); - if (!catalogue || catalogue->getName() != catalogueName()) { - return nullptr; - } - - return catalogue; -} - -QString CreateEventDialog::catalogueName() const -{ - return ui->cbCatalogue->currentText(); -} diff --git a/gui/ui/Catalogue/CreateEventDialog.ui b/gui/ui/Catalogue/CreateEventDialog.ui deleted file mode 100644 index b5352fe..0000000 --- a/gui/ui/Catalogue/CreateEventDialog.ui +++ /dev/null @@ -1,55 +0,0 @@ - - - CreateEventDialog - - - - 0 - 0 - 324 - 93 - - - - New Event - - - - - - Event Name - - - - - - - - - - Catalogue - - - - - - - true - - - QComboBox::NoInsert - - - - - - - QDialogButtonBox::Ok - - - - - - - -