mirror of
https://github.com/ankitects/anki.git
synced 2025-09-25 01:06:35 -04:00
keep fields when changing model
This commit is contained in:
parent
afd03844e2
commit
5219783182
1 changed files with 11 additions and 1 deletions
|
@ -73,6 +73,16 @@ class AddCards(QDialog):
|
||||||
oldFact = self.editor.fact
|
oldFact = self.editor.fact
|
||||||
# create a new fact
|
# create a new fact
|
||||||
fact = self.parent.deck.newFact()
|
fact = self.parent.deck.newFact()
|
||||||
|
# copy fields from old fact
|
||||||
|
if oldFact:
|
||||||
|
for field in oldFact.model.fieldModels:
|
||||||
|
try:
|
||||||
|
fact[field.name]
|
||||||
|
fact[field.name] = oldFact[field.name]
|
||||||
|
except KeyError:
|
||||||
|
pass
|
||||||
|
fact.tags = oldFact.tags
|
||||||
|
else:
|
||||||
fact.tags = self.parent.deck.lastTags
|
fact.tags = self.parent.deck.lastTags
|
||||||
# set the new fact
|
# set the new fact
|
||||||
self.editor.setFact(fact, check=True)
|
self.editor.setFact(fact, check=True)
|
||||||
|
|
Loading…
Reference in a new issue