Merge pull request #939 from abdnh/sidebar-templates

Render card templates as trees in the sidebar
This commit is contained in:
Damien Elmes 2021-01-23 17:11:55 +10:00 committed by GitHub
commit 6aba1a879c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 4 deletions

View file

@ -1224,14 +1224,25 @@ QTableView {{ gridline-color: {grid} }}
def _modelTree(self, root) -> None:
assert self.col
for m in self.col.models.all_names_and_ids():
for nt in sorted(self.col.models.all(), key=lambda nt: nt["name"].lower()):
item = SidebarItem(
m.name,
nt["name"],
":/icons/notetype.svg",
self._note_filter(m.name),
self._note_filter(nt["name"]),
item_type=SidebarItemType.NOTETYPE,
id=m.id,
id=nt["id"],
)
for c, tmpl in enumerate(nt["tmpls"]):
child = SidebarItem(
tmpl["name"],
":/icons/notetype.svg",
self._template_filter(nt["name"], c),
item_type=SidebarItemType.TEMPLATE,
)
item.addChild(child)
root.addChild(item)
# Filter tree

View file

@ -23,6 +23,7 @@ class SidebarItemType(Enum):
NOTETYPE = 5
TAG = 6
CUSTOM = 7
TEMPLATE = 8
class SidebarTreeViewBase(QTreeView):