Skip to content

Commit cb03080

Browse files
Merge pull request #38388 from mantidproject/38005_mvp_stretch
Refactor the Stretch tab in BayesFitting to meet MVP design pattern
2 parents 1648bba + 746f8a1 commit cb03080

File tree

19 files changed

+1318
-574
lines changed

19 files changed

+1318
-574
lines changed

qt/scientific_interfaces/Inelastic/BayesFitting/BayesFitting.cpp

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,10 @@
88
#include "MantidQtWidgets/Spectroscopy/SettingsWidget/Settings.h"
99
#include "Quasi.h"
1010
#include "ResNormPresenter.h"
11-
#include "Stretch.h"
11+
#include "StretchPresenter.h"
1212

1313
#include <MantidQtWidgets/Common/QtJobRunner.h>
1414

15-
using namespace MantidQt::CustomInterfaces;
16-
1715
namespace MantidQt::CustomInterfaces {
1816
DECLARE_SUBWINDOW(BayesFitting)
1917

@@ -25,17 +23,26 @@ BayesFitting::BayesFitting(QWidget *parent)
2523
// Connect Poco Notification Observer
2624
Mantid::Kernel::ConfigService::Instance().addObserver(m_changeObserver);
2725

28-
auto jobRunner = std::make_unique<MantidQt::API::QtJobRunner>(true);
29-
auto algorithmRunner = std::make_unique<MantidQt::API::AlgorithmRunner>(std::move(jobRunner));
26+
auto resNormRunner = createAlgorithmRunner();
3027

3128
// insert each tab into the interface on creation
3229
auto resNormModel = std::make_unique<ResNormModel>();
3330
auto resNormWidget = m_uiForm.bayesFittingTabs->widget(RES_NORM);
34-
m_bayesTabs.emplace(RES_NORM, new ResNormPresenter(resNormWidget, std::move(algorithmRunner), std::move(resNormModel),
31+
m_bayesTabs.emplace(RES_NORM, new ResNormPresenter(resNormWidget, std::move(resNormRunner), std::move(resNormModel),
3532
new ResNormView(resNormWidget)));
3633

3734
m_bayesTabs.emplace(QUASI, new Quasi(m_uiForm.bayesFittingTabs->widget(QUASI)));
38-
m_bayesTabs.emplace(STRETCH, new Stretch(m_uiForm.bayesFittingTabs->widget(STRETCH)));
35+
36+
auto stretchRunner = createAlgorithmRunner();
37+
38+
auto tabContent = m_uiForm.bayesFittingTabs->widget(STRETCH);
39+
m_bayesTabs.emplace(STRETCH, new StretchPresenter(tabContent, new StretchView(tabContent),
40+
std::make_unique<StretchModel>(), std::move(stretchRunner)));
41+
}
42+
43+
std::unique_ptr<MantidQt::API::AlgorithmRunner> BayesFitting::createAlgorithmRunner() const {
44+
auto jobRunner = std::make_unique<MantidQt::API::QtJobRunner>(true);
45+
return std::make_unique<MantidQt::API::AlgorithmRunner>(std::move(jobRunner));
3946
}
4047

4148
void BayesFitting::initLayout() {

qt/scientific_interfaces/Inelastic/BayesFitting/BayesFitting.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ class MANTIDQT_INELASTIC_DLL BayesFitting : public InelasticInterface {
4545
void initLayout() override;
4646

4747
private:
48+
std::unique_ptr<MantidQt::API::AlgorithmRunner> createAlgorithmRunner() const;
49+
4850
std::string documentationPage() const override;
4951

5052
void applySettings(std::map<std::string, QVariant> const &settings) override;

qt/scientific_interfaces/Inelastic/BayesFitting/CMakeLists.txt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,14 @@ set(SRC_FILES
77
ResNormModel.cpp
88
ResNormView.cpp
99
ResNormPresenter.cpp
10-
Stretch.cpp
10+
StretchView.cpp
11+
StretchPresenter.cpp
12+
StretchModel.cpp
1113
)
1214

13-
set(INC_FILES ResNormPresenter.h ResNormModel.h)
15+
set(INC_FILES ResNormPresenter.h ResNormModel.h StretchPresenter.h StretchModel.h)
1416

15-
set(MOC_FILES BayesFitting.h BayesFittingTab.h Quasi.h ResNormView.h Stretch.h)
17+
set(MOC_FILES BayesFitting.h BayesFittingTab.h Quasi.h ResNormView.h StretchView.h)
1618

1719
set(UI_FILES BayesFitting.ui Quasi.ui ResNorm.ui Stretch.ui)
1820

@@ -29,7 +31,6 @@ set(ALL_INC_FILES
2931
${ALL_INC_FILES} ${INC_FILES}
3032
PARENT_SCOPE
3133
)
32-
3334
set(ALL_MOC_FILES
3435
${ALL_MOC_FILES} ${MOC_FILES}
3536
PARENT_SCOPE

0 commit comments

Comments
 (0)