37 [
this](QAbstractItemModel* model,
int source_row,
const QModelIndex& source_parent)
39 QModelIndex index0 = model->index(source_row, 0, source_parent);
41 QStringList searchParts =
42 this->filterRegExp().pattern().split(
" ", QString::SkipEmptyParts);
44 auto result =
containsAll(index0.data().toString(), searchParts);
53 for (
const QString&
s : searchParts)
55 if (!text.contains(
s, Qt::CaseInsensitive))
76 treeView->collapseAll();
77 InfixFilterModel* proxyModel = qobject_cast<InfixFilterModel*>(treeView->model());
83 QList<QModelIndex> indexList;
84 for (
int i = 0; i < proxyModel->rowCount(); ++i)
86 indexList << proxyModel->index(i, 0);
90 while (indexList.size() > 0)
92 QModelIndex&
index = indexList.front();
94 auto sourceIndex = proxyModel->mapToSource(
index);
95 if (proxyModel->
filterAcceptsRow(sourceIndex.row(), sourceIndex.parent(),
false))
98 QModelIndex current =
index.parent();
99 while (current.isValid())
101 treeView->expand(current);
102 current = current.parent();
107 while (
index.child(i, 0).isValid())
109 indexList <<
index.child(i, 0);
112 indexList.pop_front();
124 const QModelIndex& source_parent,
125 bool considerParents)
const
127 QModelIndex index0 = sourceModel()->index(source_row, 0, source_parent);
128 QList<QModelIndex> indexList;
146 auto checkRow = [
this](
int source_row,
const QModelIndex& source_parent)
149 bool accepted =
true;
152 accepted &= f(this->sourceModel(), source_row, source_parent);
162 while (indexList.size() > 0)
164 QModelIndex&
index = indexList.front();
166 bool accepted = checkRow(
index.row(),
index.parent());
177 while (
index.child(i, 0).isValid())
179 indexList <<
index.child(i, 0);
182 indexList.pop_front();
186 QModelIndex currentParent = source_parent;
188 while (currentParent.isValid())
192 if (checkRow(currentParent.row(), currentParent.parent()))
196 currentParent = currentParent.parent();