Mantid
Loading...
Searching...
No Matches
Public Types | Public Slots | Signals | Public Member Functions | Properties | Private Slots | Private Member Functions | Private Attributes | List of all members
MantidQt::API::FileFinderWidget Class Reference

This class defines a widget for file searching. More...

#include <FileFinderWidget.h>

Inheritance diagram for MantidQt::API::FileFinderWidget:
MantidQt::API::MantidWidget

Public Types

enum  { NO_ENTRY_NUM = -1 , ALL_ENTRIES = -2 }
 Flags for workspace entries. More...
 
enum  ButtonOpts { Text , Icon , None }
 options for bringing up the load file dialog More...
 
enum  LiveButtonOpts { Hide , Show }
 Options for the live button. More...
 

Public Slots

void clear ()
 Clear the search from the widget. More...
 
void findFiles ()
 Find the files if the text edit field is modified. More...
 
void findFiles (bool isModified)
 Find the files within the text edit field and cache their full paths. More...
 
void setFileTextWithoutSearch (const QString &text)
 Just update the file text, useful for syncing two boxes. More...
 
void setFileTextWithSearch (const QString &text)
 Set the file text and try and find it. More...
 
std::shared_ptr< const Mantid::API::IAlgorithmstopLiveAlgorithm ()
 Calls cancel on a running instance of MonitorLiveData. More...
 

Signals

void fileEditingFinished ()
 Emitted when the editing has finished. More...
 
void fileFindingFinished ()
 Emitted when file finding is finished (files may or may not have been found). More...
 
void fileInspectionFinished ()
 Emitted when inspection of any found files is completed. More...
 
void filesFound ()
 Emitted when files have been found. More...
 
void filesFoundChanged ()
 Emitted when files have been found that are different to what was found last time. More...
 
void fileTextChanged (const QString &)
 Emitted when the file text changes. More...
 
void findingFiles ()
 Emitted when files finding starts. More...
 
void liveButtonPressed (bool)
 Emitted when the live button is toggled. More...
 
- Signals inherited from MantidQt::API::MantidWidget
void runAsPythonScript (const QString &code, bool)
 

Public Member Functions

bool allowMultipleFiles () const
 Return whether this widget allows multiple files to be specified within the edit box. More...
 
void allowMultipleFiles (bool)
 Set whether this widget allows multiple files to be specifed or not. More...
 
ButtonOpts doButtonOpt () const
 Returns the preference for how the dialog control should be. More...
 
void doButtonOpt (ButtonOpts buttonOpt)
 Set how the browse should appear. More...
 
bool doMultiEntry () const
 Whether to find the number of entries in the file or assume (the normal situation) of one entry. More...
 
void doMultiEntry (bool)
 Set to true to enable the period number box. More...
 
void dragEnterEvent (QDragEnterEvent *) override
 Called when an item is dragged onto a control. More...
 
void dropEvent (QDropEvent *) override
 Called when an item is dropped. More...
 
bool extsAsSingleOption () const
 Returns whether the file dialog should display the exts as a single list or as multiple items. More...
 
void extsAsSingleOption (bool value)
 Sets whether the file dialog should display the exts as a single list or as multiple items. More...
 
 FileFinderWidget (QWidget *parent=nullptr)
 Default constructor. More...
 
QString getAlgorithmProperty () const
 Returns the algorithm name. More...
 
int getEntryNum () const
 The number the user entered into the entryNum lineEdit or NO_ENTRY_NUM on error. More...
 
QStringList getFileExtensions () const
 Returns the list of file extensions the widget will search for. More...
 
QStringList getFilenames () const
 Returns the names of the files found. More...
 
QString getFileProblem ()
 Get file problem, empty string means no error. More...
 
QString getFirstFilename () const
 Safer than using getRunFiles()[0] in the situation were there are no files. More...
 
QString getInstrumentOverride ()
 Gets the instrument currently fixed to. More...
 
QString getLabelText () const
 Return the label text on the widget. More...
 
QString getLastDirectory ()
 Get the last directory. More...
 
std::vector< std::string > getStringFileExtensions () const
 
QString getText () const
 The verbatum, unexpanded text, that was entered into the box. More...
 
QVariant getUserInput () const override
 Overridden from base class to retrieve user input through a common interface. More...
 
bool isEmpty () const
 Check if any text, valid or not, has been entered into the line edit. More...
 
bool isForDirectory () const
 Returns if this widget is for selecting a directory or not. More...
 
void isForDirectory (bool)
 Sets directory searching mode. More...
 
bool isForRunFiles () const
 Returns if this widget is for run file searching or not. More...
 
void isForRunFiles (bool)
 Sets whether this widget is for run file searching or not. More...
 
bool isOptional () const
 Return whether empty input is allowed. More...
 
void isOptional (bool)
 Sets if the text field is optional. More...
 
bool isSearching () const
 Is the widget currently searching. More...
 
bool isValid () const
 Is the input within the widget valid? More...
 
bool liveButtonIsChecked () const
 
void liveButtonSetChecked (bool)
 
LiveButtonOpts liveButtonState () const
 Returns whether the live button is being shown;. More...
 
void liveButtonState (LiveButtonOpts)
 
void readSettings (const QString &group)
 Read settings from the given group. More...
 
void saveSettings (const QString &group)
 Save settings in the given group. More...
 
void setAlgorithmProperty (const QString &name)
 Sets an algorithm name that can be tied to this widget. More...
 
void setEntryNum (const int num)
 Set the entry displayed in the box to this value. More...
 
void setFileExtensions (const QStringList &extensions)
 Sets the list of file extensions the dialog will search for. More...
 
void setFileProblem (const QString &message)
 flag a problem with the file the user entered, an empty string means no error More...
 
void setInstrumentOverride (const QString &instName)
 Overrides the value of default instrument. More...
 
void setLabelMinWidth (int)
 Set the minimum width on the label widget. More...
 
void setLabelText (const QString &text)
 Set the text on the label. More...
 
