17 #include <QAbstractItemModel>
18 #include <QModelIndex>
25 if (modelType.isEmpty())
26 result.append(item->itemName());
27 else if (modelType == item->modelType())
28 result.append(item->itemName());
34 const std::function<
void(
const QModelIndex&)>& fun)
39 if (!model->hasChildren(index))
42 for (
int i = 0; i < model->rowCount(index); ++i)
43 for (
int j = 0; j < model->columnCount(index); ++j)
44 iterate(model->index(i, j, index), model, fun);
48 const std::function<
bool(
const QModelIndex&)>& fun)
50 bool proceed_with_children(
true);
52 proceed_with_children = fun(index);
54 if (!model->hasChildren(index) || !proceed_with_children)
57 for (
int i = 0; i < model->rowCount(index); ++i)
58 for (
int j = 0; j < model->columnCount(index); ++j)
59 iterate_if(model->index(i, j, index), model, fun);
Defines ModelUtils namespace.
Defines class SessionModel.
QVector< T * > topItems() const
QStringList topItemNames(SessionModel *model, const QString &modelType="")
Returns list of top iten manes.
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.
void iterate(const QModelIndex &index, const QAbstractItemModel *model, const std::function< void(const QModelIndex &)> &fun)
Iterates through all model indices and calls user function.