Merge pull request #17 from frostschutz/browser_tree_onclick
workaround for filter tree onclick not working (#729)
This commit is contained in:
commit
f13d0c329f
@ -683,8 +683,8 @@ by clicking on one on the left."""))
|
||||
######################################################################
|
||||
|
||||
class CallbackItem(QTreeWidgetItem):
|
||||
def __init__(self, name, onclick):
|
||||
QTreeWidgetItem.__init__(self, [name])
|
||||
def __init__(self, root, name, onclick):
|
||||
QTreeWidgetItem.__init__(self, root, [name])
|
||||
self.onclick = onclick
|
||||
|
||||
def setupTree(self):
|
||||
@ -698,7 +698,7 @@ by clicking on one on the left."""))
|
||||
|
||||
def buildTree(self):
|
||||
self.form.tree.clear()
|
||||
root = self.form.tree.invisibleRootItem()
|
||||
root = self.form.tree
|
||||
self._systemTagTree(root)
|
||||
self._decksTree(root)
|
||||
self._modelTree(root)
|
||||
@ -752,9 +752,8 @@ by clicking on one on the left."""))
|
||||
(_("Leech"), "emblem-important.png", "tag:leech"))
|
||||
for name, icon, cmd in tags:
|
||||
item = self.CallbackItem(
|
||||
name, lambda c=cmd: self.setFilter(c))
|
||||
root, name, lambda c=cmd: self.setFilter(c))
|
||||
item.setIcon(0, QIcon(":/icons/" + icon))
|
||||
root.addChild(item)
|
||||
return root
|
||||
|
||||
def _userTagTree(self, root):
|
||||
@ -762,19 +761,17 @@ by clicking on one on the left."""))
|
||||
if t.lower() == "marked" or t.lower() == "leech":
|
||||
continue
|
||||
item = self.CallbackItem(
|
||||
t, lambda t=t: self.setFilter("tag", t))
|
||||
root, t, lambda t=t: self.setFilter("tag", t))
|
||||
item.setIcon(0, QIcon(":/icons/anki-tag.png"))
|
||||
root.addChild(item)
|
||||
|
||||
def _decksTree(self, root):
|
||||
grps = self.col.sched.deckDueTree()
|
||||
def fillGroups(root, grps, head=""):
|
||||
for g in grps:
|
||||
item = self.CallbackItem(
|
||||
g[0], lambda g=g: self.setFilter(
|
||||
"deck", head+g[0]))
|
||||
root, g[0], lambda g=g: self.setFilter(
|
||||
"deck", head+g[0]))
|
||||
item.setIcon(0, QIcon(":/icons/deck16.png"))
|
||||
root.addChild(item)
|
||||
newhead = head + g[0]+"::"
|
||||
fillGroups(item, g[5], newhead)
|
||||
fillGroups(root, grps)
|
||||
@ -782,9 +779,8 @@ by clicking on one on the left."""))
|
||||
def _modelTree(self, root):
|
||||
for m in sorted(self.col.models.all(), key=itemgetter("name")):
|
||||
mitem = self.CallbackItem(
|
||||
m['name'], lambda m=m: self.setFilter("mid", str(m['id'])))
|
||||
root, m['name'], lambda m=m: self.setFilter("mid", str(m['id'])))
|
||||
mitem.setIcon(0, QIcon(":/icons/product_design.png"))
|
||||
root.addChild(mitem)
|
||||
# for t in m['tmpls']:
|
||||
# titem = self.CallbackItem(
|
||||
# t['name'], lambda m=m, t=t: self.setFilter(
|
||||
|
Loading…
Reference in New Issue
Block a user