Mantid
Loading...
Searching...
No Matches
PropertyWidget.h
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2012 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
10
11#include <QGridLayout>
12#include <QLabel>
13#include <QMap>
14#include <QPushButton>
15#include <QString>
16#include <QWidget>
17
18#include "MantidQtWidgets/Common/DllOption.h"
19
20class QLineEdit;
21
22namespace MantidQt {
23namespace API {
28class ClickableLabel : public QLabel {
29 Q_OBJECT
30
31public:
33 ClickableLabel(QWidget *parent);
35 ~ClickableLabel() override;
36
37signals:
39 void clicked();
40
41protected:
43 void mousePressEvent(QMouseEvent *event) override;
44};
45
51class EXPORT_OPT_MANTIDQT_COMMON PropertyWidget : public QWidget {
52 Q_OBJECT
53
54public:
57 static void setFieldPlaceholderText(Mantid::Kernel::Property *prop, QLineEdit *field);
58
59 enum Info { INVALID, REPLACE, RESTORE };
60
61 PropertyWidget(Mantid::Kernel::Property *prop, QWidget *parent = nullptr, QGridLayout *layout = nullptr,
62 int row = -1);
63 ~PropertyWidget() override;
64
65 bool inGrid() const;
66
68 virtual QString getValue() const = 0;
69
71 void setValue(const QString &value);
73 void setPreviousValue(const QString &previousValue);
75 void setPrevious_isDynamicDefault(bool flag);
76
79 void transferHistoryState(const PropertyWidget *other, const PropertyWidget *upstream = nullptr);
80
81 virtual QWidget *getMainWidget() = 0;
82
83 void setEnabled(bool val);
84 void setVisible(bool val) override;
85
87 QGridLayout *getGridLayout() { return m_gridLayout; }
88
90 int getGridRow() const { return m_row; }
91
92 void addReplaceWSButton();
93
95 const Mantid::Kernel::Property *getProperty() const { return m_prop; }
97
98 void setError(const QString &error);
99
100private:
101 virtual void setValueImpl(const QString &value) = 0;
102
103public slots:
105 void updateIconVisibility(const QString &error = "");
106
108 void replaceWSButtonClicked();
109
111 void valueChangedSlot();
112
115 void userEditedProperty();
116
118 void toggleUseHistory();
119
120private:
122 void setUseHistoryIcon(bool useHistory, bool isDynamicDefault);
123
124signals:
127 void valueChanged(const QString &propName);
128
130 void replaceWorkspaceName(const QString &propName);
131
133
134protected:
137 static void setLabelFont(Mantid::Kernel::Property *prop, QWidget *label);
138
141
143 QGridLayout *m_gridLayout;
144
146 QWidget *m_parent;
147
149 int m_row;
150
152 QString m_doc;
153
155 QPushButton *m_replaceWSButton;
156
159
161 QString m_lastValue;
162
164 QString m_error;
165
168
171
174
177
180
182 QMap<Info, ClickableLabel *> m_icons;
183
187};
188
189} // namespace API
190} // namespace MantidQt
double value
The value of the point.
Definition FitMW.cpp:51
double error
A small extension to QLabel, so that it emits a signal when clicked.
~ClickableLabel() override
Destructor.
void mousePressEvent(QMouseEvent *event) override
Catches the mouse press event and emits the signal.
void clicked()
Signal emitted when a user clicks the label.
Base class for widgets that will set Mantid::Kernel::Property* types.
virtual QWidget * getMainWidget()=0
Mantid::Kernel::Property * getProperty()
QString m_lastValue
Last modified value.
virtual QString getValue() const =0
Return the value of the property given the GUI state.
QString m_enteredValue
Stores the last value entered by the user.
QGridLayout * m_gridLayout
Grid layout of the dialog to which we are adding widgets.
QString m_doc
Documentation string (tooltip)
QPushButton * m_replaceWSButton
Button to "replace input workspace".
virtual void setValueImpl(const QString &value)=0
void replaceWorkspaceName(const QString &propName)
Signal is emitted whenever someone clicks the replace WS button.
QMap< Info, ClickableLabel * > m_icons
Allow icon access by Info enum.
QString m_previousValue
Stores the previously entered value when this dialog was last open.
QList< QWidget * > m_widgets
All contained widgets.
const Mantid::Kernel::Property * getProperty() const
bool m_isOutputWsProp
Whether or not the property is an output workspace.
QWidget * m_parent
Parent widget to add sub-widgets to.
bool m_useHistory
History on/off flag.
~PropertyWidget() override
Destructor.
int m_row
If using the GridLayout, this is the row where the widget was inserted.
void valueChanged(const QString &propName)
Signal is emitted whenever the value (as entered by the user) in the GUI changes.
QString m_error
Error message received when trying to set the value.
bool m_previous_isDynamicDefault
Stores the isDynamicDefault flag corresponding to the previously entered value.
bool m_entered_isDynamicDefault
Stores the isDynamicDefault flag corresponding to the last value entered by the user.
Mantid::Kernel::Property * m_prop
Property being looked at. This is NOT owned by the widget.
Base class for properties.
Definition Property.h:95
The AlgorithmProgressDialogPresenter keeps track of the running algorithms and displays a progress ba...