BornAgain  1.19.79
Simulate and fit neutron and x-ray scattering at grazing incidence
ModelPath.cpp
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file GUI/Model/Model/ModelPath.cpp
6 //! @brief Implements class ModelPath
7 //!
8 //! @homepage http://www.bornagainproject.org
9 //! @license GNU General Public License v3 or higher (see COPYING)
10 //! @copyright Forschungszentrum Jülich GmbH 2018
11 //! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS)
12 //
13 // ************************************************************************************************
14 
17 
18 //! Iterates through all the model and returns true if item is found. This is to
19 
21  const QModelIndex& parent)
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 }
31 
32 SessionItem* GUI::Model::Path::ancestor(SessionItem* item, const QString& requiredModelType)
33 {
34  SessionItem* cur = item;
35  while (cur && cur->modelType() != requiredModelType)
36  cur = cur->parentItem();
37 
38  return cur;
39 }
Defines namespace GUI::Model::Path.
Defines class SessionModel.
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.
Base class for a GUI data collection. A collection is e.g. all real data (RealDataModel)....
Definition: SessionModel.h:42
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
SessionItem * ancestor(SessionItem *item, const QString &requiredModelType)
Returns ancestor of given modelType for given item.
Definition: ModelPath.cpp:32