BornAgain  1.19.79
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/View/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_VIEW_PROPERTYEDITOR_CUSTOMEDITORS_H
16 #define BORNAGAIN_GUI_VIEW_PROPERTYEDITOR_CUSTOMEDITORS_H
17 
18 #include "WinDllMacros.h"
19 #include <QVariant>
20 #include <QWidget>
21 
22 class LostFocusFilter;
23 class QLabel;
24 class QComboBox;
25 class RealLimits;
26 
27 //! Base class for all custom variants editors.
28 
29 class CustomEditor : public QWidget {
30  Q_OBJECT
31 public:
32  explicit CustomEditor(QWidget* parent = nullptr)
33  : QWidget(parent)
34  {
35  }
36 
37  QVariant editorData() { return m_data; }
38 
39 public slots:
40  void setData(const QVariant& data);
41 
42 signals:
43  //! Signal emit then user changed the data through the editor
44  void dataChanged(const QVariant& data);
45 
46 protected:
47  virtual void initEditor();
48  void setDataIntern(const QVariant& data);
49  QVariant m_data;
50 };
51 
52 //! Editor for ComboProperty variant.
53 
55  Q_OBJECT
56 public:
57  explicit ComboPropertyEditor(QWidget* parent = nullptr);
58 
59  QSize sizeHint() const override;
60  QSize minimumSizeHint() const override;
61 
62 protected slots:
63  virtual void onIndexChanged(int index);
64 
65 protected:
66  void initEditor() override;
67  virtual QStringList internLabels();
68  virtual int internIndex();
69  void setConnected(bool isConnected);
70 
71  QComboBox* m_box;
73 };
74 
75 //! Editor for Double variant using ScientificSpinBox.
76 
78  Q_OBJECT
79 public:
80  ScientificSpinBoxEditor(QWidget* parent = nullptr);
81 
82  void setLimits(const RealLimits& limits);
83  void setDecimals(int decimals);
84  void setSingleStep(double step);
85 
86 private slots:
87  void onEditingFinished();
88 
89 protected:
90  void initEditor() override;
91 
92 private:
94 };
95 
96 #endif // BORNAGAIN_GUI_VIEW_PROPERTYEDITOR_CUSTOMEDITORS_H
Editor for ComboProperty variant.
Definition: CustomEditors.h:54
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)
void initEditor() override
Inits editor widgets from m_data.
QSize minimumSizeHint() const override
QSize sizeHint() const override
class WheelEventEater * m_wheel_event_filter
Definition: CustomEditors.h:72
ComboPropertyEditor(QWidget *parent=nullptr)
Base class for all custom variants editors.
Definition: CustomEditors.h:29
QVariant editorData()
Definition: CustomEditors.h:37
QVariant m_data
Definition: CustomEditors.h:49
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:32
void setDataIntern(const QVariant &data)
Saves the data from the editor and informs external delegates.
Event filter to prevent lost of focus by custom material editor.
Editor for Double variant using ScientificSpinBox.
Definition: CustomEditors.h:77
void setDecimals(int decimals)
void initEditor() override
Inits editor widgets from m_data.
void setLimits(const RealLimits &limits)
void setSingleStep(double step)
ScientificSpinBoxEditor(QWidget *parent=nullptr)
class ScientificSpinBox * m_doubleEditor
Definition: CustomEditors.h:93
Event filter to install on combo boxes and spin boxes to not to react on wheel events during scrollin...