void setLastDirectory (const QString &lastDir)
 Set the last directory. More...
 
void setLiveAlgorithm (const std::shared_ptr< Mantid::API::IAlgorithm > &monitorLiveData)
 Inform the widget of a running instance of MonitorLiveData to be used in stopLiveListener() More...
 
void setNumberOfEntries (int number)
 Alters the text label that contains the number of entries, normally run when the file is loaded. More...
 
void setProxyModel (QAbstractProxyModel *proxyModel)
 
void setReadOnly (bool readOnly)
 Set the input read-only or not. More...
 
void setText (const QString &value)
 Sets a value on the widget but doesn't emit a signal to say it has changed. More...
 
void setTextValidator (const QValidator *validator)
 Set an arbitrary validator on the line edit. More...
 
void setUseNativeWidget (bool)
 
void setUserInput (const QVariant &value) override
 Sets a value on the widget through a common interface. More...
 
virtual QVariant getUserInput () const
 Returns a QVariant containing what the widget classes as user input so that input can be returned through a common interface. More...
 
virtual void setUserInput (const QVariant &value)
 Sets a value on a mantid widget through a common interface. More...
 

Properties

QString algorithmAndProperty
 
ButtonOpts buttonOpt
 
bool extsAsSingleOption
 
QStringList fileExtensions
 
bool findDirectory
 
bool findRunFiles
 
QString instrumentOverride
 
QString label
 
LiveButtonOpts liveButton
 
bool multiEntry
 
bool multipleFiles
 
bool optional
 

Private Slots

void browseClicked ()
 Browse clicked slot. More...
 
void checkEntry ()
 currently checks only if the entry number is any integer > 0 More...
 
void inspectThreadResult (const FindFilesSearchResults &results=FindFilesSearchResults())
 Slot called when file finding thread has finished. More...
 

Private Member Functions

QString createFileFilter ()
 Create a file filter from a list of extensions. More...
 
FindFilesSearchParameters createFindFilesSearchParameters (const std::string &text) const
 Helper method to create a FindFilesSearchParameters object. More...
 
const QString findFilesGetSearchText (QString &searchText)
 gets text to use for find files search parameters More...
 
QStringList getFileExtensionsFromAlgorithm (const QString &algName, const QString &propName)
 Create an extension list from the name algorithm and property. More...
 
QStringList getFilesFromAlgorithm (const QString &algName, const QString &propName, const QString &filename)
 Create an extension list from the name algorithm and property. More...
 
QString openFileDialog ()
 Open a file dialog. More...
 
void refreshValidator ()
 displays the validator red star if either m_fileProblem or m_entryNumProblem are not empty More...
 
void runFindFiles (const QString &searchText)
 handles findFiles background thread More...
 
void setEntryNumProblem (const QString &message)
 flag a problem with the supplied entry number, an empty string means no error More...
 
void setValidatorDisplay (bool display)
 Turn on/off display of validator red star (default is on) More...
 

Private Attributes

QString m_algorithmProperty
 The algorithm name and property (can be empty) More...
 
bool m_allowMultipleFiles
 Allow multiple files. More...
 
ButtonOpts m_buttonOpt
 To use a browse button or icon or nothing at all. More...
 
FindFilesSearchResults m_cachedResults
 Handle to any results found. More...
 
QString m_defaultInstrumentName
 Cache the default instrument name. More...
 
QFileDialog m_dialog
 non-native QFileDialog More...
 
QString m_entryNumProblem
 If applicable holds any error with the user in entryNum, "" means no error. More...
 
bool m_extsAsSingleOption
 If true the exts are displayed as one option in the dialog. More...
 
QStringList m_fileExtensions
 The file extensions to look for. More...
 
QString m_fileFilter
 A file filter for the file browser. More...
 
QString m_fileProblem
 Holds any error with the user entry for the filename, "" means no error. More...
 
bool m_findRunFiles
 Is the widget for run files or standard files. More...
 
QStringList m_foundFiles
 An array of valid file names derived from the entries in the leNumber LineEdit. More...
 
bool m_isForDirectory
 If the widget is for directories. More...
 
bool m_isOptional
 Whether the widget can be empty. More...
 
QString m_lastDir
 The last directory viewed by the browse dialog. More...
 
QStringList m_lastFoundFiles
 An array of the last valid file names found. More...
 
LiveButtonOpts m_liveButtonState
 If or when live button will be shown. More...
 
std::shared_ptr< Mantid::API::IAlgorithmm_monitorLiveData
 Handle on a running instance of MonitorLiveData. More...
 
bool m_multiEntry
 Whether to allow the user to state an entry number. More...
 
FindFilesThreadPoolManager m_pool
 Handle to a find files thread pool manager. More...
 
bool m_showValidator
 Whether validation red star is being shown. More...
 
Ui::FileFinderWidget m_uiForm
 The Ui form. More...
 
bool m_useNativeDialog
 flag to control use of m_dialog More...
 
QString m_valueForProperty
 Expanded user input. More...
 

Additional Inherited Members

- Protected Member Functions inherited from MantidQt::API::MantidWidget
 MantidWidget (QWidget *parent=nullptr)
 Default constructor. More...
 
QString runPythonCode (const QString &code, bool no_output=false)
 Run python code that is passed to it and, optionally, return anything it wrote to standard output as a string. More...
 

Detailed Description

This class defines a widget for file searching.

It allows either single or multiple files to be specified.

Author
Martyn Gigg, Tessella Support Services plc
Date
24/02/2009

Definition at line 42 of file FileFinderWidget.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum

Flags for workspace entries.

Enumerator
NO_ENTRY_NUM 

error in the entry number setting

ALL_ENTRIES 

use all entries (i.e. entry number was left blank)

Definition at line 68 of file FileFinderWidget.h.

◆ ButtonOpts

options for bringing up the load file dialog

Enumerator
Text 

use a button (normally labelled "Browse")

Icon 

use an icon

None 

disable the load file dialog

