Esempio n. 1
0
 def parent(self, index=None):
     """Find the index of the parent of the item at a given index."""
     try:
         parent = self._index_to_item(index).parent
         return self.createIndex(parent.row, 0, parent)
     except:
         # Something went wrong with finding the parent so return an invalid index
         return QtCore.QModelIndex()
Esempio n. 2
0
    def index(self, row, column, parent_index):
        """Return the index of the <row>th child of parent

        :type row: int
        :type column: int
        :type parent: QtCore.QModelIndex
        """
        try:
            parent = self._index_to_item(parent_index)
            return self.createIndex(row, column, parent.children[row])
        except:
            return QtCore.QModelIndex()