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

Editor factory for cell editors in Qt trees and tables, relies on EDITORTYPE role stored on board of SessionItem. More...

Inheritance diagram for ModelView::RoleDependentEditorFactory:
[legend]
Collaboration diagram for ModelView::RoleDependentEditorFactory:
[legend]

Public Member Functions

 RoleDependentEditorFactory ()
 
std::unique_ptr< CustomEditorcreateEditor (const QModelIndex &index) const override
 Creates cell editor basing on item role. It is expected that the index belongs to a ViewModel. More...
 

Protected Member Functions

std::unique_ptr< CustomEditorcreateItemEditor (const SessionItem *item) const
 Creates cell editor basing on editor type. More...
 
EditorBuilders::builder_t findBuilder (const std::string &name) const
 
void registerBuilder (const std::string &name, EditorBuilders::builder_t builder)
 

Protected Attributes

std::map< std::string, EditorBuilders::builder_tm_nameToBuilderMap
 

Detailed Description

Editor factory for cell editors in Qt trees and tables, relies on EDITORTYPE role stored on board of SessionItem.

Definition at line 43 of file defaulteditorfactory.h.

Constructor & Destructor Documentation

◆ RoleDependentEditorFactory()

RoleDependentEditorFactory::RoleDependentEditorFactory ( )

Definition at line 51 of file defaulteditorfactory.cpp.

52 {
53  // registering set of builders for given editor types
68 }
void registerBuilder(const std::string &name, EditorBuilders::builder_t builder)
const std::string SelectableComboPropertyEditorType
const std::string ComboPropertyEditorType
const std::string ExternalPropertyEditorType
const std::string ScientficSpinBoxEditorType
const std::string ColorEditorType
const std::string ScientficDoubleEditorType
const std::string BoolEditorType
const std::string DoubleEditorType
const std::string IntegerEditorType
MVVM_VIEWMODEL_EXPORT builder_t ColorEditorBuilder()
Builder for color property editor.
MVVM_VIEWMODEL_EXPORT builder_t BoolEditorBuilder()
Builder for boolean property editor.
MVVM_VIEWMODEL_EXPORT builder_t SelectableComboPropertyEditorBuilder()
Builder for ComboProperty editor with multi-selection functionality.
MVVM_VIEWMODEL_EXPORT builder_t ScientificDoubleEditorBuilder()
Builder for double editor with scientific notation based on simple text field.
MVVM_VIEWMODEL_EXPORT builder_t ComboPropertyEditorBuilder()
Builder for ComboProperty editor.
MVVM_VIEWMODEL_EXPORT builder_t ScientificSpinBoxEditorBuilder()
Builder for double editor with scientific notation and spinbox functionality.
MVVM_VIEWMODEL_EXPORT builder_t ExternalPropertyEditorBuilder()
Builder for external property editor.
MVVM_VIEWMODEL_EXPORT builder_t IntegerEditorBuilder()
Builder for integer property editor.
MVVM_VIEWMODEL_EXPORT builder_t DoubleEditorBuilder()
Builder for double editor with limits support.

References ModelView::EditorBuilders::BoolEditorBuilder(), ModelView::Constants::BoolEditorType, ModelView::EditorBuilders::ColorEditorBuilder(), ModelView::Constants::ColorEditorType, ModelView::EditorBuilders::ComboPropertyEditorBuilder(), ModelView::Constants::ComboPropertyEditorType, ModelView::EditorBuilders::DoubleEditorBuilder(), ModelView::Constants::DoubleEditorType, ModelView::EditorBuilders::ExternalPropertyEditorBuilder(), ModelView::Constants::ExternalPropertyEditorType, ModelView::EditorBuilders::IntegerEditorBuilder(), ModelView::Constants::IntegerEditorType, ModelView::AbstractEditorFactory::registerBuilder(), ModelView::Constants::ScientficDoubleEditorType, ModelView::Constants::ScientficSpinBoxEditorType, ModelView::EditorBuilders::ScientificDoubleEditorBuilder(), ModelView::EditorBuilders::ScientificSpinBoxEditorBuilder(), ModelView::EditorBuilders::SelectableComboPropertyEditorBuilder(), and ModelView::Constants::SelectableComboPropertyEditorType.

Here is the call graph for this function:

Member Function Documentation

◆ createEditor()

std::unique_ptr< CustomEditor > RoleDependentEditorFactory::createEditor ( const QModelIndex &  index) const
overridevirtual

Creates cell editor basing on item role. It is expected that the index belongs to a ViewModel.

Implements ModelView::EditorFactoryInterface.

Definition at line 73 of file defaulteditorfactory.cpp.

74 {
75  auto item = itemFromIndex(index);
76  return item ? createItemEditor(item) : std::unique_ptr<CustomEditor>();
77 }
Base class for all custom variant editors.
Definition: customeditor.h:26
std::unique_ptr< CustomEditor > createItemEditor(const SessionItem *item) const
Creates cell editor basing on editor type.
Definition: filesystem.h:81

References createItemEditor().

Here is the call graph for this function:

◆ createItemEditor()

std::unique_ptr< CustomEditor > RoleDependentEditorFactory::createItemEditor ( const SessionItem item) const
protected

Creates cell editor basing on editor type.

Definition at line 82 of file defaulteditorfactory.cpp.

83 {
84  auto builder = findBuilder(item->editorType());
85  return builder ? builder(item) : std::unique_ptr<CustomEditor>();
86 }
EditorBuilders::builder_t findBuilder(const std::string &name) const
std::string editorType() const
Returns editor type.

References ModelView::SessionItem::editorType(), and ModelView::AbstractEditorFactory::findBuilder().

Referenced by createEditor().

Here is the call graph for this function:

◆ findBuilder()

EditorBuilders::builder_t AbstractEditorFactory::findBuilder ( const std::string &  name) const
protectedinherited

Definition at line 43 of file defaulteditorfactory.cpp.

44 {
45  auto it = m_nameToBuilderMap.find(name);
46  return it != m_nameToBuilderMap.end() ? it->second : EditorBuilders::builder_t();
47 }
std::map< std::string, EditorBuilders::builder_t > m_nameToBuilderMap
std::function< editor_t(const SessionItem *)> builder_t
QString const & name(EShape k)
Definition: particles.cpp:21

References ModelView::AbstractEditorFactory::m_nameToBuilderMap, and RealSpace::Particles::name().

Referenced by ModelView::VariantDependentEditorFactory::createEditor(), and createItemEditor().

Here is the call graph for this function:

◆ registerBuilder()

void AbstractEditorFactory::registerBuilder ( const std::string &  name,
EditorBuilders::builder_t  builder 
)
protectedinherited

Definition at line 37 of file defaulteditorfactory.cpp.

39 {
40  m_nameToBuilderMap[name] = std::move(builder);
41 }

References ModelView::AbstractEditorFactory::m_nameToBuilderMap, and RealSpace::Particles::name().

Referenced by RoleDependentEditorFactory(), and ModelView::VariantDependentEditorFactory::VariantDependentEditorFactory().

Here is the call graph for this function:

Member Data Documentation

◆ m_nameToBuilderMap

std::map<std::string, EditorBuilders::builder_t> ModelView::AbstractEditorFactory::m_nameToBuilderMap
protectedinherited

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