From 1f217be9a87b0a5e5e3e5f699f19d572193ed545 Mon Sep 17 00:00:00 2001 From: David Aguilar Date: Sat, 18 Mar 2023 21:50:43 -0700 Subject: [PATCH] branch: address the TODO to eliminate the stub rowCount() method Signed-off-by: David Aguilar --- cola/widgets/branch.py | 8 -------- cola/widgets/standard.py | 10 ++++------ 2 files changed, 4 insertions(+), 14 deletions(-) diff --git a/cola/widgets/branch.py b/cola/widgets/branch.py index 075f7219..f56960b6 100644 --- a/cola/widgets/branch.py +++ b/cola/widgets/branch.py @@ -540,14 +540,6 @@ class BranchTreeWidgetItem(QtWidgets.QTreeWidgetItem): self.setIcon(0, icon) self.setFlags(Qt.ItemIsEnabled | Qt.ItemIsSelectable) - # TODO: review standard.py 317. - # original function returns 'QTreeWidgetItem' object which has no - # attribute 'rowCount'. This workaround fix error throw when - # navigating with keyboard and press left key - @staticmethod - def rowCount(): - return 1 - class TreeEntry(object): """Tree representation for the branches widget diff --git a/cola/widgets/standard.py b/cola/widgets/standard.py index cf1ad1d7..bd58c358 100644 --- a/cola/widgets/standard.py +++ b/cola/widgets/standard.py @@ -332,14 +332,12 @@ class TreeMixin(object): # Process non-root entries with valid parents only. elif key == Qt.Key_Left and index.parent().isValid(): - # File entries have rowCount() == 0 model = widget.model() - if ( - hasattr(model, 'itemFromIndex') - and model.itemFromIndex(index).rowCount() == 0 - ): - widget.setCurrentIndex(index.parent()) + if hasattr(model, 'itemFromIndex'): + item = model.itemFromIndex(index) + if hasattr(item, 'rowCount') and item.rowCount() == 0: + widget.setCurrentIndex(index.parent()) # Otherwise, do this for collapsed directories only elif was_collapsed: -- 2.11.4.GIT