mirror of
https://github.com/ankitects/anki.git
synced 2025-09-20 06:52:21 -04:00
if model changed, refresh fact editor
This commit is contained in:
parent
26a0e7eaf2
commit
a910a99a77
2 changed files with 12 additions and 0 deletions
|
@ -14,6 +14,7 @@ from ankiqt import ui
|
||||||
import ankiqt
|
import ankiqt
|
||||||
from ankiqt.ui.utils import mungeQA, saveGeom, restoreGeom
|
from ankiqt.ui.utils import mungeQA, saveGeom, restoreGeom
|
||||||
from anki.hooks import addHook
|
from anki.hooks import addHook
|
||||||
|
from sqlalchemy.exceptions import InvalidRequestError
|
||||||
|
|
||||||
clozeColour = "#0000ff"
|
clozeColour = "#0000ff"
|
||||||
|
|
||||||
|
@ -38,6 +39,7 @@ class FactEditor(object):
|
||||||
self.changeTimer = None
|
self.changeTimer = None
|
||||||
self.lastCloze = None
|
self.lastCloze = None
|
||||||
addHook("deckClosed", self.deckClosedHook)
|
addHook("deckClosed", self.deckClosedHook)
|
||||||
|
addHook("guiReset", self.refresh)
|
||||||
|
|
||||||
def setFact(self, fact, noFocus=False, check=False):
|
def setFact(self, fact, noFocus=False, check=False):
|
||||||
"Make FACT the current fact."
|
"Make FACT the current fact."
|
||||||
|
@ -63,6 +65,15 @@ class FactEditor(object):
|
||||||
if self.deck.mediaDir(create=False):
|
if self.deck.mediaDir(create=False):
|
||||||
self.initMedia()
|
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):
|
def focusFirst(self):
|
||||||
if self.focusTarget:
|
if self.focusTarget:
|
||||||
self.focusTarget.setFocus()
|
self.focusTarget.setFocus()
|
||||||
|
|
|
@ -198,6 +198,7 @@ Please do not file a bug report with Anki.<br><br>""")
|
||||||
if count:
|
if count:
|
||||||
self.deck.rebuildCounts()
|
self.deck.rebuildCounts()
|
||||||
self.deck.rebuildQueue()
|
self.deck.rebuildQueue()
|
||||||
|
runHook("guiReset")
|
||||||
self.moveToState("initial")
|
self.moveToState("initial")
|
||||||
|
|
||||||
def moveToState(self, state):
|
def moveToState(self, state):
|
||||||
|
|
Loading…
Reference in a new issue