Mantid
Loading...
Searching...
No Matches
AddWorkspaceDialog.cpp
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI,
4// NScD Oak Ridge National Laboratory, European Spallation Source,
5// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
6// SPDX - License - Identifier: GPL - 3.0 +
10
13#include <utility>
14
16
17AddWorkspaceDialog::AddWorkspaceDialog(QWidget *parent) : QDialog(parent) {
18 m_uiForm.setupUi(this);
19 const auto validatorString = QString::fromStdString(getRegexValidatorString(RegexValidatorStrings::SpectraValidator));
20 m_uiForm.leWorkspaceIndices->setValidator(new QRegExpValidator(QRegExp(validatorString), this));
22 connect(m_uiForm.dsWorkspace, SIGNAL(filesAutoLoaded()), this, SLOT(handleAutoLoaded()));
23 connect(m_uiForm.dsWorkspace, SIGNAL(dataReady(const QString &)), this, SLOT(workspaceChanged(const QString &)));
24 connect(m_uiForm.ckAllSpectra, SIGNAL(stateChanged(int)), this, SLOT(selectAllSpectra(int)));
25 connect(m_uiForm.pbAdd, SIGNAL(clicked()), this, SLOT(emitAddData()));
26 connect(m_uiForm.pbClose, SIGNAL(clicked()), this, SLOT(close()));
27}
28
30 return m_uiForm.dsWorkspace->getCurrentDataName().toStdString();
31}
32
34 return FunctionModelSpectra(m_uiForm.leWorkspaceIndices->text().toStdString());
35}
36
37void AddWorkspaceDialog::setWSSuffices(const QStringList &suffices) { m_uiForm.dsWorkspace->setWSSuffixes(suffices); }
38
39void AddWorkspaceDialog::setFBSuffices(const QStringList &suffices) { m_uiForm.dsWorkspace->setFBSuffixes(suffices); }
40
41void AddWorkspaceDialog::setLoadProperty(const std::string &propName, bool enable) {
42 m_uiForm.dsWorkspace->setLoadProperty(propName, enable);
43}
44
46 auto const state = m_uiForm.ckAllSpectra->isChecked() ? Qt::Checked : Qt::Unchecked;
47 selectAllSpectra(state);
48}
49
51 auto const name = workspaceName();
52 if (WorkspaceUtils::doesExistInADS(name) && state == Qt::Checked) {
53 m_uiForm.leWorkspaceIndices->setText(QString::fromStdString(WorkspaceUtils::getIndexString(name)));
54 m_uiForm.leWorkspaceIndices->setEnabled(false);
55 } else
56 m_uiForm.leWorkspaceIndices->setEnabled(true);
57}
58
59void AddWorkspaceDialog::workspaceChanged(const QString &workspaceName) {
60 const auto name = workspaceName.toStdString();
62 m_uiForm.pbAdd->setText("Add");
63 m_uiForm.pbAdd->setEnabled(true);
64
65 if (workspace)
67 else
69}
70
72
74 m_uiForm.pbAdd->setText("Loading");
75 m_uiForm.pbAdd->setEnabled(false);
76}
77
80 if (m_uiForm.ckAllSpectra->isChecked()) {
81 m_uiForm.leWorkspaceIndices->setText(QString::fromStdString(WorkspaceUtils::getIndexString(workspace)));
82 m_uiForm.leWorkspaceIndices->setEnabled(false);
83 }
84}
85
86void AddWorkspaceDialog::setAllSpectraSelectionEnabled(bool doEnable) { m_uiForm.ckAllSpectra->setEnabled(doEnable); }
87
88std::string AddWorkspaceDialog::getFileName() const { return m_uiForm.dsWorkspace->getFullFilePath().toStdString(); }
89
90} // namespace MantidQt::MantidWidgets
std::string name
Definition Run.cpp:60
IPeaksWorkspace_sptr workspace
void setFBSuffices(const QStringList &suffices) override
void setWorkspace(const std::string &workspace)
void addData(MantidWidgets::IAddWorkspaceDialog *dialog)
void workspaceChanged(const QString &workspaceName)
void setLoadProperty(const std::string &propName, bool enable) override
void setWSSuffices(const QStringList &suffices) override
EXPORT_OPT_MANTIDQT_COMMON std::string getIndexString(const std::string &workspaceName)
std::shared_ptr< T > getADSWorkspace(std::string const &workspaceName)
EXPORT_OPT_MANTIDQT_COMMON bool doesExistInADS(std::string const &workspaceName)
EXPORT_OPT_MANTIDQT_COMMON std::string getRegexValidatorString(const RegexValidatorStrings &validatorMask)