Mantid
Loading...
Searching...
No Matches
PropertyWidgetFactory.cpp
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2018 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 +
16
17using namespace Mantid::Kernel;
18using namespace Mantid::API;
19
20namespace MantidQt::API {
21
22//----------------------------------------------------------------------------------------------
26
27//----------------------------------------------------------------------------------------------
31
32//----------------------------------------------------------------------------------------------
42 QGridLayout *layout, int row) {
43 auto *fileType = dynamic_cast<Mantid::API::FileProperty *>(prop);
44 auto *multipleFileType = dynamic_cast<Mantid::API::MultipleFileProperty *>(prop);
45 PropertyWithValue<bool> *boolProp = dynamic_cast<PropertyWithValue<bool> *>(prop);
46
47 if (boolProp) {
48 // CheckBox shown for BOOL properties
49 return new BoolPropertyWidget(boolProp, parent, layout, row);
50 } else if (!prop->allowedValues().empty() && !fileType && !multipleFileType) {
51 if (prop->isMultipleSelectionAllowed()) {
52 // Check if there are only certain allowed values for the property
53 return new ListPropertyWidget(prop, parent, layout, row);
54 } else {
55 // Check if there are only certain allowed values for the property
56 return new OptionsPropertyWidget(prop, parent, layout, row);
57 }
58 } else {
59 if (fileType || multipleFileType) {
60 return new FilePropertyWidget(prop, parent, layout, row);
61 } else {
62 // Generic text property
63 return new TextPropertyWidget(prop, parent, layout, row);
64 }
65 }
66}
67
68} // namespace MantidQt::API
Set of widgets representing a PropertyWithValue<bool>.
Widget for FileProperty, which has a "Browse" button.
Widget for displaying a Property that has a set of allowed values.
Widget for displaying a Property that has a set of allowed values.
static PropertyWidget * createWidget(Mantid::Kernel::Property *prop, QWidget *parent=nullptr, QGridLayout *layout=nullptr, int row=-1)
Create the appropriate PropertyWidget for the given Property.
virtual ~PropertyWidgetFactory()
Destructor.
Base class for widgets that will set Mantid::Kernel::Property* types.
The most generic widgets for Property's that are only a simple string.
A specialized class for dealing with file properties.
Definition: FileProperty.h:42
A property to allow a user to specify multiple files to load.
The concrete, templated class for properties.
Base class for properties.
Definition: Property.h:94
virtual bool isMultipleSelectionAllowed()
Is Multiple Selection Allowed.
Definition: Property.h:160
virtual std::vector< std::string > allowedValues() const
Returns the set of valid values for this property, if such a set exists.
Definition: Property.cpp:140