Make the model parent call a little more robust
This commit is contained in:
@@ -328,7 +328,7 @@ class ProjectModel(QAbstractItemModel):
|
|||||||
|
|
||||||
def parent(self, index: QModelIndex) -> QModelIndex:
|
def parent(self, index: QModelIndex) -> QModelIndex:
|
||||||
"""Get the parent model index of another index."""
|
"""Get the parent model index of another index."""
|
||||||
if index.isValid() and (parent := index.internalPointer().parent()):
|
if index.isValid() and (node := index.internalPointer()) and (parent := node.parent()):
|
||||||
return self.createIndex(parent.row(), 0, parent)
|
return self.createIndex(parent.row(), 0, parent)
|
||||||
return QModelIndex()
|
return QModelIndex()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user