mirror of
https://github.com/ankitects/anki.git
synced 2025-09-22 16:02:23 -04:00
Merge pull request #939 from abdnh/sidebar-templates
Render card templates as trees in the sidebar
This commit is contained in:
commit
6aba1a879c
2 changed files with 16 additions and 4 deletions
|
@ -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
|
||||
|
|
|
@ -23,6 +23,7 @@ class SidebarItemType(Enum):
|
|||
NOTETYPE = 5
|
||||
TAG = 6
|
||||
CUSTOM = 7
|
||||
TEMPLATE = 8
|
||||
|
||||
|
||||
class SidebarTreeViewBase(QTreeView):
|
||||
|
|
Loading…
Reference in a new issue