Definition at line 62 of file FileFinderWidget.h.

◆ LiveButtonOpts

Options for the live button.

Enumerator
Hide 

Don't use the live button.

Show 

Display the live button.

Definition at line 73 of file FileFinderWidget.h.

Constructor & Destructor Documentation

◆ FileFinderWidget()

FileFinderWidget::FileFinderWidget ( QWidget *  parent = nullptr)

Member Function Documentation

◆ allowMultipleFiles() [1/2]

bool FileFinderWidget::allowMultipleFiles ( ) const

Return whether this widget allows multiple files to be specified within the edit box.

Returns
True if multiple files can be specified, false otherwise

Definition at line 148 of file FileFinderWidget.cpp.

References m_allowMultipleFiles.

◆ allowMultipleFiles() [2/2]

void FileFinderWidget::allowMultipleFiles ( bool  allow)

Set whether this widget allows multiple files to be specifed or not.

Parameters
allow:: If true then the widget will accept multiple files else only a single file may be specified

Definition at line 155 of file FileFinderWidget.cpp.

References findFiles(), and m_allowMultipleFiles.

◆ browseClicked

void FileFinderWidget::browseClicked ( )
privateslot

Browse clicked slot.

This slot opens a file browser.

Definition at line 871 of file FileFinderWidget.cpp.

References fileEditingFinished(), m_uiForm, and openFileDialog().

Referenced by FileFinderWidget().

◆ checkEntry

void FileFinderWidget::checkEntry ( )
privateslot

currently checks only if the entry number is any integer > 0

Currently just checks that entryNum contains an int > 0 and hence might be a valid entry number.

Definition at line 885 of file FileFinderWidget.cpp.

References m_uiForm, and setEntryNumProblem().

Referenced by FileFinderWidget().

◆ clear

void FileFinderWidget::clear ( )
slot

Clear the search from the widget.

Clears the search string and found files from the widget.

Definition at line 491 of file FileFinderWidget.cpp.

References m_foundFiles, and m_uiForm.

Referenced by isForDirectory().

◆ createFileFilter()

QString FileFinderWidget::createFileFilter ( )
private

Create a file filter from a list of extensions.

Set a new file filter for the file dialog based on the given extensions.

Returns
A string containing the file filter

Definition at line 652 of file FileFinderWidget.cpp.

References extsAsSingleOption, getFileExtensionsFromAlgorithm(), Mantid::Kernel::SingletonHolder< T >::Instance(), isForRunFiles(), m_algorithmProperty, and m_fileExtensions.

Referenced by openFileDialog().

◆ createFindFilesSearchParameters()

FindFilesSearchParameters FileFinderWidget::createFindFilesSearchParameters ( const std::string &  text) const
private

◆ doButtonOpt() [1/2]

FileFinderWidget::ButtonOpts FileFinderWidget::doButtonOpt ( ) const

Returns the preference for how the dialog control should be.

Returns
the setting

Definition at line 178 of file FileFinderWidget.cpp.

References m_buttonOpt.

Referenced by FileFinderWidget().

◆ doButtonOpt() [2/2]

void FileFinderWidget::doButtonOpt ( const FileFinderWidget::ButtonOpts  buttonOpt)

Set how the browse should appear.

Parameters
buttonOptthe preference for the control, if there will be one, to activate the dialog box

Definition at line 185 of file FileFinderWidget.cpp.

References buttonOpt, Icon, m_buttonOpt, m_uiForm, None, and Text.

◆ doMultiEntry() [1/2]

bool FileFinderWidget::doMultiEntry ( ) const

Whether to find the number of entries in the file or assume (the normal situation) of one entry.

Returns
true if the widget is to look for multiple entries

Definition at line 204 of file FileFinderWidget.cpp.

References m_multiEntry.

◆ doMultiEntry() [2/2]

void FileFinderWidget::doMultiEntry ( bool  multiEntry)

Set to true to enable the period number box.

Parameters
multiEntrywhether to show the multiperiod box

Definition at line 210 of file FileFinderWidget.cpp.

References m_multiEntry, m_uiForm, multiEntry, and refreshValidator().

◆ dragEnterEvent()

void FileFinderWidget::dragEnterEvent ( QDragEnterEvent *  de)
override

Called when an item is dragged onto a control.

Parameters
de:: the drag event data package

Definition at line 926 of file FileFinderWidget.cpp.

◆ dropEvent()

void FileFinderWidget::dropEvent ( QDropEvent *  de)
override

Called when an item is dropped.

Parameters
de:: the drop event data package

Definition at line 909 of file FileFinderWidget.cpp.

References MantidQt::MantidWidgets::DropEventHelper::getFileNames(), and m_uiForm.

◆ extsAsSingleOption() [1/2]

bool FileFinderWidget::extsAsSingleOption ( ) const

Returns whether the file dialog should display the exts as a single list or as multiple items.

Returns
boolean

Definition at line 263 of file FileFinderWidget.cpp.

References m_extsAsSingleOption.

◆ extsAsSingleOption() [2/2]

void FileFinderWidget::extsAsSingleOption ( bool  value)

Sets whether the file dialog should display the exts as a single list or as multiple items.

Parameters
value:: If true the file dialog wil contain a single entry will all filters

Definition at line 271 of file FileFinderWidget.cpp.

References m_extsAsSingleOption, and value.

◆ fileEditingFinished

void MantidQt::API::FileFinderWidget::fileEditingFinished ( )
signal

Emitted when the editing has finished.

Referenced by browseClicked(), FileFinderWidget(), and setUserInput().

◆ fileFindingFinished

void MantidQt::API::FileFinderWidget::fileFindingFinished ( )
signal

Emitted when file finding is finished (files may or may not have been found).

◆ fileInspectionFinished

void MantidQt::API::FileFinderWidget::fileInspectionFinished ( )
signal

Emitted when inspection of any found files is completed.

Referenced by inspectThreadResult().

◆ filesFound

