Break up another nested if statement

This commit is contained in:
Veronica K. B. Olsen
2020-12-09 23:22:15 +01:00
parent c2321c502f
commit 15c5ffcb76
+8 -3
View File
@@ -431,7 +431,7 @@ class GuiProjectTree(QTreeWidget):
trItemS = self._getTreeItem(tHandle) trItemS = self._getTreeItem(tHandle)
nwItemS = self.theProject.projTree[tHandle] nwItemS = self.theProject.projTree[tHandle]
if nwItemS is None: if trItemS is None or nwItemS is None:
return False return False
wCount = int(trItemS.data(self.C_COUNT, Qt.UserRole)) wCount = int(trItemS.data(self.C_COUNT, Qt.UserRole))
@@ -582,11 +582,16 @@ class GuiProjectTree(QTreeWidget):
properly reported to the function. properly reported to the function.
""" """
tItem = self._getTreeItem(tHandle) tItem = self._getTreeItem(tHandle)
if tItem is not None: if tItem is None:
return
tItem.setText(self.C_COUNT, f"{theCount:n}") tItem.setText(self.C_COUNT, f"{theCount:n}")
tItem.setData(self.C_COUNT, Qt.UserRole, int(theCount)) tItem.setData(self.C_COUNT, Qt.UserRole, int(theCount))
pItem = tItem.parent() pItem = tItem.parent()
if pItem is not None: if pItem is None:
return
pCount = 0 pCount = 0
for i in range(pItem.childCount()): for i in range(pItem.childCount()):
pCount += int(pItem.child(i).data(self.C_COUNT, Qt.UserRole)) pCount += int(pItem.child(i).data(self.C_COUNT, Qt.UserRole))