From c1eea62fc3fbd3cce057d733f962707f56848e6e Mon Sep 17 00:00:00 2001 From: Gemma Guest <gemma.guest@stfc.ac.uk> Date: Wed, 19 Dec 2018 11:45:42 +0000 Subject: [PATCH] Move and rename file for the Runs tab Move them into the GUI/Runs subdirectory and rename in line with other components Re #23027 --- .../ISISReflectometry/CMakeLists.txt | 8 -- .../ISISReflectometry/GUI/CMakeLists.txt | 6 +- .../ISISReflectometry/GUI/Runs/CMakeLists.txt | 32 +++++ .../Runs/IRunsPresenter.h} | 10 +- .../Runs/IRunsView.h} | 20 +-- .../Runs/RunsPresenter.cpp} | 124 +++++++++-------- .../Runs/RunsPresenter.h} | 53 ++++---- .../Runs/RunsPresenterFactory.h} | 18 +-- .../Runs/RunsView.cpp} | 126 ++++++++---------- .../Runs/RunsView.h} | 28 ++-- .../Runs/RunsWidget.ui} | 4 +- .../ISISReflectometry/IReflBatchView.h | 4 +- .../ISISReflectometry/IReflSearcher.h | 5 +- .../ISISReflectometry/QtReflBatchView.cpp | 9 +- .../ISISReflectometry/QtReflBatchView.h | 8 +- .../ISISReflectometry/ReflAutoreduction.cpp | 4 +- .../ISISReflectometry/ReflBatchPresenter.cpp | 6 +- .../ISISReflectometry/ReflBatchPresenter.h | 6 +- .../ReflBatchPresenterFactory.h | 2 +- .../ReflMainWindowPresenter.cpp | 2 +- .../Runs/MockRunsPresenter.h | 32 +++++ .../ISISReflectometry/Runs/MockRunsView.h | 71 ++++++++++ .../test/ReflMockObjects.h | 64 --------- 23 files changed, 346 insertions(+), 296 deletions(-) create mode 100644 qt/scientific_interfaces/ISISReflectometry/GUI/Runs/CMakeLists.txt rename qt/scientific_interfaces/ISISReflectometry/{IReflRunsTabPresenter.h => GUI/Runs/IRunsPresenter.h} (84%) rename qt/scientific_interfaces/ISISReflectometry/{IReflRunsTabView.h => GUI/Runs/IRunsView.h} (83%) rename qt/scientific_interfaces/ISISReflectometry/{ReflRunsTabPresenter.cpp => GUI/Runs/RunsPresenter.cpp} (83%) rename qt/scientific_interfaces/ISISReflectometry/{ReflRunsTabPresenter.h => GUI/Runs/RunsPresenter.h} (73%) rename qt/scientific_interfaces/ISISReflectometry/{ReflRunsPresenterFactory.h => GUI/Runs/RunsPresenterFactory.h} (78%) rename qt/scientific_interfaces/ISISReflectometry/{QtReflRunsTabView.cpp => GUI/Runs/RunsView.cpp} (73%) rename qt/scientific_interfaces/ISISReflectometry/{QtReflRunsTabView.h => GUI/Runs/RunsView.h} (85%) rename qt/scientific_interfaces/ISISReflectometry/{ReflRunsTabWidget.ui => GUI/Runs/RunsWidget.ui} (99%) create mode 100644 qt/scientific_interfaces/test/ISISReflectometry/Runs/MockRunsPresenter.h create mode 100644 qt/scientific_interfaces/test/ISISReflectometry/Runs/MockRunsView.h diff --git a/qt/scientific_interfaces/ISISReflectometry/CMakeLists.txt b/qt/scientific_interfaces/ISISReflectometry/CMakeLists.txt index bd2128c8d0d..ee8630e5029 100644 --- a/qt/scientific_interfaces/ISISReflectometry/CMakeLists.txt +++ b/qt/scientific_interfaces/ISISReflectometry/CMakeLists.txt @@ -20,7 +20,6 @@ set ( SRC_FILES ExperimentOptionDefaults.cpp QtReflMainWindowView.cpp QtReflBatchView.cpp - QtReflRunsTabView.cpp ReflCatalogSearcher.cpp ReflAsciiSaver.cpp IReflAsciiSaver.cpp @@ -29,7 +28,6 @@ set ( SRC_FILES ReflMainWindowPresenter.cpp ReflBatchPresenter.cpp ReflNexusMeasurementItemSource.cpp - ReflRunsTabPresenter.cpp ReflSearchModel.cpp ReflTableSchema.cpp Parse.cpp @@ -49,14 +47,11 @@ set ( INC_FILES IReflMainWindowView.h IReflBatchView.h IReflMessageHandler.h - IReflRunsTabPresenter.h - IReflRunsTabView.h IReflSearcher.h MeasurementItem.h PrecompiledHeader.h QtReflMainWindowView.h QtReflBatchView.h - QtReflRunsTabView.h QWidgetGroup.h ReflAutoreduction.h ReflCatalogSearcher.h @@ -67,7 +62,6 @@ set ( INC_FILES ReflBatchPresenter.h ReflMeasurementItemSource.h ReflNexusMeasurementItemSource.h - ReflRunsTabPresenter.h ReflSearchModel.h ReflTableSchema.h TransferResults.h @@ -80,7 +74,6 @@ set ( INC_FILES set ( MOC_FILES ${GUI_MOC_FILES} ReflSearchModel.h - QtReflRunsTabView.h QtReflMainWindowView.h QtReflBatchView.h ) @@ -89,7 +82,6 @@ set ( UI_FILES ${GUI_UI_FILES} ReflMainWindowWidget.ui ReflBatchWidget.ui - ReflRunsTabWidget.ui ReflWindow.ui ) diff --git a/qt/scientific_interfaces/ISISReflectometry/GUI/CMakeLists.txt b/qt/scientific_interfaces/ISISReflectometry/GUI/CMakeLists.txt index 5b5201c2c77..5e1b3db9718 100644 --- a/qt/scientific_interfaces/ISISReflectometry/GUI/CMakeLists.txt +++ b/qt/scientific_interfaces/ISISReflectometry/GUI/CMakeLists.txt @@ -1,12 +1,13 @@ add_subdirectory( Event ) add_subdirectory(Experiment) add_subdirectory(Instrument) -#add_subdirectory(Runs) +add_subdirectory(Runs) add_subdirectory( RunsTable ) add_subdirectory(Save) set (GUI_SRC_FILES + ${RUNS_SRC_FILES} ${RUNS_TABLE_SRC_FILES} ${EXPERIMENT_SRC_FILES} ${EVENT_SRC_FILES} @@ -16,6 +17,7 @@ set (GUI_SRC_FILES ) set (GUI_INC_FILES + ${RUNS_INC_FILES} ${RUNS_TABLE_INC_FILES} ${EXPERIMENT_INC_FILES} ${EVENT_INC_FILES} @@ -25,6 +27,7 @@ set (GUI_INC_FILES ) set ( GUI_MOC_FILES + ${RUNS_MOC_FILES} ${RUNS_TABLE_MOC_FILES} ${EXPERIMENT_MOC_FILES} ${EVENT_MOC_FILES} @@ -34,6 +37,7 @@ set ( GUI_MOC_FILES ) set ( GUI_UI_FILES + ${RUNS_UI_FILES} ${RUNS_TABLE_UI_FILES} ${EXPERIMENT_UI_FILES} ${EVENT_UI_FILES} diff --git a/qt/scientific_interfaces/ISISReflectometry/GUI/Runs/CMakeLists.txt b/qt/scientific_interfaces/ISISReflectometry/GUI/Runs/CMakeLists.txt new file mode 100644 index 00000000000..b13956dcea6 --- /dev/null +++ b/qt/scientific_interfaces/ISISReflectometry/GUI/Runs/CMakeLists.txt @@ -0,0 +1,32 @@ +set ( RUNS_SRC_FILES + RunsPresenter.cpp + RunsView.cpp +) + +# Include files aren't required, but this makes them appear in Visual Studio +# IMPORTANT: Include files are required in the MOC_FILES set. Scroll down to find it. +set ( RUNS_INC_FILES + IRunsPresenter.h + IRunsView.h + RunsPresenter.h + RunsPresenterFactory.h + RunsView.h +) + +set ( RUNS_MOC_FILES + RunsView.h +) + +set ( RUNS_UI_FILES + RunsWidget.ui +) + +PREPEND( RUNS_SRC_FILES GUI/Runs ${RUNS_SRC_FILES}) +PREPEND( RUNS_INC_FILES GUI/Runs ${RUNS_INC_FILES}) +PREPEND( RUNS_MOC_FILES GUI/Runs ${RUNS_MOC_FILES}) +PREPEND( RUNS_UI_FILES GUI/Runs ${RUNS_UI_FILES}) + +set (RUNS_SRC_FILES ${RUNS_SRC_FILES} PARENT_SCOPE) +set (RUNS_INC_FILES ${RUNS_INC_FILES} PARENT_SCOPE) +set (RUNS_MOC_FILES ${RUNS_MOC_FILES} PARENT_SCOPE) +set (RUNS_UI_FILES ${RUNS_UI_FILES} PARENT_SCOPE) diff --git a/qt/scientific_interfaces/ISISReflectometry/IReflRunsTabPresenter.h b/qt/scientific_interfaces/ISISReflectometry/GUI/Runs/IRunsPresenter.h similarity index 84% rename from qt/scientific_interfaces/ISISReflectometry/IReflRunsTabPresenter.h rename to qt/scientific_interfaces/ISISReflectometry/GUI/Runs/IRunsPresenter.h index 15f9861de39..47a70072634 100644 --- a/qt/scientific_interfaces/ISISReflectometry/IReflRunsTabPresenter.h +++ b/qt/scientific_interfaces/ISISReflectometry/GUI/Runs/IRunsPresenter.h @@ -13,14 +13,14 @@ namespace MantidQt { namespace CustomInterfaces { -/** @class IReflRunsTabPresenter +/** @class IRunsPresenter -IReflRunsTabPresenter is an interface which defines the functions any +IRunsPresenter is an interface which defines the functions any reflectometry interface presenter needs to support. */ -class IReflRunsTabPresenter { +class IRunsPresenter { public: - virtual ~IReflRunsTabPresenter() = default; + virtual ~IRunsPresenter() = default; /// Accept a main presenter virtual void acceptMainPresenter(IReflBatchPresenter *mainPresenter) = 0; virtual void settingsChanged() = 0; @@ -40,7 +40,7 @@ public: }; // Tell the presenter something happened - virtual void notify(IReflRunsTabPresenter::Flag flag) = 0; + virtual void notify(IRunsPresenter::Flag flag) = 0; virtual bool isAutoreducing() const = 0; virtual bool isProcessing() const = 0; }; diff --git a/qt/scientific_interfaces/ISISReflectometry/IReflRunsTabView.h b/qt/scientific_interfaces/ISISReflectometry/GUI/Runs/IRunsView.h similarity index 83% rename from qt/scientific_interfaces/ISISReflectometry/IReflRunsTabView.h rename to qt/scientific_interfaces/ISISReflectometry/GUI/Runs/IRunsView.h index d32a6c0cced..264446b205a 100644 --- a/qt/scientific_interfaces/ISISReflectometry/IReflRunsTabView.h +++ b/qt/scientific_interfaces/ISISReflectometry/GUI/Runs/IRunsView.h @@ -4,8 +4,8 @@ // NScD Oak Ridge National Laboratory, European Spallation Source // & Institut Laue - Langevin // SPDX - License - Identifier: GPL - 3.0 + -#ifndef MANTID_ISISREFLECTOMETRY_IREFLRUNSTABVIEW_H -#define MANTID_ISISREFLECTOMETRY_IREFLRUNSTABVIEW_H +#ifndef MANTID_ISISREFLECTOMETRY_IRUNSVIEW_H +#define MANTID_ISISREFLECTOMETRY_IRUNSVIEW_H #include "DllConfig.h" #include "GUI/RunsTable/IRunsTableView.h" @@ -29,21 +29,21 @@ class AlgorithmRunner; namespace CustomInterfaces { namespace DataProcessor = MantidWidgets::DataProcessor; -class IReflRunsTabPresenter; +class IRunsPresenter; class ReflSearchModel; -/** @class IReflRunsTabView +/** @class IRunsView -IReflRunsTabView is the base view class for the Reflectometry Interface. It +IRunsView is the base view class for the Reflectometry Interface. It contains no QT specific functionality as that should be handled by a subclass. */ -class MANTIDQT_ISISREFLECTOMETRY_DLL IReflRunsTabView +class MANTIDQT_ISISREFLECTOMETRY_DLL IRunsView : public MantidQt::MantidWidgets::ProgressableView { public: - virtual ~IReflRunsTabView() = default; + virtual ~IRunsView() = default; - virtual void subscribe(IReflRunsTabPresenter *presenter) = 0; + virtual void subscribe(IRunsPresenter *presenter) = 0; virtual IRunsTableView *table() const = 0; // Connect the model @@ -68,7 +68,7 @@ public: virtual std::string getSearchInstrument() const = 0; virtual std::string getSearchString() const = 0; - virtual IReflRunsTabPresenter *getPresenter() const = 0; + virtual IRunsPresenter *getPresenter() const = 0; virtual boost::shared_ptr<MantidQt::API::AlgorithmRunner> getAlgorithmRunner() const = 0; virtual boost::shared_ptr<MantidQt::API::AlgorithmRunner> @@ -91,4 +91,4 @@ public: }; } // namespace CustomInterfaces } // namespace MantidQt -#endif /* MANTID_ISISREFLECTOMETRY_IREFLRUNSTABVIEW_H */ +#endif /* MANTID_ISISREFLECTOMETRY_IRUNSVIEW_H */ diff --git a/qt/scientific_interfaces/ISISReflectometry/ReflRunsTabPresenter.cpp b/qt/scientific_interfaces/ISISReflectometry/GUI/Runs/RunsPresenter.cpp similarity index 83% rename from qt/scientific_interfaces/ISISReflectometry/ReflRunsTabPresenter.cpp rename to qt/scientific_interfaces/ISISReflectometry/GUI/Runs/RunsPresenter.cpp index 4b2a2eac3b3..92b6afa8254 100644 --- a/qt/scientific_interfaces/ISISReflectometry/ReflRunsTabPresenter.cpp +++ b/qt/scientific_interfaces/ISISReflectometry/GUI/Runs/RunsPresenter.cpp @@ -4,10 +4,10 @@ // NScD Oak Ridge National Laboratory, European Spallation Source // & Institut Laue - Langevin // SPDX - License - Identifier: GPL - 3.0 + -#include "ReflRunsTabPresenter.h" +#include "RunsPresenter.h" #include "IReflMainWindowPresenter.h" #include "IReflMessageHandler.h" -#include "IReflRunsTabView.h" +#include "IRunsView.h" #include "MantidAPI/AlgorithmManager.h" #include "MantidAPI/CatalogManager.h" #include "MantidAPI/ITableWorkspace.h" @@ -63,12 +63,14 @@ Mantid::Kernel::Logger g_log("Reflectometry GUI"); * @param messageHandler :: A handler to pass messages to the user * @param searcher :: [input] The search implementation */ -ReflRunsTabPresenter::ReflRunsTabPresenter( - IReflRunsTabView *mainView, ProgressableView *progressableView, - RunsTablePresenterFactory makeRunsTablePresenter, double thetaTolerance, - std::vector<std::string> const &instruments, int defaultInstrumentIndex, - IReflMessageHandler *messageHandler, - boost::shared_ptr<IReflSearcher> searcher) +RunsPresenter::RunsPresenter(IRunsView *mainView, + ProgressableView *progressableView, + RunsTablePresenterFactory makeRunsTablePresenter, + double thetaTolerance, + std::vector<std::string> const &instruments, + int defaultInstrumentIndex, + IReflMessageHandler *messageHandler, + boost::shared_ptr<IReflSearcher> searcher) : m_view(mainView), m_progressView(progressableView), m_makeRunsTablePresenter(makeRunsTablePresenter), m_mainPresenter(nullptr), m_messageHandler(messageHandler), @@ -88,7 +90,7 @@ ReflRunsTabPresenter::ReflRunsTabPresenter( updateViewWhenMonitorStopped(); } -ReflRunsTabPresenter::~ReflRunsTabPresenter() { +RunsPresenter::~RunsPresenter() { if (m_monitorAlg) stopObserving(m_monitorAlg); } @@ -96,8 +98,7 @@ ReflRunsTabPresenter::~ReflRunsTabPresenter() { /** Accept a main presenter * @param mainPresenter :: [input] A main presenter */ -void ReflRunsTabPresenter::acceptMainPresenter( - IReflBatchPresenter *mainPresenter) { +void RunsPresenter::acceptMainPresenter(IReflBatchPresenter *mainPresenter) { m_mainPresenter = mainPresenter; // Register this presenter as the workspace receiver // When doing so, the inner presenters will notify this @@ -111,7 +112,7 @@ void ReflRunsTabPresenter::acceptMainPresenter( // presenter. } -void ReflRunsTabPresenter::settingsChanged() { +void RunsPresenter::settingsChanged() { // assert(static_cast<std::size_t>(group) < m_tablePresenters.size()); // m_tablePresenters[group]->settingsChanged(); } @@ -119,43 +120,43 @@ void ReflRunsTabPresenter::settingsChanged() { /** Used by the view to tell the presenter something has changed */ -void ReflRunsTabPresenter::notify(IReflRunsTabPresenter::Flag flag) { +void RunsPresenter::notify(IRunsPresenter::Flag flag) { switch (flag) { - case IReflRunsTabPresenter::SearchFlag: + case IRunsPresenter::SearchFlag: // Start the search algorithm. If it is not started, make sure // autoreduction is not left running if (!search()) stopAutoreduction(); break; - case IReflRunsTabPresenter::StartAutoreductionFlag: + case IRunsPresenter::StartAutoreductionFlag: startNewAutoreduction(); break; - case IReflRunsTabPresenter::PauseAutoreductionFlag: + case IRunsPresenter::PauseAutoreductionFlag: pauseAutoreduction(); break; - case IReflRunsTabPresenter::TimerEventFlag: + case IRunsPresenter::TimerEventFlag: checkForNewRuns(); break; - case IReflRunsTabPresenter::ICATSearchCompleteFlag: { + case IRunsPresenter::ICATSearchCompleteFlag: { icatSearchComplete(); break; } - case IReflRunsTabPresenter::TransferFlag: + case IRunsPresenter::TransferFlag: transfer(m_view->getSelectedSearchRows(), TransferMatch::Any); break; - case IReflRunsTabPresenter::InstrumentChangedFlag: + case IRunsPresenter::InstrumentChangedFlag: changeInstrument(); break; - case IReflRunsTabPresenter::GroupChangedFlag: + case IRunsPresenter::GroupChangedFlag: changeGroup(); break; - case IReflRunsTabPresenter::StartMonitorFlag: + case IRunsPresenter::StartMonitorFlag: startMonitor(); break; - case IReflRunsTabPresenter::StopMonitorFlag: + case IRunsPresenter::StopMonitorFlag: stopMonitor(); break; - case IReflRunsTabPresenter::StartMonitorCompleteFlag: + case IRunsPresenter::StartMonitorCompleteFlag: startMonitorComplete(); break; } @@ -166,7 +167,7 @@ void ReflRunsTabPresenter::notify(IReflRunsTabPresenter::Flag flag) { /** Searches for runs that can be used * @return : true if the search algorithm was started successfully, false if * there was a problem */ -bool ReflRunsTabPresenter::search() { +bool RunsPresenter::search() { auto const searchString = m_view->getSearchString(); // Don't bother searching if they're not searching for anything if (searchString.empty()) @@ -216,7 +217,7 @@ bool ReflRunsTabPresenter::search() { /** Populates the search results table * @param searchAlg : [input] The search algorithm */ -void ReflRunsTabPresenter::populateSearch(IAlgorithm_sptr searchAlg) { +void RunsPresenter::populateSearch(IAlgorithm_sptr searchAlg) { if (!searchAlg->isExecuted()) return; @@ -239,7 +240,7 @@ void ReflRunsTabPresenter::populateSearch(IAlgorithm_sptr searchAlg) { /** Searches ICAT for runs with given instrument and investigation id, transfers * runs to table and processes them. Clears any existing table data first. */ -void ReflRunsTabPresenter::startNewAutoreduction() { +void RunsPresenter::startNewAutoreduction() { if (requireNewAutoreduction()) { // If starting a brand new autoreduction, delete all rows / groups in // existing table first @@ -265,22 +266,21 @@ void ReflRunsTabPresenter::startNewAutoreduction() { * either the search number, transfer method or instrument has changed * @return : Boolean on whether to start a new autoreduction */ -bool ReflRunsTabPresenter::requireNewAutoreduction() const { +bool RunsPresenter::requireNewAutoreduction() const { bool searchNumChanged = m_autoreduction.searchStringChanged(m_view->getSearchString()); return searchNumChanged || m_instrumentChanged; } -bool ReflRunsTabPresenter::setupNewAutoreduction( - const std::string &searchString) { +bool RunsPresenter::setupNewAutoreduction(const std::string &searchString) { return m_autoreduction.setupNewAutoreduction(searchString); } /** Start a single autoreduction process. Called periodially to add and process * any new runs in the table. */ -void ReflRunsTabPresenter::checkForNewRuns() { +void RunsPresenter::checkForNewRuns() { // Stop notifications during processing m_view->stopTimer(); @@ -291,7 +291,7 @@ void ReflRunsTabPresenter::checkForNewRuns() { /** Run an autoreduction process based on the latest search results */ -void ReflRunsTabPresenter::autoreduceNewRuns() { +void RunsPresenter::autoreduceNewRuns() { m_autoreduction.setSearchResultsExist(); auto rowsToTransfer = m_view->getAllSearchRows(); @@ -307,28 +307,26 @@ void ReflRunsTabPresenter::autoreduceNewRuns() { } } -void ReflRunsTabPresenter::pauseAutoreduction() { +void RunsPresenter::pauseAutoreduction() { // TODO: enable autoprocessing // if (isAutoreducing()) // getTablePresenter(autoreductionGroup()) // ->notify(DataProcessorPresenter::PauseFlag); } -void ReflRunsTabPresenter::stopAutoreduction() { +void RunsPresenter::stopAutoreduction() { m_view->stopTimer(); m_autoreduction.stop(); } -bool ReflRunsTabPresenter::isAutoreducing() const { - return m_autoreduction.running(); -} +bool RunsPresenter::isAutoreducing() const { return m_autoreduction.running(); } -bool ReflRunsTabPresenter::isProcessing() const { +bool RunsPresenter::isProcessing() const { // TODO define this properly when we enable processing return false; } -void ReflRunsTabPresenter::icatSearchComplete() { +void RunsPresenter::icatSearchComplete() { // Populate the search results auto algRunner = m_view->getAlgorithmRunner(); IAlgorithm_sptr searchAlg = algRunner->getAlgorithm(); @@ -339,11 +337,11 @@ void ReflRunsTabPresenter::icatSearchComplete() { } } -RunsTablePresenter *ReflRunsTabPresenter::tablePresenter() const { +RunsTablePresenter *RunsPresenter::tablePresenter() const { return m_tablePresenter.get(); } -bool ReflRunsTabPresenter::shouldUpdateExistingSearchResults() const { +bool RunsPresenter::shouldUpdateExistingSearchResults() const { // Existing search results should be updated rather than replaced if // autoreduction is running and has valid results return m_searchModel && isAutoreducing() && @@ -354,7 +352,7 @@ bool ReflRunsTabPresenter::shouldUpdateExistingSearchResults() const { * @param rowsToTransfer : a set of row indices to transfer * @return : true if valid, false if not */ -bool ReflRunsTabPresenter::validateRowsToTransfer( +bool RunsPresenter::validateRowsToTransfer( const std::set<int> &rowsToTransfer) { // Check that we have something to transfer if (rowsToTransfer.size() == 0) { @@ -367,7 +365,7 @@ bool ReflRunsTabPresenter::validateRowsToTransfer( /** Set up the progress bar */ ProgressPresenter -ReflRunsTabPresenter::setupProgressBar(const std::set<int> &rowsToTransfer) { +RunsPresenter::setupProgressBar(const std::set<int> &rowsToTransfer) { auto start = double(0.0); auto end = static_cast<double>(rowsToTransfer.size()); @@ -412,8 +410,8 @@ RunDescriptionMetadata metadataFromDescription(std::string const &description) { * the transfer criteria * @return : The runs to transfer as a vector of maps */ -void ReflRunsTabPresenter::transfer(const std::set<int> &rowsToTransfer, - const TransferMatch matchType) { +void RunsPresenter::transfer(const std::set<int> &rowsToTransfer, + const TransferMatch matchType) { UNUSED_ARG(matchType); if (validateRowsToTransfer(rowsToTransfer)) { auto progress = setupProgressBar(rowsToTransfer); @@ -440,7 +438,7 @@ void ReflRunsTabPresenter::transfer(const std::set<int> &rowsToTransfer, /** Tells the view to update the enabled/disabled state of all relevant * widgets based on whether processing is in progress or not. */ -void ReflRunsTabPresenter::updateWidgetEnabledState() const { +void RunsPresenter::updateWidgetEnabledState() const { auto const processing = isProcessing(); auto const autoreducing = isAutoreducing(); @@ -461,7 +459,7 @@ void ReflRunsTabPresenter::updateWidgetEnabledState() const { * and the table selection model and updates the config service, printing an * information message */ -void ReflRunsTabPresenter::changeInstrument() { +void RunsPresenter::changeInstrument() { auto const instrument = m_view->getSearchInstrument(); m_mainPresenter->setInstrumentName(instrument); Mantid::Kernel::ConfigService::Instance().setString("default.instrument", @@ -470,24 +468,24 @@ void ReflRunsTabPresenter::changeInstrument() { m_instrumentChanged = true; } -void ReflRunsTabPresenter::changeGroup() { updateWidgetEnabledState(); } +void RunsPresenter::changeGroup() { updateWidgetEnabledState(); } -void ReflRunsTabPresenter::handleError(const std::string &message, - const std::exception &e) { +void RunsPresenter::handleError(const std::string &message, + const std::exception &e) { m_messageHandler->giveUserCritical(message + ": " + std::string(e.what()), "Error"); } -void ReflRunsTabPresenter::handleError(const std::string &message) { +void RunsPresenter::handleError(const std::string &message) { m_messageHandler->giveUserCritical(message, "Error"); } -std::string ReflRunsTabPresenter::liveDataReductionAlgorithm() { +std::string RunsPresenter::liveDataReductionAlgorithm() { return "ReflectometryReductionOneLiveData"; } std::string -ReflRunsTabPresenter::liveDataReductionOptions(const std::string &instrument) { +RunsPresenter::liveDataReductionOptions(const std::string &instrument) { // Get the properties for the reduction algorithm from the settings tab. We // don't have a group associated with live data. This is not ideal but for // now just use the first group. @@ -503,7 +501,7 @@ ReflRunsTabPresenter::liveDataReductionOptions(const std::string &instrument) { return optionsString; } -IAlgorithm_sptr ReflRunsTabPresenter::setupLiveDataMonitorAlgorithm() { +IAlgorithm_sptr RunsPresenter::setupLiveDataMonitorAlgorithm() { auto alg = AlgorithmManager::Instance().create("StartLiveData"); alg->initialize(); alg->setChild(true); @@ -529,24 +527,24 @@ IAlgorithm_sptr ReflRunsTabPresenter::setupLiveDataMonitorAlgorithm() { return alg; } -void ReflRunsTabPresenter::updateViewWhenMonitorStarting() { +void RunsPresenter::updateViewWhenMonitorStarting() { m_view->setStartMonitorButtonEnabled(false); m_view->setStopMonitorButtonEnabled(false); } -void ReflRunsTabPresenter::updateViewWhenMonitorStarted() { +void RunsPresenter::updateViewWhenMonitorStarted() { m_view->setStartMonitorButtonEnabled(false); m_view->setStopMonitorButtonEnabled(true); } -void ReflRunsTabPresenter::updateViewWhenMonitorStopped() { +void RunsPresenter::updateViewWhenMonitorStopped() { m_view->setStartMonitorButtonEnabled(true); m_view->setStopMonitorButtonEnabled(false); } /** Start live data monitoring */ -void ReflRunsTabPresenter::startMonitor() { +void RunsPresenter::startMonitor() { try { auto alg = setupLiveDataMonitorAlgorithm(); if (!alg) @@ -563,7 +561,7 @@ void ReflRunsTabPresenter::startMonitor() { /** Callback called when the monitor algorithm has been started */ -void ReflRunsTabPresenter::startMonitorComplete() { +void RunsPresenter::startMonitorComplete() { auto algRunner = m_view->getMonitorAlgorithmRunner(); m_monitorAlg = algRunner->getAlgorithm()->getProperty("MonitorLiveData"); if (m_monitorAlg) { @@ -576,7 +574,7 @@ void ReflRunsTabPresenter::startMonitorComplete() { /** Stop live data monitoring */ -void ReflRunsTabPresenter::stopMonitor() { +void RunsPresenter::stopMonitor() { if (!m_monitorAlg) return; @@ -588,7 +586,7 @@ void ReflRunsTabPresenter::stopMonitor() { /** Handler called when the monitor algorithm finishes */ -void ReflRunsTabPresenter::finishHandle(const IAlgorithm *alg) { +void RunsPresenter::finishHandle(const IAlgorithm *alg) { UNUSED_ARG(alg); stopObserving(m_monitorAlg); m_monitorAlg.reset(); @@ -597,8 +595,8 @@ void ReflRunsTabPresenter::finishHandle(const IAlgorithm *alg) { /** Handler called when the monitor algorithm errors */ -void ReflRunsTabPresenter::errorHandle(const IAlgorithm *alg, - const std::string &what) { +void RunsPresenter::errorHandle(const IAlgorithm *alg, + const std::string &what) { UNUSED_ARG(alg); UNUSED_ARG(what); stopObserving(m_monitorAlg); diff --git a/qt/scientific_interfaces/ISISReflectometry/ReflRunsTabPresenter.h b/qt/scientific_interfaces/ISISReflectometry/GUI/Runs/RunsPresenter.h similarity index 73% rename from qt/scientific_interfaces/ISISReflectometry/ReflRunsTabPresenter.h rename to qt/scientific_interfaces/ISISReflectometry/GUI/Runs/RunsPresenter.h index f1c0cf211c7..dba7fb453bf 100644 --- a/qt/scientific_interfaces/ISISReflectometry/ReflRunsTabPresenter.h +++ b/qt/scientific_interfaces/ISISReflectometry/GUI/Runs/RunsPresenter.h @@ -4,18 +4,16 @@ // NScD Oak Ridge National Laboratory, European Spallation Source // & Institut Laue - Langevin // SPDX - License - Identifier: GPL - 3.0 + -#ifndef MANTID_ISISREFLECTOMETRY_REFLRUNSTABPRESENTER_H -#define MANTID_ISISREFLECTOMETRY_REFLRUNSTABPRESENTER_H +#ifndef MANTID_ISISREFLECTOMETRY_RUNSPRESENTER_H +#define MANTID_ISISREFLECTOMETRY_RUNSPRESENTER_H #include "DllConfig.h" +#include "GUI/Runs/IRunsPresenter.h" #include "GUI/RunsTable/RunsTablePresenter.h" #include "GUI/RunsTable/RunsTablePresenterFactory.h" #include "IReflBatchPresenter.h" -#include "IReflRunsTabPresenter.h" #include "MantidAPI/AlgorithmObserver.h" #include "MantidAPI/IAlgorithm.h" -#include "MantidQtWidgets/Common/DataProcessorUI/DataProcessorPresenter.h" -#include "MantidQtWidgets/Common/DataProcessorUI/TreeData.h" #include "ReflAutoreduction.h" #include "SearchResult.h" #include <boost/shared_ptr.hpp> @@ -32,12 +30,11 @@ class ProgressableView; namespace CustomInterfaces { // Forward decs -class IReflRunsTabView; +class IRunsView; class IReflMessageHandler; class IReflSearcher; class ReflSearchModel; -using MantidWidgets::DataProcessor::DataProcessorPresenter; using MantidWidgets::ProgressableView; enum class TransferMatch { @@ -46,33 +43,31 @@ enum class TransferMatch { Strict // only those that exactly match all parts of the regex }; -/** @class ReflRunsTabPresenter +/** @class RunsPresenter -ReflRunsTabPresenter is a presenter class for the Reflectometry Interface. It +RunsPresenter is a presenter class for the Reflectometry Interface. It handles any interface functionality and model manipulation. */ -class MANTIDQT_ISISREFLECTOMETRY_DLL ReflRunsTabPresenter - : public IReflRunsTabPresenter, +class MANTIDQT_ISISREFLECTOMETRY_DLL RunsPresenter + : public IRunsPresenter, public Mantid::API::AlgorithmObserver { public: - ReflRunsTabPresenter(IReflRunsTabView *mainView, - ProgressableView *progressView, - RunsTablePresenterFactory makeRunsTablePresenter, - double thetaTolerance, - std::vector<std::string> const &instruments, - int defaultInstrumentIndex, - IReflMessageHandler *messageHandler, - boost::shared_ptr<IReflSearcher> searcher = - boost::shared_ptr<IReflSearcher>()); - ReflRunsTabPresenter(ReflRunsTabPresenter const &) = delete; - ~ReflRunsTabPresenter() override; - ReflRunsTabPresenter const &operator=(ReflRunsTabPresenter const &) = delete; - - ReflRunsTabPresenter(ReflRunsTabPresenter &&) = default; - ReflRunsTabPresenter &operator=(ReflRunsTabPresenter &&) = default; + RunsPresenter(IRunsView *mainView, ProgressableView *progressView, + RunsTablePresenterFactory makeRunsTablePresenter, + double thetaTolerance, + std::vector<std::string> const &instruments, + int defaultInstrumentIndex, IReflMessageHandler *messageHandler, + boost::shared_ptr<IReflSearcher> searcher = + boost::shared_ptr<IReflSearcher>()); + RunsPresenter(RunsPresenter const &) = delete; + ~RunsPresenter() override; + RunsPresenter const &operator=(RunsPresenter const &) = delete; + + RunsPresenter(RunsPresenter &&) = default; + RunsPresenter &operator=(RunsPresenter &&) = default; void acceptMainPresenter(IReflBatchPresenter *mainPresenter) override; - void notify(IReflRunsTabPresenter::Flag flag) override; + void notify(IRunsPresenter::Flag flag) override; void settingsChanged() override; bool isAutoreducing() const override; @@ -89,7 +84,7 @@ protected: private: /// The main view we're managing - IReflRunsTabView *m_view; + IRunsView *m_view; /// The progress view ProgressableView *m_progressView; RunsTablePresenterFactory m_makeRunsTablePresenter; @@ -154,4 +149,4 @@ private: }; } // namespace CustomInterfaces } // namespace MantidQt -#endif /* MANTID_ISISREFLECTOMETRY_REFLRUNSTABPRESENTER_H */ +#endif /* MANTID_ISISREFLECTOMETRY_RUNSPRESENTER_H */ diff --git a/qt/scientific_interfaces/ISISReflectometry/ReflRunsPresenterFactory.h b/qt/scientific_interfaces/ISISReflectometry/GUI/Runs/RunsPresenterFactory.h similarity index 78% rename from qt/scientific_interfaces/ISISReflectometry/ReflRunsPresenterFactory.h rename to qt/scientific_interfaces/ISISReflectometry/GUI/Runs/RunsPresenterFactory.h index a9430cdb1cc..8f143a37707 100644 --- a/qt/scientific_interfaces/ISISReflectometry/ReflRunsPresenterFactory.h +++ b/qt/scientific_interfaces/ISISReflectometry/GUI/Runs/RunsPresenterFactory.h @@ -4,15 +4,15 @@ // NScD Oak Ridge National Laboratory, European Spallation Source // & Institut Laue - Langevin // SPDX - License - Identifier: GPL - 3.0 + -#ifndef MANTID_ISISREFLECTOMETRY_REFLRUNSPRESENTERFACTORY_H -#define MANTID_ISISREFLECTOMETRY_REFLRUNSPRESENTERFACTORY_H +#ifndef MANTID_ISISREFLECTOMETRY_RUNSPRESENTERFACTORY_H +#define MANTID_ISISREFLECTOMETRY_RUNSPRESENTERFACTORY_H #include "../General/IReflSearcher.h" +#include "../RunsTable/RunsTablePresenterFactory.h" #include "DllConfig.h" -#include "GUI/RunsTable/RunsTablePresenterFactory.h" -#include "IReflRunsTabPresenter.h" -#include "IReflRunsTabView.h" +#include "IRunsPresenter.h" +#include "IRunsView.h" #include "MantidQtWidgets/Common/ProgressableView.h" -#include "ReflRunsTabPresenter.h" +#include "RunsPresenter.h" #include <memory> namespace MantidQt { @@ -33,8 +33,8 @@ public: m_defaultInstrumentIndex(std::move(defaultInstrumentIndex)), m_messageHandler(messageHandler), m_searcher(std::move(searcher)) {} - std::unique_ptr<IReflRunsTabPresenter> make(IReflRunsTabView *view) { - return std::make_unique<ReflRunsTabPresenter>( + std::unique_ptr<IRunsPresenter> make(IRunsView *view) { + return std::make_unique<RunsPresenter>( view, view, m_runsTablePresenterFactory, m_thetaTolerance, m_instruments, m_defaultInstrumentIndex, m_messageHandler, m_searcher); } @@ -49,4 +49,4 @@ private: }; } // namespace CustomInterfaces } // namespace MantidQt -#endif // MANTID_ISISREFLECTOMETRY_REFLRUNSPRESENTERFACTORY_H +#endif // MANTID_ISISREFLECTOMETRY_RUNSPRESENTERFACTORY_H diff --git a/qt/scientific_interfaces/ISISReflectometry/QtReflRunsTabView.cpp b/qt/scientific_interfaces/ISISReflectometry/GUI/Runs/RunsView.cpp similarity index 73% rename from qt/scientific_interfaces/ISISReflectometry/QtReflRunsTabView.cpp rename to qt/scientific_interfaces/ISISReflectometry/GUI/Runs/RunsView.cpp index a158e5bb44a..27ee791a1ba 100644 --- a/qt/scientific_interfaces/ISISReflectometry/QtReflRunsTabView.cpp +++ b/qt/scientific_interfaces/ISISReflectometry/GUI/Runs/RunsView.cpp @@ -4,8 +4,8 @@ // NScD Oak Ridge National Laboratory, European Spallation Source // & Institut Laue - Langevin // SPDX - License - Identifier: GPL - 3.0 + -#include "QtReflRunsTabView.h" -#include "IReflRunsTabPresenter.h" +#include "RunsView.h" +#include "IRunsPresenter.h" #include "MantidAPI/ITableWorkspace.h" #include "MantidQtWidgets/Common/AlgorithmRunner.h" #include "MantidQtWidgets/Common/DataProcessorUI/DataProcessorPresenter.h" @@ -15,8 +15,8 @@ #include "MantidQtWidgets/Common/HelpWindow.h" #include "MantidQtWidgets/Common/HintingLineEditFactory.h" #include "MantidQtWidgets/Common/SlitCalculator.h" -#include "ReflRunsTabPresenter.h" #include "ReflSearchModel.h" +#include "RunsPresenter.h" #include <QMessageBox> namespace MantidQt { @@ -29,29 +29,26 @@ using namespace MantidQt::MantidWidgets; * @param parent :: The parent of this view * @param makeRunsTableView :: The factory for the RunsTableView. */ -QtReflRunsTabView::QtReflRunsTabView(QWidget *parent, - RunsTableViewFactory makeRunsTableView) +RunsView::RunsView(QWidget *parent, RunsTableViewFactory makeRunsTableView) : m_presenter(nullptr), m_calculator(new SlitCalculator(this)), m_tableView(makeRunsTableView()) { UNUSED_ARG(parent); initLayout(); } -void QtReflRunsTabView::loginFailed(std::string const &fullError) { +void RunsView::loginFailed(std::string const &fullError) { QMessageBox::critical(this, QString::fromStdString(fullError), "Login Failed!"); } -void QtReflRunsTabView::subscribe(IReflRunsTabPresenter *presenter) { - m_presenter = presenter; -} +void RunsView::subscribe(IRunsPresenter *presenter) { m_presenter = presenter; } -IRunsTableView *QtReflRunsTabView::table() const { return m_tableView; } +IRunsTableView *RunsView::table() const { return m_tableView; } /** Initialise the Interface */ -void QtReflRunsTabView::initLayout() { +void RunsView::initLayout() { ui.setupUi(this); ui.buttonTransfer->setDefaultAction(ui.actionTransfer); @@ -95,13 +92,13 @@ void QtReflRunsTabView::initLayout() { // SLOT(instrumentChanged(int))); } -void QtReflRunsTabView::noActiveICatSessions() { +void RunsView::noActiveICatSessions() { QMessageBox::information( this, "Login Failed", "Error Logging in: Please press 'Search' to try again."); } -void QtReflRunsTabView::missingRunsToTransfer() { +void RunsView::missingRunsToTransfer() { QMessageBox::critical(this, "No runs selected", "Error: Please select at least one run to transfer."); } @@ -111,7 +108,7 @@ void QtReflRunsTabView::missingRunsToTransfer() { * according to whether processing is running or not. * @param isProcessing: Whether processing is running */ -void QtReflRunsTabView::updateMenuEnabledState(bool isProcessing) { +void RunsView::updateMenuEnabledState(bool isProcessing) { for (auto &command : m_commands) { command->updateEnabledState(isProcessing); @@ -122,7 +119,7 @@ void QtReflRunsTabView::updateMenuEnabledState(bool isProcessing) { * Sets the "Autoreduce" button enabled or disabled * @param enabled : Whether to enable or disable the button */ -void QtReflRunsTabView::setAutoreduceButtonEnabled(bool enabled) { +void RunsView::setAutoreduceButtonEnabled(bool enabled) { ui.buttonAutoreduce->setEnabled(enabled); } @@ -131,7 +128,7 @@ void QtReflRunsTabView::setAutoreduceButtonEnabled(bool enabled) { * Sets the "Autoreduce" button enabled or disabled * @param enabled : Whether to enable or disable the button */ -void QtReflRunsTabView::setAutoreducePauseButtonEnabled(bool enabled) { +void RunsView::setAutoreducePauseButtonEnabled(bool enabled) { ui.buttonAutoreducePause->setEnabled(enabled); } @@ -140,7 +137,7 @@ void QtReflRunsTabView::setAutoreducePauseButtonEnabled(bool enabled) { * Sets the "Transfer" button enabled or disabled * @param enabled : Whether to enable or disable the button */ -void QtReflRunsTabView::setTransferButtonEnabled(bool enabled) { +void RunsView::setTransferButtonEnabled(bool enabled) { ui.buttonTransfer->setEnabled(enabled); } @@ -149,7 +146,7 @@ void QtReflRunsTabView::setTransferButtonEnabled(bool enabled) { * Sets the "Instrument" combo box enabled or disabled * @param enabled : Whether to enable or disable the button */ -void QtReflRunsTabView::setInstrumentComboEnabled(bool enabled) { +void RunsView::setInstrumentComboEnabled(bool enabled) { ui.comboSearchInstrument->setEnabled(enabled); } @@ -158,7 +155,7 @@ void QtReflRunsTabView::setInstrumentComboEnabled(bool enabled) { * Sets the search text box enabled or disabled * @param enabled : Whether to enable or disable the button */ -void QtReflRunsTabView::setSearchTextEntryEnabled(bool enabled) { +void RunsView::setSearchTextEntryEnabled(bool enabled) { ui.textSearch->setEnabled(enabled); } @@ -167,7 +164,7 @@ void QtReflRunsTabView::setSearchTextEntryEnabled(bool enabled) { * Sets the search button enabled or disabled * @param enabled : Whether to enable or disable the button */ -void QtReflRunsTabView::setSearchButtonEnabled(bool enabled) { +void RunsView::setSearchButtonEnabled(bool enabled) { ui.buttonSearch->setEnabled(enabled); } @@ -176,7 +173,7 @@ void QtReflRunsTabView::setSearchButtonEnabled(bool enabled) { * Sets the start-monitor button enabled or disabled * @param enabled : Whether to enable or disable the button */ -void QtReflRunsTabView::setStartMonitorButtonEnabled(bool enabled) { +void RunsView::setStartMonitorButtonEnabled(bool enabled) { ui.buttonMonitor->setEnabled(enabled); } @@ -185,7 +182,7 @@ void QtReflRunsTabView::setStartMonitorButtonEnabled(bool enabled) { * Sets the stop-monitor enabled or disabled * @param enabled : Whether to enable or disable the button */ -void QtReflRunsTabView::setStopMonitorButtonEnabled(bool enabled) { +void RunsView::setStopMonitorButtonEnabled(bool enabled) { ui.buttonStopMonitor->setEnabled(enabled); } @@ -197,8 +194,8 @@ available instruments in the table view @param defaultInstrumentIndex : The index of the instrument to have selected by default */ -void QtReflRunsTabView::setInstrumentList( - const std::vector<std::string> &instruments, int defaultInstrumentIndex) { +void RunsView::setInstrumentList(const std::vector<std::string> &instruments, + int defaultInstrumentIndex) { ui.comboSearchInstrument->clear(); for (auto &&instrument : instruments) ui.comboSearchInstrument->addItem(QString::fromStdString(instrument)); @@ -210,7 +207,7 @@ Set the range of the progress bar @param min : The minimum value of the bar @param max : The maxmimum value of the bar */ -void QtReflRunsTabView::setProgressRange(int min, int max) { +void RunsView::setProgressRange(int min, int max) { ui.progressBar->setRange(min, max); ProgressableView::setProgressRange(min, max); } @@ -219,20 +216,18 @@ void QtReflRunsTabView::setProgressRange(int min, int max) { Set the status of the progress bar @param progress : The current value of the bar */ -void QtReflRunsTabView::setProgress(int progress) { - ui.progressBar->setValue(progress); -} +void RunsView::setProgress(int progress) { ui.progressBar->setValue(progress); } /** * Clear the progress */ -void QtReflRunsTabView::clearProgress() { ui.progressBar->reset(); } +void RunsView::clearProgress() { ui.progressBar->reset(); } /** Set a new model for search results @param model : the model to be attached to the search results */ -void QtReflRunsTabView::showSearch(ReflSearchModel_sptr model) { +void RunsView::showSearch(ReflSearchModel_sptr model) { m_searchModel = model; ui.tableSearchResults->setModel(m_searchModel.get()); ui.tableSearchResults->resizeColumnsToContents(); @@ -240,9 +235,9 @@ void QtReflRunsTabView::showSearch(ReflSearchModel_sptr model) { /** Start an icat search */ -void QtReflRunsTabView::startIcatSearch() { +void RunsView::startIcatSearch() { m_algoRunner.get()->disconnect(); // disconnect any other connections - m_presenter->notify(IReflRunsTabPresenter::SearchFlag); + m_presenter->notify(IRunsPresenter::SearchFlag); connect(m_algoRunner.get(), SIGNAL(algorithmComplete(bool)), this, SLOT(icatSearchComplete()), Qt::UniqueConnection); } @@ -250,44 +245,44 @@ void QtReflRunsTabView::startIcatSearch() { /** This slot notifies the presenter that the ICAT search was completed */ -void QtReflRunsTabView::icatSearchComplete() { - m_presenter->notify(IReflRunsTabPresenter::ICATSearchCompleteFlag); +void RunsView::icatSearchComplete() { + m_presenter->notify(IRunsPresenter::ICATSearchCompleteFlag); } /** This slot notifies the presenter that the "search" button has been pressed */ -void QtReflRunsTabView::on_actionSearch_triggered() { startIcatSearch(); } +void RunsView::on_actionSearch_triggered() { startIcatSearch(); } /** This slot conducts a search operation before notifying the presenter that the "autoreduce" button has been pressed */ -void QtReflRunsTabView::on_actionAutoreduce_triggered() { - m_presenter->notify(IReflRunsTabPresenter::StartAutoreductionFlag); +void RunsView::on_actionAutoreduce_triggered() { + m_presenter->notify(IRunsPresenter::StartAutoreductionFlag); } /** This slot conducts a search operation before notifying the presenter that the "pause autoreduce" button has been pressed */ -void QtReflRunsTabView::on_actionAutoreducePause_triggered() { - m_presenter->notify(IReflRunsTabPresenter::PauseAutoreductionFlag); +void RunsView::on_actionAutoreducePause_triggered() { + m_presenter->notify(IRunsPresenter::PauseAutoreductionFlag); } /** This slot notifies the presenter that the "transfer" button has been pressed */ -void QtReflRunsTabView::on_actionTransfer_triggered() { - m_presenter->notify(IReflRunsTabPresenter::Flag::TransferFlag); +void RunsView::on_actionTransfer_triggered() { + m_presenter->notify(IRunsPresenter::Flag::TransferFlag); } /** This slot is called each time the timer times out */ -void QtReflRunsTabView::timerEvent(QTimerEvent *event) { +void RunsView::timerEvent(QTimerEvent *event) { if (event->timerId() == m_timer.timerId()) { - m_presenter->notify(IReflRunsTabPresenter::TimerEventFlag); + m_presenter->notify(IRunsPresenter::TimerEventFlag); } else { QWidget::timerEvent(event); } @@ -295,18 +290,18 @@ void QtReflRunsTabView::timerEvent(QTimerEvent *event) { /** start the timer */ -void QtReflRunsTabView::startTimer(const int millisecs) { +void RunsView::startTimer(const int millisecs) { m_timer.start(millisecs, this); } /** stop */ -void QtReflRunsTabView::stopTimer() { m_timer.stop(); } +void RunsView::stopTimer() { m_timer.stop(); } /** This slot shows the slit calculator */ -void QtReflRunsTabView::slitCalculatorTriggered() { +void RunsView::slitCalculatorTriggered() { m_calculator->setCurrentInstrumentName( ui.comboSearchInstrument->currentText().toStdString()); m_calculator->show(); @@ -316,7 +311,7 @@ void QtReflRunsTabView::slitCalculatorTriggered() { This slot is triggered when the user right clicks on the search results table @param pos : The position of the right click within the table */ -void QtReflRunsTabView::showSearchContextMenu(const QPoint &pos) { +void RunsView::showSearchContextMenu(const QPoint &pos) { if (!ui.tableSearchResults->indexAt(pos).isValid()) return; @@ -330,21 +325,21 @@ void QtReflRunsTabView::showSearchContextMenu(const QPoint &pos) { * notifies the main presenter and updates the Slit Calculator * @param index : The index of the combo box */ -void QtReflRunsTabView::instrumentChanged(int index) { +void RunsView::instrumentChanged(int index) { ui.textSearch->clear(); if (m_searchModel) m_searchModel->clear(); m_calculator->setCurrentInstrumentName( ui.comboSearchInstrument->itemText(index).toStdString()); m_calculator->processInstrumentHasBeenChanged(); - // m_presenter->notify(IReflRunsTabPresenter::InstrumentChangedFlag); + // m_presenter->notify(IRunsPresenter::InstrumentChangedFlag); } /** Get the selected instrument for searching @returns the selected instrument to search for */ -std::string QtReflRunsTabView::getSearchInstrument() const { +std::string RunsView::getSearchInstrument() const { return ui.comboSearchInstrument->currentText().toStdString(); } @@ -352,7 +347,7 @@ std::string QtReflRunsTabView::getSearchInstrument() const { Get the indices of the highlighted search result rows @returns a set of ints containing the selected row numbers */ -std::set<int> QtReflRunsTabView::getSelectedSearchRows() const { +std::set<int> RunsView::getSelectedSearchRows() const { std::set<int> rows; auto selectionModel = ui.tableSearchResults->selectionModel(); if (selectionModel) { @@ -367,7 +362,7 @@ std::set<int> QtReflRunsTabView::getSelectedSearchRows() const { Get the indices of all search result rows @returns a set of ints containing the row numbers */ -std::set<int> QtReflRunsTabView::getAllSearchRows() const { +std::set<int> RunsView::getAllSearchRows() const { std::set<int> rows; if (!ui.tableSearchResults || !ui.tableSearchResults->model()) return rows; @@ -381,17 +376,15 @@ std::set<int> QtReflRunsTabView::getAllSearchRows() const { Get a pointer to the presenter that's currently controlling this view. @returns A pointer to the presenter */ -IReflRunsTabPresenter *QtReflRunsTabView::getPresenter() const { - return m_presenter; -} +IRunsPresenter *RunsView::getPresenter() const { return m_presenter; } boost::shared_ptr<MantidQt::API::AlgorithmRunner> -QtReflRunsTabView::getAlgorithmRunner() const { +RunsView::getAlgorithmRunner() const { return m_algoRunner; } boost::shared_ptr<MantidQt::API::AlgorithmRunner> -QtReflRunsTabView::getMonitorAlgorithmRunner() const { +RunsView::getMonitorAlgorithmRunner() const { return m_monitorAlgoRunner; } @@ -399,24 +392,23 @@ QtReflRunsTabView::getMonitorAlgorithmRunner() const { Get the string the user wants to search for. @returns The search string */ -std::string QtReflRunsTabView::getSearchString() const { +std::string RunsView::getSearchString() const { return ui.textSearch->text().toStdString(); } -void MantidQt::CustomInterfaces::QtReflRunsTabView::on_buttonMonitor_clicked() { +void MantidQt::CustomInterfaces::RunsView::on_buttonMonitor_clicked() { startMonitor(); } -void MantidQt::CustomInterfaces::QtReflRunsTabView:: - on_buttonStopMonitor_clicked() { +void MantidQt::CustomInterfaces::RunsView::on_buttonStopMonitor_clicked() { stopMonitor(); } /** Start live data monitoring */ -void QtReflRunsTabView::startMonitor() { +void RunsView::startMonitor() { m_monitorAlgoRunner.get()->disconnect(); // disconnect any other connections - m_presenter->notify(IReflRunsTabPresenter::StartMonitorFlag); + m_presenter->notify(IRunsPresenter::StartMonitorFlag); connect(m_monitorAlgoRunner.get(), SIGNAL(algorithmComplete(bool)), this, SLOT(startMonitorComplete()), Qt::UniqueConnection); } @@ -424,14 +416,14 @@ void QtReflRunsTabView::startMonitor() { /** This slot notifies the presenter that the monitoring algorithm finished */ -void QtReflRunsTabView::startMonitorComplete() { - m_presenter->notify(IReflRunsTabPresenter::StartMonitorCompleteFlag); +void RunsView::startMonitorComplete() { + m_presenter->notify(IRunsPresenter::StartMonitorCompleteFlag); } /** Stop live data monitoring */ -void QtReflRunsTabView::stopMonitor() { - m_presenter->notify(IReflRunsTabPresenter::StopMonitorFlag); +void RunsView::stopMonitor() { + m_presenter->notify(IRunsPresenter::StopMonitorFlag); } } // namespace CustomInterfaces diff --git a/qt/scientific_interfaces/ISISReflectometry/QtReflRunsTabView.h b/qt/scientific_interfaces/ISISReflectometry/GUI/Runs/RunsView.h similarity index 85% rename from qt/scientific_interfaces/ISISReflectometry/QtReflRunsTabView.h rename to qt/scientific_interfaces/ISISReflectometry/GUI/Runs/RunsView.h index a5ae53dec4f..35a71e552ad 100644 --- a/qt/scientific_interfaces/ISISReflectometry/QtReflRunsTabView.h +++ b/qt/scientific_interfaces/ISISReflectometry/GUI/Runs/RunsView.h @@ -4,17 +4,17 @@ // NScD Oak Ridge National Laboratory, European Spallation Source // & Institut Laue - Langevin // SPDX - License - Identifier: GPL - 3.0 + -#ifndef MANTID_ISISREFLECTOMETRY_QTREFLRUNSTABVIEW_H_ -#define MANTID_ISISREFLECTOMETRY_QTREFLRUNSTABVIEW_H_ +#ifndef MANTID_ISISREFLECTOMETRY_RUNSTABVIEW_H_ +#define MANTID_ISISREFLECTOMETRY_RUNSTABVIEW_H_ #include "DllConfig.h" #include "GUI/RunsTable/RunsTableView.h" -#include "IReflRunsTabView.h" +#include "IRunsView.h" #include "MantidKernel/System.h" #include "MantidQtWidgets/Common/DataProcessorUI/QtCommandAdapter.h" #include "MantidQtWidgets/Common/MantidWidget.h" -#include "ui_ReflRunsTabWidget.h" +#include "ui_RunsWidget.h" #include <QBasicTimer> @@ -34,23 +34,23 @@ class AlgorithmRunner; namespace CustomInterfaces { // Forward decs -class IReflRunsTabPresenter; +class IRunsPresenter; class ReflSearchModel; using MantidWidgets::SlitCalculator; namespace DataProcessor = MantidWidgets::DataProcessor; -/** QtReflRunsTabView : Provides an interface for the "Runs" tab in the +/** RunsView : Provides an interface for the "Runs" tab in the ISIS Reflectometry interface. */ -class MANTIDQT_ISISREFLECTOMETRY_DLL QtReflRunsTabView +class MANTIDQT_ISISREFLECTOMETRY_DLL RunsView : public MantidQt::API::MantidWidget, - public IReflRunsTabView { + public IRunsView { Q_OBJECT public: - QtReflRunsTabView(QWidget *parent, RunsTableViewFactory makeView); + RunsView(QWidget *parent, RunsTableViewFactory makeView); - void subscribe(IReflRunsTabPresenter *presenter) override; + void subscribe(IRunsPresenter *presenter) override; IRunsTableView *table() const override; // Connect the model @@ -81,7 +81,7 @@ public: std::string getSearchInstrument() const override; std::string getSearchString() const override; - IReflRunsTabPresenter *getPresenter() const override; + IRunsPresenter *getPresenter() const override; boost::shared_ptr<MantidQt::API::AlgorithmRunner> getAlgorithmRunner() const override; boost::shared_ptr<MantidQt::API::AlgorithmRunner> @@ -110,14 +110,14 @@ private: boost::shared_ptr<MantidQt::API::AlgorithmRunner> m_monitorAlgoRunner; // the presenter - IReflRunsTabPresenter *m_presenter; + IRunsPresenter *m_presenter; // the search model boost::shared_ptr<ReflSearchModel> m_searchModel; // Command adapters std::vector<std::unique_ptr<DataProcessor::QtCommandAdapter>> m_commands; // the interface (uses actions owned by m_commands) - Ui::ReflRunsTabWidget ui; + Ui::RunsWidget ui; // the slit calculator SlitCalculator *m_calculator; // Timer for triggering periodic autoreduction @@ -142,4 +142,4 @@ private slots: } // namespace CustomInterfaces } // namespace MantidQt -#endif /* MANTID_ISISREFLECTOMETRY_QTREFLRUNSTABVIEW_H_ */ +#endif /* MANTID_ISISREFLECTOMETRY_RUNSVIEW_H_ */ diff --git a/qt/scientific_interfaces/ISISReflectometry/ReflRunsTabWidget.ui b/qt/scientific_interfaces/ISISReflectometry/GUI/Runs/RunsWidget.ui similarity index 99% rename from qt/scientific_interfaces/ISISReflectometry/ReflRunsTabWidget.ui rename to qt/scientific_interfaces/ISISReflectometry/GUI/Runs/RunsWidget.ui index 6aec2432332..f5779fff803 100644 --- a/qt/scientific_interfaces/ISISReflectometry/ReflRunsTabWidget.ui +++ b/qt/scientific_interfaces/ISISReflectometry/GUI/Runs/RunsWidget.ui @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> <ui version="4.0"> - <class>ReflRunsTabWidget</class> - <widget class="QWidget" name="ReflRunsTabWidget"> + <class>RunsWidget</class> + <widget class="QWidget" name="RunsWidget"> <property name="geometry"> <rect> <x>0</x> diff --git a/qt/scientific_interfaces/ISISReflectometry/IReflBatchView.h b/qt/scientific_interfaces/ISISReflectometry/IReflBatchView.h index ed2125cec52..c11fefaaa11 100644 --- a/qt/scientific_interfaces/ISISReflectometry/IReflBatchView.h +++ b/qt/scientific_interfaces/ISISReflectometry/IReflBatchView.h @@ -10,8 +10,8 @@ #include "GUI/Event/IEventView.h" #include "GUI/Experiment/IExperimentView.h" #include "GUI/Instrument/IInstrumentView.h" +#include "GUI/Runs/IRunsView.h" #include "GUI/Save/ISaveView.h" -#include "IReflRunsTabView.h" #include <string> namespace MantidQt { @@ -26,7 +26,7 @@ the help button. */ class IReflBatchView { public: - virtual IReflRunsTabView *runs() const = 0; + virtual IRunsView *runs() const = 0; virtual IEventView *eventHandling() const = 0; virtual ISaveView *save() const = 0; virtual IExperimentView *experiment() const = 0; diff --git a/qt/scientific_interfaces/ISISReflectometry/IReflSearcher.h b/qt/scientific_interfaces/ISISReflectometry/IReflSearcher.h index 10dfd7de3f0..77493ac2127 100644 --- a/qt/scientific_interfaces/ISISReflectometry/IReflSearcher.h +++ b/qt/scientific_interfaces/ISISReflectometry/IReflSearcher.h @@ -9,7 +9,7 @@ #include <string> -#include "IReflRunsTabPresenter.h" +#include "GUI/Runs/IRunsPresenter.h" #include "MantidAPI/ITableWorkspace_fwd.h" namespace MantidQt { @@ -17,8 +17,7 @@ namespace CustomInterfaces { /** @class IReflSearcher IReflSearcher is an interface for search implementations used by -IReflRunsTabPresenter -implementations. +IRunsPresenter implementations. */ class IReflSearcher { public: diff --git a/qt/scientific_interfaces/ISISReflectometry/QtReflBatchView.cpp b/qt/scientific_interfaces/ISISReflectometry/QtReflBatchView.cpp index 2461c44e24b..94856d259fb 100644 --- a/qt/scientific_interfaces/ISISReflectometry/QtReflBatchView.cpp +++ b/qt/scientific_interfaces/ISISReflectometry/QtReflBatchView.cpp @@ -6,13 +6,12 @@ // SPDX - License - Identifier: GPL - 3.0 + #include "QtReflBatchView.h" #include "GUI/Event/EventView.h" +#include "GUI/Runs/RunsView.h" #include "GUI/Save/SaveView.h" #include "MantidAPI/AlgorithmManager.h" #include "MantidKernel/make_unique.h" -#include "QtReflRunsTabView.h" #include "ReflAsciiSaver.h" #include "ReflBatchPresenter.h" -#include "ReflRunsTabPresenter.h" #include <QMessageBox> @@ -52,7 +51,7 @@ IInstrumentView *QtReflBatchView::instrument() const { return m_instrument.get(); } -IReflRunsTabView *QtReflBatchView::runs() const { return m_runs.get(); } +IRunsView *QtReflBatchView::runs() const { return m_runs.get(); } IEventView *QtReflBatchView::eventHandling() const { return m_eventHandling.get(); @@ -60,10 +59,10 @@ IEventView *QtReflBatchView::eventHandling() const { ISaveView *QtReflBatchView::save() const { return m_save.get(); } -std::unique_ptr<QtReflRunsTabView> QtReflBatchView::createRunsTab() { +std::unique_ptr<RunsView> QtReflBatchView::createRunsTab() { auto instruments = std::vector<std::string>( {{"INTER", "SURF", "CRISP", "POLREF", "OFFSPEC"}}); - return Mantid::Kernel::make_unique<QtReflRunsTabView>( + return Mantid::Kernel::make_unique<RunsView>( this, RunsTableViewFactory(instruments)); } diff --git a/qt/scientific_interfaces/ISISReflectometry/QtReflBatchView.h b/qt/scientific_interfaces/ISISReflectometry/QtReflBatchView.h index 7331b54d8bb..ed5bb31bcae 100644 --- a/qt/scientific_interfaces/ISISReflectometry/QtReflBatchView.h +++ b/qt/scientific_interfaces/ISISReflectometry/QtReflBatchView.h @@ -10,11 +10,11 @@ #include "GUI/Event/EventView.h" #include "GUI/Experiment/ExperimentView.h" #include "GUI/Instrument/InstrumentView.h" +#include "GUI/Runs/RunsView.h" #include "GUI/Save/SaveView.h" #include "IReflBatchPresenter.h" #include "IReflBatchView.h" #include "MantidAPI/IAlgorithm.h" -#include "QtReflRunsTabView.h" #include "ui_ReflBatchWidget.h" #include <memory> @@ -29,7 +29,7 @@ public: explicit QtReflBatchView(QWidget *parent = nullptr); void subscribe(IReflBatchPresenter *notifyee); - IReflRunsTabView *runs() const override; + IRunsView *runs() const override; IEventView *eventHandling() const override; ISaveView *save() const override; IExperimentView *experiment() const override; @@ -39,13 +39,13 @@ private: void initLayout(); Mantid::API::IAlgorithm_sptr createReductionAlg(); - std::unique_ptr<QtReflRunsTabView> createRunsTab(); + std::unique_ptr<RunsView> createRunsTab(); std::unique_ptr<EventView> createEventTab(); std::unique_ptr<SaveView> createSaveTab(); Ui::ReflBatchWidget m_ui; IReflBatchPresenter *m_notifyee; - std::unique_ptr<QtReflRunsTabView> m_runs; + std::unique_ptr<RunsView> m_runs; std::unique_ptr<EventView> m_eventHandling; std::unique_ptr<SaveView> m_save; std::unique_ptr<ExperimentView> m_experiment; diff --git a/qt/scientific_interfaces/ISISReflectometry/ReflAutoreduction.cpp b/qt/scientific_interfaces/ISISReflectometry/ReflAutoreduction.cpp index 4462046e3d6..62ebb079d20 100644 --- a/qt/scientific_interfaces/ISISReflectometry/ReflAutoreduction.cpp +++ b/qt/scientific_interfaces/ISISReflectometry/ReflAutoreduction.cpp @@ -5,9 +5,9 @@ // & Institut Laue - Langevin // SPDX - License - Identifier: GPL - 3.0 + #include "ReflAutoreduction.h" +#include "GUI/Runs/IRunsView.h" +#include "GUI/Runs/RunsPresenter.h" #include "IReflMainWindowPresenter.h" -#include "IReflRunsTabView.h" -#include "ReflRunsTabPresenter.h" namespace MantidQt { namespace CustomInterfaces { diff --git a/qt/scientific_interfaces/ISISReflectometry/ReflBatchPresenter.cpp b/qt/scientific_interfaces/ISISReflectometry/ReflBatchPresenter.cpp index aa2466d13a3..3202ffd1b85 100644 --- a/qt/scientific_interfaces/ISISReflectometry/ReflBatchPresenter.cpp +++ b/qt/scientific_interfaces/ISISReflectometry/ReflBatchPresenter.cpp @@ -8,9 +8,9 @@ #include "GUI/Event/IEventPresenter.h" #include "GUI/Experiment/IExperimentPresenter.h" #include "GUI/Instrument/IInstrumentPresenter.h" +#include "GUI/Runs/IRunsPresenter.h" #include "GUI/Save/ISavePresenter.h" #include "IReflBatchView.h" -#include "IReflRunsTabPresenter.h" #include "MantidQtWidgets/Common/HelpWindow.h" using namespace MantidQt::MantidWidgets::DataProcessor; @@ -30,7 +30,7 @@ namespace CustomInterfaces { * @param savePresenter :: [input] A pointer to the 'Save ASCII' tab presenter */ ReflBatchPresenter::ReflBatchPresenter( - IReflBatchView *view, std::unique_ptr<IReflRunsTabPresenter> runsPresenter, + IReflBatchView *view, std::unique_ptr<IRunsPresenter> runsPresenter, std::unique_ptr<IEventPresenter> eventPresenter, std::unique_ptr<IExperimentPresenter> experimentPresenter, std::unique_ptr<IInstrumentPresenter> instrumentPresenter, @@ -45,7 +45,7 @@ ReflBatchPresenter::ReflBatchPresenter( m_runsPresenter->acceptMainPresenter(this); // Trigger the setting of the current instrument name in settings tab - m_runsPresenter->notify(IReflRunsTabPresenter::InstrumentChangedFlag); + m_runsPresenter->notify(IRunsPresenter::InstrumentChangedFlag); } bool ReflBatchPresenter::requestClose() const { return true; } diff --git a/qt/scientific_interfaces/ISISReflectometry/ReflBatchPresenter.h b/qt/scientific_interfaces/ISISReflectometry/ReflBatchPresenter.h index 36063811723..6775fc8c66a 100644 --- a/qt/scientific_interfaces/ISISReflectometry/ReflBatchPresenter.h +++ b/qt/scientific_interfaces/ISISReflectometry/ReflBatchPresenter.h @@ -11,9 +11,9 @@ #include "GUI/Event/IEventPresenter.h" #include "GUI/Experiment/IExperimentPresenter.h" #include "GUI/Instrument/IInstrumentPresenter.h" +#include "GUI/Runs/IRunsPresenter.h" #include "GUI/Save/ISavePresenter.h" #include "IReflBatchPresenter.h" -#include "IReflRunsTabPresenter.h" #include <memory> namespace MantidQt { @@ -31,7 +31,7 @@ class MANTIDQT_ISISREFLECTOMETRY_DLL ReflBatchPresenter public: /// Constructor ReflBatchPresenter(IReflBatchView *view, - std::unique_ptr<IReflRunsTabPresenter> runsPresenter, + std::unique_ptr<IRunsPresenter> runsPresenter, std::unique_ptr<IEventPresenter> eventPresenter, std::unique_ptr<IExperimentPresenter> experimentPresenter, std::unique_ptr<IInstrumentPresenter> instrumentPresenter, @@ -67,7 +67,7 @@ private: /// The view we are handling IReflBatchView *m_view; /// The presenter of tab 'Runs' - std::unique_ptr<IReflRunsTabPresenter> m_runsPresenter; + std::unique_ptr<IRunsPresenter> m_runsPresenter; /// The presenter of tab 'Event Handling' std::unique_ptr<IEventPresenter> m_eventPresenter; /// The presenter of tab 'Settings' diff --git a/qt/scientific_interfaces/ISISReflectometry/ReflBatchPresenterFactory.h b/qt/scientific_interfaces/ISISReflectometry/ReflBatchPresenterFactory.h index 00593ec46d9..53953da9fe5 100644 --- a/qt/scientific_interfaces/ISISReflectometry/ReflBatchPresenterFactory.h +++ b/qt/scientific_interfaces/ISISReflectometry/ReflBatchPresenterFactory.h @@ -10,11 +10,11 @@ #include "GUI/Event/EventPresenterFactory.h" #include "GUI/Experiment/ExperimentPresenterFactory.h" #include "GUI/Instrument/InstrumentPresenterFactory.h" +#include "GUI/Runs/RunsPresenterFactory.h" #include "GUI/Save/SavePresenterFactory.h" #include "IReflBatchPresenter.h" #include "IReflBatchView.h" #include "ReflBatchPresenter.h" -#include "ReflRunsPresenterFactory.h" #include <memory> namespace MantidQt { diff --git a/qt/scientific_interfaces/ISISReflectometry/ReflMainWindowPresenter.cpp b/qt/scientific_interfaces/ISISReflectometry/ReflMainWindowPresenter.cpp index 33c3012449a..68d4df0d02f 100644 --- a/qt/scientific_interfaces/ISISReflectometry/ReflMainWindowPresenter.cpp +++ b/qt/scientific_interfaces/ISISReflectometry/ReflMainWindowPresenter.cpp @@ -5,8 +5,8 @@ // & Institut Laue - Langevin // SPDX - License - Identifier: GPL - 3.0 + #include "ReflMainWindowPresenter.h" +#include "GUI/Runs/IRunsPresenter.h" #include "IReflMainWindowView.h" -#include "IReflRunsTabPresenter.h" #include "MantidQtWidgets/Common/HelpWindow.h" using namespace MantidQt::MantidWidgets::DataProcessor; diff --git a/qt/scientific_interfaces/test/ISISReflectometry/Runs/MockRunsPresenter.h b/qt/scientific_interfaces/test/ISISReflectometry/Runs/MockRunsPresenter.h new file mode 100644 index 00000000000..7d633a43560 --- /dev/null +++ b/qt/scientific_interfaces/test/ISISReflectometry/Runs/MockRunsPresenter.h @@ -0,0 +1,32 @@ +// Mantid Repository : https://github.com/mantidproject/mantid +// +// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI, +// NScD Oak Ridge National Laboratory, European Spallation Source +// & Institut Laue - Langevin +// SPDX - License - Identifier: GPL - 3.0 + +#ifndef MANTID_CUSTOMINTERFACES_MOCKBATCHPRESENTER_H_ +#define MANTID_CUSTOMINTERFACES_MOCKBATCHPRESENTER_H_ +#include "DllConfig.h" +#include "GUI/Runs/IRunsPresenter.h" +#include "MantidKernel/WarningSuppressions.h" +#include <gmock/gmock.h> + +GNU_DIAG_OFF_SUGGEST_OVERRIDE + +namespace MantidQt { +namespace CustomInterfaces { +class MockRunsPresenter : public IRunsPresenter { +public: + MOCK_CONST_METHOD0(isAutoreducing, bool()); + MOCK_METHOD0(settingsChanged, void()); + void notify(IRunsPresenter::Flag flag) override { UNUSED_ARG(flag); }; + void acceptMainPresenter(IReflBatchPresenter *presenter) override { + UNUSED_ARG(presenter); + } + bool isProcessing() const override { return false; } + ~MockRunsPresenter() override{}; +}; +} // namespace CustomInterfaces +} // namespace MantidQt +GNU_DIAG_ON_SUGGEST_OVERRIDE +#endif // MANTID_CUSTOMINTERFACES_MOCKRUNSPRESENTER_H_ diff --git a/qt/scientific_interfaces/test/ISISReflectometry/Runs/MockRunsView.h b/qt/scientific_interfaces/test/ISISReflectometry/Runs/MockRunsView.h new file mode 100644 index 00000000000..f7fe34d26f0 --- /dev/null +++ b/qt/scientific_interfaces/test/ISISReflectometry/Runs/MockRunsView.h @@ -0,0 +1,71 @@ +// Mantid Repository : https://github.com/mantidproject/mantid +// +// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI, +// NScD Oak Ridge National Laboratory, European Spallation Source +// & Institut Laue - Langevin +// SPDX - License - Identifier: GPL - 3.0 + +#ifndef MANTID_CUSTOMINTERFACES_MOCKBATCHVIEW_H_ +#define MANTID_CUSTOMINTERFACES_MOCKBATCHVIEW_H_ +#include "DllConfig.h" +#include "GUI/Runs/IRunsView.h" +#include "GUI/RunsTable/IRunsTableView.h" +#include "MantidKernel/WarningSuppressions.h" +#include <gmock/gmock.h> + +GNU_DIAG_OFF_SUGGEST_OVERRIDE + +namespace MantidQt { +namespace CustomInterfaces { + +class MockRunsView : public IRunsView { +public: + MockRunsTabView() { + ON_CALL(*this, table()).WillByDefault(testing::Return(m_tableView)); + } + + // IO + MOCK_CONST_METHOD0(getSelectedSearchRows, std::set<int>()); + MOCK_CONST_METHOD0(getAllSearchRows, std::set<int>()); + MOCK_CONST_METHOD0(getSearchString, std::string()); + MOCK_CONST_METHOD0(getSearchInstrument, std::string()); + MOCK_CONST_METHOD0(getTransferMethod, std::string()); + MOCK_CONST_METHOD0(getAlgorithmRunner, + boost::shared_ptr<MantidQt::API::AlgorithmRunner>()); + MOCK_CONST_METHOD0(getMonitorAlgorithmRunner, + boost::shared_ptr<MantidQt::API::AlgorithmRunner>()); + MOCK_CONST_METHOD0(getSelectedGroup, int()); + MOCK_METHOD1(setTransferMethods, void(const std::set<std::string> &)); + MOCK_METHOD0(setTableCommandsProxy, void()); + MOCK_METHOD0(setRowCommandsProxy, void()); + MOCK_METHOD0(clearCommands, void()); + MOCK_METHOD2(setInstrumentList, void(const std::vector<std::string> &, int)); + MOCK_METHOD1(updateMenuEnabledState, void(bool)); + MOCK_METHOD1(setAutoreduceButtonEnabled, void(bool)); + MOCK_METHOD1(setAutoreducePauseButtonEnabled, void(bool)); + MOCK_METHOD1(setTransferButtonEnabled, void(bool)); + MOCK_METHOD1(setInstrumentComboEnabled, void(bool)); + MOCK_METHOD1(subscribe, void(IReflRunsTabPresenter *)); + MOCK_CONST_METHOD0(table, IRunsTableView *()); + MOCK_METHOD1(setSearchTextEntryEnabled, void(bool)); + MOCK_METHOD1(setSearchButtonEnabled, void(bool)); + MOCK_METHOD1(setStartMonitorButtonEnabled, void(bool)); + MOCK_METHOD1(setStopMonitorButtonEnabled, void(bool)); + MOCK_METHOD1(startTimer, void(const int)); + MOCK_METHOD0(stopTimer, void()); + MOCK_METHOD0(startIcatSearch, void()); + MOCK_METHOD0(startMonitor, void()); + MOCK_METHOD0(stopMonitor, void()); + MOCK_METHOD0(updateMonitorRunning, void()); + MOCK_METHOD0(updateMonitorStopped, void()); + + // Calls we don't care about + void showSearch(ReflSearchModel_sptr) override{}; + IReflRunsTabPresenter *getPresenter() const override { return nullptr; }; + +private: + IRunsTableView *m_tableView; +}; +} // namespace CustomInterfaces +} // namespace MantidQt +GNU_DIAG_ON_SUGGEST_OVERRIDE +#endif // MANTID_CUSTOMINTERFACES_MOCKRUNSVIEW_H_ diff --git a/qt/scientific_interfaces/test/ReflMockObjects.h b/qt/scientific_interfaces/test/ReflMockObjects.h index 5fbef231cf7..3eaa8bd5055 100644 --- a/qt/scientific_interfaces/test/ReflMockObjects.h +++ b/qt/scientific_interfaces/test/ReflMockObjects.h @@ -7,13 +7,10 @@ #ifndef MANTID_CUSTOMINTERFACES_REFLMOCKOBJECTS_H #define MANTID_CUSTOMINTERFACES_REFLMOCKOBJECTS_H -#include "../ISISReflectometry/GUI/RunsTable/IRunsTableView.h" #include "../ISISReflectometry/IReflAsciiSaver.h" #include "../ISISReflectometry/IReflBatchPresenter.h" #include "../ISISReflectometry/IReflMainWindowPresenter.h" #include "../ISISReflectometry/IReflMainWindowView.h" -#include "../ISISReflectometry/IReflRunsTabPresenter.h" -#include "../ISISReflectometry/IReflRunsTabView.h" #include "../ISISReflectometry/InstrumentOptionDefaults.h" #include "../ISISReflectometry/ReflSearchModel.h" #include "MantidAPI/AlgorithmManager.h" @@ -45,55 +42,6 @@ public: /**** Views ****/ -class MockRunsTabView : public IReflRunsTabView { -public: - MockRunsTabView() { - ON_CALL(*this, table()).WillByDefault(testing::Return(m_tableView)); - } - - // IO - MOCK_CONST_METHOD0(getSelectedSearchRows, std::set<int>()); - MOCK_CONST_METHOD0(getAllSearchRows, std::set<int>()); - MOCK_CONST_METHOD0(getSearchString, std::string()); - MOCK_CONST_METHOD0(getSearchInstrument, std::string()); - MOCK_CONST_METHOD0(getTransferMethod, std::string()); - MOCK_CONST_METHOD0(getAlgorithmRunner, - boost::shared_ptr<MantidQt::API::AlgorithmRunner>()); - MOCK_CONST_METHOD0(getMonitorAlgorithmRunner, - boost::shared_ptr<MantidQt::API::AlgorithmRunner>()); - MOCK_CONST_METHOD0(getSelectedGroup, int()); - MOCK_METHOD1(setTransferMethods, void(const std::set<std::string> &)); - MOCK_METHOD0(setTableCommandsProxy, void()); - MOCK_METHOD0(setRowCommandsProxy, void()); - MOCK_METHOD0(clearCommands, void()); - MOCK_METHOD2(setInstrumentList, void(const std::vector<std::string> &, int)); - MOCK_METHOD1(updateMenuEnabledState, void(bool)); - MOCK_METHOD1(setAutoreduceButtonEnabled, void(bool)); - MOCK_METHOD1(setAutoreducePauseButtonEnabled, void(bool)); - MOCK_METHOD1(setTransferButtonEnabled, void(bool)); - MOCK_METHOD1(setInstrumentComboEnabled, void(bool)); - MOCK_METHOD1(subscribe, void(IReflRunsTabPresenter *)); - MOCK_CONST_METHOD0(table, IRunsTableView *()); - MOCK_METHOD1(setSearchTextEntryEnabled, void(bool)); - MOCK_METHOD1(setSearchButtonEnabled, void(bool)); - MOCK_METHOD1(setStartMonitorButtonEnabled, void(bool)); - MOCK_METHOD1(setStopMonitorButtonEnabled, void(bool)); - MOCK_METHOD1(startTimer, void(const int)); - MOCK_METHOD0(stopTimer, void()); - MOCK_METHOD0(startIcatSearch, void()); - MOCK_METHOD0(startMonitor, void()); - MOCK_METHOD0(stopMonitor, void()); - MOCK_METHOD0(updateMonitorRunning, void()); - MOCK_METHOD0(updateMonitorStopped, void()); - - // Calls we don't care about - void showSearch(ReflSearchModel_sptr) override{}; - IReflRunsTabPresenter *getPresenter() const override { return nullptr; }; - -private: - IRunsTableView *m_tableView; -}; - class MockMainWindowView : public IReflMainWindowView { public: MOCK_METHOD3(askUserString, @@ -110,18 +58,6 @@ public: /**** Presenters ****/ -class MockRunsTabPresenter : public IReflRunsTabPresenter { -public: - MOCK_CONST_METHOD0(isAutoreducing, bool()); - MOCK_METHOD0(settingsChanged, void()); - void notify(IReflRunsTabPresenter::Flag flag) override { UNUSED_ARG(flag); }; - void acceptMainPresenter(IReflBatchPresenter *presenter) override { - UNUSED_ARG(presenter); - } - bool isProcessing() const override { return false; } - ~MockRunsTabPresenter() override{}; -}; - class MockMainWindowPresenter : public IReflMainWindowPresenter { public: MOCK_METHOD1(runPythonAlgorithm, std::string(const std::string &)); -- GitLab