void MantidQt::API::FileFinderWidget::filesFound ( )
signal

Emitted when files have been found.

Referenced by inspectThreadResult().

◆ filesFoundChanged

void MantidQt::API::FileFinderWidget::filesFoundChanged ( )
signal

Emitted when files have been found that are different to what was found last time.

Referenced by inspectThreadResult().

◆ fileTextChanged

void MantidQt::API::FileFinderWidget::fileTextChanged ( const QString &  )
signal

Emitted when the file text changes.

Referenced by FileFinderWidget().

◆ findFiles [1/2]

void FileFinderWidget::findFiles ( )
slot

Find the files if the text edit field is modified.

Finds the files if the user has changed the parameter text.

Definition at line 499 of file FileFinderWidget.cpp.

References findFiles(), and m_uiForm.

Referenced by allowMultipleFiles(), FileFinderWidget(), findFiles(), isOptional(), setFileTextWithSearch(), and setInstrumentOverride().

◆ findFiles [2/2]

void FileFinderWidget::findFiles ( bool  isModified)
slot

Find the files within the text edit field and cache their full paths.

Finds the files specified by the user in a background thread.

Definition at line 504 of file FileFinderWidget.cpp.

References findFilesGetSearchText(), inspectThreadResult(), m_cachedResults, m_foundFiles, m_isForDirectory, m_uiForm, runFindFiles(), and setFileProblem().

◆ findFilesGetSearchText()

const QString FileFinderWidget::findFilesGetSearchText ( QString &  searchText)
private

gets text to use for find files search parameters

Gets the search text to find files with.

Parameters
searchText:: text entered by user
Returns
search text to create search params with

Definition at line 533 of file FileFinderWidget.cpp.

References m_defaultInstrumentName.

Referenced by findFiles().

◆ findingFiles

void MantidQt::API::FileFinderWidget::findingFiles ( )
signal

Emitted when files finding starts.

Referenced by runFindFiles().

◆ getAlgorithmProperty()

QString FileFinderWidget::getAlgorithmProperty ( ) const

Returns the algorithm name.

Returns
The algorithm name

Definition at line 226 of file FileFinderWidget.cpp.

References m_algorithmProperty.

◆ getEntryNum()

int FileFinderWidget::getEntryNum ( ) const

The number the user entered into the entryNum lineEdit or NO_ENTRY_NUM on error.

Checking if isValid is true should eliminate the possiblity of getting NO_ENTRY_NUM

Definition at line 335 of file FileFinderWidget.cpp.

References ALL_ENTRIES, isValid(), m_multiEntry, m_uiForm, and NO_ENTRY_NUM.

◆ getFileExtensions()

QStringList FileFinderWidget::getFileExtensions ( ) const

Returns the list of file extensions the widget will search for.

Returns
list of file extensions

Definition at line 238 of file FileFinderWidget.cpp.

References m_fileExtensions.

◆ getFileExtensionsFromAlgorithm()

QStringList FileFinderWidget::getFileExtensionsFromAlgorithm ( const QString &  algName,
const QString &  propName 
)
private

Create an extension list from the name algorithm and property.

Create a list of file extensions from the given algorithm.

Parameters
algName:: The name of the algorithm
propName:: The name of the property
Returns
A list of file extensions

Definition at line 735 of file FileFinderWidget.cpp.

References Mantid::Kernel::PropertyWithValue< TYPE >::allowedValues(), Mantid::API::FileProperty::getDefaultExt(), index, and Mantid::Kernel::SingletonHolder< T >::Instance().

Referenced by createFileFilter().

◆ getFilenames()

QStringList FileFinderWidget::getFilenames ( ) const

Returns the names of the files found.

Returns
an array of filenames entered in the box

Definition at line 305 of file FileFinderWidget.cpp.

References m_foundFiles.

◆ getFileProblem()

QString FileFinderWidget::getFileProblem ( )

Get file problem, empty string means no error.

Return the error.

Returns
A string explaining the error.

Definition at line 405 of file FileFinderWidget.cpp.

References m_fileProblem.

Referenced by MantidQt::CustomInterfaces::UserInputValidator::checkFileFinderWidgetIsValid().

◆ getFilesFromAlgorithm()

QStringList MantidQt::API::FileFinderWidget::getFilesFromAlgorithm ( const QString &  algName,
const QString &  propName,
const QString &  filename 
)
private

Create an extension list from the name algorithm and property.

◆ getFirstFilename()

QString FileFinderWidget::getFirstFilename ( ) const

Safer than using getRunFiles()[0] in the situation were there are no files.

Returns
an empty string is returned if no input files have been defined or one of the files can't be found, otherwise it's the name of the first input file
Exceptions
invalid_argumentif one of the files couldn't be found it then no filenames are returned

Definition at line 314 of file FileFinderWidget.cpp.

References m_foundFiles.

◆ getInstrumentOverride()

QString FileFinderWidget::getInstrumentOverride ( )

Gets the instrument currently fixed to.

Gets the instrument currently set by the override property.

If no override is set then the instrument set by default instrument configurtion option will be used and this function returns an empty string.

Returns
Name of instrument, empty if not set

Definition at line 448 of file FileFinderWidget.cpp.

References m_defaultInstrumentName.

◆ getLabelText()

QString FileFinderWidget::getLabelText ( ) const

Return the label text on the widget.

Returns
The current value of the text on the label

Definition at line 127 of file FileFinderWidget.cpp.

References m_uiForm.

◆ getLastDirectory()

QString MantidQt::API::FileFinderWidget::getLastDirectory ( )
inline

Get the last directory.

Definition at line 148 of file FileFinderWidget.h.

◆ getStringFileExtensions()

std::vector< std::string > FileFinderWidget::getStringFileExtensions ( ) const

Definition at line 240 of file FileFinderWidget.cpp.

References m_fileExtensions.

Referenced by createFindFilesSearchParameters().

◆ getText()

QString FileFinderWidget::getText ( ) const

The verbatum, unexpanded text, that was entered into the box.

Returns
the contents shown in the Line Edit

Definition at line 329 of file FileFinderWidget.cpp.

References m_uiForm.

Referenced by openFileDialog().

◆ getUserInput()

QVariant FileFinderWidget::getUserInput ( ) const
overridevirtual

Overridden from base class to retrieve user input through a common interface.

Retrieve user input from this widget.

This expands the current file text to include the found absolute paths so that no more searching is required NOTE: This knows nothing of periods yet

Returns
A QVariant containing the text string for the algorithm property

Reimplemented from MantidQt::API::MantidWidget.

Definition at line 361 of file FileFinderWidget.cpp.

References m_valueForProperty.

◆ inspectThreadResult

void FileFinderWidget::inspectThreadResult ( const FindFilesSearchResults results = FindFilesSearchResults())
privateslot

Slot called when file finding thread has finished.

Called when the file finding thread finishes.

Inspects the result of the thread, and emits fileFound() if it has been successful.

Definition at line 594 of file FileFinderWidget.cpp.

References MantidQt::API::FindFilesSearchResults::error, fileInspectionFinished(), MantidQt::API::FindFilesSearchResults::filenames, filesFound(), filesFoundChanged(), isOptional(), m_cachedResults, m_foundFiles, m_lastFoundFiles, m_valueForProperty, setFileProblem(), and MantidQt::API::FindFilesSearchResults::valueForProperty.

Referenced by findFiles().

◆ isEmpty()

bool FileFinderWidget::isEmpty ( ) const

Check if any text, valid or not, has been entered into the line edit.

Returns
true if no text has been entered

Definition at line 324 of file FileFinderWidget.cpp.

References m_uiForm.

◆ isForDirectory() [1/2]

bool FileFinderWidget::isForDirectory ( ) const

Returns if this widget is for selecting a directory or not.

Returns
True if selecting a directory

Definition at line 112 of file FileFinderWidget.cpp.

References m_isForDirectory.

◆ isForDirectory() [2/2]

void FileFinderWidget::isForDirectory ( bool  mode)

Sets directory searching mode.

Parameters
modeTrue to search for directories only

Definition at line 118 of file FileFinderWidget.cpp.

References clear(), and m_isForDirectory.

◆ isForRunFiles() [1/2]

bool FileFinderWidget::isForRunFiles ( ) const

Returns if this widget is for run file searching or not.

Returns
True if this widget searches for run files, false otherwise

Definition at line 100 of file FileFinderWidget.cpp.

References m_findRunFiles.

Referenced by createFileFilter(), and createFindFilesSearchParameters().

◆ isForRunFiles() [2/2]

void FileFinderWidget::isForRunFiles ( bool  mode)

Sets whether this widget is for run file searching or not.

Parameters
mode:: True if this widget searches for run files, false otherwise

Definition at line 106 of file FileFinderWidget.cpp.

References m_findRunFiles.

◆ isOptional() [1/2]

bool FileFinderWidget::isOptional ( ) const

Return whether empty input is allowed.

Definition at line 163 of file FileFinderWidget.cpp.

References m_isOptional.

Referenced by createFindFilesSearchParameters(), and inspectThreadResult().

◆ isOptional() [2/2]

void FileFinderWidget::isOptional ( bool  optional)

Sets if the text field is optional.

Parameters
optional:: Set the optional status of the text field

Definition at line 169 of file FileFinderWidget.cpp.

References findFiles(), m_isOptional, and optional.

◆ isSearching()

bool FileFinderWidget::isSearching ( ) const

Is the widget currently searching.

Returns
True if a search is inprogress

Definition at line 299 of file FileFinderWidget.cpp.

References MantidQt::API::FindFilesThreadPoolManager::isSearchRunning(), and m_pool.

◆ isValid()

bool FileFinderWidget::isValid ( ) const

Is the input within the widget valid?

Returns
True of the file names within the widget are valid, false otherwise

Definition at line 293 of file FileFinderWidget.cpp.

References m_uiForm.

Referenced by MantidQt::CustomInterfaces::UserInputValidator::checkFileFinderWidgetIsValid(), and getEntryNum().

◆ liveButtonIsChecked()

bool FileFinderWidget::liveButtonIsChecked ( ) const

Definition at line 287 of file FileFinderWidget.cpp.

References m_uiForm.

◆ liveButtonPressed

void MantidQt::API::FileFinderWidget::liveButtonPressed ( bool  )
signal

Emitted when the live button is toggled.

Referenced by FileFinderWidget().

◆ liveButtonSetChecked()

void FileFinderWidget::liveButtonSetChecked ( bool  checked)

Definition at line 285 of file FileFinderWidget.cpp.

References m_uiForm.

◆ liveButtonState() [1/2]

FileFinderWidget::LiveButtonOpts FileFinderWidget::liveButtonState ( ) const

Returns whether the live button is being shown;.

Definition at line 274 of file FileFinderWidget.cpp.

References m_liveButtonState.

Referenced by FileFinderWidget().

◆ liveButtonState() [2/2]

void FileFinderWidget::liveButtonState ( LiveButtonOpts  option)

Definition at line 276 of file FileFinderWidget.cpp.

References Hide, m_liveButtonState, m_uiForm, and Show.

◆ openFileDialog()

QString FileFinderWidget::openFileDialog ( )
private

Open a file dialog.

Lauches a load file browser allowing a user to select multiple files.

Returns
the names of the selected files as a comma separated list

Definition at line 779 of file FileFinderWidget.cpp.

References createFileFilter(), getText(), m_allowMultipleFiles, m_dialog, m_fileFilter, m_isForDirectory, m_lastDir, and m_useNativeDialog.

Referenced by browseClicked().

◆ readSettings()

void FileFinderWidget::readSettings ( const QString &  group)

Read settings from the given group.

Parameters
group:: The name of the group key to retrieve data from

Definition at line 632 of file FileFinderWidget.cpp.

References Mantid::Kernel::SingletonHolder< T >::Instance(), and m_lastDir.

◆ refreshValidator()

void FileFinderWidget::refreshValidator ( )
private

displays the validator red star if either m_fileProblem or m_entryNumProblem are not empty

Checks the data m_fileProblem and m_entryNumProblem to see if the validator label needs to be displayed.

Validator always hidden if m_showValidator set false.

Definition at line 853 of file FileFinderWidget.cpp.

References m_entryNumProblem, m_fileProblem, m_multiEntry, m_showValidator, and m_uiForm.

Referenced by doMultiEntry(), setEntryNumProblem(), setFileProblem(), and setReadOnly().

◆ runFindFiles()

void FileFinderWidget::runFindFiles ( const QString &  searchText)
private

handles findFiles background thread

creates background thread for find files

Parameters
searchText:: text to create search parameters from

Definition at line 568 of file FileFinderWidget.cpp.

References createFindFilesSearchParameters(), MantidQt::API::FindFilesThreadPoolManager::createWorker(), findingFiles(), and m_pool.

Referenced by findFiles().

◆ saveSettings()

void FileFinderWidget::saveSettings ( const QString &  group)

Save settings in the given group.

Save settings to the given group.

Parameters
group:: The name of the group key to save to

Definition at line 411 of file FileFinderWidget.cpp.

References m_lastDir.

◆ setAlgorithmProperty()

void FileFinderWidget::setAlgorithmProperty ( const QString &  text)

Sets an algorithm name that can be tied to this widget.

Parameters
text:: The name of the algorithm and property in the form [AlgorithmName|PropertyName]

Definition at line 233 of file FileFinderWidget.cpp.

References m_algorithmProperty.

◆ setEntryNum()

void FileFinderWidget::setEntryNum ( const int  num)

Set the entry displayed in the box to this value.

Parameters
numthe period number to use

Definition at line 352 of file FileFinderWidget.cpp.

References m_uiForm.

◆ setEntryNumProblem()

void FileFinderWidget::setEntryNumProblem ( const QString &  message)
private

flag a problem with the supplied entry number, an empty string means no error

flag a problem with the supplied entry number, an empty string means no error.

file errors take precedence of these errors

Parameters
messagethe message to display

Definition at line 844 of file FileFinderWidget.cpp.

References m_entryNumProblem, and refreshValidator().

Referenced by checkEntry().

◆ setFileExtensions()

void FileFinderWidget::setFileExtensions ( const QStringList &  extensions)

Sets the list of file extensions the dialog will search for.

Only taken notice of if AlgorithmProperty not set.

Parameters
extensions:: list of file extensions

Definition at line 253 of file FileFinderWidget.cpp.

References m_fileExtensions, and m_fileFilter.

◆ setFileProblem()

void FileFinderWidget::setFileProblem ( const QString &  message)

flag a problem with the file the user entered, an empty string means no error

Flag a problem with the file the user entered, an empty string means no error but there may be an error with the entry box if enabled.

Errors passed here are shown first

Parameters
message:: A message to include or "" for no error

Definition at line 396 of file FileFinderWidget.cpp.

References m_fileProblem, and refreshValidator().

Referenced by findFiles(), and inspectThreadResult().

◆ setFileTextWithoutSearch

void FileFinderWidget::setFileTextWithoutSearch ( const QString &  text)
slot

Just update the file text, useful for syncing two boxes.

Set the file text but do not search.

Parameters
text:: The text string to set

Definition at line 483 of file FileFinderWidget.cpp.

References m_uiForm.

Referenced by setFileTextWithSearch().

◆ setFileTextWithSearch

void FileFinderWidget::setFileTextWithSearch ( const QString &  text)
slot

Set the file text and try and find it.

Set the file text.

This is different to setText in that it emits findFiles, as well changing the state of the text box widget to "modified = true" which is a prerequisite of findFiles.

Parameters
text:: The text string to set

Definition at line 475 of file FileFinderWidget.cpp.

References findFiles(), and setFileTextWithoutSearch().

◆ setInstrumentOverride()

void FileFinderWidget::setInstrumentOverride ( const QString &  instName)

Overrides the value of default instrument.

Sets an instrument to fix the widget to.

If an instrument name is geven then the widget will only look for files for that instrument, providing na empty string will remove this restriction and will search using the default instrument.

Parameters
instNameName of instrument, empty to disable override

Definition at line 461 of file FileFinderWidget.cpp.

References findFiles(), and m_defaultInstrumentName.

◆ setLabelMinWidth()

void FileFinderWidget::setLabelMinWidth ( int  width)

Set the minimum width on the label widget.

Parameters
widthThe new minimum width of the widget

Definition at line 141 of file FileFinderWidget.cpp.

References m_uiForm.

◆ setLabelText()

void FileFinderWidget::setLabelText ( const QString &  text)

Set the text on the label.

Parameters
text:: A string giving the label to use for the text

Definition at line 133 of file FileFinderWidget.cpp.

References m_uiForm.

◆ setLastDirectory()

void MantidQt::API::FileFinderWidget::setLastDirectory ( const QString &  lastDir)
inline

Set the last directory.

Definition at line 150 of file FileFinderWidget.h.

◆ setLiveAlgorithm()

void FileFinderWidget::setLiveAlgorithm ( const std::shared_ptr< Mantid::API::IAlgorithm > &  monitorLiveData)

Inform the widget of a running instance of MonitorLiveData to be used in stopLiveListener()

Inform the widget of a running instance of MonitorLiveData to be used in stopLiveListener().

Note that the type passed in is IAlgorithm and that no check is made that it actually refers to an instance of MonitorLiveData.

Parameters
monitorLiveDataThe running algorithm

Definition at line 437 of file FileFinderWidget.cpp.

References m_monitorLiveData.

◆ setNumberOfEntries()

void FileFinderWidget::setNumberOfEntries ( int  number)

Alters the text label that contains the number of entries, normally run when the file is loaded.

Writes the total number of periods in a file to the NumEntries Qlabel.

Parameters
numberthe number to write, if this is < 1 a ? will be displayed in it's place

Definition at line 425 of file FileFinderWidget.cpp.

References m_uiForm.

◆ setProxyModel()

void FileFinderWidget::setProxyModel ( QAbstractProxyModel *  proxyModel)

Definition at line 990 of file FileFinderWidget.cpp.

References m_dialog.

◆ setReadOnly()

void FileFinderWidget::setReadOnly ( bool  readOnly)

Set the input read-only or not.

Sets the text read-only or editable and the Browse button disabled or enabled.

If read-only, disable the red asterisk validator.

Parameters
readOnly:: [input] whether read-only or editable

Definition at line 950 of file FileFinderWidget.cpp.

References m_uiForm, refreshValidator(), and setValidatorDisplay().

◆ setText()

void FileFinderWidget::setText ( const QString &  value)

Sets a value on the widget but doesn't emit a signal to say it has changed.

"Silently" sets the value of the widget.

It does NOT emit a signal to say it has changed, and as far as the file finding routine is concerned it has not been modified and so it will NOT go searching for files.

Parameters
valueA QString containing text to be entered into the widget

Definition at line 371 of file FileFinderWidget.cpp.

References m_uiForm, and value.

◆ setTextValidator()

void FileFinderWidget::setTextValidator ( const QValidator *  validator)

Set an arbitrary validator on the line edit.

Definition at line 982 of file FileFinderWidget.cpp.

References m_uiForm.

◆ setUseNativeWidget()

void FileFinderWidget::setUseNativeWidget ( bool  native)

Definition at line 984 of file FileFinderWidget.cpp.

References m_dialog, and m_useNativeDialog.

◆ setUserInput()

void FileFinderWidget::setUserInput ( const QVariant &  value)
overridevirtual

Sets a value on the widget through a common interface.

The QVariant is assumed to be text and to contain a file string. Note that this is primarily here for use within the AlgorithmDialog.

Emits fileEditingFinished(), and changes to state of the text box widget to be "modified", so that the file finder will try and find the file(s).

Parameters
valueA QVariant containing user text

Reimplemented from MantidQt::API::MantidWidget.

Definition at line 383 of file FileFinderWidget.cpp.

References fileEditingFinished(), m_uiForm, and value.

◆ setValidatorDisplay()

void FileFinderWidget::setValidatorDisplay ( bool  display)
private

Turn on/off display of validator red star (default is on)

Turn on/off the display of the red validator star.

Validation is still performed, this just controls the display of the result.

Parameters
display:: [input] whether to show validator result or not

Definition at line 963 of file FileFinderWidget.cpp.

References m_showValidator.

Referenced by setReadOnly().

◆ stopLiveAlgorithm

IAlgorithm_const_sptr FileFinderWidget::stopLiveAlgorithm ( )
slot

Calls cancel on a running instance of MonitorLiveData.

Requires that a handle to the MonitorLiveData instance has been set via setLiveListener()

Returns
A handle to the cancelled algorithm (usable if the method is called directly)

Definition at line 581 of file FileFinderWidget.cpp.

References m_monitorLiveData.

Member Data Documentation

◆ m_algorithmProperty

QString MantidQt::API::FileFinderWidget::m_algorithmProperty
private

The algorithm name and property (can be empty)

Definition at line 245 of file FileFinderWidget.h.

Referenced by createFileFilter(), createFindFilesSearchParameters(), getAlgorithmProperty(), and setAlgorithmProperty().

◆ m_allowMultipleFiles

bool MantidQt::API::FileFinderWidget::m_allowMultipleFiles
private

Allow multiple files.

Definition at line 233 of file FileFinderWidget.h.

Referenced by allowMultipleFiles(), and openFileDialog().

◆ m_buttonOpt

ButtonOpts MantidQt::API::FileFinderWidget::m_buttonOpt
private

To use a browse button or icon or nothing at all.

Definition at line 239 of file FileFinderWidget.h.

Referenced by doButtonOpt(), and FileFinderWidget().

◆ m_cachedResults

FindFilesSearchResults MantidQt::API::FileFinderWidget::m_cachedResults
private

Handle to any results found.

Definition at line 274 of file FileFinderWidget.h.

Referenced by findFiles(), and inspectThreadResult().

◆ m_defaultInstrumentName

QString MantidQt::API::FileFinderWidget::m_defaultInstrumentName
private

Cache the default instrument name.

Definition at line 268 of file FileFinderWidget.h.

Referenced by findFilesGetSearchText(), getInstrumentOverride(), and setInstrumentOverride().

◆ m_dialog

QFileDialog MantidQt::API::FileFinderWidget::m_dialog
private

non-native QFileDialog

Definition at line 276 of file FileFinderWidget.h.

Referenced by openFileDialog(), setProxyModel(), and setUseNativeWidget().

◆ m_entryNumProblem

QString MantidQt::API::FileFinderWidget::m_entryNumProblem
private

If applicable holds any error with the user in entryNum, "" means no error.

Definition at line 243 of file FileFinderWidget.h.

Referenced by refreshValidator(), and setEntryNumProblem().

◆ m_extsAsSingleOption

bool MantidQt::API::FileFinderWidget::m_extsAsSingleOption
private

If true the exts are displayed as one option in the dialog.

Definition at line 249 of file FileFinderWidget.h.

Referenced by extsAsSingleOption().

◆ m_fileExtensions

QStringList MantidQt::API::FileFinderWidget::m_fileExtensions
private

The file extensions to look for.

Definition at line 247 of file FileFinderWidget.h.

Referenced by createFileFilter(), getFileExtensions(), getStringFileExtensions(), and setFileExtensions().

◆ m_fileFilter

QString MantidQt::API::FileFinderWidget::m_fileFilter
private

A file filter for the file browser.

Definition at line 266 of file FileFinderWidget.h.

Referenced by openFileDialog(), and setFileExtensions().

