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

Constructs row of QStandardItem's for given SessionItem. More...

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

Public Member Functions

 PropertiesRowStrategy (std::vector< std::string > labels={})
 
std::vector< std::unique_ptr< ViewItem > > constructRow (SessionItem *item) override
 
QStringList horizontalHeaderLabels () const override
 

Private Member Functions

void update_column_labels (std::vector< ModelView::SessionItem * > items)
 Updates current column labels. More...
 

Private Attributes

std::vector< std::string > current_column_labels
 
std::vector< std::string > user_defined_column_labels
 

Detailed Description

Constructs row of QStandardItem's for given SessionItem.

Row consists of columns with all PropertyItem's of given SessionItem.

Definition at line 29 of file propertiesrowstrategy.h.

Constructor & Destructor Documentation

◆ PropertiesRowStrategy()

PropertiesRowStrategy::PropertiesRowStrategy ( std::vector< std::string >  labels = {})

Definition at line 22 of file propertiesrowstrategy.cpp.

23  : user_defined_column_labels(std::move(labels))
24 {
25 }
std::vector< std::string > user_defined_column_labels

Member Function Documentation

◆ constructRow()

std::vector< std::unique_ptr< ViewItem > > PropertiesRowStrategy::constructRow ( SessionItem item)
overridevirtual

Implements ModelView::RowStrategyInterface.

Definition at line 37 of file propertiesrowstrategy.cpp.

38 {
39  std::vector<std::unique_ptr<ViewItem>> result;
40 
41  if (!item)
42  return result;
43 
44  auto items_in_row = Utils::SinglePropertyItems(*item);
45  if (user_defined_column_labels.empty())
46  update_column_labels(items_in_row);
47 
48  for (auto child : items_in_row) {
49  if (child->hasData())
50  result.emplace_back(std::make_unique<ViewDataItem>(child));
51  else
52  result.emplace_back(std::make_unique<ViewLabelItem>(child));
53  }
54 
55  return result;
56 }
void update_column_labels(std::vector< ModelView::SessionItem * > items)
Updates current column labels.
MVVM_MODEL_EXPORT std::vector< SessionItem * > SinglePropertyItems(const SessionItem &item)
Returns vector of children representing property items.
Definition: itemutils.cpp:122

References ModelView::Utils::SinglePropertyItems(), update_column_labels(), and user_defined_column_labels.

Referenced by TEST_F().

Here is the call graph for this function:

◆ horizontalHeaderLabels()

QStringList PropertiesRowStrategy::horizontalHeaderLabels ( ) const
overridevirtual

Implements ModelView::RowStrategyInterface.

Definition at line 27 of file propertiesrowstrategy.cpp.

28 {
29  QStringList result;
30  auto labels =
32  std::transform(labels.begin(), labels.end(), std::back_inserter(result),
33  [](const std::string& str) { return QString::fromStdString(str); });
34  return result;
35 }
std::vector< std::string > current_column_labels

References current_column_labels, and user_defined_column_labels.

Referenced by TEST_F().

◆ update_column_labels()

void PropertiesRowStrategy::update_column_labels ( std::vector< ModelView::SessionItem * >  items)
private

Updates current column labels.

Definition at line 60 of file propertiesrowstrategy.cpp.

61 {
62  current_column_labels.clear();
63  std::transform(items.begin(), items.end(), std::back_inserter(current_column_labels),
64  [](const SessionItem* item) { return item->displayName(); });
65 }
The main object representing an editable/displayable/serializable entity.
Definition: sessionitem.h:38

References current_column_labels.

Referenced by constructRow().

Member Data Documentation

◆ current_column_labels

std::vector<std::string> ModelView::PropertiesRowStrategy::current_column_labels
private

Definition at line 39 of file propertiesrowstrategy.h.

Referenced by horizontalHeaderLabels(), and update_column_labels().

◆ user_defined_column_labels

std::vector<std::string> ModelView::PropertiesRowStrategy::user_defined_column_labels
private

Definition at line 40 of file propertiesrowstrategy.h.

Referenced by constructRow(), and horizontalHeaderLabels().


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