Hi. i have a treeview. What I need is to hide parents if they don't match but their child do. As I guess it leads to tree reconstruction - changing parent of visible children. How is it better to do it?
Currently I have this, but of course it does show parents if children matches

Qt Code:
  1. bool TreeFilteredModel::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const
  2. {
  3. bool ret = false;
  4. QModelIndex subIndex = sourceModel()->index(sourceRow, 0, sourceParent);
  5. WorkflowTreeItem* item = (WorkflowTreeItem*)subIndex.internalPointer();
  6. int childCound = sourceModel()->rowCount(subIndex);
  7. if (subIndex.isValid())
  8. {
  9. for (int i = 0; i < childCound; ++i)
  10. {
  11. ret = ret || filterAcceptsRow(i, subIndex);
  12. }
  13. }
  14. ret |= (item->command()->getName().contains(m_commandSearchParameter, Qt::CaseInsensitive) && item->command()->getName().contains(m_textSearchParameter, Qt::CaseInsensitive));
  15. return ret;
  16. }
To copy to clipboard, switch view to plain text mode 

thanks