◆ m_fileProblem

QString MantidQt::API::FileFinderWidget::m_fileProblem
private

Holds any error with the user entry for the filename, "" means no error.

Definition at line 241 of file FileFinderWidget.h.

Referenced by getFileProblem(), refreshValidator(), and setFileProblem().

◆ m_findRunFiles

bool MantidQt::API::FileFinderWidget::m_findRunFiles
private

Is the widget for run files or standard files.

Definition at line 229 of file FileFinderWidget.h.

Referenced by isForRunFiles().

◆ m_foundFiles

QStringList MantidQt::API::FileFinderWidget::m_foundFiles
private

An array of valid file names derived from the entries in the leNumber LineEdit.

Definition at line 260 of file FileFinderWidget.h.

Referenced by clear(), findFiles(), getFilenames(), getFirstFilename(), and inspectThreadResult().

◆ m_isForDirectory

bool MantidQt::API::FileFinderWidget::m_isForDirectory
private

If the widget is for directories.

Definition at line 231 of file FileFinderWidget.h.

Referenced by findFiles(), isForDirectory(), and openFileDialog().

◆ m_isOptional

bool MantidQt::API::FileFinderWidget::m_isOptional
private

Whether the widget can be empty.

Definition at line 235 of file FileFinderWidget.h.

Referenced by isOptional().

◆ m_lastDir

QString MantidQt::API::FileFinderWidget::m_lastDir
private

The last directory viewed by the browse dialog.

Definition at line 264 of file FileFinderWidget.h.

Referenced by FileFinderWidget(), openFileDialog(), readSettings(), and saveSettings().

◆ m_lastFoundFiles

QStringList MantidQt::API::FileFinderWidget::m_lastFoundFiles
private

An array of the last valid file names found.

Definition at line 262 of file FileFinderWidget.h.

Referenced by inspectThreadResult().

◆ m_liveButtonState

LiveButtonOpts MantidQt::API::FileFinderWidget::m_liveButtonState
private

If or when live button will be shown.

Definition at line 251 of file FileFinderWidget.h.

Referenced by FileFinderWidget(), and liveButtonState().

◆ m_monitorLiveData

std::shared_ptr<Mantid::API::IAlgorithm> MantidQt::API::FileFinderWidget::m_monitorLiveData
private

Handle on a running instance of MonitorLiveData.

Definition at line 253 of file FileFinderWidget.h.

Referenced by setLiveAlgorithm(), and stopLiveAlgorithm().

◆ m_multiEntry

bool MantidQt::API::FileFinderWidget::m_multiEntry
private

Whether to allow the user to state an entry number.

Definition at line 237 of file FileFinderWidget.h.

Referenced by doMultiEntry(), FileFinderWidget(), getEntryNum(), and refreshValidator().

◆ m_pool

FindFilesThreadPoolManager MantidQt::API::FileFinderWidget::m_pool
private

Handle to a find files thread pool manager.

Definition at line 272 of file FileFinderWidget.h.

Referenced by isSearching(), and runFindFiles().

◆ m_showValidator

bool MantidQt::API::FileFinderWidget::m_showValidator
private

Whether validation red star is being shown.

Definition at line 255 of file FileFinderWidget.h.

Referenced by refreshValidator(), and setValidatorDisplay().

◆ m_uiForm

Ui::FileFinderWidget MantidQt::API::FileFinderWidget::m_uiForm
private

◆ m_useNativeDialog

bool MantidQt::API::FileFinderWidget::m_useNativeDialog
private

flag to control use of m_dialog

Definition at line 278 of file FileFinderWidget.h.

Referenced by openFileDialog(), and setUseNativeWidget().

◆ m_valueForProperty

QString MantidQt::API::FileFinderWidget::m_valueForProperty
private

Expanded user input.

Definition at line 270 of file FileFinderWidget.h.

Referenced by getUserInput(), and inspectThreadResult().

Property Documentation

◆ algorithmAndProperty

QString MantidQt::API::FileFinderWidget::algorithmAndProperty
readwrite

Definition at line 42 of file FileFinderWidget.h.

◆ buttonOpt

ButtonOpts MantidQt::API::FileFinderWidget::buttonOpt
readwrite

Definition at line 42 of file FileFinderWidget.h.

Referenced by doButtonOpt().

◆ extsAsSingleOption

bool MantidQt::API::FileFinderWidget::extsAsSingleOption
readwrite

Definition at line 42 of file FileFinderWidget.h.

Referenced by createFileFilter().

◆ fileExtensions

QStringList MantidQt::API::FileFinderWidget::fileExtensions
readwrite

Definition at line 42 of file FileFinderWidget.h.

◆ findDirectory

bool MantidQt::API::FileFinderWidget::findDirectory
readwrite

Definition at line 42 of file FileFinderWidget.h.

◆ findRunFiles

bool MantidQt::API::FileFinderWidget::findRunFiles
readwrite

Definition at line 42 of file FileFinderWidget.h.

◆ instrumentOverride

QString MantidQt::API::FileFinderWidget::instrumentOverride
readwrite

Definition at line 42 of file FileFinderWidget.h.

◆ label

QString MantidQt::API::FileFinderWidget::label
readwrite

Definition at line 42 of file FileFinderWidget.h.

◆ liveButton

LiveButtonOpts MantidQt::API::FileFinderWidget::liveButton
readwrite

Definition at line 42 of file FileFinderWidget.h.

◆ multiEntry

bool MantidQt::API::FileFinderWidget::multiEntry
readwrite

Definition at line 42 of file FileFinderWidget.h.

Referenced by doMultiEntry().

◆ multipleFiles

bool MantidQt::API::FileFinderWidget::multipleFiles
readwrite

Definition at line 42 of file FileFinderWidget.h.

◆ optional

bool MantidQt::API::FileFinderWidget::optional
readwrite

Definition at line 42 of file FileFinderWidget.h.

Referenced by isOptional().


The documentation for this class was generated from the following files: