Mantid
Loading...
Searching...
No Matches
Public Slots | Signals | Public Member Functions | Static Public Member Functions | Private Types | Private Slots | Private Member Functions | Private Attributes | List of all members
MantidQt::MantidWidgets::SaveWorkspaces Class Reference

Implements a dialog box that allows users to save multiple Mantid workspaces. More...

#include <SaveWorkspaces.h>

Inheritance diagram for MantidQt::MantidWidgets::SaveWorkspaces:
MantidQt::API::MantidDialog

Public Slots

void onSaveAsZeroErrorFreeChanged (int state)
 Reacts to a user change wether the workspace is to be saved as zero-error-free or not. More...
 
void onUpdateGeomtryInformation (QString &geometryID, QString &sampleHeight, QString &sampleWidth, QString &sampleThickness)
 Recieves an update for the geometry information. More...
 

Signals

void closing ()
 
void createZeroErrorFreeWorkspace (QString &originalWorkspace, QString &zeroFreeWorkspace)
 
void deleteZeroErrorFreeWorkspace (QString &zeroFreeWorkspace)
 
void updateGeometryInformation ()
 
- Signals inherited from MantidQt::API::MantidDialog
void runAsPythonScript (const QString &code, bool)
 

Public Member Functions

void initLayout ()
 Set up the dialog layout. More...
 
 SaveWorkspaces (QWidget *parent, const QString &suggFname, QHash< const QCheckBox *const, QString > &defSavs, bool saveAsZeroErrorFree)
 
- Public Member Functions inherited from MantidQt::API::MantidDialog
 MantidDialog (QWidget *parent=nullptr, const Qt::WindowFlags &flags=Qt::WindowCloseButtonHint|Qt::WindowType::WindowTitleHint)
 DefaultConstructor. More...
 
 ~MantidDialog () override
 Destructor. More...
 

Static Public Member Functions

static QString getSaveAlgExt (const QString &algName)
 Returns the save extension expected the name algorithm. More...
 
- Static Public Member Functions inherited from MantidQt::API::MantidDialog
static bool handle (QObject *receiver, const std::exception &e)
 Handles the exception caught in an event handler. More...
 

Private Types

using SavFormatsConstIt = QHash< QCheckBox *const, QString >::const_iterator
 

Private Slots

void saveFileBrowse ()
 Raises a browse dialog and inserts the selected file into the save text edit box, outfile_edit. More...
 
void saveSel ()
 Excutes the selected save algorithms on the workspaces that have been selected to be saved. More...
 
void setFileName (int row)
 Sets the filename to the name of the selected workspace. More...
 

Private Member Functions

void addButtonsDisab (int row)
 
void closeEvent (QCloseEvent *event) override
 Called in response to a close event. More...
 
bool isValid ()
 Checks if the save option selection is compatible with the dimensionality selection. More...
 
QHash< QString, QString > provideZeroFreeWorkspaces (const QListWidget *workspaces)
 Goes through all selected workspaces and maps them to a zero-error free clone, if the user has selected to do this otherwise the value of the hash is set to the same as the key. More...
 
void readSettings ()
 Sets up some controls from what is in the QSettings. More...
 
void removeZeroFreeWorkspaces (const QHash< QString, QString > &workspaces)
 Remove all the zero-error free workspaces. More...
 
QString saveList (const QList< QListWidgetItem * > &list, const QString &algorithm, QString fileBase, bool toAppend, QHash< QString, QString > workspaceMap)
 
void saveSettings () const
 Saves the state of some controls to the QSettings. More...
 
void setFileName (const QString &newName)
 Set the name of the output file. More...
 
void setupFormatTicks (const QHash< const QCheckBox *const, QString > &defSavs)
 For each save format tick box take the user setting from the main form. More...
 
void setupLine1 (QHBoxLayout *const lineOne)
 Puts the controls that go on the first line, the output filename commands, on to the layout that's passed to it. More...
 
