Limit tags in custom study dialog to those in the selected deck

This commit is contained in:
bogdanteleaga 2015-11-20 20:14:12 +02:00
parent 52f8a4a75e
commit 1f1220cf7c
2 changed files with 14 additions and 1 deletions

View File

@ -67,6 +67,19 @@ class TagManager(object):
def save(self):
self.changed = True
def byDeck(self, did, children=False):
basequery = "select n.tags from cards c, notes n WHERE c.nid = n.id"
if not children:
query = basequery + " AND c.did=?"
res = self.col.db.list(query, did)
return list(set(self.split(" ".join(res))))
dids = [did]
for name, id in self.col.decks.children(did):
dids.append(id)
query = basequery + " AND c.did IN " + ids2str(dids)
res = self.col.db.list(query)
return list(set(self.split(" ".join(res))))
# Bulk addition/removal from notes
#############################################################

View File

@ -19,7 +19,7 @@ class TagLimit(QDialog):
self.exec_()
def rebuildTagList(self):
usertags = self.mw.col.tags.all()
usertags = self.mw.col.tags.byDeck(self.deck['id'], True)
yes = self.deck.get("activeTags", [])
no = self.deck.get("inactiveTags", [])
yesHash = {}