BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
gui2::CustomLayerTreeEditorFactory Class Reference

Custom editor factory for LayerTreeView. More...

Inheritance diagram for gui2::CustomLayerTreeEditorFactory:
[legend]
Collaboration diagram for gui2::CustomLayerTreeEditorFactory:
[legend]

Public Member Functions

 CustomLayerTreeEditorFactory (ApplicationModels *models)
 
 ~CustomLayerTreeEditorFactory ()
 
std::unique_ptr< ModelView::CustomEditorcreateEditor (const QModelIndex &index) const
 

Private Attributes

ApplicationModelsm_models
 
std::unique_ptr< RoleDependentEditorFactorym_roleDependentFactory
 
std::unique_ptr< VariantDependentEditorFactorym_variantDependentFactory
 

Detailed Description

Custom editor factory for LayerTreeView.

Substitutes default ExternalProperty editor with custom one, which will offer the choice between all defined materials.

Definition at line 28 of file customlayertreeeditorfactory.h.

Constructor & Destructor Documentation

◆ CustomLayerTreeEditorFactory()

gui2::CustomLayerTreeEditorFactory::CustomLayerTreeEditorFactory ( ApplicationModels models)

Definition at line 41 of file customlayertreeeditorfactory.cpp.

42  : m_models(models)
43 {
44 }

◆ ~CustomLayerTreeEditorFactory()

gui2::CustomLayerTreeEditorFactory::~CustomLayerTreeEditorFactory ( )
default

Member Function Documentation

◆ createEditor()

std::unique_ptr< CustomEditor > gui2::CustomLayerTreeEditorFactory::createEditor ( const QModelIndex &  index) const
virtual

Implements ModelView::EditorFactoryInterface.

Definition at line 47 of file customlayertreeeditorfactory.cpp.

48 {
49  auto value = index.data(Qt::EditRole);
50  if (Utils::IsExtPropertyVariant(value)) {
51  auto material_choice_callback = [this]() {
52  return get_choice_of_materials(m_models->materialModel());
53  };
54  return std::make_unique<ExternalPropertyComboEditor>(material_choice_callback);
55  } else {
57  }
58 }
std::unique_ptr< CustomEditor > createEditor(const QModelIndex &index) const override
Creates editor for given model index basing either on editorType() or specific variant name.
MaterialModel * materialModel()
MVVM_MODEL_EXPORT bool IsExtPropertyVariant(const Variant &variant)
Returns true in the case of ExternalProperty based variant.

References ModelView::DefaultEditorFactory::createEditor(), ModelView::Utils::IsExtPropertyVariant(), m_models, and gui2::ApplicationModels::materialModel().

Here is the call graph for this function:

Member Data Documentation

◆ m_models

ApplicationModels* gui2::CustomLayerTreeEditorFactory::m_models
private

Definition at line 36 of file customlayertreeeditorfactory.h.

Referenced by createEditor().

◆ m_roleDependentFactory

std::unique_ptr<RoleDependentEditorFactory> ModelView::DefaultEditorFactory::m_roleDependentFactory
privateinherited

◆ m_variantDependentFactory

std::unique_ptr<VariantDependentEditorFactory> ModelView::DefaultEditorFactory::m_variantDependentFactory
privateinherited

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