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#include "MantidKernel/System.h"
11
12#include <QGridLayout>
13#include <QLabel>
14#include <QMap>
15#include <QPushButton>
16#include <QString>
17#include <QWidget>
18
19#include "DllOption.h"
20
21class QLineEdit;
22
23namespace MantidQt {
24namespace API {
29class ClickableLabel : public QLabel {
30 Q_OBJECT
31
32public:
34 ClickableLabel(QWidget *parent);
36 ~ClickableLabel() override;
37
38signals:
40 void clicked();
41
42protected:
44 void mousePressEvent(QMouseEvent *event) override;
45};
46
53 Q_OBJECT
54
55public:
58 static void setFieldPlaceholderText(Mantid::Kernel::Property *prop, QLineEdit *field);
59
60 enum Info { INVALID, REPLACE, RESTORE };
61
62 PropertyWidget(Mantid::Kernel::Property *prop, QWidget *parent = nullptr, QGridLayout *layout = nullptr,
63 int row = -1);
64 ~PropertyWidget() override;
65
66 bool inGrid() const;
67
69 virtual QString getValue() const = 0;
70
72 void setValue(const QString &value);
74 void setPreviousValue(const QString &previousValue);
76 void setPrevious_isDynamicDefault(bool flag);
77
80 void transferHistoryState(const PropertyWidget *other, const PropertyWidget *upstream = nullptr);
81
82 virtual QWidget *getMainWidget() = 0;
83
84 void setEnabled(bool val);
85 void setVisible(bool val) override;
86
88 QGridLayout *getGridLayout() { return m_gridLayout; }
89
91 int getGridRow() { return m_row; }
92
93 void addReplaceWSButton();
94
96 const Mantid::Kernel::Property *getProperty() const { return m_prop; }
98
99 void setError(const QString &error);
100
101private:
102 virtual void setValueImpl(const QString &value) = 0;
103
104public slots:
106 void updateIconVisibility(const QString &error = "");
107
109 void replaceWSButtonClicked();
110
112 void valueChangedSlot();
113
116 void userEditedProperty();
117
119 void toggleUseHistory();
120
121private:
123 void setUseHistoryIcon(bool useHistory, bool isDynamicDefault);
124
125signals:
128 void valueChanged(const QString &propName);
129
131 void replaceWorkspaceName(const QString &propName);
132
134
135protected:
138 static void setLabelFont(Mantid::Kernel::Property *prop, QWidget *label);
139
142
144 QGridLayout *m_gridLayout;
145
147 QWidget *m_parent;
148
150 int m_row;
151
153 QString m_doc;
154
156 QPushButton *m_replaceWSButton;
157
159 QVector<QWidget *> m_widgets;
160
162 QString m_lastValue;
163
165 QString m_error;
166
169
172
175
178
181
183 QMap<Info, ClickableLabel *> m_icons;
184
188};
189
190} // namespace API
191} // namespace MantidQt
#define EXPORT_OPT_MANTIDQT_COMMON
Definition DllOption.h:15
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)
QVector< QWidget * > m_widgets
All contained widgets.
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.
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:94
The AlgorithmProgressDialogPresenter keeps track of the running algorithms and displays a progress ba...