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);
75
76 virtual QWidget *getMainWidget() = 0;
77
78 void setEnabled(bool val);
79 void setVisible(bool val) override;
80
82 QGridLayout *getGridLayout() { return m_gridLayout; }
83
85 int getGridRow() { return m_row; }
86
87 void addReplaceWSButton();
88
91
92 void setError(const QString &error);
93
94private:
95 virtual void setValueImpl(const QString &value) = 0;
96
97public slots:
99 void updateIconVisibility(const QString &error = "");
101 void replaceWSButtonClicked();
103 void valueChangedSlot();
106 void userEditedProperty();
108 void toggleUseHistory();
109
110private:
112 void setUseHistoryIcon(bool useHistory);
113
114signals:
117 void valueChanged(const QString &propName);
118
120 void replaceWorkspaceName(const QString &propName);
121
123
124protected:
127 static void setLabelFont(Mantid::Kernel::Property *prop, QWidget *label);
128
131
133 QGridLayout *m_gridLayout;
134
136 QWidget *m_parent;
137
139 int m_row;
140
142 QString m_doc;
143
145 QPushButton *m_replaceWSButton;
146
148 QVector<QWidget *> m_widgets;
149
151 QString m_error;
152
155
158
161
163 QMap<Info, ClickableLabel *> m_icons;
164
168};
169
170} // namespace API
171} // 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
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()
virtual QString getValue() const =0
Return the value of the property given the GUI state.
QString m_enteredValue
Stored the last non-previously-entered value entered 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.
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.
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...