From 2dad0d23e1dd6bc7c2b761129269ef96c2ae87d2 Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Thu, 2 Dec 2010 04:18:56 +0900 Subject: [PATCH] fix fact provided case, give template q/a format more useful defaults --- ankiqt/ui/clayout.py | 4 ++-- ankiqt/ui/modelproperties.py | 10 ++++++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/ankiqt/ui/clayout.py b/ankiqt/ui/clayout.py index 8229bf832..cc82dbb03 100644 --- a/ankiqt/ui/clayout.py +++ b/ankiqt/ui/clayout.py @@ -28,9 +28,10 @@ class CardLayout(QDialog): self.mw = ankiqt.mw self.deck = self.mw.deck self.factedit = factedit + self.card = card if factedit: self.fact = factOrModel - self.model = fact.model + self.model = self.fact.model else: self.model = factOrModel # see if there's an available fact @@ -43,7 +44,6 @@ class CardLayout(QDialog): self.fact = self.deck.newFact(self.model) for f in self.fact.keys(): self.fact[f] = f - self.card = card self.plastiqueStyle = None if (sys.platform.startswith("darwin") or sys.platform.startswith("win32")): diff --git a/ankiqt/ui/modelproperties.py b/ankiqt/ui/modelproperties.py index 2149c6532..fa4155ed5 100644 --- a/ankiqt/ui/modelproperties.py +++ b/ankiqt/ui/modelproperties.py @@ -160,8 +160,14 @@ class ModelProperties(QDialog): def addCard(self): cards = len(self.m.cardModels) - name = _("Name_%d") % (cards+1) - cm = CardModel(name=name) + name = _("Template_%d") % (cards+1) + fields = self.m.fieldModels + qformat = "{{%s}}" % fields[0].name + if len(fields) > 1: + aformat = "{{%s}}" % fields[1].name + else: + aformat = "" + cm = CardModel(name, qformat, aformat) self.m.addCardModel(cm) self.updateCards() self.dialog.cardList.setCurrentRow(len(self.m.cardModels)-1)