BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
BoolEditor Class Reference
Inheritance diagram for BoolEditor:
[legend]
Collaboration diagram for BoolEditor:
[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

 BoolEditor (QWidget *parent=nullptr)
 
QVariant editorData ()
 

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 onCheckBoxChange (bool value)
 

Private Attributes

QCheckBox * m_checkBox
 

Detailed Description

Definition at line 177 of file CustomEditors.h.

Constructor & Destructor Documentation

◆ BoolEditor()

BoolEditor::BoolEditor ( QWidget *  parent = nullptr)

Definition at line 419 of file CustomEditors.cpp.

419  : CustomEditor(parent), m_checkBox(new QCheckBox)
420 {
421  setAutoFillBackground(true);
422  auto layout = new QHBoxLayout;
423  layout->setContentsMargins(4, 0, 0, 0);
424  layout->addWidget(m_checkBox);
425  setLayout(layout);
426 
427  connect(m_checkBox, &QCheckBox::toggled, this, &BoolEditor::onCheckBoxChange);
428  setFocusProxy(m_checkBox);
429  m_checkBox->setText(tr("True"));
430 }
QCheckBox * m_checkBox
void onCheckBoxChange(bool value)
CustomEditor(QWidget *parent=nullptr)
Definition: CustomEditors.h:31

References m_checkBox, and onCheckBoxChange().

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 BoolEditor::initEditor ( )
protectedvirtual

Inits editor widgets from m_data.

Reimplemented from CustomEditor.

Definition at line 438 of file CustomEditors.cpp.

439 {
440  ASSERT(m_data.type() == QVariant::Bool);
441  bool value = m_data.toBool();
442 
443  m_checkBox->blockSignals(true);
444  m_checkBox->setChecked(value);
445  m_checkBox->setText(value ? "True" : "False");
446  m_checkBox->blockSignals(false);
447 }
#define ASSERT(condition)
Definition: Assert.h:31

References ASSERT, m_checkBox, and CustomEditor::m_data.

◆ onCheckBoxChange

void BoolEditor::onCheckBoxChange ( bool  value)
privateslot

Definition at line 432 of file CustomEditors.cpp.

433 {
434  if (value != m_data.toBool())
435  setDataIntern(QVariant(value));
436 }
void setDataIntern(const QVariant &data)
Saves the data from the editor and informs external delegates.

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

Referenced by BoolEditor().

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(), onCheckBoxChange(), ScientificDoublePropertyEditor::onEditingFinished(), DoubleEditor::onEditingFinished(), ScientificSpinBoxEditor::onEditingFinished(), IntEditor::onEditingFinished(), ComboPropertyEditor::onIndexChanged(), and MultiComboPropertyEditor::onModelDataChanged().

Member Data Documentation

◆ m_checkBox

QCheckBox* BoolEditor::m_checkBox
private

Definition at line 189 of file CustomEditors.h.

Referenced by BoolEditor(), and initEditor().

◆ m_data


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