add 'untagged', and make clicking on 'tags' show all tagged cards

This commit is contained in:
Damien Elmes 2021-02-09 12:50:35 +10:00
parent 9048a1ff3c
commit 63b369b8a6
2 changed files with 14 additions and 0 deletions

View File

@ -128,3 +128,4 @@ browsing-added-today = Added
browsing-again-today = Again
browsing-edited-today = Edited
browsing-sidebar-due-today = Due
browsing-sidebar-untagged = Untagged

View File

@ -46,6 +46,7 @@ class SidebarItemType(Enum):
NOTETYPE = auto()
NOTETYPE_TEMPLATE = auto()
TAG_ROOT = auto()
TAG_NONE = auto()
TAG = auto()
CUSTOM = auto()
@ -785,6 +786,16 @@ class SidebarTreeView(QTreeView):
collapse_key=Config.Bool.COLLAPSE_TAGS,
type=SidebarItemType.TAG_ROOT,
)
root.on_click = self._filter_func(
self.col.build_search_string(SearchTerm(tag="none"), negate=True)
)
root.add_simple(
name=tr(TR.BROWSING_SIDEBAR_UNTAGGED),
icon=icon,
type=SidebarItemType.TAG_NONE,
on_click=self._filter_func(SearchTerm(tag="none")),
)
render(root, tree.children)
# Tree: Decks
@ -881,6 +892,8 @@ class SidebarTreeView(QTreeView):
return
self.show_context_menu(item, idx)
# idx is only None when triggering the context menu from a left click on
# saved searches - perhaps there is a better way to handle that?
def show_context_menu(self, item: SidebarItem, idx: Optional[QModelIndex]) -> None:
m = QMenu()