diff --git a/qt/scientific_interfaces/ISISReflectometry/GUI/Batch/BatchPresenter.cpp b/qt/scientific_interfaces/ISISReflectometry/GUI/Batch/BatchPresenter.cpp index e2aa9487ac009e6700a8149d516254b455f6c00a..4db12e9289cf552a4c8ae06b6db71efc5eaa4422 100644 --- a/qt/scientific_interfaces/ISISReflectometry/GUI/Batch/BatchPresenter.cpp +++ b/qt/scientific_interfaces/ISISReflectometry/GUI/Batch/BatchPresenter.cpp @@ -69,6 +69,10 @@ void BatchPresenter::acceptMainPresenter(IMainWindowPresenter *mainPresenter) { m_mainPresenter = mainPresenter; } +void BatchPresenter::initInstrumentList() { + m_runsPresenter->initInstrumentList(); +} + bool BatchPresenter::requestClose() const { return true; } void BatchPresenter::notifyInstrumentChangedRequested( diff --git a/qt/scientific_interfaces/ISISReflectometry/GUI/Batch/BatchPresenter.h b/qt/scientific_interfaces/ISISReflectometry/GUI/Batch/BatchPresenter.h index 1290e6bee479661963cc90e4a12a5ab9f74aa2da..211ef6204176793fcc824a8e24334484feb247de 100644 --- a/qt/scientific_interfaces/ISISReflectometry/GUI/Batch/BatchPresenter.h +++ b/qt/scientific_interfaces/ISISReflectometry/GUI/Batch/BatchPresenter.h @@ -55,6 +55,7 @@ public: // IBatchPresenter overrides void acceptMainPresenter(IMainWindowPresenter *mainPresenter) override; + void initInstrumentList() override; void notifyReductionPaused() override; void notifyReductionResumed() override; void notifyAutoreductionResumed() override; diff --git a/qt/scientific_interfaces/ISISReflectometry/GUI/Batch/IBatchPresenter.h b/qt/scientific_interfaces/ISISReflectometry/GUI/Batch/IBatchPresenter.h index a9d95e7f9e62894cd15fa8389b324f851324c256..3196b64433e9da4ad791945ae07341ebd072eb63 100644 --- a/qt/scientific_interfaces/ISISReflectometry/GUI/Batch/IBatchPresenter.h +++ b/qt/scientific_interfaces/ISISReflectometry/GUI/Batch/IBatchPresenter.h @@ -30,6 +30,7 @@ public: virtual ~IBatchPresenter() = default; virtual void acceptMainPresenter(IMainWindowPresenter *mainPresenter) = 0; + virtual void initInstrumentList() = 0; virtual void notifyReductionPaused() = 0; virtual void notifyReductionResumed() = 0; diff --git a/qt/scientific_interfaces/ISISReflectometry/GUI/MainWindow/MainWindowPresenter.cpp b/qt/scientific_interfaces/ISISReflectometry/GUI/MainWindow/MainWindowPresenter.cpp index 71c098055b2418f437be1b8599f9cecc4ba82baa..d9d8c9b51e417e5398427e3d7e827e5ea6e3af9d 100644 --- a/qt/scientific_interfaces/ISISReflectometry/GUI/MainWindow/MainWindowPresenter.cpp +++ b/qt/scientific_interfaces/ISISReflectometry/GUI/MainWindow/MainWindowPresenter.cpp @@ -130,15 +130,21 @@ bool MainWindowPresenter::isAnyBatchAutoreducing() const { void MainWindowPresenter::addNewBatch(IBatchView *batchView) { m_batchPresenters.emplace_back(m_batchPresenterFactory->make(batchView)); m_batchPresenters.back()->acceptMainPresenter(this); + initNewBatch(m_batchPresenters.back().get()); +} + +void MainWindowPresenter::initNewBatch(IBatchPresenter *batchPresenter) { + + batchPresenter->initInstrumentList(); // starts in the paused state - m_batchPresenters.back()->reductionPaused(); + batchPresenter->reductionPaused(); // Ensure autoreduce button is enabled/disabled correctly for the new batch if (isAnyBatchAutoreducing()) - m_batchPresenters.back()->anyBatchAutoreductionResumed(); + batchPresenter->anyBatchAutoreductionResumed(); else - m_batchPresenters.back()->anyBatchAutoreductionPaused(); + batchPresenter->anyBatchAutoreductionPaused(); } void MainWindowPresenter::showHelp() { diff --git a/qt/scientific_interfaces/ISISReflectometry/GUI/MainWindow/MainWindowPresenter.h b/qt/scientific_interfaces/ISISReflectometry/GUI/MainWindow/MainWindowPresenter.h index 16de5b1ce81780168d7892361a1e244e96b645ff..aac7bed1ba97cde42da00a571c1e72cd3e5c6b4a 100644 --- a/qt/scientific_interfaces/ISISReflectometry/GUI/MainWindow/MainWindowPresenter.h +++ b/qt/scientific_interfaces/ISISReflectometry/GUI/MainWindow/MainWindowPresenter.h @@ -72,6 +72,7 @@ private: void showHelp(); void addNewBatch(IBatchView *batchView); + void initNewBatch(IBatchPresenter *batchPresenter); void changeInstrument(std::string const &instrumentName); void updateInstrument(const std::string &instrumentName); diff --git a/qt/scientific_interfaces/ISISReflectometry/GUI/Runs/IRunsPresenter.h b/qt/scientific_interfaces/ISISReflectometry/GUI/Runs/IRunsPresenter.h index 4411d07bdf7b654f75f5507dd3eda4bc1f884f43..1d874ad4afd66595203c0db3a9439a2f3291099e 100644 --- a/qt/scientific_interfaces/ISISReflectometry/GUI/Runs/IRunsPresenter.h +++ b/qt/scientific_interfaces/ISISReflectometry/GUI/Runs/IRunsPresenter.h @@ -25,6 +25,7 @@ class IRunsPresenter { public: virtual ~IRunsPresenter() = default; virtual void acceptMainPresenter(IBatchPresenter *mainPresenter) = 0; + virtual void initInstrumentList() = 0; virtual RunsTable const &runsTable() const = 0; virtual RunsTable &mutableRunsTable() = 0; diff --git a/qt/scientific_interfaces/ISISReflectometry/GUI/Runs/RunsPresenter.cpp b/qt/scientific_interfaces/ISISReflectometry/GUI/Runs/RunsPresenter.cpp index d2082b2c987a17a3dabd4dd573cfde7d71652ff6..bb75361962cea64b029f5167fc38655c5f739e7b 100644 --- a/qt/scientific_interfaces/ISISReflectometry/GUI/Runs/RunsPresenter.cpp +++ b/qt/scientific_interfaces/ISISReflectometry/GUI/Runs/RunsPresenter.cpp @@ -77,8 +77,9 @@ RunsPresenter::~RunsPresenter() { */ void RunsPresenter::acceptMainPresenter(IBatchPresenter *mainPresenter) { m_mainPresenter = mainPresenter; - // Must do this after setting main presenter or notifications don't get - // through +} + +void RunsPresenter::initInstrumentList() { m_view->setInstrumentList(m_instruments, m_defaultInstrumentIndex); } diff --git a/qt/scientific_interfaces/ISISReflectometry/GUI/Runs/RunsPresenter.h b/qt/scientific_interfaces/ISISReflectometry/GUI/Runs/RunsPresenter.h index 3634bb95cdb8f17a9bf4d26bf52548b077d72616..26bff04c749c34775771235f789d66c0ad0c5e7a 100644 --- a/qt/scientific_interfaces/ISISReflectometry/GUI/Runs/RunsPresenter.h +++ b/qt/scientific_interfaces/ISISReflectometry/GUI/Runs/RunsPresenter.h @@ -69,6 +69,7 @@ public: // IRunsPresenter overrides void acceptMainPresenter(IBatchPresenter *mainPresenter) override; + void initInstrumentList() override; RunsTable const &runsTable() const override; RunsTable &mutableRunsTable() override; bool isProcessing() const override; diff --git a/qt/scientific_interfaces/test/ISISReflectometry/Batch/BatchPresenterTest.h b/qt/scientific_interfaces/test/ISISReflectometry/Batch/BatchPresenterTest.h index 9cb4b2b72e06194eb698d37a6c7757658a62cf2d..d6fd51685b406b2b7e8f912e43744608e6ec5e4b 100644 --- a/qt/scientific_interfaces/test/ISISReflectometry/Batch/BatchPresenterTest.h +++ b/qt/scientific_interfaces/test/ISISReflectometry/Batch/BatchPresenterTest.h @@ -54,6 +54,13 @@ public: verifyAndClear(); } + void testInitInstrumentListUpdatesRunsPresenter() { + auto presenter = makePresenter(); + EXPECT_CALL(*m_runsPresenter, initInstrumentList()).Times(1); + presenter.initInstrumentList(); + verifyAndClear(); + } + void testMainPresenterUpdatedWhenInstrumentChangedRequested() { auto presenter = makePresenter(); auto const instrument = std::string("POLREF"); diff --git a/qt/scientific_interfaces/test/ISISReflectometry/MainWindow/MainWindowPresenterTest.h b/qt/scientific_interfaces/test/ISISReflectometry/MainWindow/MainWindowPresenterTest.h index c61a1b126aac7ae231d04485a2e4315138bf453b..892f3d48e8e709efa697989dabb43f746ef087e5 100644 --- a/qt/scientific_interfaces/test/ISISReflectometry/MainWindow/MainWindowPresenterTest.h +++ b/qt/scientific_interfaces/test/ISISReflectometry/MainWindow/MainWindowPresenterTest.h @@ -283,6 +283,7 @@ private: void expectBatchAdded(MockBatchPresenter *batchPresenter) { EXPECT_CALL(*batchPresenter, acceptMainPresenter(_)).Times(1); + EXPECT_CALL(*batchPresenter, initInstrumentList()).Times(1); EXPECT_CALL(*batchPresenter, reductionPaused()).Times(1); EXPECT_CALL(*batchPresenter, anyBatchAutoreductionPaused()).Times(1); } diff --git a/qt/scientific_interfaces/test/ISISReflectometry/ReflMockObjects.h b/qt/scientific_interfaces/test/ISISReflectometry/ReflMockObjects.h index e918840f1b93bc3f88897a9d7cb849251a7ef08a..76d85c9a488816a86c6a1e8e60dd30258fa169e6 100644 --- a/qt/scientific_interfaces/test/ISISReflectometry/ReflMockObjects.h +++ b/qt/scientific_interfaces/test/ISISReflectometry/ReflMockObjects.h @@ -55,6 +55,7 @@ public: class MockBatchPresenter : public IBatchPresenter { public: MOCK_METHOD1(acceptMainPresenter, void(IMainWindowPresenter *)); + MOCK_METHOD0(initInstrumentList, void()); MOCK_METHOD0(notifyReductionResumed, void()); MOCK_METHOD0(notifyReductionPaused, void()); MOCK_METHOD0(notifyAutoreductionResumed, void()); @@ -82,6 +83,7 @@ public: class MockRunsPresenter : public IRunsPresenter { public: MOCK_METHOD1(acceptMainPresenter, void(IBatchPresenter *)); + MOCK_METHOD0(initInstrumentList, void()); MOCK_CONST_METHOD0(runsTable, RunsTable const &()); MOCK_METHOD0(mutableRunsTable, RunsTable &()); MOCK_METHOD1(notifyInstrumentChangedRequested, void(std::string const &)); diff --git a/qt/scientific_interfaces/test/ISISReflectometry/Runs/RunsPresenterTest.h b/qt/scientific_interfaces/test/ISISReflectometry/Runs/RunsPresenterTest.h index 52b924f46da99c07769e4e8462aed8540f59d2b0..3fab9cc199a697fb59f414ac7a43241549770206 100644 --- a/qt/scientific_interfaces/test/ISISReflectometry/Runs/RunsPresenterTest.h +++ b/qt/scientific_interfaces/test/ISISReflectometry/Runs/RunsPresenterTest.h @@ -70,12 +70,13 @@ public: verifyAndClear(); } - void testCreatePresenterSetsInstrumentList() { + void testInitInstrumentListUpdatesView() { auto const defaultInstrumentIndex = 0; + auto presenter = makePresenter(); EXPECT_CALL(m_view, setInstrumentList(m_instruments, defaultInstrumentIndex)) .Times(1); - auto presenter = makePresenter(); + presenter.initInstrumentList(); verifyAndClear(); }