Enable adding/removing tags from the sidebar ...

... to selected notes.
This commit is contained in:
RumovZ 2021-09-21 11:48:43 +02:00
parent 94b261f1ef
commit 75f210a66c
2 changed files with 19 additions and 0 deletions

View File

@ -1,6 +1,8 @@
browsing-add-notes = Add Notes... browsing-add-notes = Add Notes...
browsing-add-tags = Add Tags browsing-add-tags = Add Tags
browsing-add-tags2 = Add Tags... browsing-add-tags2 = Add Tags...
browsing-add-to-selected-notes = Add to selected Notes
browsing-remove-from-selected-notes = Remove from selected Notes
browsing-addon = Add-on browsing-addon = Add-on
browsing-all-card-types = All Card Types browsing-all-card-types = All Card Types
browsing-all-fields = All Fields browsing-all-fields = All Fields

View File

@ -897,6 +897,15 @@ class SidebarTreeView(QTreeView):
tr.browsing_update_saved_search(), tr.browsing_update_saved_search(),
lambda: self.update_saved_search(item), lambda: self.update_saved_search(item),
) )
elif item.item_type == SidebarItemType.TAG:
if all(s.item_type == item.item_type for s in self._selected_items()):
menu.addAction(
tr.browsing_add_to_selected_notes(), self.add_tags_to_selected_notes
)
menu.addAction(
tr.browsing_remove_from_selected_notes(),
self.remove_tags_from_selected_notes,
)
def _maybe_add_delete_action( def _maybe_add_delete_action(
self, menu: QMenu, item: SidebarItem, index: QModelIndex self, menu: QMenu, item: SidebarItem, index: QModelIndex
@ -1090,6 +1099,14 @@ class SidebarTreeView(QTreeView):
new_name=new_full_name, new_name=new_full_name,
).success(success).run_in_background() ).success(success).run_in_background()
def add_tags_to_selected_notes(self) -> None:
tags = " ".join(item.full_name for item in self._selected_items())
self.browser.add_tags_to_selected_notes(tags)
def remove_tags_from_selected_notes(self) -> None:
tags = " ".join(item.full_name for item in self._selected_items())
self.browser.remove_tags_from_selected_notes(tags)
# Saved searches # Saved searches
#################################### ####################################