void setupLine2 (QHBoxLayout *const lineTwo, const QHash< const QCheckBox *const, QString > &defSavs)
 Puts the controls that go on the second line, the workspace list and save commands, on to the layout that's passed to it. More...
 

Private Attributes

QCheckBox * m_append
 
QLineEdit * m_fNameEdit
 
QString m_geometryID
 
QString m_lastName
 
QString m_sampleHeight
 
QString m_sampleThickness
 
QString m_sampleWidth
 
bool m_saveAsZeroErrorFree
 
QHash< QCheckBox *const, QString > m_savFormats
 
QListWidget * m_workspaces
 

Additional Inherited Members

- Protected Member Functions inherited from MantidQt::API::MantidDialog
virtual void handleException (const std::exception &e)
 Override this method to handle an exception in a derived class. 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

Implements a dialog box that allows users to save multiple Mantid workspaces.

Author
Steve Williams

Definition at line 26 of file SaveWorkspaces.h.

Member Typedef Documentation

◆ SavFormatsConstIt

using MantidQt::MantidWidgets::SaveWorkspaces::SavFormatsConstIt = QHash<QCheckBox *const, QString>::const_iterator
private

Definition at line 58 of file SaveWorkspaces.h.

Constructor & Destructor Documentation

◆ SaveWorkspaces()

SaveWorkspaces::SaveWorkspaces ( QWidget *  parent,
const QString &  suggFname,
QHash< const QCheckBox *const, QString > &  defSavs,
bool  saveAsZeroErrorFree 
)
Parameters
parent:: used by QT
suggFname:: sets the initial entry in the filename box
defSavs:: sets which boxes are ticked
saveAsZeroErrorFree:: if the workspace should be saved with the zero errors replaced by a default value or not

Definition at line 61 of file SaveWorkspaces.cpp.

References readSettings(), setFileName(), setupLine1(), and setupLine2().

Member Function Documentation

◆ addButtonsDisab()

void MantidQt::MantidWidgets::SaveWorkspaces::addButtonsDisab ( int  row)
private

◆ closeEvent()

void SaveWorkspaces::closeEvent ( QCloseEvent *  event)
overrideprivate

Called in response to a close event.

Parameters
eventThe event object

Definition at line 215 of file SaveWorkspaces.cpp.

References closing(), and saveSettings().

◆ closing

void MantidQt::MantidWidgets::SaveWorkspaces::closing ( )
signal

Referenced by closeEvent().

◆ createZeroErrorFreeWorkspace

void MantidQt::MantidWidgets::SaveWorkspaces::createZeroErrorFreeWorkspace ( QString &  originalWorkspace,
QString &  zeroFreeWorkspace 
)
signal

◆ deleteZeroErrorFreeWorkspace

void MantidQt::MantidWidgets::SaveWorkspaces::deleteZeroErrorFreeWorkspace ( QString &  zeroFreeWorkspace)
signal

◆ getSaveAlgExt()

QString SaveWorkspaces::getSaveAlgExt ( const QString &  algName)
static

Returns the save extension expected the name algorithm.

Gets the first extension that the algorithm passed algorithm has in it's FileProperty (the FileProperty must have the name "Filename".

Parameters
algName:: name of the Mantid save algorithm
Returns
the first extension, if the algorithm's Filename property has an extension list or ""

Definition at line 284 of file SaveWorkspaces.cpp.

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

Referenced by saveList().

◆ initLayout()

void SaveWorkspaces::initLayout ( )

Set up the dialog layout.

Definition at line 84 of file SaveWorkspaces.cpp.

◆ isValid()

bool SaveWorkspaces::isValid ( )
private

Checks if the save option selection is compatible with the dimensionality selection.

Returns
true if the save option selection is compatible with the dimensionality selection else false

Definition at line 343 of file SaveWorkspaces.cpp.

References Mantid::Kernel::SingletonHolder< T >::Instance(), m_savFormats, m_workspaces, and workspace.

Referenced by saveSel().

◆ onSaveAsZeroErrorFreeChanged

void SaveWorkspaces::onSaveAsZeroErrorFreeChanged ( int  state)
slot

Reacts to a user change wether the workspace is to be saved as zero-error-free or not.

Parameters
state:: 0 if we don't save with the zero-error correction, otherwise anything else

Definition at line 461 of file SaveWorkspaces.cpp.

References m_saveAsZeroErrorFree.

◆ onUpdateGeomtryInformation

void SaveWorkspaces::onUpdateGeomtryInformation ( QString &  geometryID,
QString &  sampleHeight,
QString &  sampleWidth,
QString &  sampleThickness 
)
slot

Recieves an update for the geometry information.

Definition at line 472 of file SaveWorkspaces.cpp.

References m_geometryID, m_sampleHeight, m_sampleThickness, and m_sampleWidth.

◆ provideZeroFreeWorkspaces()

QHash< QString, QString > SaveWorkspaces::provideZeroFreeWorkspaces ( const QListWidget *  workspaces)
private

Goes through all selected workspaces and maps them to a zero-error free clone, if the user has selected to do this otherwise the value of the hash is set to the same as the key.

Parameters
workspaces:: a QListWIdget which contains the selected workspaces
Returns
a hash which maps the original workspace to the zero-error free workspace

Definition at line 424 of file SaveWorkspaces.cpp.

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

Referenced by saveSel().

◆ readSettings()

void SaveWorkspaces::readSettings ( )
private

Sets up some controls from what is in the QSettings.

Definition at line 170 of file SaveWorkspaces.cpp.

References m_append, and m_lastName.

Referenced by SaveWorkspaces().

◆ removeZeroFreeWorkspaces()

void SaveWorkspaces::removeZeroFreeWorkspaces ( const QHash< QString, QString > &  workspaces)
private

Remove all the zero-error free workspaces.

Parameters
workspaces:: a map containing the names of all zero-error-free workspaces.

Definition at line 448 of file SaveWorkspaces.cpp.

References deleteZeroErrorFreeWorkspace().

Referenced by saveSel().

◆ saveFileBrowse

void SaveWorkspaces::saveFileBrowse ( )
privateslot

Raises a browse dialog and inserts the selected file into the save text edit box, outfile_edit.

Definition at line 392 of file SaveWorkspaces.cpp.

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

Referenced by setupLine1().

◆ saveList()

QString SaveWorkspaces::saveList ( const QList< QListWidgetItem * > &  list,
const QString &  algorithm,
QString  fileBase,
bool  toAppend,
QHash< QString, QString >  workspaceMap 
)
private

◆ saveSel

void SaveWorkspaces::saveSel ( )
privateslot

Excutes the selected save algorithms on the workspaces that have been selected to be saved.

Definition at line 298 of file SaveWorkspaces.cpp.

References isValid(), m_append, m_fNameEdit, m_saveAsZeroErrorFree, m_savFormats, m_workspaces, provideZeroFreeWorkspaces(), removeZeroFreeWorkspaces(), MantidQt::API::MantidDialog::runPythonCode(), and saveList().

Referenced by setupLine2().

◆ saveSettings()

void SaveWorkspaces::saveSettings ( ) const
private

Saves the state of some controls to the QSettings.

Definition at line 205 of file SaveWorkspaces.cpp.

References m_append, and m_lastName.

Referenced by closeEvent().

◆ setFileName() [1/2]

void SaveWorkspaces::setFileName ( const QString &  newName)
private

Set the name of the output file.

Parameters
newNamefilename to use

Definition at line 179 of file SaveWorkspaces.cpp.

References m_append, m_fNameEdit, and m_lastName.

◆ setFileName [2/2]

void SaveWorkspaces::setFileName ( int  row)
privateslot

Sets the filename to the name of the selected workspace.

Parameters
rownumber of the row that is selected

Definition at line 388 of file SaveWorkspaces.cpp.

References m_workspaces, and setFileName().

Referenced by SaveWorkspaces(), setFileName(), and setupLine2().

