BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
CustomEditors.h
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file GUI/coregui/Views/PropertyEditor/CustomEditors.h
6 //! @brief Defines CustomEditors classes
7 //!
8 //! @homepage http://www.bornagainproject.org
9 //! @license GNU General Public License v3 or higher (see COPYING)
10 //! @copyright Forschungszentrum Jülich GmbH 2018
11 //! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS)
12 //
13 // ************************************************************************************************
14 
15 #ifndef BORNAGAIN_GUI_COREGUI_VIEWS_PROPERTYEDITOR_CUSTOMEDITORS_H
16 #define BORNAGAIN_GUI_COREGUI_VIEWS_PROPERTYEDITOR_CUSTOMEDITORS_H
17 
18 #include <QVariant>
19 #include <QWidget>
20 
21 class LostFocusFilter;
22 class QLabel;
23 class QComboBox;
24 class RealLimits;
25 
26 //! Base class for all custom variants editors.
27 
28 class CustomEditor : public QWidget {
29  Q_OBJECT
30 public:
31  explicit CustomEditor(QWidget* parent = nullptr) : QWidget(parent) {}
32 
33  QVariant editorData() { return m_data; }
34 
35 public slots:
36  void setData(const QVariant& data);
37 
38 signals:
39  //! Signal emit then user changed the data through the editor
40  void dataChanged(const QVariant& data);
41 
42 protected:
43  virtual void initEditor();
44  void setDataIntern(const QVariant& data);
45  QVariant m_data;
46 };
47 
48 //! Editor for ExternalProperty variant.
49 
51  Q_OBJECT
52 public:
53  explicit ExternalPropertyEditor(QWidget* parent = nullptr);
54 
55  void setExternalDialogType(const QString& dialogType);
56 
57 private slots:
58  void buttonClicked();
59 
60 protected:
61  void initEditor();
62 
63 private:
64  QLabel* m_textLabel;
65  QLabel* m_pixmapLabel;
67  QString m_extDialogType; //!< Type of the dialog which will be created on button click
68 };
69 
70 //! Editor for ComboProperty variant.
71 
73  Q_OBJECT
74 public:
75  explicit ComboPropertyEditor(QWidget* parent = nullptr);
76 
77  QSize sizeHint() const;
78  QSize minimumSizeHint() const;
79 
80 protected slots:
81  virtual void onIndexChanged(int index);
82 
83 protected:
84  void initEditor();
85  virtual QStringList internLabels();
86  virtual int internIndex();
87  void setConnected(bool isConnected);
88 
89  QComboBox* m_box;
91 };
92 
93 //! Editor for ScientificDoubleProperty variant.
94 
96  Q_OBJECT
97 public:
98  ScientificDoublePropertyEditor(QWidget* parent = nullptr);
99 
100  void setLimits(const RealLimits& limits);
101 
102 private slots:
103  void onEditingFinished();
104 
105 protected:
106  void initEditor();
107 
108 private:
109  class QLineEdit* m_lineEdit;
110  class QDoubleValidator* m_validator;
111 };
112 
113 //! Editor for Double variant.
114 
115 class DoubleEditor : public CustomEditor {
116  Q_OBJECT
117 public:
118  DoubleEditor(QWidget* parent = nullptr);
119 
120  void setLimits(const RealLimits& limits);
121  void setDecimals(int decimals);
122 
123 private slots:
124  void onEditingFinished();
125 
126 protected:
127  void initEditor();
128 
129 private:
130  class QDoubleSpinBox* m_doubleEditor;
131 };
132 
133 //! Editor for Double variant using ScientificSpinBox.
134 
136  Q_OBJECT
137 public:
138  ScientificSpinBoxEditor(QWidget* parent = nullptr);
139 
140  void setLimits(const RealLimits& limits);
141  void setDecimals(int decimals);
142  void setSingleStep(double step);
143 
144 private slots:
145  void onEditingFinished();
146 
147 protected:
148  void initEditor();
149 
150 private:
152 };
153 
154 //! Editor for Int variant.
155 
156 class IntEditor : public CustomEditor {
157  Q_OBJECT
158 public:
159  IntEditor(QWidget* parent = nullptr);
160 
161  void setLimits(const RealLimits& limits);
162 
163 private slots:
164  void onEditingFinished();
165 
166 protected:
167  void initEditor();
168 
169 private:
170  class QSpinBox* m_intEditor;
171 };
172 
173 //! Editor for boolean.
174 
175 class QCheckBox;
176 
177 class BoolEditor : public CustomEditor {
178  Q_OBJECT
179 public:
180  BoolEditor(QWidget* parent = nullptr);
181 
182 private slots:
183  void onCheckBoxChange(bool value);
184 
185 protected:
186  void initEditor();
187 
188 private:
189  QCheckBox* m_checkBox;
190 };
191 
192 #endif // BORNAGAIN_GUI_COREGUI_VIEWS_PROPERTYEDITOR_CUSTOMEDITORS_H
BoolEditor(QWidget *parent=nullptr)
void initEditor()
Inits editor widgets from m_data.
QCheckBox * m_checkBox
void onCheckBoxChange(bool value)
Editor for ComboProperty variant.
Definition: CustomEditors.h:72
virtual int internIndex()
Returns index for QComboBox.
void setConnected(bool isConnected)
virtual QStringList internLabels()
Returns list of labels for QComboBox.
virtual void onIndexChanged(int index)
QSize sizeHint() const
class WheelEventEater * m_wheel_event_filter
Definition: CustomEditors.h:90
QSize minimumSizeHint() const
void initEditor()
Inits editor widgets from m_data.
ComboPropertyEditor(QWidget *parent=nullptr)
Base class for all custom variants editors.
Definition: CustomEditors.h:28
QVariant editorData()
Definition: CustomEditors.h:33
QVariant m_data
Definition: CustomEditors.h:45
void dataChanged(const QVariant &data)
Signal emit then user changed the data through the editor.
virtual void initEditor()
Inits editor widgets from m_data.
void setData(const QVariant &data)
Sets the data from the model to editor.
CustomEditor(QWidget *parent=nullptr)
Definition: CustomEditors.h:31
void setDataIntern(const QVariant &data)
Saves the data from the editor and informs external delegates.
Editor for Double variant.
void setDecimals(int decimals)
void setLimits(const RealLimits &limits)
class QDoubleSpinBox * m_doubleEditor
DoubleEditor(QWidget *parent=nullptr)
void onEditingFinished()
void initEditor()
Inits editor widgets from m_data.
Editor for ExternalProperty variant.
Definition: CustomEditors.h:50
ExternalPropertyEditor(QWidget *parent=nullptr)
void setExternalDialogType(const QString &dialogType)
LostFocusFilter * m_focusFilter
Definition: CustomEditors.h:66
QString m_extDialogType
Type of the dialog which will be created on button click.
Definition: CustomEditors.h:67
void initEditor()
Inits editor widgets from m_data.
Editor for Int variant.
IntEditor(QWidget *parent=nullptr)
class QSpinBox * m_intEditor
void setLimits(const RealLimits &limits)
void initEditor()
Inits editor widgets from m_data.
void onEditingFinished()
Event filter to prevent lost of focus by custom material editor.
Limits for a real fit parameter.
Definition: RealLimits.h:24
Editor for ScientificDoubleProperty variant.
Definition: CustomEditors.h:95
void initEditor()
Inits editor widgets from m_data.
void setLimits(const RealLimits &limits)
ScientificDoublePropertyEditor(QWidget *parent=nullptr)
class QDoubleValidator * m_validator
Editor for Double variant using ScientificSpinBox.
void setDecimals(int decimals)
void setLimits(const RealLimits &limits)
void initEditor()
Inits editor widgets from m_data.
void setSingleStep(double step)
ScientificSpinBoxEditor(QWidget *parent=nullptr)
class ScientificSpinBox * m_doubleEditor
Event filter to install on combo boxes and spin boxes to not to react on wheel events during scrollin...