//SubClass of QSortFilterProxyModel
bool TreeProxyFilter::filterAcceptsRow(int sourceRow,
{
QModelIndex index
= sourceModel
()->index
(sourceRow,
0, sourceParent
);
return ShowThis(index);
}
bool TreeProxyFilter
::ShowThis(const QModelIndex index
) const {
bool retVal = false;
//Gives you the info for number of childs with a parent
if ( sourceModel()->rowCount(index) > 0 )
{
for( int nChild = 0; nChild < sourceModel()->rowCount(index); nChild++)
{
QModelIndex childIndex
= sourceModel
()->index
(nChild,
0,index
);
if ( ! childIndex.isValid() )
break;
retVal = ShowThis(childIndex);
if (retVal)
{
break;
}
}
}
else
{
QModelIndex useIndex
= sourceModel
()->index
(index.
row(),
0, index.
parent());
QString type
= sourceModel
()->data
(useIndex, Qt
::DisplayRole).
toString();
if ( ! type.contains(filterRegExp()))
{
retVal = false;
}
else
{
retVal = true;
}
}
return retVal;
}