Example #1
0
 def index(self, row, column, parent):
     if not self.hasIndex(row, column, parent):
         return Q.QModelIndex()
     if not parent.isValid():
         parentItem = self._rootItem
     else:
         parentItem = parent.internalPointer()
     childItem = parentItem.child(row)
     if childItem:
         return self.createIndex(row, column, childItem)
     else:
         return Q.QModelIndex()
Example #2
0
    def parent(self, index):
        if not index:
            return Q.QModelIndex()
        if not index.isValid():
            return Q.QModelIndex()
        childItem = index.internalPointer()
        if not childItem:
            return Q.QModelIndex()

        parentItem = childItem.parent
        if not parentItem:
            return Q.QModelIndex()
        if parentItem is self._rootItem:
            return Q.QModelIndex()
        return self.indexForItem(parentItem)
Example #3
0
 def __init__(self, *args, **kwargs):
     player = kwargs.pop('player', None)
     self._player = player
     super().__init__(*args, **kwargs)
     self._headerData = ["name", "value"]
     self._rootItem = TreeItem(name='root', player=player)
     self.setupModelData(player)
     print(self.__class__.__name__, 'rowCount() is ',
           self.rowCount(Q.QModelIndex()))
Example #4
0
 def rowCount(self, parent=Q.QModelIndex()):
     return len(self._props)
Example #5
0
 def columnCount(self, parent=Q.QModelIndex()):
     return 2