Enable deleting multiple saved searches
This commit is contained in:
parent
e199bf0b47
commit
f4aeb0c097
@ -21,6 +21,11 @@ browsing-change-note-type2 = Change Note Type...
|
|||||||
browsing-change-to = Change { $val } to:
|
browsing-change-to = Change { $val } to:
|
||||||
browsing-clear-unused = Clear Unused
|
browsing-clear-unused = Clear Unused
|
||||||
browsing-clear-unused-tags = Clear Unused Tags
|
browsing-clear-unused-tags = Clear Unused Tags
|
||||||
|
browsing-confirm-saved-searches-deletion =
|
||||||
|
{ $count ->
|
||||||
|
[one] Are you sure you want to delete the selected saved search?
|
||||||
|
*[other] Are you sure you want to delete the { $count } selected saved searches?
|
||||||
|
}
|
||||||
browsing-created = Created
|
browsing-created = Created
|
||||||
browsing-ctrlandshiftande = Ctrl+Shift+E
|
browsing-ctrlandshiftande = Ctrl+Shift+E
|
||||||
browsing-current-deck = Current Deck
|
browsing-current-deck = Current Deck
|
||||||
|
@ -353,7 +353,7 @@ class SidebarTreeView(QTreeView):
|
|||||||
),
|
),
|
||||||
SidebarItemType.SAVED_SEARCH: (
|
SidebarItemType.SAVED_SEARCH: (
|
||||||
(tr(TR.ACTIONS_RENAME), self.rename_saved_search),
|
(tr(TR.ACTIONS_RENAME), self.rename_saved_search),
|
||||||
(tr(TR.ACTIONS_DELETE), self.remove_saved_search),
|
(tr(TR.ACTIONS_DELETE), self.remove_saved_searches),
|
||||||
),
|
),
|
||||||
SidebarItemType.NOTETYPE: ((tr(TR.ACTIONS_MANAGE), self.manage_notetype),),
|
SidebarItemType.NOTETYPE: ((tr(TR.ACTIONS_MANAGE), self.manage_notetype),),
|
||||||
SidebarItemType.SAVED_SEARCH_ROOT: (
|
SidebarItemType.SAVED_SEARCH_ROOT: (
|
||||||
@ -1177,12 +1177,17 @@ class SidebarTreeView(QTreeView):
|
|||||||
def _set_saved_searches(self, searches: Dict[str, str]) -> None:
|
def _set_saved_searches(self, searches: Dict[str, str]) -> None:
|
||||||
self.col.set_config(self._saved_searches_key, searches)
|
self.col.set_config(self._saved_searches_key, searches)
|
||||||
|
|
||||||
def remove_saved_search(self, item: SidebarItem) -> None:
|
def remove_saved_searches(self, _item: SidebarItem) -> None:
|
||||||
name = item.name
|
selected = self._selected_saved_searches()
|
||||||
if not askUser(tr(TR.BROWSING_REMOVE_FROM_YOUR_SAVED_SEARCHES, val=name)):
|
if len(selected) == 1:
|
||||||
|
query = tr(TR.BROWSING_REMOVE_FROM_YOUR_SAVED_SEARCHES, val=selected[0])
|
||||||
|
else:
|
||||||
|
query = tr(TR.BROWSING_CONFIRM_SAVED_SEARCHES_DELETION, count=len(selected))
|
||||||
|
if not askUser(query):
|
||||||
return
|
return
|
||||||
conf = self._get_saved_searches()
|
conf = self._get_saved_searches()
|
||||||
del conf[name]
|
for name in selected:
|
||||||
|
del conf[name]
|
||||||
self._set_saved_searches(conf)
|
self._set_saved_searches(conf)
|
||||||
self.refresh()
|
self.refresh()
|
||||||
|
|
||||||
@ -1234,3 +1239,10 @@ class SidebarTreeView(QTreeView):
|
|||||||
for item in self._selected_items()
|
for item in self._selected_items()
|
||||||
if item.item_type == SidebarItemType.DECK
|
if item.item_type == SidebarItemType.DECK
|
||||||
]
|
]
|
||||||
|
|
||||||
|
def _selected_saved_searches(self) -> List[str]:
|
||||||
|
return [
|
||||||
|
item.name
|
||||||
|
for item in self._selected_items()
|
||||||
|
if item.item_type == SidebarItemType.SAVED_SEARCH
|
||||||
|
]
|
||||||
|
Loading…
Reference in New Issue
Block a user