BornAgain  1.19.79
Simulate and fit neutron and x-ray scattering at grazing incidence
ScientificSpinBoxEditor Class Reference

Description

Editor for Double variant using ScientificSpinBox.

Definition at line 77 of file CustomEditors.h.

Inheritance diagram for ScientificSpinBoxEditor:
[legend]
Collaboration diagram for ScientificSpinBoxEditor:
[legend]

Public Slots

void setData (const QVariant &data)
 Sets the data from the model to editor. More...
 

Signals

void dataChanged (const QVariant &data)
 Signal emit then user changed the data through the editor. More...
 

Public Member Functions

 ScientificSpinBoxEditor (QWidget *parent=nullptr)
 
QVariant editorData ()
 
void setDecimals (int decimals)
 
void setLimits (const RealLimits &limits)
 
void setSingleStep (double step)
 

Protected Member Functions

void initEditor () override
 Inits editor widgets from m_data. More...
 
void setDataIntern (const QVariant &data)
 Saves the data from the editor and informs external delegates. More...
 

Protected Attributes

QVariant m_data
 

Private Slots

void onEditingFinished ()
 

Private Attributes

class ScientificSpinBoxm_doubleEditor
 

Constructor & Destructor Documentation

◆ ScientificSpinBoxEditor()

ScientificSpinBoxEditor::ScientificSpinBoxEditor ( QWidget *  parent = nullptr)

Definition at line 142 of file CustomEditors.cpp.

143  : CustomEditor(parent)
145 {
146  setAutoFillBackground(true);
147  setFocusPolicy(Qt::StrongFocus);
148  m_doubleEditor->setFocusPolicy(Qt::StrongFocus);
149  m_doubleEditor->setKeyboardTracking(false);
150 
151  auto* layout = new QVBoxLayout;
152  layout->setMargin(0);
153  layout->setSpacing(0);
154 
155  layout->addWidget(m_doubleEditor);
156 
158 
159  setLayout(layout);
160 
161  setFocusProxy(m_doubleEditor);
162 }
CustomEditor(QWidget *parent=nullptr)
Definition: CustomEditors.h:32
class ScientificSpinBox * m_doubleEditor
Definition: CustomEditors.h:93
void valueChanged(double value)

References m_doubleEditor, onEditingFinished(), and ScientificSpinBox::valueChanged().

Here is the call graph for this function:

Member Function Documentation

◆ dataChanged

void CustomEditor::dataChanged ( const QVariant &  data)
signalinherited

Signal emit then user changed the data through the editor.

Referenced by FitParameterDelegate::createEditor(), and CustomEditor::setDataIntern().

◆ editorData()

QVariant CustomEditor::editorData ( )
inlineinherited

Definition at line 37 of file CustomEditors.h.

37 { return m_data; }
QVariant m_data
Definition: CustomEditors.h:49

References CustomEditor::m_data.

◆ initEditor()

void ScientificSpinBoxEditor::initEditor ( )
overrideprotectedvirtual

Inits editor widgets from m_data.

Reimplemented from CustomEditor.

Definition at line 191 of file CustomEditors.cpp.

192 {
193  ASSERT(m_data.type() == QVariant::Double);
194  m_doubleEditor->setValue(m_data.toDouble());
195 }
void setValue(double val)

References CustomEditor::m_data, m_doubleEditor, and ScientificSpinBox::setValue().

Here is the call graph for this function:

◆ onEditingFinished

void ScientificSpinBoxEditor::onEditingFinished ( )
privateslot

Definition at line 183 of file CustomEditors.cpp.

184 {
185  double new_value = m_doubleEditor->value();
186 
187  if (new_value != m_data.toDouble())
188  setDataIntern(QVariant::fromValue(new_value));
189 }
void setDataIntern(const QVariant &data)
Saves the data from the editor and informs external delegates.

References CustomEditor::m_data, m_doubleEditor, CustomEditor::setDataIntern(), and ScientificSpinBox::value.

Referenced by ScientificSpinBoxEditor().

Here is the call graph for this function:

◆ setData

void CustomEditor::setData ( const QVariant &  data)
slotinherited

Sets the data from the model to editor.

Definition at line 40 of file CustomEditors.cpp.

41 {
42  m_data = data;
43  initEditor();
44 }
virtual void initEditor()
Inits editor widgets from m_data.

References CustomEditor::initEditor(), and CustomEditor::m_data.

Here is the call graph for this function:

◆ setDataIntern()

void CustomEditor::setDataIntern ( const QVariant &  data)
protectedinherited

Saves the data from the editor and informs external delegates.

Definition at line 52 of file CustomEditors.cpp.

53 {
54  m_data = data;
56 }
void dataChanged(const QVariant &data)
Signal emit then user changed the data through the editor.

References CustomEditor::dataChanged(), and CustomEditor::m_data.

Referenced by onEditingFinished(), and ComboPropertyEditor::onIndexChanged().

◆ setDecimals()

void ScientificSpinBoxEditor::setDecimals ( int  decimals)

Definition at line 172 of file CustomEditors.cpp.

173 {
174  m_doubleEditor->setDecimals(decimals);
175  m_doubleEditor->setSingleStep(singleStep(decimals));
176 }
void setSingleStep(double step)

References m_doubleEditor, ScientificSpinBox::setDecimals(), and ScientificSpinBox::setSingleStep().

Here is the call graph for this function:

◆ setLimits()

void ScientificSpinBoxEditor::setLimits ( const RealLimits &  limits)

Definition at line 164 of file CustomEditors.cpp.

165 {
166  m_doubleEditor->setMinimum(limits.hasLowerLimit() ? limits.lowerLimit()
167  : std::numeric_limits<double>::lowest());
168  m_doubleEditor->setMaximum(limits.hasUpperLimit() ? limits.upperLimit()
169  : std::numeric_limits<double>::max());
170 }
void setMaximum(double max)
void setMinimum(double min)

References m_doubleEditor, ScientificSpinBox::setMaximum(), and ScientificSpinBox::setMinimum().

Referenced by GUI::View::PropertyEditorFactory::CreateEditor().

Here is the call graph for this function:

◆ setSingleStep()

void ScientificSpinBoxEditor::setSingleStep ( double  step)

Definition at line 178 of file CustomEditors.cpp.

179 {
181 }

References m_doubleEditor, and ScientificSpinBox::setSingleStep().

Here is the call graph for this function:

Member Data Documentation

◆ m_data

◆ m_doubleEditor

class ScientificSpinBox* ScientificSpinBoxEditor::m_doubleEditor
private

The documentation for this class was generated from the following files: