if model changed, refresh fact editor

This commit is contained in:
Damien Elmes 2009-03-14 05:41:28 +09:00
parent 26a0e7eaf2
commit a910a99a77
2 changed files with 12 additions and 0 deletions

View file

@ -14,6 +14,7 @@ from ankiqt import ui
import ankiqt
from ankiqt.ui.utils import mungeQA, saveGeom, restoreGeom
from anki.hooks import addHook
from sqlalchemy.exceptions import InvalidRequestError
clozeColour = "#0000ff"
@ -38,6 +39,7 @@ class FactEditor(object):
self.changeTimer = None
self.lastCloze = None
addHook("deckClosed", self.deckClosedHook)
addHook("guiReset", self.refresh)
def setFact(self, fact, noFocus=False, check=False):
"Make FACT the current fact."
@ -63,6 +65,15 @@ class FactEditor(object):
if self.deck.mediaDir(create=False):
self.initMedia()
def refresh(self):
if self.fact:
try:
self.deck.s.refresh(self.fact)
except InvalidRequestError:
# not attached to session yet, add cards dialog will handle
return
self.setFact(self.fact, check=True)
def focusFirst(self):
if self.focusTarget:
self.focusTarget.setFocus()

View file

@ -198,6 +198,7 @@ Please do not file a bug report with Anki.<br><br>""")
if count:
self.deck.rebuildCounts()
self.deck.rebuildQueue()
runHook("guiReset")
self.moveToState("initial")
def moveToState(self, state):