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

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

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

Public Member Functions

 VariantDependentEditorFactory ()
 
std::unique_ptr< CustomEditorcreateEditor (const QModelIndex &index) const override
 Creates cell editor basing on variant name. More...
 

Protected Member Functions

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 variant type stored as DATA role on board of SessionItem.

Definition at line 56 of file defaulteditorfactory.h.

Constructor & Destructor Documentation

◆ VariantDependentEditorFactory()

VariantDependentEditorFactory::VariantDependentEditorFactory ( )

Definition at line 90 of file defaulteditorfactory.cpp.

91 {
92  // registering set of builders for given variant names
101 }
void registerBuilder(const std::string &name, EditorBuilders::builder_t builder)
const std::string bool_type_name
const std::string comboproperty_type_name
const std::string double_type_name
const std::string extproperty_type_name
const std::string qcolor_type_name
const std::string int_type_name
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 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.

References ModelView::Constants::bool_type_name, ModelView::EditorBuilders::BoolEditorBuilder(), ModelView::EditorBuilders::ColorEditorBuilder(), ModelView::Constants::comboproperty_type_name, ModelView::EditorBuilders::ComboPropertyEditorBuilder(), ModelView::Constants::double_type_name, ModelView::EditorBuilders::ExternalPropertyEditorBuilder(), ModelView::Constants::extproperty_type_name, ModelView::Constants::int_type_name, ModelView::EditorBuilders::IntegerEditorBuilder(), ModelView::Constants::qcolor_type_name, ModelView::AbstractEditorFactory::registerBuilder(), and ModelView::EditorBuilders::ScientificSpinBoxEditorBuilder().

Here is the call graph for this function:

Member Function Documentation

◆ createEditor()

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

Creates cell editor basing on variant name.

Implements ModelView::EditorFactoryInterface.

Definition at line 106 of file defaulteditorfactory.cpp.

107 {
108  auto item = itemFromIndex(index);
109  auto value = item ? item->data<QVariant>() : index.data(Qt::EditRole);
110  auto builder = findBuilder(Utils::VariantName(value));
111  return builder ? builder(item) : std::unique_ptr<CustomEditor>();
112 }
EditorBuilders::builder_t findBuilder(const std::string &name) const
Base class for all custom variant editors.
Definition: customeditor.h:26
MVVM_MODEL_EXPORT std::string VariantName(const Variant &variant)
Returns name of variant.
Definition: filesystem.h:81

References ModelView::AbstractEditorFactory::findBuilder(), and ModelView::Utils::VariantName().

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 createEditor(), and ModelView::RoleDependentEditorFactory::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 ModelView::RoleDependentEditorFactory::RoleDependentEditorFactory(), and 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: