Add more sidebar section roots

This commit is contained in:
abdo 2021-02-02 04:51:45 +03:00
parent 3a8fce69dd
commit 6f5d1bca3f

View File

@ -55,6 +55,8 @@ class SidebarItemType(Enum):
TEMPLATE = 8 TEMPLATE = 8
SAVED_SEARCH_ROOT = 9 SAVED_SEARCH_ROOT = 9
DECK_ROOT = 10 DECK_ROOT = 10
NOTETYPE_ROOT = 11
TAG_ROOT = 12
# used by an add-on hook # used by an add-on hook
@ -113,10 +115,11 @@ class SidebarItem:
if self._search_matches_child: if self._search_matches_child:
return True return True
# if search matches top level, expand children one level # if search matches top level, expand children one level
# FIXME: add types for other roots
return self._search_matches_self and self.item_type in ( return self._search_matches_self and self.item_type in (
SidebarItemType.SAVED_SEARCH_ROOT, SidebarItemType.SAVED_SEARCH_ROOT,
SidebarItemType.DECK_ROOT, SidebarItemType.DECK_ROOT,
SidebarItemType.NOTETYPE_ROOT,
SidebarItemType.TAG_ROOT,
) )
def is_highlighted(self) -> bool: def is_highlighted(self) -> bool:
@ -558,6 +561,7 @@ class SidebarTreeView(QTreeView):
name=TR.BROWSING_SIDEBAR_TAGS, name=TR.BROWSING_SIDEBAR_TAGS,
icon=icon, icon=icon,
collapse_key=ConfigBoolKey.COLLAPSE_TAGS, collapse_key=ConfigBoolKey.COLLAPSE_TAGS,
type=SidebarItemType.TAG_ROOT,
) )
render(root, tree.children) render(root, tree.children)
@ -604,6 +608,7 @@ class SidebarTreeView(QTreeView):
name=TR.BROWSING_SIDEBAR_NOTETYPES, name=TR.BROWSING_SIDEBAR_NOTETYPES,
icon=icon, icon=icon,
collapse_key=ConfigBoolKey.COLLAPSE_NOTETYPES, collapse_key=ConfigBoolKey.COLLAPSE_NOTETYPES,
type=SidebarItemType.NOTETYPE_ROOT,
) )
for nt in sorted(self.col.models.all(), key=lambda nt: nt["name"].lower()): for nt in sorted(self.col.models.all(), key=lambda nt: nt["name"].lower()):