BornAgain  1.19.79
Simulate and fit neutron and x-ray scattering at grazing incidence
GUI::Model::Path Namespace Reference

Functions

SessionItemancestor (SessionItem *item, const QString &requiredModelType)
 Returns ancestor of given modelType for given item. More...
 
bool isValidItem (SessionModel *model, SessionItem *item, const QModelIndex &parent)
 Iterates through all the model and returns true if item is found. This is to. More...
 

Function Documentation

◆ ancestor()

SessionItem * GUI::Model::Path::ancestor ( SessionItem item,
const QString &  requiredModelType 
)

Returns ancestor of given modelType for given item.

For example, returns corresponding jobItem owning ParameterItem via ParameterContainer.

Definition at line 32 of file ModelPath.cpp.

33 {
34  SessionItem* cur = item;
35  while (cur && cur->modelType() != requiredModelType)
36  cur = cur->parentItem();
37 
38  return cur;
39 }
Base class for a GUI data item.
Definition: SessionItem.h:204
SessionItem * parentItem() const
Returns parent of this item.
Definition: SessionItem.cpp:67
QString modelType() const
Get model type.

References SessionItem::modelType(), and SessionItem::parentItem().

Here is the call graph for this function:

◆ isValidItem()

bool GUI::Model::Path::isValidItem ( SessionModel model,
SessionItem item,
const QModelIndex &  parent 
)

Iterates through all the model and returns true if item is found. This is to.

Definition at line 20 of file ModelPath.cpp.

22 {
23  for (int i_row = 0; i_row < model->rowCount(parent); ++i_row) {
24  QModelIndex index = model->index(i_row, 0, parent);
25  SessionItem* curr = model->itemForIndex(index);
26  if (curr == item || isValidItem(model, item, index))
27  return true;
28  }
29  return false;
30 }
SessionItem * itemForIndex(const QModelIndex &index) const
QModelIndex index(int row, int column, const QModelIndex &parent) const override
int rowCount(const QModelIndex &parent) const override
bool isValidItem(SessionModel *model, SessionItem *item, const QModelIndex &parent)
Iterates through all the model and returns true if item is found. This is to.
Definition: ModelPath.cpp:20

References SessionModel::index(), SessionModel::itemForIndex(), and SessionModel::rowCount().

Referenced by FitParameterModel::isValidSourceItem().

Here is the call graph for this function: