From 5219783182e396ab5153e8f721468c8307562413 Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Fri, 14 Nov 2008 16:22:58 +0900 Subject: [PATCH] keep fields when changing model --- ankiqt/ui/addcards.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/ankiqt/ui/addcards.py b/ankiqt/ui/addcards.py index ba7668d31..0c2675b4f 100644 --- a/ankiqt/ui/addcards.py +++ b/ankiqt/ui/addcards.py @@ -73,7 +73,17 @@ class AddCards(QDialog): oldFact = self.editor.fact # create a new fact fact = self.parent.deck.newFact() - fact.tags = self.parent.deck.lastTags + # 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 # set the new fact self.editor.setFact(fact, check=True)