diff --git a/qt/scientific_interfaces/Inelastic/QENSFitting/ConvFitDataView.cpp b/qt/scientific_interfaces/Inelastic/QENSFitting/ConvFitDataView.cpp index f793afc2f58a..a395e24bed6f 100644 --- a/qt/scientific_interfaces/Inelastic/QENSFitting/ConvFitDataView.cpp +++ b/qt/scientific_interfaces/Inelastic/QENSFitting/ConvFitDataView.cpp @@ -7,6 +7,7 @@ #include "ConvFitDataView.h" #include "Common/InterfaceUtils.h" #include "ConvFitAddWorkspaceDialog.h" +#include "FitDataPresenter.h" #include #include @@ -27,11 +28,9 @@ QStringList convFitHeaders() { namespace MantidQt::CustomInterfaces::Inelastic { -ConvFitDataView::ConvFitDataView(QWidget *parent, std::string const &tabName) - : ConvFitDataView(convFitHeaders(), parent, tabName) {} +ConvFitDataView::ConvFitDataView(QWidget *parent) : ConvFitDataView(convFitHeaders(), parent) {} -ConvFitDataView::ConvFitDataView(const QStringList &headers, QWidget *parent, std::string const &tabName) - : FitDataView(headers, parent, tabName) { +ConvFitDataView::ConvFitDataView(const QStringList &headers, QWidget *parent) : FitDataView(headers, parent) { auto header = m_uiForm->tbFitData->horizontalHeader(); header->setSectionResizeMode(1, QHeaderView::Stretch); } @@ -41,11 +40,12 @@ void ConvFitDataView::showAddWorkspaceDialog() { connect(dialog, SIGNAL(addData(MantidWidgets::IAddWorkspaceDialog *)), this, SLOT(notifyAddData(MantidWidgets::IAddWorkspaceDialog *))); + auto tabName = m_presenter->tabName(); dialog->setAttribute(Qt::WA_DeleteOnClose); - dialog->setWSSuffices(InterfaceUtils::getSampleWSSuffixes(m_tabName)); - dialog->setFBSuffices(InterfaceUtils::getSampleFBSuffixes(m_tabName)); - dialog->setResolutionWSSuffices(InterfaceUtils::getResolutionWSSuffixes(m_tabName)); - dialog->setResolutionFBSuffices(InterfaceUtils::getResolutionFBSuffixes(m_tabName)); + dialog->setWSSuffices(InterfaceUtils::getSampleWSSuffixes(tabName)); + dialog->setFBSuffices(InterfaceUtils::getSampleFBSuffixes(tabName)); + dialog->setResolutionWSSuffices(InterfaceUtils::getResolutionWSSuffixes(tabName)); + dialog->setResolutionFBSuffices(InterfaceUtils::getResolutionFBSuffixes(tabName)); dialog->updateSelectedSpectra(); dialog->show(); } diff --git a/qt/scientific_interfaces/Inelastic/QENSFitting/ConvFitDataView.h b/qt/scientific_interfaces/Inelastic/QENSFitting/ConvFitDataView.h index 38457e4aacb4..a57dc98483c9 100644 --- a/qt/scientific_interfaces/Inelastic/QENSFitting/ConvFitDataView.h +++ b/qt/scientific_interfaces/Inelastic/QENSFitting/ConvFitDataView.h @@ -22,11 +22,11 @@ Presenter for a table of convolution fitting data. class MANTIDQT_INELASTIC_DLL ConvFitDataView : public FitDataView { Q_OBJECT public: - ConvFitDataView(QWidget *parent, std::string const &tabName); + ConvFitDataView(QWidget *parent); void addTableEntry(size_t row, FitDataRow newRow) override; protected: - ConvFitDataView(const QStringList &headers, QWidget *parent, std::string const &tabName); + ConvFitDataView(const QStringList &headers, QWidget *parent); protected slots: void showAddWorkspaceDialog() override; diff --git a/qt/scientific_interfaces/Inelastic/QENSFitting/FitDataPresenter.cpp b/qt/scientific_interfaces/Inelastic/QENSFitting/FitDataPresenter.cpp index 5fcccdde5ad0..7bd5655e1683 100644 --- a/qt/scientific_interfaces/Inelastic/QENSFitting/FitDataPresenter.cpp +++ b/qt/scientific_interfaces/Inelastic/QENSFitting/FitDataPresenter.cpp @@ -26,6 +26,8 @@ std::vector *FitDataPresenter::getFittingData() { return m_model->getFi IFitDataView const *FitDataPresenter::getView() const { return m_view; } +std::string FitDataPresenter::tabName() const { return m_tab->tabName(); } + bool FitDataPresenter::addWorkspaceFromDialog(MantidWidgets::IAddWorkspaceDialog const *dialog) { if (const auto indirectDialog = dynamic_cast(dialog)) { addWorkspace(indirectDialog->workspaceName(), indirectDialog->workspaceIndices()); diff --git a/qt/scientific_interfaces/Inelastic/QENSFitting/FitDataPresenter.h b/qt/scientific_interfaces/Inelastic/QENSFitting/FitDataPresenter.h index bb7ffa6dd5ed..d91e20bc218f 100644 --- a/qt/scientific_interfaces/Inelastic/QENSFitting/FitDataPresenter.h +++ b/qt/scientific_interfaces/Inelastic/QENSFitting/FitDataPresenter.h @@ -24,6 +24,8 @@ class IFitTab; class MANTIDQT_INELASTIC_DLL IFitDataPresenter { public: + virtual std::string tabName() const = 0; + virtual void handleAddData(MantidWidgets::IAddWorkspaceDialog const *dialog) = 0; virtual void handleRemoveClicked() = 0; virtual void handleUnifyClicked() = 0; @@ -73,6 +75,8 @@ class MANTIDQT_INELASTIC_DLL FitDataPresenter : public IFitDataPresenter, public virtual void subscribeFitPropertyBrowser(IInelasticFitPropertyBrowser *browser) { UNUSED_ARG(browser); }; + std::string tabName() const override; + void handleAddData(MantidWidgets::IAddWorkspaceDialog const *dialog) override; void handleRemoveClicked() override; void handleUnifyClicked() override; diff --git a/qt/scientific_interfaces/Inelastic/QENSFitting/FitDataView.cpp b/qt/scientific_interfaces/Inelastic/QENSFitting/FitDataView.cpp index 66dbc7f2ea11..564f7a0ba0cc 100644 --- a/qt/scientific_interfaces/Inelastic/QENSFitting/FitDataView.cpp +++ b/qt/scientific_interfaces/Inelastic/QENSFitting/FitDataView.cpp @@ -32,11 +32,10 @@ namespace MantidQt { namespace CustomInterfaces { namespace Inelastic { -FitDataView::FitDataView(QWidget *parent, std::string const &tabName) - : FitDataView(defaultHeaders(), parent, tabName) {} +FitDataView::FitDataView(QWidget *parent) : FitDataView(defaultHeaders(), parent) {} -FitDataView::FitDataView(const QStringList &headers, QWidget *parent, std::string const &tabName) - : QTabWidget(parent), m_uiForm(new Ui::FitDataView), m_tabName(tabName) { +FitDataView::FitDataView(const QStringList &headers, QWidget *parent) + : QTabWidget(parent), m_uiForm(new Ui::FitDataView) { m_uiForm->setupUi(this); setHorizontalHeaders(headers); @@ -136,9 +135,10 @@ void FitDataView::showAddWorkspaceDialog() { connect(dialog, SIGNAL(addData(MantidWidgets::IAddWorkspaceDialog *)), this, SLOT(notifyAddData(MantidWidgets::IAddWorkspaceDialog *))); + auto tabName = m_presenter->tabName(); dialog->setAttribute(Qt::WA_DeleteOnClose); - dialog->setWSSuffices(InterfaceUtils::getSampleWSSuffixes(m_tabName)); - dialog->setFBSuffices(InterfaceUtils::getSampleFBSuffixes(m_tabName)); + dialog->setWSSuffices(InterfaceUtils::getSampleWSSuffixes(tabName)); + dialog->setFBSuffices(InterfaceUtils::getSampleFBSuffixes(tabName)); dialog->updateSelectedSpectra(); dialog->show(); } diff --git a/qt/scientific_interfaces/Inelastic/QENSFitting/FitDataView.h b/qt/scientific_interfaces/Inelastic/QENSFitting/FitDataView.h index eb7bb2ebea62..cb4030fc0b93 100644 --- a/qt/scientific_interfaces/Inelastic/QENSFitting/FitDataView.h +++ b/qt/scientific_interfaces/Inelastic/QENSFitting/FitDataView.h @@ -28,7 +28,7 @@ class IFitDataPresenter; class MANTIDQT_INELASTIC_DLL FitDataView : public QTabWidget, public IFitDataView { Q_OBJECT public: - FitDataView(QWidget *parent, std::string const &tabName); + FitDataView(QWidget *parent); ~FitDataView() override = default; void subscribePresenter(IFitDataPresenter *presenter) override; @@ -51,9 +51,7 @@ protected slots: void notifyAddData(MantidWidgets::IAddWorkspaceDialog *dialog); protected: - FitDataView(const QStringList &headers, QWidget *parent, std::string const &tabName); - - std::string m_tabName; + FitDataView(const QStringList &headers, QWidget *parent); std::unique_ptr m_uiForm; void setCell(std::unique_ptr cell, size_t row, size_t column); diff --git a/qt/scientific_interfaces/Inelastic/QENSFitting/FitTab.cpp b/qt/scientific_interfaces/Inelastic/QENSFitting/FitTab.cpp index 660cc6816e6e..38031313495a 100644 --- a/qt/scientific_interfaces/Inelastic/QENSFitting/FitTab.cpp +++ b/qt/scientific_interfaces/Inelastic/QENSFitting/FitTab.cpp @@ -20,10 +20,11 @@ namespace MantidQt { namespace CustomInterfaces { namespace Inelastic { -FitTab::FitTab(QWidget *parent) +FitTab::FitTab(QWidget *parent, std::string const &tabName) : IndirectTab(parent), m_uiForm(new Ui::FitTab), m_dataPresenter(), m_fittingModel(), m_plotPresenter(), m_outOptionsPresenter(), m_fitPropertyBrowser(), m_fittingAlgorithm() { m_uiForm->setupUi(parent); + parent->setWindowTitle(QString::fromStdString(tabName)); } void FitTab::setup() { @@ -329,6 +330,8 @@ void FitTab::updateResultOptions() { m_outOptionsPresenter->setSaveEnabled(isFit); } +std::string FitTab::tabName() const { return m_parentWidget->windowTitle().toStdString(); } + void FitTab::handleDataChanged() { updateDataReferences(); m_fittingModel->removeFittingData(); diff --git a/qt/scientific_interfaces/Inelastic/QENSFitting/FitTab.h b/qt/scientific_interfaces/Inelastic/QENSFitting/FitTab.h index c15fac7ee21e..cc9593bb4511 100644 --- a/qt/scientific_interfaces/Inelastic/QENSFitting/FitTab.h +++ b/qt/scientific_interfaces/Inelastic/QENSFitting/FitTab.h @@ -28,6 +28,7 @@ namespace Inelastic { class MANTIDQT_INELASTIC_DLL IFitTab { public: // Used by FitDataPresenter + virtual std::string tabName() const = 0; virtual void handleDataAdded(IAddWorkspaceDialog const *dialog) = 0; virtual void handleDataChanged() = 0; virtual void handleDataRemoved() = 0; @@ -53,7 +54,7 @@ class MANTIDQT_INELASTIC_DLL FitTab : public IndirectTab, public IFitTab { Q_OBJECT public: - FitTab(QWidget *parent); + FitTab(QWidget *parent, std::string const &tabName); virtual ~FitTab() override = default; template void setupFittingModel() { m_fittingModel = std::make_unique(); } @@ -73,8 +74,8 @@ class MANTIDQT_INELASTIC_DLL FitTab : public IndirectTab, public IFitTab { m_fitPropertyBrowser->setOutputCompositeMembers(true); } - template void setupFitDataView(std::string const &tabName) { - m_uiForm->dockArea->setFitDataView(new FitDataView(m_uiForm->dockArea, tabName)); + template void setupFitDataView() { + m_uiForm->dockArea->setFitDataView(new FitDataView(m_uiForm->dockArea)); } template void setUpFitDataPresenter() { @@ -86,6 +87,8 @@ class MANTIDQT_INELASTIC_DLL FitTab : public IndirectTab, public IFitTab { void setupPlotView(std::optional> const &xPlotBounds = std::nullopt); void subscribeFitBrowserToDataPresenter(); + std::string tabName() const override; + void handleDataAdded(IAddWorkspaceDialog const *dialog) override; void handleDataChanged() override; void handleDataRemoved() override; diff --git a/qt/scientific_interfaces/Inelastic/QENSFitting/FqFitDataView.cpp b/qt/scientific_interfaces/Inelastic/QENSFitting/FqFitDataView.cpp index cff7dc275847..1db0c2de559c 100644 --- a/qt/scientific_interfaces/Inelastic/QENSFitting/FqFitDataView.cpp +++ b/qt/scientific_interfaces/Inelastic/QENSFitting/FqFitDataView.cpp @@ -29,13 +29,11 @@ QStringList FqFitHeaders() { namespace MantidQt::CustomInterfaces::Inelastic { -FqFitDataView::FqFitDataView(QWidget *parent, std::string const &tabName) - : FqFitDataView(FqFitHeaders(), parent, tabName) { +FqFitDataView::FqFitDataView(QWidget *parent) : FqFitDataView(FqFitHeaders(), parent) { connect(m_uiForm->pbAdd, SIGNAL(clicked()), this, SLOT(notifyAddClicked())); } -FqFitDataView::FqFitDataView(const QStringList &headers, QWidget *parent, std::string const &tabName) - : FitDataView(headers, parent, tabName) { +FqFitDataView::FqFitDataView(const QStringList &headers, QWidget *parent) : FitDataView(headers, parent) { auto header = m_uiForm->tbFitData->horizontalHeader(); header->setSectionResizeMode(1, QHeaderView::Stretch); } @@ -49,9 +47,10 @@ void FqFitDataView::showAddWorkspaceDialog() { connect(dialog, SIGNAL(parameterTypeChanged(FqFitAddWorkspaceDialog *, const std::string &)), this, SLOT(notifyParameterTypeChanged(FqFitAddWorkspaceDialog *, const std::string &))); + auto tabName = m_presenter->tabName(); dialog->setAttribute(Qt::WA_DeleteOnClose); - dialog->setWSSuffices(InterfaceUtils::getSampleWSSuffixes(m_tabName)); - dialog->setFBSuffices(InterfaceUtils::getSampleFBSuffixes(m_tabName)); + dialog->setWSSuffices(InterfaceUtils::getSampleWSSuffixes(tabName)); + dialog->setFBSuffices(InterfaceUtils::getSampleFBSuffixes(tabName)); dialog->updateSelectedSpectra(); dialog->show(); } diff --git a/qt/scientific_interfaces/Inelastic/QENSFitting/FqFitDataView.h b/qt/scientific_interfaces/Inelastic/QENSFitting/FqFitDataView.h index 4fac629edd58..cc93f6c491de 100644 --- a/qt/scientific_interfaces/Inelastic/QENSFitting/FqFitDataView.h +++ b/qt/scientific_interfaces/Inelastic/QENSFitting/FqFitDataView.h @@ -23,11 +23,11 @@ Presenter for a table of convolution fitting data. class MANTIDQT_INELASTIC_DLL FqFitDataView : public FitDataView { Q_OBJECT public: - FqFitDataView(QWidget *parent, std::string const &tabName); + FqFitDataView(QWidget *parent); void addTableEntry(size_t row, FitDataRow newRow) override; protected: - FqFitDataView(const QStringList &headers, QWidget *parent, std::string const &tabName); + FqFitDataView(const QStringList &headers, QWidget *parent); protected slots: void showAddWorkspaceDialog() override; diff --git a/qt/scientific_interfaces/Inelastic/QENSFitting/TabFactory.cpp b/qt/scientific_interfaces/Inelastic/QENSFitting/TabFactory.cpp index 9076e76f0896..743084f25124 100644 --- a/qt/scientific_interfaces/Inelastic/QENSFitting/TabFactory.cpp +++ b/qt/scientific_interfaces/Inelastic/QENSFitting/TabFactory.cpp @@ -39,11 +39,11 @@ namespace MantidQt::CustomInterfaces::Inelastic { TabFactory::TabFactory(QTabWidget *tabWidget) : m_tabWidget(tabWidget) {} FitTab *TabFactory::makeMSDFitTab(int const index) const { - auto tab = new FitTab(m_tabWidget->widget(index)); + auto tab = new FitTab(m_tabWidget->widget(index), MSDFit::TAB_NAME); tab->setupFittingModel(); tab->setupFitPropertyBrowser( MSDFit::HIDDEN_PROPS); - tab->setupFitDataView(MSDFit::TAB_NAME); + tab->setupFitDataView(); tab->setupOutputOptionsPresenter(); tab->setUpFitDataPresenter(); tab->setupPlotView(); @@ -51,12 +51,12 @@ FitTab *TabFactory::makeMSDFitTab(int const index) const { } FitTab *TabFactory::makeIqtFitTab(int const index) const { - auto tab = new FitTab(m_tabWidget->widget(index)); + auto tab = new FitTab(m_tabWidget->widget(index), IqtFit::TAB_NAME); tab->setupFittingModel(); auto browserCustomizations = packBrowserCustomizations(IqtFit::templateSubTypes()); tab->setupFitPropertyBrowser( IqtFit::HIDDEN_PROPS, false, std::move(browserCustomizations)); - tab->setupFitDataView(IqtFit::TAB_NAME); + tab->setupFitDataView(); tab->setupOutputOptionsPresenter(true); tab->setUpFitDataPresenter(); tab->setupPlotView(); @@ -64,12 +64,12 @@ FitTab *TabFactory::makeIqtFitTab(int const index) const { } FitTab *TabFactory::makeConvFitTab(int const index) const { - auto tab = new FitTab(m_tabWidget->widget(index)); + auto tab = new FitTab(m_tabWidget->widget(index), ConvFit::TAB_NAME); tab->setupFittingModel(); auto browserCustomizations = packBrowserCustomizations(ConvFit::templateSubTypes()); tab->setupFitPropertyBrowser( ConvFit::HIDDEN_PROPS, true, std::move(browserCustomizations)); - tab->setupFitDataView(ConvFit::TAB_NAME); + tab->setupFitDataView(); tab->setupOutputOptionsPresenter(true); tab->setUpFitDataPresenter(); tab->setupPlotView(); @@ -77,11 +77,11 @@ FitTab *TabFactory::makeConvFitTab(int const index) const { } FitTab *TabFactory::makeFqFitTab(int const index) const { - auto tab = new FitTab(m_tabWidget->widget(index)); + auto tab = new FitTab(m_tabWidget->widget(index), FqFit::TAB_NAME); tab->setupFittingModel(); tab->setupFitPropertyBrowser( FqFit::HIDDEN_PROPS); - tab->setupFitDataView(FqFit::TAB_NAME); + tab->setupFitDataView(); tab->setupOutputOptionsPresenter(); tab->setUpFitDataPresenter(); tab->subscribeFitBrowserToDataPresenter(); diff --git a/qt/scientific_interfaces/Inelastic/test/QENSFitting/MockObjects.h b/qt/scientific_interfaces/Inelastic/test/QENSFitting/MockObjects.h index fac57a37bca7..c362e5c8b855 100644 --- a/qt/scientific_interfaces/Inelastic/test/QENSFitting/MockObjects.h +++ b/qt/scientific_interfaces/Inelastic/test/QENSFitting/MockObjects.h @@ -35,6 +35,7 @@ class MockFitTab : public IFitTab { public: virtual ~MockFitTab() = default; + MOCK_CONST_METHOD0(tabName, std::string()); MOCK_METHOD1(handleDataAdded, void(MantidQt::MantidWidgets::IAddWorkspaceDialog const *dialog)); MOCK_METHOD0(handleDataChanged, void()); MOCK_METHOD0(handleDataRemoved, void());