BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
DefaultEditorFactoryTest Class Reference
Inheritance diagram for DefaultEditorFactoryTest:
[legend]
Collaboration diagram for DefaultEditorFactoryTest:
[legend]

Public Member Functions

 DefaultEditorFactoryTest ()
 
 ~DefaultEditorFactoryTest ()
 
std::unique_ptr< CustomEditorcreateEditor (const QVariant &variant, RealLimits limits=RealLimits::limitless(), const std::string &editor_type={})
 Helper function to build temporary model and create editor for cell. More...
 

Static Public Member Functions

static void SetUpTestSuite ()
 
static void TearDownTestSuite ()
 

Protected Attributes

std::unique_ptr< DefaultEditorFactorym_factory
 

Static Protected Attributes

static QApplication * m_app = nullptr
 

Detailed Description

Definition at line 42 of file defaulteditorfactory.test.cpp.

Constructor & Destructor Documentation

◆ DefaultEditorFactoryTest()

DefaultEditorFactoryTest::DefaultEditorFactoryTest ( )
inline

Definition at line 44 of file defaulteditorfactory.test.cpp.

44 : m_factory(std::make_unique<DefaultEditorFactory>()) {}
std::unique_ptr< DefaultEditorFactory > m_factory

◆ ~DefaultEditorFactoryTest()

DefaultEditorFactoryTest::~DefaultEditorFactoryTest ( )
default

Member Function Documentation

◆ createEditor()

std::unique_ptr<CustomEditor> DefaultEditorFactoryTest::createEditor ( const QVariant &  variant,
RealLimits  limits = RealLimits::limitless(),
const std::string &  editor_type = {} 
)
inline

Helper function to build temporary model and create editor for cell.

Definition at line 48 of file defaulteditorfactory.test.cpp.

50  {})
51  {
52  // populating model with data
53  SessionModel model;
54  auto propertyItem = model.insertItem<PropertyItem>();
55  propertyItem->setData(variant);
56  if (limits.hasLowerLimit() || limits.hasUpperLimit())
57  propertyItem->setLimits(limits);
58  if (!editor_type.empty())
59  propertyItem->setEditorType(editor_type);
60 
61  // create view model and use index of data cell to create an editor
62  DefaultViewModel viewModel(&model);
63  return m_factory->createEditor(viewModel.index(0, 1));
64  }
View model to show content of SessionModel in Qt widgets: two column tree with label/data.
Item to carry concrete editable entity (e.g.
Definition: propertyitem.h:27
bool hasUpperLimit() const
if has upper limit
Definition: reallimits.cpp:81
bool hasLowerLimit() const
if has lower limit
Definition: reallimits.cpp:71
bool setData(const T &value, int role=ItemDataRole::DATA, bool direct=false)
Sets data for a given role.
Definition: sessionitem.h:141
Main class to hold hierarchy of SessionItem objects.
Definition: sessionmodel.h:37
T * insertItem(SessionItem *parent=nullptr, const TagRow &tagrow={})
Inserts item into given parent under given tagrow.
Definition: sessionmodel.h:104

◆ SetUpTestSuite()

void WidgetBasedTest::SetUpTestSuite ( )
staticinherited

Definition at line 29 of file widgetbasedtest.cpp.

30 {
31  m_app = new QApplication(argc, argv);
32 }
static QApplication * m_app

References WidgetBasedTest::m_app.

◆ TearDownTestSuite()

void WidgetBasedTest::TearDownTestSuite ( )
staticinherited

Definition at line 34 of file widgetbasedtest.cpp.

35 {
36  delete m_app;
37  m_app = 0;
38 }

References WidgetBasedTest::m_app.

Member Data Documentation

◆ m_app

QApplication * WidgetBasedTest::m_app = nullptr
staticprotectedinherited

◆ m_factory

std::unique_ptr<DefaultEditorFactory> DefaultEditorFactoryTest::m_factory
protected

Definition at line 67 of file defaulteditorfactory.test.cpp.


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