34 addCustomFilter([
this](QAbstractItemModel * model,
int source_row,
const QModelIndex & source_parent)
36 QModelIndex index0 = model->index(source_row, 0, source_parent);
38 QStringList searchParts = this->filterRegExp().pattern().split(
" ", QString::SkipEmptyParts);
40 auto result =
containsAll(index0.data().toString(), searchParts);
48 for (
const QString&
s : searchParts)
50 if (!text.contains(
s, Qt::CaseInsensitive))
69 treeView->collapseAll();
70 InfixFilterModel* proxyModel = qobject_cast<InfixFilterModel*>(treeView->model());
76 QList<QModelIndex> indexList;
77 for (
int i = 0; i < proxyModel->rowCount(); ++i)
79 indexList << proxyModel->index(i, 0);
83 while (indexList.size() > 0)
85 QModelIndex&
index = indexList.front();
87 auto sourceIndex = proxyModel->mapToSource(
index);
88 if (proxyModel->
filterAcceptsRow(sourceIndex.row(), sourceIndex.parent(),
false))
91 QModelIndex current =
index.parent();
92 while (current.isValid())
94 treeView->expand(current);
95 current = current.parent();
100 while (
index.child(i, 0).isValid())
102 indexList <<
index.child(i, 0);
105 indexList.pop_front();
116 QModelIndex index0 = sourceModel()->index(source_row, 0, source_parent);
117 QList<QModelIndex> indexList;
135 auto checkRow = [
this](
int source_row,
const QModelIndex & source_parent)
138 bool accepted =
true;
141 accepted &= f(this->sourceModel(), source_row, source_parent);
151 while (indexList.size() > 0)
153 QModelIndex&
index = indexList.front();
155 bool accepted = checkRow(
index.row(),
index.parent());
166 while (
index.child(i, 0).isValid())
168 indexList <<
index.child(i, 0);
171 indexList.pop_front();
175 QModelIndex currentParent = source_parent;
177 while (currentParent.isValid())
181 if (checkRow(currentParent.row(), currentParent.parent()))
185 currentParent = currentParent.parent();