Skip to content
Snippets Groups Projects
Commit 7879b40c authored by Wuttke, Joachim's avatar Wuttke, Joachim
Browse files

[j.0] ctd ()

Merging branch 'j.0'  into 'main'.

See merge request !2699
parents de4bbf10 8ab24288
No related branches found
No related tags found
1 merge request!2699ctd
Pipeline #153810 passed
......@@ -3,7 +3,7 @@
// BornAgain: simulate and fit reflection and scattering
//
//! @file GUI/View/Sample/ISelectionForm.cpp
//! @brief Implements class ISelectionForm, except for templated functions.
//! @brief Implements class ISelectionForm.
//!
//! @homepage http://www.bornagainproject.org
//! @license GNU General Public License v3 or higher (see COPYING)
......@@ -21,6 +21,29 @@ ISelectionForm::ISelectionForm(QWidget* parent, SampleEditorController* ec)
{
}
void ISelectionForm::initUI(PolyBase& d)
{
m_grid_layout = new QGridLayout(this);
m_grid_layout->setContentsMargins(0, 0, 0, 0);
m_grid_layout->setSpacing(6);
m_combo = new QComboBox;
WheelEventEater::install(m_combo);
m_combo->addItems(d.menuEntries());
m_combo->setCurrentIndex(d.certainIndex());
m_combo->setMaxVisibleItems(m_combo->count());
QObject::connect(m_combo, &QComboBox::currentIndexChanged, [this, &d](int current) {
clear();
d.setCertainIndex(current);
createContent();
emit gDoc->sampleChanged();
});
m_grid_layout->addWidget(m_combo, 1, 0);
createContent();
}
void ISelectionForm::clear()
{
auto* layoutItemOfComboBox = m_grid_layout->itemAtPosition(1, 0);
......
......@@ -3,7 +3,7 @@
// BornAgain: simulate and fit reflection and scattering
//
//! @file GUI/View/Sample/ISelectionForm.h
//! @brief Defines class ISelectionForm, and implements templated functions.
//! @brief Defines class ISelectionForm.
//!
//! @homepage http://www.bornagainproject.org
//! @license GNU General Public License v3 or higher (see COPYING)
......@@ -22,11 +22,8 @@
#include <QComboBox>
#include <QGridLayout>
//! 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).
//! Abstract widget class that provides a combo box for selecting a polymorphous class.
class ISelectionForm : public QWidget {
public:
virtual void createContent() = 0;
......@@ -34,37 +31,15 @@ public:
protected:
ISelectionForm(QWidget* parent, SampleEditorController* ec);
void initUI(PolyBase& d)
{
m_grid_layout = new QGridLayout(this);
m_grid_layout->setContentsMargins(0, 0, 0, 0);
m_grid_layout->setSpacing(6);
m_combo = new QComboBox;
WheelEventEater::install(m_combo);
m_combo->addItems(d.menuEntries());
m_combo->setCurrentIndex(d.certainIndex());
m_combo->setMaxVisibleItems(m_combo->count());
void initUI(PolyBase& d);
QObject::connect(m_combo, &QComboBox::currentIndexChanged, [this, &d](int current) {
clear();
d.setCertainIndex(current);
createContent();
emit gDoc->sampleChanged();
});
m_grid_layout->addWidget(m_combo, 1, 0);
createContent();
}
QGridLayout* m_grid_layout;
QComboBox* m_combo;
SampleEditorController* m_ec;
private:
//! Remove all properties from the layout
void clear();
protected:
QGridLayout* m_grid_layout;
QComboBox* m_combo;
SampleEditorController* m_ec;
};
#endif // BORNAGAIN_GUI_VIEW_SAMPLE_ISELECTIONFORM_H
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment