示例#1
0
    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)
示例#2
0
 def setSourceModel(self, model):
     BaseProxyModel.setSourceModel(self, model)
     self.filterRootIndex = model.indexFromItem(self.sourceModel().invisibleRootItem())