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

Editor for Double variant using ScientificSpinBox. More...

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 ()
 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
 

Detailed Description

Editor for Double variant using ScientificSpinBox.

Definition at line 135 of file CustomEditors.h.

Constructor & Destructor Documentation

◆ ScientificSpinBoxEditor()

ScientificSpinBoxEditor::ScientificSpinBoxEditor ( QWidget *  parent = nullptr)

Definition at line 316 of file CustomEditors.cpp.

318 {
319  setAutoFillBackground(true);
320  setFocusPolicy(Qt::StrongFocus);
321  m_doubleEditor->setFocusPolicy(Qt::StrongFocus);
322  m_doubleEditor->setKeyboardTracking(false);
323 
324  auto layout = new QVBoxLayout;
325  layout->setMargin(0);
326  layout->setSpacing(0);
327 
328  layout->addWidget(m_doubleEditor);
329 
331 
332  setLayout(layout);
333 
334  setFocusProxy(m_doubleEditor);
335 }
CustomEditor(QWidget *parent=nullptr)
Definition: CustomEditors.h:31
class ScientificSpinBox * m_doubleEditor
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 PropertyWidgetItem::connectEditor(), SessionModelDelegate::createEditor(), and CustomEditor::setDataIntern().

◆ editorData()

QVariant CustomEditor::editorData ( )
inlineinherited

Definition at line 33 of file CustomEditors.h.

33 { return m_data; }
QVariant m_data
Definition: CustomEditors.h:45

References CustomEditor::m_data.

◆ initEditor()

void ScientificSpinBoxEditor::initEditor ( )
protectedvirtual

Inits editor widgets from m_data.

Reimplemented from CustomEditor.

Definition at line 364 of file CustomEditors.cpp.

365 {
366  ASSERT(m_data.type() == QVariant::Double);
367  m_doubleEditor->setValue(m_data.toDouble());
368 }
#define ASSERT(condition)
Definition: Assert.h:31
void setValue(double val)

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

Here is the call graph for this function:

◆ onEditingFinished

void ScientificSpinBoxEditor::onEditingFinished ( )
privateslot

Definition at line 356 of file CustomEditors.cpp.

357 {
358  double new_value = m_doubleEditor->value();
359 
360  if (new_value != m_data.toDouble())
361  setDataIntern(QVariant::fromValue(new_value));
362 }
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 48 of file CustomEditors.cpp.

49 {
50  m_data = data;
51  initEditor();
52 }
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 60 of file CustomEditors.cpp.

61 {
62  m_data = data;
64 }
void dataChanged(const QVariant &data)
Signal emit then user changed the data through the editor.

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

Referenced by ExternalPropertyEditor::buttonClicked(), BoolEditor::onCheckBoxChange(), ScientificDoublePropertyEditor::onEditingFinished(), DoubleEditor::onEditingFinished(), onEditingFinished(), IntEditor::onEditingFinished(), ComboPropertyEditor::onIndexChanged(), and MultiComboPropertyEditor::onModelDataChanged().

◆ setDecimals()

void ScientificSpinBoxEditor::setDecimals ( int  decimals)

Definition at line 345 of file CustomEditors.cpp.

346 {
347  m_doubleEditor->setDecimals(decimals);
348  m_doubleEditor->setSingleStep(singleStep(decimals));
349 }
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 337 of file CustomEditors.cpp.

338 {
340  : std::numeric_limits<double>::lowest());
342  : std::numeric_limits<double>::max());
343 }
bool hasUpperLimit() const
if has upper limit
Definition: RealLimits.cpp:57
double upperLimit() const
Returns upper limit.
Definition: RealLimits.cpp:62
double lowerLimit() const
Returns lower limit.
Definition: RealLimits.cpp:40
bool hasLowerLimit() const
if has lower limit
Definition: RealLimits.cpp:35
void setMaximum(double max)
void setMinimum(double min)

References RealLimits::hasLowerLimit(), RealLimits::hasUpperLimit(), RealLimits::lowerLimit(), m_doubleEditor, ScientificSpinBox::setMaximum(), ScientificSpinBox::setMinimum(), and RealLimits::upperLimit().

Here is the call graph for this function:

◆ setSingleStep()

void ScientificSpinBoxEditor::setSingleStep ( double  step)

Definition at line 351 of file CustomEditors.cpp.

352 {
354 }

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: