mirror of
https://github.com/ankitects/anki.git
synced 2025-11-12 15:47:12 -05:00
add new tag hook
This commit is contained in:
parent
fe029250d9
commit
d401f92016
1 changed files with 5 additions and 0 deletions
|
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
import simplejson
|
import simplejson
|
||||||
from anki.utils import intTime, ids2str
|
from anki.utils import intTime, ids2str
|
||||||
|
from anki.hooks import runHook
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Anki maintains a cache of used tags so it can quickly present a list of tags
|
Anki maintains a cache of used tags so it can quickly present a list of tags
|
||||||
|
|
@ -38,10 +39,14 @@ class TagManager(object):
|
||||||
"Given a list of tags, add any missing ones to tag registry."
|
"Given a list of tags, add any missing ones to tag registry."
|
||||||
# case is stored as received, so user can create different case
|
# case is stored as received, so user can create different case
|
||||||
# versions of the same tag if they ignore the qt autocomplete.
|
# versions of the same tag if they ignore the qt autocomplete.
|
||||||
|
found = False
|
||||||
for t in tags:
|
for t in tags:
|
||||||
if t not in self.tags:
|
if t not in self.tags:
|
||||||
|
found = True
|
||||||
self.tags[t] = self.col.usn() if usn is None else usn
|
self.tags[t] = self.col.usn() if usn is None else usn
|
||||||
self.changed = True
|
self.changed = True
|
||||||
|
if found:
|
||||||
|
runHook("newTag")
|
||||||
|
|
||||||
def all(self):
|
def all(self):
|
||||||
return self.tags.keys()
|
return self.tags.keys()
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue