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

Property editor to modify property of the object currently selected on the graphics scene. More...

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

Public Slots

void selectionChanged (const QItemSelection &selected, const QItemSelection &)
 

Public Member Functions

 SamplePropertyWidget (QItemSelectionModel *selection_model, QWidget *parent=nullptr)
 
QSize minimumSizeHint () const
 
void setSelectionModel (QItemSelectionModel *selection_model)
 
QSize sizeHint () const
 

Private Attributes

ComponentEditorm_propertyEditor
 
QItemSelectionModel * m_selection_model
 

Detailed Description

Property editor to modify property of the object currently selected on the graphics scene.

Located in the bottom right corner of SampleView.

Definition at line 27 of file SamplePropertyWidget.h.

Constructor & Destructor Documentation

◆ SamplePropertyWidget()

SamplePropertyWidget::SamplePropertyWidget ( QItemSelectionModel *  selection_model,
QWidget *  parent = nullptr 
)

Definition at line 23 of file SamplePropertyWidget.cpp.

24  : QWidget(parent)
25  , m_selection_model(nullptr)
27 {
28  setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
29  setWindowTitle(QLatin1String("Property Editor"));
30  setObjectName(QLatin1String("SamplePropertyWidget"));
31 
32  setSelectionModel(selection_model);
33 
34  auto mainLayout = new QVBoxLayout;
35  mainLayout->setMargin(0);
36  mainLayout->setSpacing(0);
37  mainLayout->addWidget(m_propertyEditor);
38 
39  setLayout(mainLayout);
40 }
Component editor for SessionItem.
void setSelectionModel(QItemSelectionModel *selection_model)
ComponentEditor * m_propertyEditor
QItemSelectionModel * m_selection_model

References m_propertyEditor, and setSelectionModel().

Here is the call graph for this function:

Member Function Documentation

◆ minimumSizeHint()

QSize SamplePropertyWidget::minimumSizeHint ( ) const

Definition at line 47 of file SamplePropertyWidget.cpp.

48 {
49  return QSize(230, 64);
50 }

◆ selectionChanged

void SamplePropertyWidget::selectionChanged ( const QItemSelection &  selected,
const QItemSelection &   
)
slot

Definition at line 72 of file SamplePropertyWidget.cpp.

73 {
74  QModelIndexList indices = selected.indexes();
75 
76  if (!indices.empty()) {
77  QModelIndex index = indices.back();
78 
79  if (auto proxy = dynamic_cast<QSortFilterProxyModel*>(
80  const_cast<QAbstractItemModel*>(indices.front().model())))
81  index = proxy->mapToSource(indices.back());
82 
83  SessionItem* item = static_cast<SessionItem*>(index.internalPointer());
84  if (item)
86 
87  } else {
88  m_propertyEditor->setItem(nullptr);
89  }
90 }
void setItem(SessionItem *item)

References m_propertyEditor, and ComponentEditor::setItem().

Referenced by setSelectionModel().

Here is the call graph for this function:

◆ setSelectionModel()

void SamplePropertyWidget::setSelectionModel ( QItemSelectionModel *  selection_model)

Definition at line 52 of file SamplePropertyWidget.cpp.

53 {
54  if (selection_model == m_selection_model)
55  return;
56 
57  if (m_selection_model) {
58  disconnect(m_selection_model, &QItemSelectionModel::selectionChanged, this,
60  }
61 
62  m_selection_model = selection_model;
63 
64  if (m_selection_model) {
65  connect(m_selection_model, &QItemSelectionModel::selectionChanged, this,
67  }
68 }
void selectionChanged(const QItemSelection &selected, const QItemSelection &)

References m_selection_model, and selectionChanged().

Referenced by SamplePropertyWidget().

Here is the call graph for this function:

◆ sizeHint()

QSize SamplePropertyWidget::sizeHint ( ) const

Definition at line 42 of file SamplePropertyWidget.cpp.

43 {
44  return QSize(230, 256);
45 }

Member Data Documentation

◆ m_propertyEditor

ComponentEditor* SamplePropertyWidget::m_propertyEditor
private

Definition at line 42 of file SamplePropertyWidget.h.

Referenced by SamplePropertyWidget(), and selectionChanged().

◆ m_selection_model

QItemSelectionModel* SamplePropertyWidget::m_selection_model
private

Definition at line 41 of file SamplePropertyWidget.h.

Referenced by setSelectionModel().


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