Mantid
Loading...
Searching...
No Matches
DataSelector.h
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2011 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 +
7#pragma once
8
9#include "DllOption.h"
10#include "ui_DataSelector.h"
11
15
16#include <QWidget>
17
18namespace MantidQt {
19namespace MantidWidgets {
20
23
37 Q_OBJECT
38
39 // These are properties of the file browser sub-widget
40 Q_PROPERTY(QStringList fileBrowserSuffixes READ getFBSuffixes WRITE setFBSuffixes)
41 Q_PROPERTY(bool showLoad READ willShowLoad WRITE setShowLoad)
42 Q_PROPERTY(QString instrumentOverride READ getInstrumentOverride WRITE setInstrumentOverride)
43 Q_PROPERTY(bool multipleFiles READ allowMultipleFiles WRITE allowMultipleFiles)
44 Q_PROPERTY(bool findRunFiles READ isForRunFiles WRITE isForRunFiles)
45 Q_PROPERTY(bool findDirectory READ isForDirectory WRITE isForDirectory)
46 Q_PROPERTY(QString label READ getLabelText WRITE setLabelText)
47 Q_PROPERTY(bool multiEntry READ doMultiEntry WRITE doMultiEntry)
48 Q_PROPERTY(QString algorithmAndProperty READ getAlgorithmProperty WRITE setAlgorithmProperty)
49 Q_PROPERTY(bool extsAsSingleOption READ extsAsSingleOption WRITE extsAsSingleOption)
50 Q_PROPERTY(ButtonOpts buttonOpts READ doButtonOpt WRITE doButtonOpt)
51 Q_PROPERTY(LiveButtonOpts liveButton READ liveButtonState WRITE liveButtonState)
52 Q_ENUMS(ButtonOpts)
53 Q_ENUMS(LiveButtonOpts)
54
55 // These are properties of the workspace selector sub-widget
56 Q_PROPERTY(QStringList workspaceSuffixes READ getWSSuffixes WRITE setWSSuffixes)
57 Q_PROPERTY(QStringList WorkspaceTypes READ getWorkspaceTypes WRITE setWorkspaceTypes)
58 Q_PROPERTY(bool ShowHidden READ showHiddenWorkspaces WRITE showHiddenWorkspaces)
59 Q_PROPERTY(bool ShowGroups READ showWorkspaceGroups WRITE showWorkspaceGroups)
60 Q_PROPERTY(QString Algorithm READ getValidatingAlgorithm WRITE setValidatingAlgorithm)
61
62 // These are global properties of data selector
63 Q_PROPERTY(bool optional READ isOptional WRITE isOptional)
64 Q_PROPERTY(QString loadLabelText READ getLoadBtnText WRITE setLoadBtnText)
65
66public:
67 DataSelector(QWidget *parent = nullptr);
68 ~DataSelector() override;
69
71 QString getFullFilePath() const;
73 QString getWsNameFromFiles() const;
75 virtual QString getCurrentDataName(bool const autoLoad = true) const;
77 void setSelectorIndex(int index);
79 void setTypeSelectorVisible(bool visible);
81 void setWorkspaceSelectorIndex(QString const &workspaceName);
83 bool isFileSelectorVisible() const;
85 bool isWorkspaceSelectorVisible() const;
87 virtual bool isValid(bool const autoLoad = true);
89 QString getProblem() const;
91 void readSettings(const QString & /*group*/);
93 void saveSettings(const QString & /*group*/);
95 bool isOptional() const;
97 void isOptional(bool /*optional*/);
99 bool willShowLoad();
101 void setShowLoad(bool load);
103 QString getLoadBtnText() const;
105 void setLoadBtnText(const QString & /*text*/);
107 void setAlwaysLoadAsGroup(bool const loadAsGroup);
109 void setLoadProperty(std::string const &propertyName, bool const value);
110
111 // These are accessors/modifiers of the child FileFinderWidget
117 bool allowMultipleFiles() const { return m_uiForm.rfFileInput->allowMultipleFiles(); }
118
126 void allowMultipleFiles(const bool allow) { m_uiForm.rfFileInput->allowMultipleFiles(allow); }
127
132 bool isForRunFiles() const { return m_uiForm.rfFileInput->isForRunFiles(); }
133
138 void isForRunFiles(const bool mode) { m_uiForm.rfFileInput->isForRunFiles(mode); }
139
144 bool isForDirectory() const { return m_uiForm.rfFileInput->isForDirectory(); }
145
150 void isForDirectory(const bool mode) { m_uiForm.rfFileInput->isForDirectory(mode); }
151
156 QString getLabelText() const { return m_uiForm.rfFileInput->getLabelText(); }
157
162 void setLabelText(const QString &text) { m_uiForm.rfFileInput->setLabelText(text); }
163
169 bool doMultiEntry() const { return m_uiForm.rfFileInput->doMultiEntry(); }
170
175 void doMultiEntry(const bool multiEntry) { m_uiForm.rfFileInput->doMultiEntry(multiEntry); }
176
181 QString getAlgorithmProperty() const { return m_uiForm.rfFileInput->getAlgorithmProperty(); }
182
188 void setAlgorithmProperty(const QString &text) { m_uiForm.rfFileInput->setAlgorithmProperty(text); }
189
195 bool extsAsSingleOption() const { return m_uiForm.rfFileInput->extsAsSingleOption(); }
196
203 void extsAsSingleOption(const bool value) { m_uiForm.rfFileInput->extsAsSingleOption(value); }
204
210 QStringList getFBSuffixes() { return m_uiForm.rfFileInput->getFileExtensions(); }
211
217 void setFBSuffixes(const QStringList &suffixes) { m_uiForm.rfFileInput->setFileExtensions(suffixes); }
218
224 QString getInstrumentOverride() { return m_uiForm.rfFileInput->getInstrumentOverride(); }
225
231 void setInstrumentOverride(const QString &instName) { m_uiForm.rfFileInput->setInstrumentOverride(instName); }
232
237 ButtonOpts doButtonOpt() const { return m_uiForm.rfFileInput->doButtonOpt(); }
238
245 void doButtonOpt(const ButtonOpts buttonOpt) { m_uiForm.rfFileInput->doButtonOpt(buttonOpt); }
246
252 LiveButtonOpts liveButtonState() const { return m_uiForm.rfFileInput->liveButtonState(); }
253
259 void liveButtonState(const LiveButtonOpts option) { m_uiForm.rfFileInput->liveButtonState(option); }
260
261 // These are accessors/modifiers of the child WorkspaceSelector
267 QStringList getWSSuffixes() { return m_uiForm.wsWorkspaceInput->getSuffixes(); }
268
274 void setWSSuffixes(const QStringList &suffixes) { m_uiForm.wsWorkspaceInput->setSuffixes(suffixes); }
275
281 QStringList getWorkspaceTypes() const { return m_uiForm.wsWorkspaceInput->getWorkspaceTypes(); }
282
288 void setWorkspaceTypes(const QStringList &types) { m_uiForm.wsWorkspaceInput->setWorkspaceTypes(types); }
289
295 bool showHiddenWorkspaces() const { return m_uiForm.wsWorkspaceInput->showHiddenWorkspaces(); }
296
302 void showHiddenWorkspaces(bool show) { m_uiForm.wsWorkspaceInput->showHiddenWorkspaces(show); }
303
309 bool showWorkspaceGroups() const { return m_uiForm.wsWorkspaceInput->showWorkspaceGroups(); }
310
316 void showWorkspaceGroups(bool show) { m_uiForm.wsWorkspaceInput->showWorkspaceGroups(show); }
317
323 QString getValidatingAlgorithm() const { return m_uiForm.wsWorkspaceInput->getValidatingAlgorithm(); }
324
330 void setValidatingAlgorithm(const QString &algName) { m_uiForm.wsWorkspaceInput->setValidatingAlgorithm(algName); }
331
332signals:
341 void dataReady(const QString &wsname);
346
347protected:
348 // Method for handling drop events
349 void dropEvent(QDropEvent * /*unused*/) override;
350 // called when a drag event enters the class
351 void dragEnterEvent(QDragEnterEvent * /*unused*/) override;
352
353private slots:
355 void handleViewChanged(int index);
357 void handleFileInput();
359 void handleWorkspaceInput();
361 void handleAutoLoadComplete(bool error);
362
363private:
365 void autoLoadFile(const QString &filenames);
367 void executeLoadAlgorithm(std::string const &filename, std::string const &outputWorkspace);
369 Ui::DataSelector m_uiForm;
380};
381
382} /* namespace MantidWidgets */
383} /* namespace MantidQt */
#define EXPORT_OPT_MANTIDQT_COMMON
Definition DllOption.h:15
double value
The value of the point.
Definition FitMW.cpp:51
double error
std::map< DeltaEMode::Type, std::string > index
ButtonOpts
options for bringing up the load file dialog
LiveButtonOpts
Options for the live button.
This is the base class all customised widgets that do not wish to be tied to a specific Mantid algori...
The QtAlgorithmRunner is a QObject that encapsulates methods for running an algorithm asynchronously ...
This class defines a widget for selecting a workspace of file path by using a combination of two chil...
Mantid::API::AlgorithmRuntimeProps m_loadProperties
Extra load properties to set on the load algorithm before execution.
void setAlgorithmProperty(const QString &text)
Sets an algorithm name that can be tied to this widget.
bool m_alwaysLoadAsGroup
Flag to always load data, placing it inside a WorkspaceGroup, even if there is 1 entry.
Ui::DataSelector m_uiForm
Member containing the widgets child widgets.
QStringList getWorkspaceTypes() const
Gets the workspace types allowed by the workspace selector.
void filesFound()
Signal emitted when files were found but widget isn't autoloading.
void fileViewVisible()
Signal emitted when file input is visible.
QString getLabelText() const
Return the label text on the widget.
void isForRunFiles(const bool mode)
Sets whether this widget is for run file searching or not.
bool extsAsSingleOption() const
Returns whether the file dialog should display the exts as a single list or as multiple items.
QString getAlgorithmProperty() const
Returns the algorithm name.
void setValidatingAlgorithm(const QString &algName)
Sets the validating algorithm of workspace selector.
void filesAutoLoaded()
Signal emitted when files are found and autoloaded.
void extsAsSingleOption(const bool value)
Sets whether the file dialog should display the exts as a single list or as multiple items.
void showHiddenWorkspaces(bool show)
Sets if the workspace selector shows hidden workspaces.
void setWSSuffixes(const QStringList &suffixes)
Sets the suffixes allowed by the workspace selector.
bool isForRunFiles() const
Returns if this widget is for run file searching or not.
bool isForDirectory() const
Returns if this widget is for selecting a directory or not.
bool m_showLoad
Flag to show or hide the load button. By default this is set to true.
LiveButtonOpts liveButtonState() const
Gets the live button state.
void isForDirectory(const bool mode)
Sets directory searching mode.
QString getInstrumentOverride()
Gets the instrument override.
void doButtonOpt(const ButtonOpts buttonOpt)
Set how the browse should appear.
void setFBSuffixes(const QStringList &suffixes)
Sets the suffixes allowed by the file browser.
void setLabelText(const QString &text)
Set the text on the label.
MantidQt::API::QtAlgorithmRunner m_algRunner
Algorithm Runner used to run the load algorithm.
QStringList getFBSuffixes()
Gets the suffixes allowed by the file browser.
QString getValidatingAlgorithm() const
Gets if the validating algorithm of workspace selector.
void liveButtonState(const LiveButtonOpts option)
Sets the live button state.
void allowMultipleFiles(const bool allow)
Set whether this widget allows multiple files to be specifed or not.
void doMultiEntry(const bool multiEntry)
Set to true to enable the period number box.
void setWorkspaceTypes(const QStringList &types)
Sets the workspace types allowed by the workspace selector.
bool doMultiEntry() const
Whether to find the number of entries in the file or assume (the normal situation) of one entry.
void dataReady(const QString &wsname)
Signal emitted when data is ready from a workspace selector or file browser.
bool allowMultipleFiles() const
Return whether this widget allows multiple files to be specified within the edit box.
void loadClicked()
Signal emitted when the load button is clicked.
bool showHiddenWorkspaces() const
Gets if the workspace selector shows hidden workspaces.
ButtonOpts doButtonOpt() const
Returns the preference for how the dialog control should be.
void setInstrumentOverride(const QString &instName)
Sets the instrument override.
void workspaceViewVisible()
Signal emitted when workspace selector is visible.
QStringList getWSSuffixes()
Gets the suffixes allowed by the workspace selector.
bool showWorkspaceGroups() const
Gets if the workspace selector shows group workspaces.
void showWorkspaceGroups(bool show)
Sets if the workspace selector shows workspace groups.
Base class from which all concrete algorithm classes should be derived.
Definition Algorithm.h:76
The AlgorithmProgressDialogPresenter keeps track of the running algorithms and displays a progress ba...
STL namespace.