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
14
15#include <QWidget>
16
17namespace MantidQt {
18namespace MantidWidgets {
19
22
36 Q_OBJECT
37
38 // These are properties of the file browser sub-widget
39 Q_PROPERTY(QStringList fileBrowserSuffixes READ getFBSuffixes WRITE setFBSuffixes)
40 Q_PROPERTY(bool showLoad READ willShowLoad WRITE setShowLoad)
41 Q_PROPERTY(QString instrumentOverride READ getInstrumentOverride WRITE setInstrumentOverride)
42 Q_PROPERTY(bool multipleFiles READ allowMultipleFiles WRITE allowMultipleFiles)
43 Q_PROPERTY(bool findRunFiles READ isForRunFiles WRITE isForRunFiles)
44 Q_PROPERTY(bool findDirectory READ isForDirectory WRITE isForDirectory)
45 Q_PROPERTY(QString label READ getLabelText WRITE setLabelText)
46 Q_PROPERTY(bool multiEntry READ doMultiEntry WRITE doMultiEntry)
47 Q_PROPERTY(QString algorithmAndProperty READ getAlgorithmProperty WRITE setAlgorithmProperty)
48 Q_PROPERTY(bool extsAsSingleOption READ extsAsSingleOption WRITE extsAsSingleOption)
49 Q_PROPERTY(ButtonOpts buttonOpts READ doButtonOpt WRITE doButtonOpt)
50 Q_PROPERTY(LiveButtonOpts liveButton READ liveButtonState WRITE liveButtonState)
51 Q_ENUMS(ButtonOpts)
52 Q_ENUMS(LiveButtonOpts)
53
54 // These are properties of the workspace selector sub-widget
55 Q_PROPERTY(QStringList workspaceSuffixes READ getWSSuffixes WRITE setWSSuffixes)
56 Q_PROPERTY(QStringList WorkspaceTypes READ getWorkspaceTypes WRITE setWorkspaceTypes)
57 Q_PROPERTY(bool ShowHidden READ showHiddenWorkspaces WRITE showHiddenWorkspaces)
58 Q_PROPERTY(bool ShowGroups READ showWorkspaceGroups WRITE showWorkspaceGroups)
59 Q_PROPERTY(QString Algorithm READ getValidatingAlgorithm WRITE setValidatingAlgorithm)
60
61 // These are global properties of data selector
62 Q_PROPERTY(bool optional READ isOptional WRITE isOptional)
63 Q_PROPERTY(bool autoLoad READ willAutoLoad WRITE setAutoLoad)
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() 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();
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 willAutoLoad() const;
101 void setAutoLoad(bool /*load*/);
103 bool willShowLoad();
105 void setShowLoad(bool load);
107 QString getLoadBtnText() const;
109 void setLoadBtnText(const QString & /*text*/);
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);
344
345protected:
346 // Method for handling drop events
347 void dropEvent(QDropEvent * /*unused*/) override;
348 // called when a drag event enters the class
349 void dragEnterEvent(QDragEnterEvent * /*unused*/) override;
350
351private slots:
353 void handleViewChanged(int index);
355 void handleFileInput();
357 void handleWorkspaceInput();
359 void handleAutoLoadComplete(bool error);
360
361private:
363 void autoLoadFile(const QString &filenames);
365 Ui::DataSelector m_uiForm;
374};
375
376} /* namespace MantidWidgets */
377} /* namespace MantidQt */
#define EXPORT_OPT_MANTIDQT_COMMON
Definition: DllOption.h:15
double value
The value of the point.
Definition: FitMW.cpp:51
double error
Definition: IndexPeaks.cpp:133
std::map< DeltaEMode::Type, std::string > index
Definition: DeltaEMode.cpp:19
The AlgorithmRunner is a QObject that encapsulates methods for running an algorithm asynchronously (i...
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...
Definition: MantidWidget.h:27
This class defines a widget for selecting a workspace of file path by using a combination of two chil...
Definition: DataSelector.h:35
void setAlgorithmProperty(const QString &text)
Sets an algorithm name that can be tied to this widget.
Definition: DataSelector.h:188
MantidQt::API::AlgorithmRunner m_algRunner
Algorithm Runner used to run the load algorithm.
Definition: DataSelector.h:367
Ui::DataSelector m_uiForm
Member containing the widgets child widgets.
Definition: DataSelector.h:365
QStringList getWorkspaceTypes() const
Gets the workspace types allowed by the workspace selector.
Definition: DataSelector.h:281
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.
Definition: DataSelector.h:156
void isForRunFiles(const bool mode)
Sets whether this widget is for run file searching or not.
Definition: DataSelector.h:138
bool extsAsSingleOption() const
Returns whether the file dialog should display the exts as a single list or as multiple items.
Definition: DataSelector.h:195
QString getAlgorithmProperty() const
Returns the algorithm name.
Definition: DataSelector.h:181
void setValidatingAlgorithm(const QString &algName)
Sets the validating algorithm of workspace selector.
Definition: DataSelector.h:330
void extsAsSingleOption(const bool value)
Sets whether the file dialog should display the exts as a single list or as multiple items.
Definition: DataSelector.h:203
void showHiddenWorkspaces(bool show)
Sets if the workspace selector shows hidden workspaces.
Definition: DataSelector.h:302
void setWSSuffixes(const QStringList &suffixes)
Sets the suffixes allowed by the workspace selector.
Definition: DataSelector.h:274
bool isForRunFiles() const
Returns if this widget is for run file searching or not.
Definition: DataSelector.h:132
bool m_isOptional
Flag if optional.
Definition: DataSelector.h:373
bool isForDirectory() const
Returns if this widget is for selecting a directory or not.
Definition: DataSelector.h:144
bool m_showLoad
Flag to show or hide the load button. By default this is set to true.
Definition: DataSelector.h:371
LiveButtonOpts liveButtonState() const
Gets the live button state.
Definition: DataSelector.h:252
void isForDirectory(const bool mode)
Sets directory searching mode.
Definition: DataSelector.h:150
QString getInstrumentOverride()
Gets the instrument override.
Definition: DataSelector.h:224
void doButtonOpt(const ButtonOpts buttonOpt)
Set how the browse should appear.
Definition: DataSelector.h:245
void setFBSuffixes(const QStringList &suffixes)
Sets the suffixes allowed by the file browser.
Definition: DataSelector.h:217
void setLabelText(const QString &text)
Set the text on the label.
Definition: DataSelector.h:162
QStringList getFBSuffixes()
Gets the suffixes allowed by the file browser.
Definition: DataSelector.h:210
QString getValidatingAlgorithm() const
Gets if the validating algorithm of workspace selector.
Definition: DataSelector.h:323
void liveButtonState(const LiveButtonOpts option)
Sets the live button state.
Definition: DataSelector.h:259
void allowMultipleFiles(const bool allow)
Set whether this widget allows multiple files to be specifed or not.
Definition: DataSelector.h:126
void doMultiEntry(const bool multiEntry)
Set to true to enable the period number box.
Definition: DataSelector.h:175
bool m_autoLoad
Flag to enable auto loading. By default this is set to true.
Definition: DataSelector.h:369
void setWorkspaceTypes(const QStringList &types)
Sets the workspace types allowed by the workspace selector.
Definition: DataSelector.h:288
bool doMultiEntry() const
Whether to find the number of entries in the file or assume (the normal situation) of one entry.
Definition: DataSelector.h:169
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.
Definition: DataSelector.h:117
void loadClicked()
Signal emitted when the load button is clicked.
bool showHiddenWorkspaces() const
Gets if the workspace selector shows hidden workspaces.
Definition: DataSelector.h:295
ButtonOpts doButtonOpt() const
Returns the preference for how the dialog control should be.
Definition: DataSelector.h:237
void setInstrumentOverride(const QString &instName)
Sets the instrument override.
Definition: DataSelector.h:231
void workspaceViewVisible()
Signal emitted when workspace selector is visible.
QStringList getWSSuffixes()
Gets the suffixes allowed by the workspace selector.
Definition: DataSelector.h:267
bool showWorkspaceGroups() const
Gets if the workspace selector shows group workspaces.
Definition: DataSelector.h:309
void showWorkspaceGroups(bool show)
Sets if the workspace selector shows workspace groups.
Definition: DataSelector.h:316
Base class from which all concrete algorithm classes should be derived.
Definition: Algorithm.h:85
The AlgorithmProgressDialogPresenter keeps track of the running algorithms and displays a progress ba...