def filterAcceptsRow(self, srcRow, srcParentIndex): srcModel = self.sourceModel() parentItem = srcModel.itemFromIndex(srcParentIndex) if parentItem: childItem = parentItem.child(srcRow, srcParentIndex.column()) return childItem.hasChildren() return BaseProxyModel.filterAcceptsRow(self, srcRow, srcParentIndex)
def setSourceModel(self, model): BaseProxyModel.setSourceModel(self, model) self.filterRootIndex = model.indexFromItem(self.sourceModel().invisibleRootItem())