Make a new item the current item after refresh
This commit is contained in:
parent
985ce2466b
commit
c85ae24347
@ -146,15 +146,13 @@ class SidebarTreeView(QTreeView):
|
|||||||
self.refresh()
|
self.refresh()
|
||||||
self._refresh_needed = False
|
self._refresh_needed = False
|
||||||
|
|
||||||
def refresh(self) -> None:
|
def refresh(self, new_current: SidebarItem = None) -> None:
|
||||||
"Refresh list. No-op if sidebar is not visible."
|
"Refresh list. No-op if sidebar is not visible."
|
||||||
if not self.isVisible():
|
if not self.isVisible():
|
||||||
return
|
return
|
||||||
|
|
||||||
if self.model() and (idx := self.currentIndex()):
|
if not new_current and self.model() and (idx := self.currentIndex()):
|
||||||
current_item = self.model().item_for_index(idx)
|
new_current = self.model().item_for_index(idx)
|
||||||
else:
|
|
||||||
current_item = None
|
|
||||||
|
|
||||||
def on_done(root: SidebarItem) -> None:
|
def on_done(root: SidebarItem) -> None:
|
||||||
# user may have closed browser
|
# user may have closed browser
|
||||||
@ -171,8 +169,8 @@ class SidebarTreeView(QTreeView):
|
|||||||
self.search_for(self.current_search)
|
self.search_for(self.current_search)
|
||||||
else:
|
else:
|
||||||
self._expand_where_necessary(model)
|
self._expand_where_necessary(model)
|
||||||
if current_item:
|
if new_current:
|
||||||
self.restore_current(current_item)
|
self.restore_current(new_current)
|
||||||
|
|
||||||
self.setUpdatesEnabled(True)
|
self.setUpdatesEnabled(True)
|
||||||
|
|
||||||
@ -1017,7 +1015,7 @@ class SidebarTreeView(QTreeView):
|
|||||||
return
|
return
|
||||||
conf[name] = search
|
conf[name] = search
|
||||||
self._set_saved_searches(conf)
|
self._set_saved_searches(conf)
|
||||||
self.refresh()
|
self.refresh(SidebarItem(name, "", item_type=SidebarItemType.SAVED_SEARCH))
|
||||||
|
|
||||||
def remove_saved_searches(self, _item: SidebarItem) -> None:
|
def remove_saved_searches(self, _item: SidebarItem) -> None:
|
||||||
selected = self._selected_saved_searches()
|
selected = self._selected_saved_searches()
|
||||||
|
Loading…
Reference in New Issue
Block a user