def rowCount(self, parent: PySide2.QtCore.QModelIndex = ...):
        if not parent.isValid():
            parent_node = self.root
        else:
            parent_node = parent.internalPointer()

        return len(parent_node.children)
 def rowCount(self, parent: PySide2.QtCore.QModelIndex = ...) -> int:
     if parent.column() > 0:
         return 0
     if not parent.isValid():
         parent_item = self.root_item
     else:
         parent_item = parent.internalPointer()
     return parent_item.children_count()
    def index(self, row: int, column: int, parent: PySide2.QtCore.QModelIndex = ...):
        if not parent.isValid():
            parent_node = self.root
        else:
            parent_node = parent.internalPointer()

        child_node = parent_node.children[row]
        return self.createIndex(row, column, child_node)
 def data(self,
          index: PySide2.QtCore.QModelIndex,
          role: int = ...) -> typing.Any:
     if index.isValid() is False:
         return None
     if role != Qt.DisplayRole:
         return None
     item = index.internalPointer()
     return item.data(index.column())
 def parent(
         self,
         child: PySide2.QtCore.QModelIndex = ...
 ) -> PySide2.QtCore.QModelIndex:
     if not child.isValid():
         return QModelIndex()
     child_item = child.internalPointer()
     parent_item = child_item.parent()
     if (parent_item == self.root_item):
         return QModelIndex()
     return self.createIndex(parent_item.row(), 0, parent_item)
    def data(self, index: PySide2.QtCore.QModelIndex, role: int = ...):
        if not index.isValid():
            return None

        node = index.internalPointer()
        if role == Qt.DisplayRole:
            if node.is_leaf:
                return "{}: {}".format(node.name, node.value)
            else:
                return "{} [{}]".format(node.name, node.class_name)

        return None
    def parent(self, index: PySide2.QtCore.QModelIndex):
        if not index.isValid:
            return QModelIndex()

        child_node = index.internalPointer()
        if not child_node:
            return QModelIndex()

        parent_node = child_node.parent
        if parent_node == self.root:
            return QModelIndex()

        row = parent_node.parent.children.index(parent_node)
        return self.createIndex(row, 0, parent_node)
    def data(self, index: PySide2.QtCore.QModelIndex, role: int = ...):
        if not index.isValid():
            return None

        node = index.internalPointer()
        if role == Qt.DisplayRole:
            column = index.column()
            if column == 0:
                return node.value.timestamp
            elif column == 1:
                return node.value.server
            elif column == 2:
                return node.value.source
            elif column == 3:
                return len(node.value.packets)
    def index(self,
              row: int,
              column: int,
              parent: PySide2.QtCore.QModelIndex = ...
              ) -> PySide2.QtCore.QModelIndex:
        if not self.hasIndex(row, column, parent):
            return QModelIndex()
        if not parent.isValid():
            parent_item = self.root_item
        else:
            parent_item = parent.internalPointer()

        child_item = parent_item.child(row)
        if child_item:
            return self.createIndex(row, column, child_item)
        return QModelIndex()
    def data(self, index: PySide2.QtCore.QModelIndex, role: int = ...):
        if not index.isValid():
            return None

        node = index.internalPointer()
        if role == Qt.DisplayRole:
            column = index.column()
            if column == 0:
                return self.name_resolver.get(node,
                                              '../../../../../../server').value
            elif column == 1:
                return node.value.code
            elif column == 2:
                return self.name_resolver.get(node, './content').class_name
            elif column == 3:
                return self.name_resolver.get(node,
                                              './content/content').class_name
Beispiel #11
0
 def columnCount(self, parent: PySide2.QtCore.QModelIndex = ...) -> int:
     if parent.isValid():
         # print(parent.internalPointer().columnCount())
         return parent.internalPointer().columnCount()
     # print(self.root_item.column_count())
     return self.root_item.column_count()