From 9766e238956be75691261f7600be909c14afe106 Mon Sep 17 00:00:00 2001 From: Martyn Gigg <martyn.gigg@stfc.ac.uk> Date: Wed, 9 Feb 2011 08:25:46 +0000 Subject: [PATCH] Modified LoadEventPreNeXus so that it is compatible with the Load algorithm, Refs #2168. Also made a couple of adjustments to the layout of the MWRunFiles widget to make it better at resizing with the dialogs it is attached to. Re #2329 --- .../API/inc/MantidAPI/IDataFileChecker.h | 2 + .../inc/MantidDataHandling/Load.h | 12 +- .../MantidDataHandling/LoadEventPreNeXus.h | 15 +- .../Framework/DataHandling/src/Load.cpp | 54 +++++--- .../DataHandling/src/LoadEventPreNeXus.cpp | 48 ++++++- .../Framework/DataHandling/test/LoadTest.h | 10 +- .../inc/MantidQtCustomDialogs/LoadDialog.h | 18 ++- .../MantidQt/CustomDialogs/src/LoadDialog.cpp | 129 ++++++++++-------- .../inc/MantidQtMantidWidgets/MWRunFiles.ui | 49 +++---- .../MantidQt/MantidWidgets/src/MWRunFiles.cpp | 15 +- 10 files changed, 227 insertions(+), 125 deletions(-) diff --git a/Code/Mantid/Framework/API/inc/MantidAPI/IDataFileChecker.h b/Code/Mantid/Framework/API/inc/MantidAPI/IDataFileChecker.h index 76ec84ebaa3..63a374b4081 100644 --- a/Code/Mantid/Framework/API/inc/MantidAPI/IDataFileChecker.h +++ b/Code/Mantid/Framework/API/inc/MantidAPI/IDataFileChecker.h @@ -45,6 +45,8 @@ namespace Mantid IDataFileChecker(); /// virtual destructor virtual ~IDataFileChecker(); + /// Returns the name of the property to be considered as the Filename for Load + virtual const char * filePropertyName() const { return "Filename"; } /// Magic signature identifying a HDF5 file. static const unsigned char g_hdf5_signature[8]; diff --git a/Code/Mantid/Framework/DataHandling/inc/MantidDataHandling/Load.h b/Code/Mantid/Framework/DataHandling/inc/MantidDataHandling/Load.h index cc7b3954402..fb4a2d669a5 100644 --- a/Code/Mantid/Framework/DataHandling/inc/MantidDataHandling/Load.h +++ b/Code/Mantid/Framework/DataHandling/inc/MantidDataHandling/Load.h @@ -60,21 +60,21 @@ namespace Mantid virtual int fileCheck(const std::string& filePath); /// This method returns shared pointer to a load algorithm which got /// the highest preference after file check. - API::IAlgorithm_sptr getFileLoader(const std::string& filePath); + API::IDataFileChecker_sptr getFileLoader(const std::string& filePath); /// Declare any additional input properties from the concrete loader - void declareLoaderProperties(const API::IAlgorithm_sptr loader); + void declareLoaderProperties(const API::IDataFileChecker_sptr loader); /// Initialize the static base properties void init(); /// Execute void exec(); /// Create the concrete instance use for the actual loading. - API::IAlgorithm_sptr createLoader(const std::string & name, const double startProgress = -1.0, - const double endProgress=-1.0, const bool logging = true) const; + API::IDataFileChecker_sptr createLoader(const std::string & name, const double startProgress = -1.0, + const double endProgress=-1.0, const bool logging = true) const; /// Set the output workspace(s) - void setOutputWorkspace(const API::IAlgorithm_sptr loader); + void setOutputWorkspace(const API::IDataFileChecker_sptr loader); /// Retrieve a pointer to the output workspace from the sub algorithm - API::Workspace_sptr getOutputWorkspace(const API::IAlgorithm_sptr loader) const; + API::Workspace_sptr getOutputWorkspace(const API::IDataFileChecker_sptr loader) const; private: diff --git a/Code/Mantid/Framework/DataHandling/inc/MantidDataHandling/LoadEventPreNeXus.h b/Code/Mantid/Framework/DataHandling/inc/MantidDataHandling/LoadEventPreNeXus.h index 60263417aae..99708fe53d1 100644 --- a/Code/Mantid/Framework/DataHandling/inc/MantidDataHandling/LoadEventPreNeXus.h +++ b/Code/Mantid/Framework/DataHandling/inc/MantidDataHandling/LoadEventPreNeXus.h @@ -4,7 +4,7 @@ #include <fstream> #include <string> #include <vector> -#include "MantidAPI/Algorithm.h" +#include "MantidAPI/IDataFileChecker.h" #include "MantidKernel/BinaryFile.h" #include "MantidDataObjects/EventWorkspace.h" @@ -98,7 +98,7 @@ struct Pulse #pragma pack(pop) -class DLLExport LoadEventPreNeXus : public Mantid::API::Algorithm +class DLLExport LoadEventPreNeXus : public API::IDataFileChecker { public: /// Constructor @@ -111,14 +111,21 @@ public: virtual int version() const { return (1); } /// Algorithm's category for identification virtual const std::string category() const { return "DataHandling"; } - + /// Returns the name of the property to be considered as the Filename for Load + virtual const char * filePropertyName() const; + /// do a quick check that this file can be loaded + bool quickFileCheck(const std::string& filePath,size_t nread,const file_header& header); + /// check the structure of the file and return a value between 0 and 100 of how much this file can be loaded + int fileCheck(const std::string& filePath); + /// Map between the DAS pixel IDs and our pixel IDs, used while loading. std::vector<PixelType> pixelmap; void setMaxEventsToLoad(std::size_t max_events_to_load); - private: + + /// Initialisation code void init(); ///Execution code diff --git a/Code/Mantid/Framework/DataHandling/src/Load.cpp b/Code/Mantid/Framework/DataHandling/src/Load.cpp index b16b0aa9951..1ebc892219b 100644 --- a/Code/Mantid/Framework/DataHandling/src/Load.cpp +++ b/Code/Mantid/Framework/DataHandling/src/Load.cpp @@ -3,8 +3,8 @@ //---------------------------------------------------------------------- #include "MantidDataHandling/Load.h" #include "MantidAPI/FileProperty.h" +#include "MantidAPI/IEventWorkspace.h" #include "MantidKernel/ArrayProperty.h" -#include "MantidDataObjects/Workspace2D.h" #include "MantidAPI/LoadAlgorithmFactory.h" #include "MantidAPI/AlgorithmManager.h" @@ -36,7 +36,7 @@ namespace Mantid { IDataFileChecker::setPropertyValue(name, value); - IAlgorithm_sptr loader; + IDataFileChecker_sptr loader; if( name == "Filename" ) { loader = getFileLoader(getPropertyValue(name)); @@ -46,7 +46,8 @@ namespace Mantid const std::string loaderName = getProperty("LoaderName"); if( !loaderName.empty() ) { - loader = API::AlgorithmManager::Instance().createUnmanaged(loaderName); + loader = boost::static_pointer_cast<IDataFileChecker>( + API::AlgorithmManager::Instance().createUnmanaged(loaderName)); loader->initialize(); } } @@ -85,7 +86,7 @@ namespace Mantid * @param filePath :: path of the file * @returns A shared pointer to the unmanaged algorithm */ - API::IAlgorithm_sptr Load::getFileLoader(const std::string& filePath) + API::IDataFileChecker_sptr Load::getFileLoader(const std::string& filePath) { /* Open the file and read in the first bufferSize bytes - these will * be used to determine the type of the file @@ -114,7 +115,7 @@ namespace Mantid // giving its certainty about be able to load the file. The highest wins. std::vector<std::string> loaderNames = API::LoadAlgorithmFactory::Instance().getKeys(); int highestPref(0); - API::IAlgorithm_sptr winningLoader; + API::IDataFileChecker_sptr winningLoader; std::vector<std::string>::const_iterator cend = loaderNames.end(); for( std::vector<std::string>::const_iterator citr = loaderNames.begin(); citr != cend; ++citr ) @@ -148,7 +149,7 @@ namespace Mantid * Declare any additional properties of the concrete loader here * @param loader A pointer to the concrete loader */ - void Load::declareLoaderProperties(const IAlgorithm_sptr loader) + void Load::declareLoaderProperties(const IDataFileChecker_sptr loader) { const std::vector<Property*> existingProps = this->getProperties(); for( size_t i = 0; i < existingProps.size(); ++i ) @@ -162,10 +163,12 @@ namespace Mantid } const std::vector<Property*> &loaderProps = loader->getProperties(); + const std::string filePropName(loader->filePropertyName()); size_t numProps(loaderProps.size()); for (size_t i = 0; i < numProps; ++i) { Property* loadProp = loaderProps[i]; + if( loadProp->name() == filePropName ) continue; try { declareProperty(loadProp->clone(), loadProp->documentation()); @@ -232,22 +235,24 @@ namespace Mantid { throw std::invalid_argument("Cannot find loader, LoaderName property has not been set."); } - IAlgorithm_sptr loader = createLoader(loaderName); + IDataFileChecker_sptr loader = createLoader(loaderName); g_log.information() << "Using " << loaderName << " version " << loader->version() << ".\n"; - // Get the list of properties for the Load algorithm - std::vector<Kernel::Property*> props = this->getProperties(); ///get the list properties for the concrete loader load algorithm - std::vector<Kernel::Property*> loader_props = loader->getProperties(); + const std::vector<Kernel::Property*> & loader_props = loader->getProperties(); - //loop through the properties of this algorithm - std::vector<Kernel::Property*>::iterator itr; - for (itr = props.begin(); itr != props.end(); ++itr) + // Loop through and set the properties on the sub algorithm + std::vector<Kernel::Property*>::const_iterator itr; + for (itr = loader_props.begin(); itr != loader_props.end(); ++itr) { const std::string propName = (*itr)->name(); - if( loader->existsProperty(propName) ) + if( this->existsProperty(propName) ) { loader->setPropertyValue(propName, getPropertyValue(propName)); } + else if( propName == loader->filePropertyName() ) + { + loader->setPropertyValue(propName, getPropertyValue("Filename")); + } } // Execute the concrete loader @@ -265,10 +270,11 @@ namespace Mantid * algorithm where this child algorithm ends * @param logging :: Set to false to disable logging from the child algorithm */ - API::IAlgorithm_sptr Load::createLoader(const std::string & name, const double startProgress, - const double endProgress, const bool logging) const + API::IDataFileChecker_sptr Load::createLoader(const std::string & name, const double startProgress, + const double endProgress, const bool logging) const { - IAlgorithm_sptr loader = AlgorithmManager::Instance().createUnmanaged(name); + IDataFileChecker_sptr loader = boost::static_pointer_cast<IDataFileChecker>( + API::AlgorithmManager::Instance().createUnmanaged(name)); loader->initialize(); if( !loader ) { @@ -301,7 +307,7 @@ namespace Mantid * Set the output workspace(s) if the load's return workspace has type API::Workspace * @param load :: Shared pointer to load algorithm */ - void Load::setOutputWorkspace(const API::IAlgorithm_sptr load) + void Load::setOutputWorkspace(const API::IDataFileChecker_sptr load) { Workspace_sptr childWS = getOutputWorkspace(load); if( WorkspaceGroup_sptr wsGroup = boost::dynamic_pointer_cast<WorkspaceGroup>(childWS) ) @@ -326,8 +332,9 @@ namespace Mantid * Return the top-level workspace property * @returns A pointer to the OutputWorkspace property of the sub algorithm */ - API::Workspace_sptr Load::getOutputWorkspace(const API::IAlgorithm_sptr loader) const + API::Workspace_sptr Load::getOutputWorkspace(const API::IDataFileChecker_sptr loader) const { + // @todo Need to try and find a better way using the getValue methods try { return loader->getProperty("OutputWorkspace"); @@ -344,6 +351,15 @@ namespace Mantid catch(std::runtime_error&) { } + // EventWorkspace + try + { + IEventWorkspace_sptr childWS = loader->getProperty("OutputWorkspace"); + return childWS; + } + catch(std::runtime_error&) + { + } return Workspace_sptr(); } diff --git a/Code/Mantid/Framework/DataHandling/src/LoadEventPreNeXus.cpp b/Code/Mantid/Framework/DataHandling/src/LoadEventPreNeXus.cpp index 9575b64f59f..8e6da416016 100644 --- a/Code/Mantid/Framework/DataHandling/src/LoadEventPreNeXus.cpp +++ b/Code/Mantid/Framework/DataHandling/src/LoadEventPreNeXus.cpp @@ -9,6 +9,7 @@ #include <vector> #include <boost/timer.hpp> #include "MantidAPI/FileFinder.h" +#include "MantidAPI/LoadAlgorithmFactory.h" #include "MantidDataHandling/LoadEventPreNeXus.h" #include "MantidDataObjects/EventWorkspace.h" #include "MantidDataObjects/EventList.h" @@ -31,6 +32,7 @@ namespace DataHandling { // Register the algorithm into the AlgorithmFactory DECLARE_ALGORITHM(LoadEventPreNeXus) +DECLARE_LOADALGORITHM(LoadEventPreNeXus) using namespace Kernel; using namespace API; @@ -74,7 +76,7 @@ static const double TOF_CONVERSION = .1; /// Conversion factor between picoColumbs and microAmp*hours static const double CURRENT_CONVERSION = 1.e-6 / 3600.; -LoadEventPreNeXus::LoadEventPreNeXus() : Mantid::API::Algorithm() +LoadEventPreNeXus::LoadEventPreNeXus() : Mantid::API::IDataFileChecker() { this->eventfile = NULL; this->max_events = 0; @@ -86,6 +88,50 @@ LoadEventPreNeXus::~LoadEventPreNeXus() delete this->eventfile; } +/** + * Returns the name of the property to be considered as the Filename for Load + * @returns A character string containing the file property's name + */ +const char * LoadEventPreNeXus::filePropertyName() const +{ + return EVENT_PARAM.c_str(); +} + +/** + * Do a quick file type check by looking at the first 100 bytes of the file + * @param filePath :: path of the file including name. + * @param nread :: no.of bytes read + * @param header :: The first 100 bytes of the file as a union + * @return true if the given file is of type which can be loaded by this algorithm + */ +bool LoadEventPreNeXus::quickFileCheck(const std::string& filePath,size_t,const file_header&) +{ + std::string ext = extension(filePath); + return (ext.rfind("dat") != std::string::npos); +} + +/** + * Checks the file by opening it and reading few lines + * @param filePath :: name of the file inluding its path + * @return an integer value how much this algorithm can load the file + */ +int LoadEventPreNeXus::fileCheck(const std::string& filePath) +{ + int confidence(0); + try + { + // If this looks like a binary file where the exact file length is a multiple + // of the DasEvent struct then we're probably okay + BinaryFile<DasEvent> event_file = BinaryFile<DasEvent>(filePath); + confidence = 80; + } + catch(std::runtime_error &) + { + } + return confidence; +} + + //----------------------------------------------------------------------------- /** Initialize the algorithm */ void LoadEventPreNeXus::init() diff --git a/Code/Mantid/Framework/DataHandling/test/LoadTest.h b/Code/Mantid/Framework/DataHandling/test/LoadTest.h index 0ae5598cf6f..e55ba55570b 100644 --- a/Code/Mantid/Framework/DataHandling/test/LoadTest.h +++ b/Code/Mantid/Framework/DataHandling/test/LoadTest.h @@ -7,7 +7,6 @@ #include "MantidAPI/MatrixWorkspace.h" #include "MantidAPI/WorkspaceGroup.h" #include "MantidAPI/AnalysisDataService.h" - #include "MantidAPI/AlgorithmManager.h" using namespace Mantid::API; @@ -251,6 +250,15 @@ public: TS_ASSERT(ws); AnalysisDataService::Instance().remove("LoadTest_Output"); } + + void testEventFileWithNoExecute() + { + Load loader; + loader.initialize(); + TS_ASSERT_THROWS_NOTHING(loader.setPropertyValue("Filename", "CNCS_7860_neutron_event.dat")); + TS_ASSERT_EQUALS(loader.existsProperty("EventFilename"), false); + } + }; #endif /*LOADTEST_H_*/ diff --git a/Code/Mantid/MantidQt/CustomDialogs/inc/MantidQtCustomDialogs/LoadDialog.h b/Code/Mantid/MantidQt/CustomDialogs/inc/MantidQtCustomDialogs/LoadDialog.h index d0fc453b1ea..bfa06cf932d 100644 --- a/Code/Mantid/MantidQt/CustomDialogs/inc/MantidQtCustomDialogs/LoadDialog.h +++ b/Code/Mantid/MantidQt/CustomDialogs/inc/MantidQtCustomDialogs/LoadDialog.h @@ -71,6 +71,13 @@ namespace MantidQt /// Default constructor LoadDialog(QWidget *parent = NULL); + private slots: + /// Create the widgets and layouts that are dynamic, i.e they depend on + /// the specific load algorithm + void createDynamicWidgets(); + /// Override the help button clicked method + void helpClicked(); + private: /// Initialize the layout void initLayout(); @@ -83,17 +90,12 @@ namespace MantidQt void tieStaticWidgets(const bool readHistory); /// Clears all of the widgets from the old layout void setupDynamicLayout(); + /// Create + void createDynamicLayout(); /// Create the widgets for a given property QBoxLayout* createWidgetsForProperty(const Mantid::Kernel::Property* prop, QGridLayout *loaderGrid); - private slots: - /// Create the widgets and layouts that are dynamic, i.e they depend on - /// the specific load algorithm - void createDynamicWidgets(); - /// Override the help button clicked method - void helpClicked(); - private: /// A widget for the filename text input MantidWidgets::MWRunFiles *m_fileWidget; @@ -105,6 +107,8 @@ namespace MantidQt QVBoxLayout *m_dialogLayout; /// The dynamic layout QGridLayout *m_loaderLayout; + /// The current file + QString m_currentFile; }; } diff --git a/Code/Mantid/MantidQt/CustomDialogs/src/LoadDialog.cpp b/Code/Mantid/MantidQt/CustomDialogs/src/LoadDialog.cpp index fbabc3e9b55..0bd44522177 100644 --- a/Code/Mantid/MantidQt/CustomDialogs/src/LoadDialog.cpp +++ b/Code/Mantid/MantidQt/CustomDialogs/src/LoadDialog.cpp @@ -29,13 +29,36 @@ namespace MantidQt /// Default constructor LoadDialog:: LoadDialog(QWidget *parent) : API::AlgorithmDialog(parent), m_fileWidget(NULL), m_wkspaceWidget(NULL), - m_wkspaceLayout(NULL), m_dialogLayout(NULL), m_loaderLayout(NULL) - + m_wkspaceLayout(NULL), m_dialogLayout(NULL), m_loaderLayout(NULL), + m_currentFile() { QSizePolicy sizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum); setSizePolicy(sizePolicy); } + //-------------------------------------------------------------------------- + // Private methods (slot) + //--------------------------------------------------------------------------- + + /** + * Activated when the file has been changed + */ + void LoadDialog::createDynamicWidgets() + { + m_fileWidget->blockSignals(true); + createDynamicLayout(); + m_fileWidget->blockSignals(false); + } + + /// Override the help button clicked method + void LoadDialog::helpClicked() + { + const std::string & loaderName = getAlgorithm()->getPropertyValue("LoaderName"); + QString helpPage = (loaderName.empty()) ? QString("Load") : QString::fromStdString(loaderName); + QDesktopServices::openUrl(QUrl(QString("http://www.mantidproject.org/") + helpPage)); + } + + //-------------------------------------------------------------------------- // Private methods (non-slot) //--------------------------------------------------------------------------- @@ -92,6 +115,7 @@ namespace MantidQt m_fileWidget->allowMultipleFiles(false); m_fileWidget->isOptional(false); m_fileWidget->doMultiEntry(false); + m_fileWidget->setAlgorithmProperty("Load"); // Slight hack to get only the all-files option in browse m_fileWidget->readSettings("Mantid/Algorithms/Load"); QHBoxLayout *propLine = new QHBoxLayout; propLine->addWidget(m_fileWidget); @@ -149,6 +173,52 @@ namespace MantidQt } } + /** + * Create the dynamic widgets for the concrete loader + */ + void LoadDialog::createDynamicLayout() + { + using namespace Mantid::API; + using namespace Mantid::Kernel; + + if( !m_fileWidget->isValid() ) return; + // First step is the get the specific loader that is reponsible + IAlgorithm *loadAlg = getAlgorithm(); + const QString filename = m_fileWidget->getFirstFilename(); + if( filename == m_currentFile ) return; + m_currentFile = filename; + if( m_currentFile.isEmpty() ) return; + try + { + loadAlg->setPropertyValue("Filename", filename.toStdString()); + } + catch(std::exception & exc) + { + m_fileWidget->setFileProblem(QString::fromStdString(exc.what())); + return; + } + // Reset the algorithm pointer so that the base class re-reads the properties and drops links from + // old widgets meaning they are safe to remove + this->setAlgorithm(loadAlg); + + setupDynamicLayout(); + tieStaticWidgets(false); + const std::vector<Property*> & inputProps = loadAlg->getProperties(); + for( size_t i = 0; i < inputProps.size(); ++i ) + { + const Property* prop = inputProps[i]; + const QString propName = QString::fromStdString(prop->name()); + if( propName == "OutputWorkspace" || propName == "Filename" ) continue; + if( requiresUserInput(propName) ) + { + createWidgetsForProperty(prop, m_loaderLayout); + } + } + + // Attempt to set any values that may have been retrieved + setPropertyValues(); + } + /** * Return a layout containing suitable widgets for the given property * @param prop A pointer to the algorithm property @@ -224,61 +294,6 @@ namespace MantidQt return NULL; } - //-------------------------------------------------------------------------- - // Private methods (slot) - //--------------------------------------------------------------------------- - - /** - * Create the widgets and layouts that are dynamic - */ - void LoadDialog::createDynamicWidgets() - { - using namespace Mantid::API; - using namespace Mantid::Kernel; - - if( !m_fileWidget->isValid() ) return; - // First step is the get the specific loader that is reponsible - IAlgorithm *loadAlg = getAlgorithm(); - const std::string filename = m_fileWidget->getFirstFilename().toStdString(); - if( filename.empty() ) return; - try - { - loadAlg->setPropertyValue("Filename", filename); - } - catch(std::exception & exc) - { - m_fileWidget->setFileProblem(QString::fromStdString(exc.what())); - return; - } - // Reset the algorithm pointer so that the base class re-reads the properties and drops links from - // old widgets meaning they are safe to remove - this->setAlgorithm(loadAlg); - - setupDynamicLayout(); - tieStaticWidgets(false); - const std::vector<Property*> & inputProps = loadAlg->getProperties(); - for( size_t i = 0; i < inputProps.size(); ++i ) - { - const Property* prop = inputProps[i]; - const QString propName = QString::fromStdString(prop->name()); - if( propName == "OutputWorkspace" || propName == "Filename" ) continue; - if( requiresUserInput(propName) ) - { - createWidgetsForProperty(prop, m_loaderLayout); - } - } - - // Attempt to set any values that may have been retrieved - setPropertyValues(); - } - - /// Override the help button clicked method - void LoadDialog::helpClicked() - { - const std::string & loaderName = getAlgorithm()->getPropertyValue("LoaderName"); - QString helpPage = (loaderName.empty()) ? QString("Load") : QString::fromStdString(loaderName); - QDesktopServices::openUrl(QUrl(QString("http://www.mantidproject.org/") + helpPage)); - } } } diff --git a/Code/Mantid/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/MWRunFiles.ui b/Code/Mantid/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/MWRunFiles.ui index 9a37da8e458..34fc88d5f19 100644 --- a/Code/Mantid/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/MWRunFiles.ui +++ b/Code/Mantid/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/MWRunFiles.ui @@ -6,8 +6,8 @@ <rect> <x>0</x> <y>0</y> - <width>238</width> - <height>41</height> + <width>334</width> + <height>27</height> </rect> </property> <property name="sizePolicy"> @@ -19,17 +19,21 @@ <property name="windowTitle"> <string>Form</string> </property> - <layout class="QGridLayout" name="gridLayout"> + <layout class="QHBoxLayout" name="horizontalLayout"> <property name="sizeConstraint"> - <enum>QLayout::SetFixedSize</enum> - </property> - <property name="verticalSpacing"> - <number>0</number> + <enum>QLayout::SetDefaultConstraint</enum> </property> <property name="margin"> <number>0</number> </property> - <item row="0" column="1"> + <item> + <widget class="QLabel" name="textLabel"> + <property name="text"> + <string>TextLabel</string> + </property> + </widget> + </item> + <item> <widget class="QLineEdit" name="fileEditor"> <property name="sizePolicy"> <sizepolicy hsizetype="Expanding" vsizetype="Fixed"> @@ -37,23 +41,15 @@ <verstretch>20</verstretch> </sizepolicy> </property> - </widget> - </item> - <item row="0" column="5"> - <widget class="QPushButton" name="browseBtn"> - <property name="text"> - <string>Browse</string> - </property> - </widget> - </item> - <item row="0" column="0"> - <widget class="QLabel" name="textLabel"> - <property name="text"> - <string>TextLabel</string> + <property name="minimumSize"> + <size> + <width>125</width> + <height>0</height> + </size> </property> </widget> </item> - <item row="0" column="3"> + <item> <widget class="QLineEdit" name="entryNum"> <property name="sizePolicy"> <sizepolicy hsizetype="Maximum" vsizetype="Fixed"> @@ -75,7 +71,7 @@ </property> </widget> </item> - <item row="0" column="4"> + <item> <widget class="QLabel" name="valid"> <property name="sizePolicy"> <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> @@ -125,6 +121,13 @@ </property> </widget> </item> + <item> + <widget class="QPushButton" name="browseBtn"> + <property name="text"> + <string>Browse</string> + </property> + </widget> + </item> </layout> </widget> <resources/> diff --git a/Code/Mantid/MantidQt/MantidWidgets/src/MWRunFiles.cpp b/Code/Mantid/MantidQt/MantidWidgets/src/MWRunFiles.cpp index c5dcfa26523..78044979b62 100644 --- a/Code/Mantid/MantidQt/MantidWidgets/src/MWRunFiles.cpp +++ b/Code/Mantid/MantidQt/MantidWidgets/src/MWRunFiles.cpp @@ -408,7 +408,7 @@ QString MWRunFiles::createFileFilter() { fileExts = m_fileExtensions; } - else + else if( isForRunFiles() ) { std::vector<std::string> exts = ConfigService::Instance().Facility().extensions(); for( std::vector<std::string>::iterator ex= exts.begin(); ex != exts.end(); ++ex ) @@ -416,6 +416,7 @@ QString MWRunFiles::createFileFilter() fileExts.append(QString::fromStdString(*ex)); } } + else {} } else { @@ -427,23 +428,23 @@ QString MWRunFiles::createFileFilter() } QString fileFilter; - QStringListIterator itr(fileExts); - if (itr.hasNext()) + if( !fileExts.isEmpty() ) { + QStringListIterator itr(fileExts); fileFilter += "Files ("; while( itr.hasNext() ) { QString ext = itr.next(); - fileFilter += "*" + ext.toLower() + " "; - fileFilter += "*" + ext.toUpper(); + fileFilter += "*" + ext; if( itr.hasNext() ) { - fileFilter += " "; + fileFilter += " "; } } fileFilter += ")"; + fileFilter += ";;"; } - fileFilter += ";;All Files (*.*)"; + fileFilter += "All Files (*.*)"; return fileFilter; } -- GitLab