Factor out reportAddedFact

This commit is contained in:
Shawn M Moore 2010-02-14 17:49:20 -05:00
parent bd595a1e0d
commit 79579676c5

View file

@ -122,6 +122,16 @@ class AddCards(QDialog):
self.setTabOrder(self.addButton, self.closeButton) self.setTabOrder(self.addButton, self.closeButton)
self.setTabOrder(self.closeButton, self.helpButton) self.setTabOrder(self.closeButton, self.helpButton)
def reportAddedFact(self, fact):
self.dialog.status.append(
_("Added %(num)d card(s) for <a href=\"%(id)d\">"
"%(str)s</a>.") % {
"num": len(fact.cards),
"id": fact.id,
# we're guaranteed that all fields will exist now
"str": stripHTML(fact[fact.fields[0].name]),
})
def addCards(self): def addCards(self):
# make sure updated # make sure updated
self.editor.saveFieldsNow() self.editor.saveFieldsNow()
@ -140,14 +150,9 @@ class AddCards(QDialog):
The input you have provided would make an empty The input you have provided would make an empty
question or answer on all cards."""), parent=self) question or answer on all cards."""), parent=self)
return return
self.dialog.status.append(
_("Added %(num)d card(s) for <a href=\"%(id)d\">" self.reportAddedFact(fact)
"%(str)s</a>.") % {
"num": len(fact.cards),
"id": fact.id,
# we're guaranteed that all fields will exist now
"str": stripHTML(fact[fact.fields[0].name]),
})
# stop anything playing # stop anything playing
clearAudioQueue() clearAudioQueue()
self.parent.deck.setUndoEnd(n) self.parent.deck.setUndoEnd(n)