diff --git a/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/Reflectometry/IReflMainWindowPresenter.h b/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/Reflectometry/IReflMainWindowPresenter.h index 75c56fd3c013579e75c31b769f9fe4603788ba04..b3bce89ed13d1c383505144b28b8332e8d46ac21 100644 --- a/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/Reflectometry/IReflMainWindowPresenter.h +++ b/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/Reflectometry/IReflMainWindowPresenter.h @@ -49,10 +49,14 @@ public: virtual std::string askUserString(const std::string &prompt, const std::string &title, const std::string &defaultValue) = 0; - virtual bool askUserYesNo(std::string prompt, std::string title) = 0; - virtual void giveUserWarning(std::string prompt, std::string title) = 0; - virtual void giveUserCritical(std::string prompt, std::string title) = 0; - virtual void giveUserInfo(std::string prompt, std::string title) = 0; + virtual bool askUserYesNo(const std::string &prompt, + const std::string &title) = 0; + virtual void giveUserWarning(const std::string &prompt, + const std::string &title) = 0; + virtual void giveUserCritical(const std::string &prompt, + const std::string &title) = 0; + virtual void giveUserInfo(const std::string &prompt, + const std::string &title) = 0; virtual std::string runPythonAlgorithm(const std::string &pythonCode) = 0; }; } diff --git a/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/Reflectometry/IReflMainWindowView.h b/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/Reflectometry/IReflMainWindowView.h index 5a7a775709702fdba95f8c94af2a7fbd3087198b..d53151432840aef7ddb9027be9d33c3bf632a587 100644 --- a/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/Reflectometry/IReflMainWindowView.h +++ b/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/Reflectometry/IReflMainWindowView.h @@ -43,10 +43,14 @@ public: virtual std::string askUserString(const std::string &prompt, const std::string &title, const std::string &defaultValue) = 0; - virtual bool askUserYesNo(std::string prompt, std::string title) = 0; - virtual void giveUserWarning(std::string prompt, std::string title) = 0; - virtual void giveUserCritical(std::string prompt, std::string title) = 0; - virtual void giveUserInfo(std::string prompt, std::string title) = 0; + virtual bool askUserYesNo(const std::string &prompt, + const std::string &title) = 0; + virtual void giveUserWarning(const std::string &prompt, + const std::string &title) = 0; + virtual void giveUserCritical(const std::string &prompt, + const std::string &title) = 0; + virtual void giveUserInfo(const std::string &prompt, + const std::string &title) = 0; virtual std::string runPythonAlgorithm(const std::string &pythonCode) = 0; }; } diff --git a/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/Reflectometry/QtReflMainWindowView.h b/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/Reflectometry/QtReflMainWindowView.h index 2bc9ed23ed3e33b986d33152de9734de0db0c92a..a3f05e178c4e3f85ecb5242911c9dbd0942d0a26 100644 --- a/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/Reflectometry/QtReflMainWindowView.h +++ b/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/Reflectometry/QtReflMainWindowView.h @@ -53,10 +53,14 @@ public: /// Dialog/Prompt methods std::string askUserString(const std::string &prompt, const std::string &title, const std::string &defaultValue) override; - bool askUserYesNo(std::string prompt, std::string title) override; - void giveUserWarning(std::string prompt, std::string title) override; - void giveUserCritical(std::string prompt, std::string title) override; - void giveUserInfo(std::string prompt, std::string title) override; + bool askUserYesNo(const std::string &prompt, + const std::string &title) override; + void giveUserWarning(const std::string &prompt, + const std::string &title) override; + void giveUserCritical(const std::string &prompt, + const std::string &title) override; + void giveUserInfo(const std::string &prompt, + const std::string &title) override; std::string runPythonAlgorithm(const std::string &pythonCode) override; private: diff --git a/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/Reflectometry/QtReflSettingsTabView.h b/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/Reflectometry/QtReflSettingsTabView.h index a624226de5183d6118f5cc562ec5b3a38584b7ce..afa5c5882bafe16124dee2f37529206bb742cb81 100644 --- a/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/Reflectometry/QtReflSettingsTabView.h +++ b/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/Reflectometry/QtReflSettingsTabView.h @@ -43,15 +43,15 @@ public: /// Destructor ~QtReflSettingsTabView() override; /// Returns the presenter managing this view - IReflSettingsTabPresenter *getPresenter() const; + IReflSettingsTabPresenter *getPresenter() const override; /// Returns global options for 'Plus' algorithm - std::string getPlusOptions() const; + std::string getPlusOptions() const override; /// Returns global options for 'CreateTransmissionWorkspaceAuto' - std::string getTransmissionOptions() const; + std::string getTransmissionOptions() const override; /// Returns global options for 'ReflectometryReductionOneAuto' - std::string getReductionOptions() const; + std::string getReductionOptions() const override; /// Returns global options for 'Stitch1DMany' - std::string getStitchOptions() const; + std::string getStitchOptions() const override; /// Creates hints for 'Plus' void diff --git a/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/Reflectometry/ReflMainWindowPresenter.h b/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/Reflectometry/ReflMainWindowPresenter.h index 396db08609cd467ae2786abe74a796acbb29413b..eb5f07ac6ddf2cd80064835282215f4fd54356c5 100644 --- a/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/Reflectometry/ReflMainWindowPresenter.h +++ b/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/Reflectometry/ReflMainWindowPresenter.h @@ -47,20 +47,24 @@ public: /// Destructor ~ReflMainWindowPresenter() override; /// Returns global options for 'Plus' algorithm - std::string getPlusOptions() const; + std::string getPlusOptions() const override; /// Returns global options for 'CreateTransmissionWorkspaceAuto' - std::string getTransmissionOptions() const; + std::string getTransmissionOptions() const override; /// Returns global options for 'ReflectometryReductionOneAuto' - std::string getReductionOptions() const; + std::string getReductionOptions() const override; /// Returns global options for 'Stitch1DMany' - std::string getStitchOptions() const; + std::string getStitchOptions() const override; /// Dialog/Prompt methods std::string askUserString(const std::string &prompt, const std::string &title, const std::string &defaultValue) override; - bool askUserYesNo(std::string prompt, std::string title) override; - void giveUserWarning(std::string prompt, std::string title) override; - void giveUserCritical(std::string prompt, std::string title) override; - void giveUserInfo(std::string prompt, std::string title) override; + bool askUserYesNo(const std::string &prompt, + const std::string &title) override; + void giveUserWarning(const std::string &prompt, + const std::string &title) override; + void giveUserCritical(const std::string &prompt, + const std::string &title) override; + void giveUserInfo(const std::string &prompt, + const std::string &title) override; std::string runPythonAlgorithm(const std::string &pythonCode) override; private: @@ -75,4 +79,4 @@ private: }; } } -#endif /* MANTID_CUSTOMINTERFACES_REFLMAINWINDOWPRESENTER_H */ \ No newline at end of file +#endif /* MANTID_CUSTOMINTERFACES_REFLMAINWINDOWPRESENTER_H */ diff --git a/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/Reflectometry/ReflSettingsTabPresenter.h b/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/Reflectometry/ReflSettingsTabPresenter.h index 8e803b5fbbf0b681c66e0b826702607071326e7e..0e3b1affad2e5ba7f713bfd1c7bb5449f2975612 100644 --- a/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/Reflectometry/ReflSettingsTabPresenter.h +++ b/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/Reflectometry/ReflSettingsTabPresenter.h @@ -48,13 +48,13 @@ public: void acceptMainPresenter(IReflMainWindowPresenter *mainPresenter) override; /// Returns global options for 'Plus' algorithm - std::string getPlusOptions() const; + std::string getPlusOptions() const override; /// Returns global options for 'CreateTransmissionWorkspaceAuto' - std::string getTransmissionOptions() const; + std::string getTransmissionOptions() const override; /// Returns global options for 'ReflectometryReductionOneAuto' - std::string getReductionOptions() const; + std::string getReductionOptions() const override; /// Returns global options for 'Stitch1DMany' - std::string getStitchOptions() const; + std::string getStitchOptions() const override; private: void createPlusHints(); diff --git a/MantidQt/CustomInterfaces/src/Reflectometry/QtReflMainWindowView.cpp b/MantidQt/CustomInterfaces/src/Reflectometry/QtReflMainWindowView.cpp index 43399c538f303485491eb1fdffa4608e4643934c..3c082f951ecfa11ae093d168e07c4e4a6caf80b6 100644 --- a/MantidQt/CustomInterfaces/src/Reflectometry/QtReflMainWindowView.cpp +++ b/MantidQt/CustomInterfaces/src/Reflectometry/QtReflMainWindowView.cpp @@ -64,10 +64,11 @@ Show an critical error dialog @param prompt : The prompt to appear on the dialog @param title : The text for the title bar of the dialog */ -void QtReflMainWindowView::giveUserCritical(std::string prompt, - std::string title) { - QMessageBox::critical(this, QString(title.c_str()), QString(prompt.c_str()), - QMessageBox::Ok, QMessageBox::Ok); +void QtReflMainWindowView::giveUserCritical(const std::string &prompt, + const std::string &title) { + QMessageBox::critical(this, QString::fromStdString(title), + QString::fromStdString(prompt), QMessageBox::Ok, + QMessageBox::Ok); } /** @@ -75,10 +76,11 @@ Show a warning dialog @param prompt : The prompt to appear on the dialog @param title : The text for the title bar of the dialog */ -void QtReflMainWindowView::giveUserWarning(std::string prompt, - std::string title) { - QMessageBox::warning(this, QString(title.c_str()), QString(prompt.c_str()), - QMessageBox::Ok, QMessageBox::Ok); +void QtReflMainWindowView::giveUserWarning(const std::string &prompt, + const std::string &title) { + QMessageBox::warning(this, QString::fromStdString(title), + QString::fromStdString(prompt), QMessageBox::Ok, + QMessageBox::Ok); } /** @@ -86,9 +88,10 @@ Show an information dialog @param prompt : The prompt to appear on the dialog @param title : The text for the title bar of the dialog */ -void QtReflMainWindowView::giveUserInfo(std::string prompt, std::string title) { - QMessageBox::information(this, QString(title.c_str()), - QString(prompt.c_str()), QMessageBox::Ok, +void QtReflMainWindowView::giveUserInfo(const std::string &prompt, + const std::string &title) { + QMessageBox::information(this, QString::fromStdString(title), + QString::fromStdString(prompt), QMessageBox::Ok, QMessageBox::Ok); } @@ -98,9 +101,10 @@ Ask the user a Yes/No question @param title : The text for the title bar of the dialog @returns a boolean true if Yes, false if No */ -bool QtReflMainWindowView::askUserYesNo(std::string prompt, std::string title) { +bool QtReflMainWindowView::askUserYesNo(const std::string &prompt, + const std::string &title) { auto response = QMessageBox::question( - this, QString(title.c_str()), QString(prompt.c_str()), + this, QString::fromStdString(title), QString::fromStdString(prompt), QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes); if (response == QMessageBox::Yes) { return true; diff --git a/MantidQt/CustomInterfaces/src/Reflectometry/ReflMainWindowPresenter.cpp b/MantidQt/CustomInterfaces/src/Reflectometry/ReflMainWindowPresenter.cpp index 66884b4b604084a4db7c4b77175903b33aef3aea..0a58beb754261ade0625b59589d2cf660c979942 100644 --- a/MantidQt/CustomInterfaces/src/Reflectometry/ReflMainWindowPresenter.cpp +++ b/MantidQt/CustomInterfaces/src/Reflectometry/ReflMainWindowPresenter.cpp @@ -73,8 +73,8 @@ Tells the view to show an critical error dialog @param prompt : The prompt to appear on the dialog @param title : The text for the title bar of the dialog */ -void ReflMainWindowPresenter::giveUserCritical(std::string prompt, - std::string title) { +void ReflMainWindowPresenter::giveUserCritical(const std::string &prompt, + const std::string &title) { m_view->giveUserCritical(prompt, title); } @@ -84,8 +84,8 @@ Tells the view to show a warning dialog @param prompt : The prompt to appear on the dialog @param title : The text for the title bar of the dialog */ -void ReflMainWindowPresenter::giveUserWarning(std::string prompt, - std::string title) { +void ReflMainWindowPresenter::giveUserWarning(const std::string &prompt, + const std::string &title) { m_view->giveUserWarning(prompt, title); } @@ -95,8 +95,8 @@ Tells the view to show an information dialog @param prompt : The prompt to appear on the dialog @param title : The text for the title bar of the dialog */ -void ReflMainWindowPresenter::giveUserInfo(std::string prompt, - std::string title) { +void ReflMainWindowPresenter::giveUserInfo(const std::string &prompt, + const std::string &title) { m_view->giveUserInfo(prompt, title); } @@ -107,8 +107,8 @@ Tells the view to ask the user a Yes/No question @param title : The text for the title bar of the dialog @returns a boolean true if Yes, false if No */ -bool ReflMainWindowPresenter::askUserYesNo(std::string prompt, - std::string title) { +bool ReflMainWindowPresenter::askUserYesNo(const std::string &prompt, + const std::string &title) { return m_view->askUserYesNo(prompt, title); } @@ -148,4 +148,4 @@ void ReflMainWindowPresenter::checkPtrValid( throw std::invalid_argument("Could not read settings"); } } -} \ No newline at end of file +} diff --git a/MantidQt/CustomInterfaces/test/ReflMockObjects.h b/MantidQt/CustomInterfaces/test/ReflMockObjects.h index 0dd4c8d1029c68de7859cd4dbef88909cc0ff3cd..6daba719226532521604147ce3ae88cba9e29765 100644 --- a/MantidQt/CustomInterfaces/test/ReflMockObjects.h +++ b/MantidQt/CustomInterfaces/test/ReflMockObjects.h @@ -94,10 +94,11 @@ public: MOCK_METHOD3(askUserString, std::string(const std::string &, const std::string &, const std::string &)); - MOCK_METHOD2(askUserYesNo, bool(std::string, std::string)); - MOCK_METHOD2(giveUserWarning, void(std::string, std::string)); - MOCK_METHOD2(giveUserCritical, void(std::string, std::string)); - MOCK_METHOD2(giveUserInfo, void(std::string, std::string)); + MOCK_METHOD2(askUserYesNo, bool(const std::string &, const std::string &)); + MOCK_METHOD2(giveUserWarning, void(const std::string &, const std::string &)); + MOCK_METHOD2(giveUserCritical, + void(const std::string &, const std::string &)); + MOCK_METHOD2(giveUserInfo, void(const std::string &, const std::string &)); MOCK_METHOD1(runPythonAlgorithm, std::string(const std::string &)); ~MockMainWindowView() override{}; }; @@ -135,10 +136,11 @@ public: MOCK_METHOD3(askUserString, std::string(const std::string &, const std::string &, const std::string &)); - MOCK_METHOD2(askUserYesNo, bool(std::string, std::string)); - MOCK_METHOD2(giveUserWarning, void(std::string, std::string)); - MOCK_METHOD2(giveUserCritical, void(std::string, std::string)); - MOCK_METHOD2(giveUserInfo, void(std::string, std::string)); + MOCK_METHOD2(askUserYesNo, bool(const std::string &, const std::string &)); + MOCK_METHOD2(giveUserWarning, void(const std::string &, const std::string &)); + MOCK_METHOD2(giveUserCritical, + void(const std::string &, const std::string &)); + MOCK_METHOD2(giveUserInfo, void(const std::string &, const std::string &)); MOCK_METHOD1(runPythonAlgorithm, std::string(const std::string &)); ~MockMainWindowPresenter() override{}; };