@@ -21,6 +21,9 @@ Mantid::Kernel::Logger g_log("DensityOfStates");
21
21
} // namespace
22
22
23
23
namespace MantidQt ::CustomInterfaces {
24
+
25
+ enum class DensityOfStates ::InputFormat : int { Unsupported = 0 , Phonon, Castep, ForceConstants };
26
+
24
27
DensityOfStates::DensityOfStates (QWidget *parent) : SimulationTab(parent) {
25
28
m_uiForm.setupUi (parent);
26
29
m_runPresenter = std::make_unique<RunPresenter>(this , new RunView (m_uiForm.runWidget ));
@@ -35,10 +38,20 @@ DensityOfStates::DensityOfStates(QWidget *parent) : SimulationTab(parent) {
35
38
}
36
39
37
40
void DensityOfStates::handleValidation (IUserInputValidator *validator) const {
38
- const auto filename = m_uiForm.mwInputFile ->getFirstFilename ().toStdString ();
39
- InputFormat format = filenameToFormat (filename);
40
- QString specType = m_uiForm.cbSpectrumType ->currentText ();
41
- auto items = m_uiForm.lwIons ->selectedItems ();
41
+ auto const filename = m_uiForm.mwInputFile ->getFirstFilename ().toStdString ();
42
+ if (filename.empty ()) {
43
+ validator->addErrorMessage (" A data file has not been loaded." );
44
+ return ;
45
+ }
46
+ auto const format = filenameToFormat (filename);
47
+ if (format == InputFormat::Unsupported) {
48
+ validator->addErrorMessage (" The provided file format is unsupported. The supported extensions are 'phonon', "
49
+ " 'castep', 'castep_bin' and 'yaml'." );
50
+ return ;
51
+ }
52
+
53
+ auto const specType = m_uiForm.cbSpectrumType ->currentText ();
54
+ auto const items = m_uiForm.lwIons ->selectedItems ();
42
55
43
56
if (specType == " DensityOfStates" && isPdosFile (format) && items.size () < 1 )
44
57
validator->addErrorMessage (" Must select at least one ion for DensityOfStates." );
@@ -217,12 +230,6 @@ void DensityOfStates::saveClicked() {
217
230
218
231
void DensityOfStates::setSaveEnabled (bool enabled) { m_uiForm.pbSave ->setEnabled (enabled); }
219
232
220
- /* *
221
- * Handle file formats
222
- */
223
-
224
- enum class DensityOfStates ::InputFormat : int { Unsupported = 0 , Phonon, Castep, ForceConstants };
225
-
226
233
DensityOfStates::InputFormat DensityOfStates::filenameToFormat (std::string const &filename) const {
227
234
QFileInfo inputFileInfo (QString::fromStdString (filename));
228
235
const auto suffix = inputFileInfo.suffix ().toStdString ();
0 commit comments