mirror of
https://github.com/ankitects/anki.git
synced 2025-12-13 06:46:55 -05:00
make sure to save facts before closing editor, etc
This commit is contained in:
parent
7f83f471e2
commit
7563879093
4 changed files with 21 additions and 2 deletions
|
|
@ -90,8 +90,7 @@ class AddCards(QDialog):
|
|||
|
||||
def addCards(self):
|
||||
# make sure updated
|
||||
w = self.editor.focusedEdit()
|
||||
self.addButton.setFocus()
|
||||
self.editor.saveFieldsNow()
|
||||
fact = self.editor.fact
|
||||
try:
|
||||
cards = self.parent.deck.addFact(fact)
|
||||
|
|
|
|||
|
|
@ -631,6 +631,7 @@ where id in (%s)""" % ",".join([
|
|||
self.updateAfterCardChange(reset=True)
|
||||
|
||||
def accept(self):
|
||||
self.editor.saveFieldsNow()
|
||||
self.hide()
|
||||
self.deck.deleteCards(self.model.deleted.keys())
|
||||
if len(self.model.deleted):
|
||||
|
|
|
|||
|
|
@ -37,6 +37,9 @@ class FactEditor(object):
|
|||
"Make FACT the current fact."
|
||||
self.fact = fact
|
||||
self.factState = None
|
||||
if self.changeTimer:
|
||||
self.changeTimer.stop()
|
||||
self.changeTimer = None
|
||||
if self.needToRedraw():
|
||||
self.drawFields(noFocus, check)
|
||||
else:
|
||||
|
|
@ -330,6 +333,21 @@ class FactEditor(object):
|
|||
self.onChange()
|
||||
self.changeTimer = None
|
||||
|
||||
def saveFieldsNow(self):
|
||||
"Must call this before adding cards, closing dialog, etc."
|
||||
# disable timer
|
||||
if self.changeTimer:
|
||||
self.changeTimer.stop()
|
||||
self.changeTimer = None
|
||||
if self.onChange:
|
||||
self.onChange()
|
||||
# save fields and run features
|
||||
w = self.focusedEdit()
|
||||
if w:
|
||||
self.onFocusLost(w)
|
||||
# ensure valid
|
||||
self.checkValid()
|
||||
|
||||
def checkValid(self):
|
||||
empty = []
|
||||
dupe = []
|
||||
|
|
|
|||
|
|
@ -201,6 +201,7 @@ class AnkiQt(QMainWindow):
|
|||
self.mainWin.fieldsArea.show()
|
||||
self.editor.setFact(self.currentCard.fact)
|
||||
elif state == "saveEdit":
|
||||
self.editor.saveFieldsNow()
|
||||
self.deck.s.flush()
|
||||
return self.moveToState("auto")
|
||||
self.updateViews(state)
|
||||
|
|
|
|||
Loading…
Reference in a new issue