forked from Arthur-Milchior/anki-enhance-main-window
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchangeFunction.py
38 lines (31 loc) · 1.04 KB
/
changeFunction.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
from .node import idToNode, renderDeckTree
from anki.notes import Note
from anki.decks import DeckManager
from anki.sched import Scheduler
from aqt.deckbrowser import DeckBrowser
from .debug import debug
oldNoteFluh = Note.flush
def noteFlush(note, mod = None):
debug("flush")
oldNoteFluh(note,mod = mod)
Note.flush = noteFlush
oldDeckSave = DeckManager.save
def deckSave(self, g = None, mainChange = True):
if mainChange:
debug("change main deck")
oldDeckSave(self,g = g)
DeckManager.save = deckSave
oldRebuildDyn = Scheduler.rebuildDyn
def rebuidDyn(self, did = None):
return oldRebuildDyn(self, did = None)
oldCollapse = DeckManager.collapse
def collapse(self,did):
deck = self.get(did)
deck['collapsed'] = not deck['collapsed']
self.save(deck,mainChange = False)
DeckManager.collapse = collapse
#based on Anki 2.0.36 aqt/deckbrowser.py DeckBrowser._deckRow
def deckRow(self, node, depth, cnt):
return node.htmlRow(self,depth,cnt)
DeckBrowser._deckRow = deckRow
DeckBrowser._renderDeckTree = renderDeckTree