BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
ModelUtils.h
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file GUI/coregui/Models/ModelUtils.h
6 //! @brief Defines ModelUtils namespace
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 
15 #ifndef BORNAGAIN_GUI_COREGUI_MODELS_MODELUTILS_H
16 #define BORNAGAIN_GUI_COREGUI_MODELS_MODELUTILS_H
17 
18 #include <QString>
19 #include <functional>
20 
21 class QModelIndex;
22 class QAbstractItemModel;
23 class SessionModel;
24 
25 namespace ModelUtils {
26 //! Returns list of top iten manes.
27 QStringList topItemNames(SessionModel* model, const QString& modelType = "");
28 
29 //! Iterates through all model indices and calls user function.
30 void iterate(const QModelIndex& index, const QAbstractItemModel* model,
31  const std::function<void(const QModelIndex&)>& fun);
32 
33 //! Iterates through all model indices and calls user function.
34 //! If function returns false for given index, iteration will not go down to children.
35 void iterate_if(const QModelIndex& index, const QAbstractItemModel* model,
36  const std::function<bool(const QModelIndex&)>& fun);
37 
38 } // namespace ModelUtils
39 
40 #endif // BORNAGAIN_GUI_COREGUI_MODELS_MODELUTILS_H
QStringList topItemNames(SessionModel *model, const QString &modelType="")
Returns list of top iten manes.
Definition: ModelUtils.cpp:20
void iterate_if(const QModelIndex &index, const QAbstractItemModel *model, const std::function< bool(const QModelIndex &)> &fun)
Iterates through all model indices and calls user function.
Definition: ModelUtils.cpp:47
void iterate(const QModelIndex &index, const QAbstractItemModel *model, const std::function< void(const QModelIndex &)> &fun)
Iterates through all model indices and calls user function.
Definition: ModelUtils.cpp:33