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
18class QSettings;
19
20namespace MantidQt {
21namespace MantidWidgets {
22
25
39 Q_OBJECT
40
41 // These are properties of the file browser sub-widget
42 Q_PROPERTY(QStringList fileBrowserSuffixes READ getFBSuffixes WRITE setFBSuffixes)
43 Q_PROPERTY(bool showLoad READ willShowLoad WRITE setShowLoad)
44 Q_PROPERTY(QString instrumentOverride READ getInstrumentOverride WRITE setInstrumentOverride)
45 Q_PROPERTY(bool multipleFiles READ allowMultipleFiles WRITE allowMultipleFiles)
46 Q_PROPERTY(bool findRunFiles READ isForRunFiles WRITE isForRunFiles)
47 Q_PROPERTY(bool findDirectory READ isForDirectory WRITE isForDirectory)
48 Q_PROPERTY(QString label READ getLabelText WRITE setLabelText)
49 Q_PROPERTY(bool multiEntry READ doMultiEntry WRITE doMultiEntry)
50 Q_PROPERTY(QString algorithmAndProperty READ getAlgorithmProperty WRITE setAlgorithmProperty)
51 Q_PROPERTY(bool extsAsSingleOption READ extsAsSingleOption WRITE extsAsSingleOption)
52 Q_PROPERTY(ButtonOpts buttonOpts READ doButtonOpt WRITE doButtonOpt)
53 Q_PROPERTY(LiveButtonOpts liveButton READ liveButtonState WRITE liveButtonState)
54 Q_ENUMS(ButtonOpts)
55 Q_ENUMS(LiveButtonOpts)
56
57 // These are properties of the workspace selector sub-widget
58 Q_PROPERTY(QStringList workspaceSuffixes READ getWSSuffixes WRITE setWSSuffixes)
59 Q_PROPERTY(QStringList WorkspaceTypes READ getWorkspaceTypes WRITE setWorkspaceTypes)
60 Q_PROPERTY(bool ShowHidden READ showHiddenWorkspaces WRITE showHiddenWorkspaces)
61 Q_PROPERTY(bool ShowGroups READ showWorkspaceGroups WRITE showWorkspaceGroups)
62 Q_PROPERTY(QString Algorithm READ getValidatingAlgorithm WRITE setValidatingAlgorithm)
63
64 // These are global properties of data selector
65 Q_PROPERTY(bool optional READ isOptional WRITE isOptional)
66 Q_PROPERTY(QString loadLabelText READ getLoadBtnText WRITE setLoadBtnText)
67
68public:
69 DataSelector(QWidget *parent = nullptr);
70 ~DataSelector() override;
71
73 QString getFullFilePath() const;
75 QString getWsNameFromFiles() const;
77 virtual QString getCurrentDataName(bool const autoLoad = true) const;
79 void setSelectorIndex(int index);
81 void setTypeSelectorVisible(bool visible);
83 void setWorkspaceSelectorIndex(QString const &workspaceName);
85 bool isFileSelectorVisible() const;
87 bool isWorkspaceSelectorVisible() const;
89 virtual bool isValid(bool const autoLoad = true);
91 QString getProblem() const;
93 [[nodiscard]] static API::FileFinderSettings readSettings(const QSettings &settings);
95 void restoreSettings(const API::FileFinderSettings &settings);
97 [[nodiscard]] API::FileFinderSettings captureSettings() const;
99 void saveSettings(QSettings &settings, const API::FileFinderSettings &values) const;
101 bool isOptional() const;
103 void isOptional(bool /*optional*/);
105 bool willShowLoad();
107 void setShowLoad(bool load);
109 QString getLoadBtnText() const;
111 void setLoadBtnText(const QString & /*text*/);
113 void setAlwaysLoadAsGroup(bool const loadAsGroup);
115 void setLoadProperty(std::string const &propertyName, bool const value);
117 void setLoadProperty(std::string const &propertyName, std::string const &value);
118
119 // These are accessors/modifiers of the child FileFinderWidget
125 bool allowMultipleFiles() const { return m_uiForm.rfFileInput->allowMultipleFiles(); }
126
134 void allowMultipleFiles(const bool allow) { m_uiForm.rfFileInput->allowMultipleFiles(allow); }
135
140 bool isForRunFiles() const { return m_uiForm.rfFileInput->isForRunFiles(); }
141
146 void isForRunFiles(const bool mode) { m_uiForm.rfFileInput->isForRunFiles(mode); }
147
152 bool isForDirectory() const { return m_uiForm.rfFileInput->isForDirectory(); }
153
158 void isForDirectory(const bool mode) { m_uiForm.rfFileInput->isForDirectory(mode); }
159
164 QString getLabelText() const { return m_uiForm.rfFileInput->getLabelText(); }
165
170 void setLabelText(const QString &text) { m_uiForm.rfFileInput->setLabelText(text); }
171
177 bool doMultiEntry() const { return m_uiForm.rfFileInput->doMultiEntry(); }
178
183 void doMultiEntry(const bool multiEntry) { m_uiForm.rfFileInput->doMultiEntry(multiEntry); }
184
189 QString getAlgorithmProperty() const { return m_uiForm.rfFileInput->getAlgorithmProperty(); }
190
196 void setAlgorithmProperty(const QString &text) { m_uiForm.rfFileInput->setAlgorithmProperty(text); }
197
203 bool extsAsSingleOption() const { return m_uiForm.rfFileInput->extsAsSingleOption(); }
204
211 void extsAsSingleOption(const bool value) { m_uiForm.rfFileInput->extsAsSingleOption(value); }
212
218 QStringList getFBSuffixes() { return m_uiForm.rfFileInput->getFileExtensions(); }
219
225 void setFBSuffixes(const QStringList &suffixes) { m_uiForm.rfFileInput->setFileExtensions(suffixes); }
226
232 QString getInstrumentOverride() { return m_uiForm.rfFileInput->getInstrumentOverride(); }
233
239 void setInstrumentOverride(const QString &instName) { m_uiForm.rfFileInput->setInstrumentOverride(instName); }
240
245 ButtonOpts doButtonOpt() const { return m_uiForm.rfFileInput->doButtonOpt(); }
246
253 void doButtonOpt(const ButtonOpts buttonOpt) { m_uiForm.rfFileInput->doButtonOpt(buttonOpt); }
254
260 LiveButtonOpts liveButtonState() const { return m_uiForm.rfFileInput->liveButtonState(); }
261
267 void liveButtonState(const LiveButtonOpts option) { m_uiForm.rfFileInput->liveButtonState(option); }
268
269 // These are accessors/modifiers of the child WorkspaceSelector
275 QStringList getWSSuffixes() { return m_uiForm.wsWorkspaceInput->getSuffixes(); }
276
282 void setWSSuffixes(const QStringList &suffixes) { m_uiForm.wsWorkspaceInput->setSuffixes(suffixes); }
283
289 QStringList getWorkspaceTypes() const { return m_uiForm.wsWorkspaceInput->getWorkspaceTypes(); }
290
296 void setWorkspaceTypes(const QStringList &types) { m_uiForm.wsWorkspaceInput->setWorkspaceTypes(types); }
297
303 bool showHiddenWorkspaces() const { return m_uiForm.wsWorkspaceInput->showHiddenWorkspaces(); }
304
310 void showHiddenWorkspaces(bool show) { m_uiForm.wsWorkspaceInput->showHiddenWorkspaces(show); }
311
317 bool showWorkspaceGroups() const { return m_uiForm.wsWorkspaceInput->showWorkspaceGroups(); }
318
324 void showWorkspaceGroups(bool show) { m_uiForm.wsWorkspaceInput->showWorkspaceGroups(show); }
325
331 QString getValidatingAlgorithm() const { return m_uiForm.wsWorkspaceInput->getValidatingAlgorithm(); }
332
338 void setValidatingAlgorithm(const QString &algName) { m_uiForm.wsWorkspaceInput->setValidatingAlgorithm(algName); }
339
340signals:
349 void dataReady(const QString &wsname);
354
355protected:
356 // Method for handling drop events
357 void dropEvent(QDropEvent * /*unused*/) override;
358 // called when a drag event enters the class
359 void dragEnterEvent(QDragEnterEvent * /*unused*/) override;
360
361private slots:
363 void handleViewChanged(int index);
365 void handleFileInput();
367 void handleWorkspaceInput();
369 void handleAutoLoadComplete(bool error);
370
371private:
373 void autoLoadFile(const QString &filenames);
375 void executeLoadAlgorithm(std::string const &filename, std::string const &outputWorkspace);
377 Ui::DataSelector m_uiForm;
388};
389
390} /* namespace MantidWidgets */
391} /* 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.
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.