filter parent items, too

This commit is contained in:
Martchus 2016-03-15 15:33:13 +01:00
parent 55c41d8fa2
commit 9ababd9279
2 changed files with 13 additions and 3 deletions

View File

@ -22,9 +22,15 @@ bool EntryFilterModel::filterAcceptsRow(int sourceRow, const QModelIndex &source
if(QSortFilterProxyModel::filterAcceptsRow(sourceRow, sourceParent)) {
return true;
}
QModelIndex sourceIndex = sourceModel()->index(sourceRow, 0, sourceParent);
if(sourceModel()->hasChildren(sourceIndex)) {
return true;
return hasAcceptedChildren(sourceModel()->index(sourceRow, 0, sourceParent));
}
bool EntryFilterModel::hasAcceptedChildren(const QModelIndex &index) const
{
for(int i = 0, rowCount = sourceModel()->rowCount(index); i < rowCount; ++i) {
if(filterAcceptsRow(i, index)) {
return true;
}
}
return false;
}

View File

@ -13,6 +13,10 @@ public:
protected:
bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const;
private:
bool hasAcceptedChildren(const QModelIndex &index) const;
};
}