BornAgain  1.19.79
Simulate and fit neutron and x-ray scattering at grazing incidence
AbstractSelectionContainerForm Class Referenceabstract

Description

Abstract widget base class to contain a selection, defined by a SelectionDescriptor.

This abstract base class contains only the selection combo box and the infrastructure to call the SampleEditorController to change the current selection. A derived class has to implement the showing of the contents (method createContent).

Definition at line 30 of file SelectionContainerForm.h.

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

Public Member Functions

virtual void createContent ()=0
 

Protected Member Functions

 AbstractSelectionContainerForm (QWidget *parent, SampleEditorController *ec)
 
template<typename T >
void initUI (const SelectionDescriptor< T > &d)
 

Protected Attributes

QComboBox * m_combo
 
SampleEditorControllerm_ec
 
QGridLayout * m_gridLayout
 

Private Member Functions

void clear ()
 Remove all descriptors from the layout. More...
 

Constructor & Destructor Documentation

◆ AbstractSelectionContainerForm()

AbstractSelectionContainerForm::AbstractSelectionContainerForm ( QWidget *  parent,
SampleEditorController ec 
)
inlineprotected

Definition at line 35 of file SelectionContainerForm.h.

36  : QWidget(parent)
37  , m_ec(ec)
38  {
39  }

Member Function Documentation

◆ clear()

void AbstractSelectionContainerForm::clear ( )
inlineprivate

Remove all descriptors from the layout.

Definition at line 66 of file SelectionContainerForm.h.

67  {
68  auto* layoutItemOfComboBox = m_gridLayout->itemAtPosition(1, 0);
69  m_gridLayout->takeAt(m_gridLayout->indexOf(layoutItemOfComboBox));
71  m_gridLayout->addWidget(layoutItemOfComboBox->widget(), 1, 0);
72  }
void clearLayout(QLayout *layout, bool deleteWidgets=true)
Removes content from box layout.
Definition: LayoutUtils.cpp:68

References GUI::Util::Layout::clearLayout(), and m_gridLayout.

Referenced by initUI().

Here is the call graph for this function:

◆ createContent()

virtual void AbstractSelectionContainerForm::createContent ( )
pure virtual

◆ initUI()

template<typename T >
void AbstractSelectionContainerForm::initUI ( const SelectionDescriptor< T > &  d)
inlineprotected

Definition at line 42 of file SelectionContainerForm.h.

43  {
44  m_gridLayout = new QGridLayout(this);
45  m_gridLayout->setContentsMargins(0, 0, 0, 0);
46  m_gridLayout->setSpacing(6);
47 
48  m_combo = new QComboBox;
50  m_combo->addItems(d.options);
51  m_combo->setCurrentIndex(d.currentIndex());
52  m_combo->setMaxVisibleItems(m_combo->count());
53 
54  QObject::connect(m_combo, QOverload<int>::of(&QComboBox::currentIndexChanged),
55  [=](int current) {
56  clear();
57  m_ec->setCurrentIndex(this, current, d);
58  });
59 
60  m_gridLayout->addWidget(m_combo, 1, 0);
61  createContent();
62  }
void clear()
Remove all descriptors from the layout.
virtual void createContent()=0
void setCurrentIndex(AbstractSelectionContainerForm *widget, int index, const AbstractSelectionDescriptor &d)
int currentIndex() const override
Get currently selected option.
QStringList options
List of options, usually presented as combo entries.
static void install(QObject *obj)

References clear(), createContent(), SelectionDescriptor< T >::currentIndex(), WheelEventEater::install(), m_combo, m_ec, m_gridLayout, SelectionDescriptor< T >::options, and SampleEditorController::setCurrentIndex().

Referenced by LatticeTypeSelectionForm::LatticeTypeSelectionForm(), and SelectionContainerForm::SelectionContainerForm().

Here is the call graph for this function:

Member Data Documentation

◆ m_combo

QComboBox* AbstractSelectionContainerForm::m_combo
protected

Definition at line 76 of file SelectionContainerForm.h.

Referenced by initUI().

◆ m_ec

SampleEditorController* AbstractSelectionContainerForm::m_ec
protected

◆ m_gridLayout

QGridLayout* AbstractSelectionContainerForm::m_gridLayout
protected

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