mirror of
https://github.com/ankitects/anki.git
synced 2025-09-19 14:32:22 -04:00
use inner function instead of return value in _expand_where_necessary()
This commit is contained in:
parent
33e6662dda
commit
ecabf35350
1 changed files with 23 additions and 19 deletions
|
@ -225,15 +225,18 @@ class SidebarTreeView(QTreeView):
|
||||||
parent: Optional[QModelIndex] = None,
|
parent: Optional[QModelIndex] = None,
|
||||||
searching: bool = False,
|
searching: bool = False,
|
||||||
scroll_to_first_match: bool = False,
|
scroll_to_first_match: bool = False,
|
||||||
) -> bool:
|
) -> None:
|
||||||
parent = parent or QModelIndex()
|
def expand_node(parent: QModelIndex) -> None:
|
||||||
|
nonlocal scroll_to_first_match
|
||||||
|
|
||||||
for row in range(model.rowCount(parent)):
|
for row in range(model.rowCount(parent)):
|
||||||
idx = model.index(row, 0, parent)
|
idx = model.index(row, 0, parent)
|
||||||
if not idx.isValid():
|
if not idx.isValid():
|
||||||
continue
|
continue
|
||||||
scroll_to_first_match = self._expand_where_necessary(
|
|
||||||
model, idx, searching, scroll_to_first_match
|
# descend into children first
|
||||||
)
|
expand_node(idx)
|
||||||
|
|
||||||
if item := model.item_for_index(idx):
|
if item := model.item_for_index(idx):
|
||||||
if item.show_expanded(searching):
|
if item.show_expanded(searching):
|
||||||
self.setExpanded(idx, True)
|
self.setExpanded(idx, True)
|
||||||
|
@ -243,7 +246,8 @@ class SidebarTreeView(QTreeView):
|
||||||
)
|
)
|
||||||
self.scrollTo(idx)
|
self.scrollTo(idx)
|
||||||
scroll_to_first_match = False
|
scroll_to_first_match = False
|
||||||
return scroll_to_first_match
|
|
||||||
|
expand_node(parent or QModelIndex())
|
||||||
|
|
||||||
def update_search(
|
def update_search(
|
||||||
self,
|
self,
|
||||||
|
|
Loading…
Reference in a new issue