◆ setupFormatTicks()

void SaveWorkspaces::setupFormatTicks ( const QHash< const QCheckBox *const, QString > &  defSavs)
private

For each save format tick box take the user setting from the main form.

Parameters
defSavsthe formats to save into

Definition at line 191 of file SaveWorkspaces.cpp.

References m_savFormats.

Referenced by setupLine2().

◆ setupLine1()

void SaveWorkspaces::setupLine1 ( QHBoxLayout *const  lineOne)
private

Puts the controls that go on the first line, the output filename commands, on to the layout that's passed to it.

Parameters
lineOne:: the layout on to which the controls will be placed

Definition at line 89 of file SaveWorkspaces.cpp.

References m_fNameEdit, and saveFileBrowse().

Referenced by SaveWorkspaces().

◆ setupLine2()

void SaveWorkspaces::setupLine2 ( QHBoxLayout *const  lineTwo,
const QHash< const QCheckBox *const, QString > &  defSavs 
)
private

Puts the controls that go on the second line, the workspace list and save commands, on to the layout that's passed to it.

Parameters
lineTwo:: the layout on to which the controls will be placed
defSavsthe formats to save into, sets the check boxes to be checked

Definition at line 108 of file SaveWorkspaces.cpp.

References Mantid::Kernel::SingletonHolder< T >::Instance(), m_append, m_savFormats, m_workspaces, saveSel(), setFileName(), and setupFormatTicks().

Referenced by SaveWorkspaces().

◆ updateGeometryInformation

void MantidQt::MantidWidgets::SaveWorkspaces::updateGeometryInformation ( )
signal

Referenced by saveList().

Member Data Documentation

◆ m_append

QCheckBox* MantidQt::MantidWidgets::SaveWorkspaces::m_append
private

◆ m_fNameEdit

QLineEdit* MantidQt::MantidWidgets::SaveWorkspaces::m_fNameEdit
private

Definition at line 47 of file SaveWorkspaces.h.

Referenced by saveFileBrowse(), saveSel(), setFileName(), and setupLine1().

◆ m_geometryID

QString MantidQt::MantidWidgets::SaveWorkspaces::m_geometryID
private

Definition at line 52 of file SaveWorkspaces.h.

Referenced by onUpdateGeomtryInformation(), and saveList().

◆ m_lastName

QString MantidQt::MantidWidgets::SaveWorkspaces::m_lastName
private

Definition at line 50 of file SaveWorkspaces.h.

Referenced by readSettings(), saveSettings(), and setFileName().

◆ m_sampleHeight

QString MantidQt::MantidWidgets::SaveWorkspaces::m_sampleHeight
private

Definition at line 53 of file SaveWorkspaces.h.

Referenced by onUpdateGeomtryInformation(), and saveList().

◆ m_sampleThickness

QString MantidQt::MantidWidgets::SaveWorkspaces::m_sampleThickness
private

Definition at line 55 of file SaveWorkspaces.h.

Referenced by onUpdateGeomtryInformation(), and saveList().

◆ m_sampleWidth

QString MantidQt::MantidWidgets::SaveWorkspaces::m_sampleWidth
private

Definition at line 54 of file SaveWorkspaces.h.

Referenced by onUpdateGeomtryInformation(), and saveList().

◆ m_saveAsZeroErrorFree

bool MantidQt::MantidWidgets::SaveWorkspaces::m_saveAsZeroErrorFree
private

◆ m_savFormats

QHash<QCheckBox *const, QString> MantidQt::MantidWidgets::SaveWorkspaces::m_savFormats
private

Definition at line 57 of file SaveWorkspaces.h.

Referenced by isValid(), saveSel(), setupFormatTicks(), and setupLine2().

◆ m_workspaces

QListWidget* MantidQt::MantidWidgets::SaveWorkspaces::m_workspaces
private

Definition at line 48 of file SaveWorkspaces.h.

Referenced by isValid(), saveSel(), setFileName(), and setupLine2().


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