diff --git a/anki/tags.py b/anki/tags.py index e752fdb7c..b87b0ddeb 100644 --- a/anki/tags.py +++ b/anki/tags.py @@ -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 ############################################################# diff --git a/aqt/taglimit.py b/aqt/taglimit.py index 6ade8bee8..77edd7999 100644 --- a/aqt/taglimit.py +++ b/aqt/taglimit.py @@ -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 = {}