Ask before removing tags from collection
This commit is contained in:
parent
6c4d6457fb
commit
f07890c178
@ -134,3 +134,5 @@ browsing-edited-today = Edited
|
|||||||
browsing-sidebar-due-today = Due
|
browsing-sidebar-due-today = Due
|
||||||
browsing-sidebar-untagged = Untagged
|
browsing-sidebar-untagged = Untagged
|
||||||
browsing-sidebar-overdue = Overdue
|
browsing-sidebar-overdue = Overdue
|
||||||
|
browsing-sidebar-remove-tag = Are you sure you want to delete the tag “{ $name }” from { $count } notes?
|
||||||
|
browsing-sidebar-remove-tags = Are you sure you want to delete all selected tags from { $count } notes?
|
||||||
|
@ -1142,6 +1142,8 @@ class SidebarTreeView(QTreeView):
|
|||||||
|
|
||||||
def _remove_tags(self, _item: SidebarItem) -> None:
|
def _remove_tags(self, _item: SidebarItem) -> None:
|
||||||
tags = self._selected_tags()
|
tags = self._selected_tags()
|
||||||
|
if not self.ask_remove_tags(tags):
|
||||||
|
return
|
||||||
|
|
||||||
def do_remove() -> None:
|
def do_remove() -> None:
|
||||||
self.col._backend.expunge_tags(" ".join(tags))
|
self.col._backend.expunge_tags(" ".join(tags))
|
||||||
@ -1349,3 +1351,19 @@ class SidebarTreeView(QTreeView):
|
|||||||
for item in self._selected_items()
|
for item in self._selected_items()
|
||||||
if item.item_type == SidebarItemType.TAG
|
if item.item_type == SidebarItemType.TAG
|
||||||
]
|
]
|
||||||
|
|
||||||
|
def ask_remove_tags(self, tags: List[str]) -> bool:
|
||||||
|
count = len(
|
||||||
|
self.col.find_notes(
|
||||||
|
self.col.build_search_string(
|
||||||
|
*(SearchNode(tag=tag) for tag in tags), joiner="OR"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
if not count:
|
||||||
|
return True
|
||||||
|
if len(tags) == 1:
|
||||||
|
return askUser(
|
||||||
|
tr(TR.BROWSING_SIDEBAR_REMOVE_TAG, name=tags[0], count=count)
|
||||||
|
)
|
||||||
|
return askUser(tr(TR.BROWSING_SIDEBAR_REMOVE_TAGS, count=count))
|
||||||
|
Loading…
Reference in New Issue
Block a user