filter parent items, too
This commit is contained in:
parent
55c41d8fa2
commit
9ababd9279
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -13,6 +13,10 @@ public:
|
|||
|
||||
protected:
|
||||
bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const;
|
||||
|
||||
private:
|
||||
bool hasAcceptedChildren(const QModelIndex &index) const;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue