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 @@ ...@@ -3,7 +3,7 @@
// BornAgain: simulate and fit reflection and scattering // BornAgain: simulate and fit reflection and scattering
// //
//! @file GUI/View/Sample/ISelectionForm.cpp //! @file GUI/View/Sample/ISelectionForm.cpp
//! @brief Implements class ISelectionForm, except for templated functions. //! @brief Implements class ISelectionForm.
//! //!
//! @homepage http://www.bornagainproject.org //! @homepage http://www.bornagainproject.org
//! @license GNU General Public License v3 or higher (see COPYING) //! @license GNU General Public License v3 or higher (see COPYING)
...@@ -21,6 +21,29 @@ ISelectionForm::ISelectionForm(QWidget* parent, SampleEditorController* ec) ...@@ -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() void ISelectionForm::clear()
{ {
auto* layoutItemOfComboBox = m_grid_layout->itemAtPosition(1, 0); auto* layoutItemOfComboBox = m_grid_layout->itemAtPosition(1, 0);
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
// BornAgain: simulate and fit reflection and scattering // BornAgain: simulate and fit reflection and scattering
// //
//! @file GUI/View/Sample/ISelectionForm.h //! @file GUI/View/Sample/ISelectionForm.h
//! @brief Defines class ISelectionForm, and implements templated functions. //! @brief Defines class ISelectionForm.
//! //!
//! @homepage http://www.bornagainproject.org //! @homepage http://www.bornagainproject.org
//! @license GNU General Public License v3 or higher (see COPYING) //! @license GNU General Public License v3 or higher (see COPYING)
...@@ -22,11 +22,8 @@ ...@@ -22,11 +22,8 @@
#include <QComboBox> #include <QComboBox>
#include <QGridLayout> #include <QGridLayout>
//! Abstract widget base class to contain a selection, defined by a SelectionDescriptor. //! Abstract widget class that provides a combo box for selecting a polymorphous class.
//!
//! 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).
class ISelectionForm : public QWidget { class ISelectionForm : public QWidget {
public: public:
virtual void createContent() = 0; virtual void createContent() = 0;
...@@ -34,37 +31,15 @@ public: ...@@ -34,37 +31,15 @@ public:
protected: protected:
ISelectionForm(QWidget* parent, SampleEditorController* ec); ISelectionForm(QWidget* parent, SampleEditorController* ec);
void initUI(PolyBase& d) 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());
QObject::connect(m_combo, &QComboBox::currentIndexChanged, [this, &d](int current) { QGridLayout* m_grid_layout;
clear(); QComboBox* m_combo;
d.setCertainIndex(current); SampleEditorController* m_ec;
createContent();
emit gDoc->sampleChanged();
});
m_grid_layout->addWidget(m_combo, 1, 0);
createContent();
}
private: private:
//! Remove all properties from the layout //! Remove all properties from the layout
void clear(); void clear();
protected:
QGridLayout* m_grid_layout;
QComboBox* m_combo;
SampleEditorController* m_ec;
}; };
#endif // BORNAGAIN_GUI_VIEW_SAMPLE_ISELECTIONFORM_H #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