mirror of
https://github.com/ankitects/anki.git
synced 2025-09-22 07:52:24 -04:00
refresh current card on edit
This commit is contained in:
parent
270bfab5a7
commit
95fc3978a9
2 changed files with 20 additions and 3 deletions
|
@ -48,6 +48,15 @@ class DeckModel(QAbstractTableModel):
|
||||||
self.cardObjs[id] = self.deck.getCard(id)
|
self.cardObjs[id] = self.deck.getCard(id)
|
||||||
return self.cardObjs[id]
|
return self.cardObjs[id]
|
||||||
|
|
||||||
|
def refreshFact(self, fact):
|
||||||
|
refresh = False
|
||||||
|
for c in fact.cards():
|
||||||
|
if c.id in self.cardObjs:
|
||||||
|
del self.cardObjs[c.id]
|
||||||
|
refresh = True
|
||||||
|
if refresh:
|
||||||
|
self.emit(SIGNAL("layoutChanged()"))
|
||||||
|
|
||||||
# Model interface
|
# Model interface
|
||||||
######################################################################
|
######################################################################
|
||||||
|
|
||||||
|
@ -473,6 +482,9 @@ class Browser(QMainWindow):
|
||||||
self.showCardInfo(self.card)
|
self.showCardInfo(self.card)
|
||||||
self.updateToggles()
|
self.updateToggles()
|
||||||
|
|
||||||
|
def refreshCurrentCard(self, fact):
|
||||||
|
self.model.refreshFact(fact)
|
||||||
|
|
||||||
# Headers & sorting
|
# Headers & sorting
|
||||||
######################################################################
|
######################################################################
|
||||||
|
|
||||||
|
@ -882,10 +894,14 @@ where id in %s""" % ids2str(sf))
|
||||||
def setupHooks(self):
|
def setupHooks(self):
|
||||||
addHook("checkpoint", self.onCheckpoint)
|
addHook("checkpoint", self.onCheckpoint)
|
||||||
addHook("reset", self.onReset)
|
addHook("reset", self.onReset)
|
||||||
|
addHook("editTimer", self.refreshCurrentCard)
|
||||||
|
addHook("editFocusLost", self.refreshCurrentCard)
|
||||||
|
|
||||||
def teardownHooks(self):
|
def teardownHooks(self):
|
||||||
removeHook("reset", self.onReset)
|
removeHook("reset", self.onReset)
|
||||||
removeHook("checkpoint", self.onCheckpoint)
|
removeHook("checkpoint", self.onCheckpoint)
|
||||||
|
removeHook("editTimer", self.refreshCurrentCard)
|
||||||
|
removeHook("editFocusLost", self.refreshCurrentCard)
|
||||||
|
|
||||||
def onCheckpoint(self):
|
def onCheckpoint(self):
|
||||||
if self.mw.form.actionUndo.isEnabled():
|
if self.mw.form.actionUndo.isEnabled():
|
||||||
|
|
|
@ -314,13 +314,13 @@ class Editor(object):
|
||||||
(type, txt) = str.split(":", 1)
|
(type, txt) = str.split(":", 1)
|
||||||
self.fact.fields[self.currentField] = self.mungeHTML(txt)
|
self.fact.fields[self.currentField] = self.mungeHTML(txt)
|
||||||
self.mw.requireReset()
|
self.mw.requireReset()
|
||||||
|
self.fact.flush()
|
||||||
if type == "blur":
|
if type == "blur":
|
||||||
if not self._keepButtons:
|
if not self._keepButtons:
|
||||||
self.disableButtons()
|
self.disableButtons()
|
||||||
runHook("editor.focusLost", self.fact)
|
runHook("editFocusLost", self.fact)
|
||||||
else:
|
else:
|
||||||
runHook("editor.keyPressed", self.fact)
|
runHook("editTimer", self.fact)
|
||||||
self.fact.flush()
|
|
||||||
self.checkValid()
|
self.checkValid()
|
||||||
# focused into field?
|
# focused into field?
|
||||||
elif str.startswith("focus"):
|
elif str.startswith("focus"):
|
||||||
|
@ -474,6 +474,7 @@ class Editor(object):
|
||||||
self.fact.updateCardGids()
|
self.fact.updateCardGids()
|
||||||
self.fact.tags = parseTags(unicode(self.tags.text()))
|
self.fact.tags = parseTags(unicode(self.tags.text()))
|
||||||
self.fact.flush()
|
self.fact.flush()
|
||||||
|
runHook("tagsAndGroupUpdated", self.fact)
|
||||||
|
|
||||||
# Format buttons
|
# Format buttons
|
||||||
######################################################################
|
######################################################################
|
||||||
|
|
Loading…
Reference in a new issue