_fields -> fields

This commit is contained in:
Damien Elmes 2011-04-13 22:44:41 +09:00
parent 2245be962a
commit 8865ca6131
6 changed files with 15 additions and 11 deletions

View file

@ -93,9 +93,9 @@ class AddCards(QDialog):
# copy fields from old fact # copy fields from old fact
if oldFact: if oldFact:
self.removeTempFact(oldFact) self.removeTempFact(oldFact)
for n in range(len(fact._fields)): for n in range(len(fact.fields)):
try: try:
fact._fields[n] = oldFact._fields[n] fact.fields[n] = oldFact.fields[n]
except IndexError: except IndexError:
break break
self.editor.setFact(fact) self.editor.setFact(fact)
@ -107,7 +107,7 @@ class AddCards(QDialog):
self.mw.deck._delFacts([fact.id]) self.mw.deck._delFacts([fact.id])
def addHistory(self, fact): def addHistory(self, fact):
txt = stripHTMLMedia(",".join(fact._fields))[:30] txt = stripHTMLMedia(",".join(fact.fields))[:30]
self.history.append((fact.id, txt)) self.history.append((fact.id, txt))
self.history = self.history[-15:] self.history = self.history[-15:]
self.historyButton.setEnabled(True) self.historyButton.setEnabled(True)

View file

@ -195,7 +195,7 @@ class DeckModel(QAbstractTableModel):
return self.formatQA(c.a()) return self.formatQA(c.a())
elif type == "factFld": elif type == "factFld":
f = c.fact() f = c.fact()
return self.formatQA(f._fields[f.model().sortIdx()]) return self.formatQA(f.fields[f.model().sortIdx()])
elif type == "template": elif type == "template":
return c.template()['name'] return c.template()['name']
elif type == "cardDue": elif type == "cardDue":

View file

@ -311,7 +311,7 @@ class Editor(object):
# focus lost or key/button pressed? # focus lost or key/button pressed?
if str.startswith("blur") or str.startswith("key"): if str.startswith("blur") or str.startswith("key"):
(type, txt) = str.split(":", 1) (type, txt) = str.split(":", 1)
self.fact._fields[self.currentField] = self.mungeHTML(txt) self.fact.fields[self.currentField] = self.mungeHTML(txt)
if type == "blur": if type == "blur":
if not self._keepButtons: if not self._keepButtons:
self.disableButtons() self.disableButtons()
@ -405,7 +405,7 @@ class Editor(object):
def fieldsAreBlank(self): def fieldsAreBlank(self):
if not self.fact: if not self.fact:
return True return True
for f in self.fact._fields: for f in self.fact.fields:
if f: if f:
return False return False
return True return True
@ -420,10 +420,10 @@ class Editor(object):
form.setupUi(d) form.setupUi(d)
d.connect(form.buttonBox, SIGNAL("helpRequested()"), d.connect(form.buttonBox, SIGNAL("helpRequested()"),
lambda: aqt.openHelp("HtmlEditor")) lambda: aqt.openHelp("HtmlEditor"))
form.textEdit.setPlainText(self.fact._fields[self.currentField]) form.textEdit.setPlainText(self.fact.fields[self.currentField])
form.textEdit.moveCursor(QTextCursor.End) form.textEdit.moveCursor(QTextCursor.End)
d.exec_() d.exec_()
self.fact._fields[self.currentField] = unicode( self.fact.fields[self.currentField] = unicode(
form.textEdit.toPlainText()) form.textEdit.toPlainText())
self.loadFact(self.currentField) self.loadFact(self.currentField)
@ -503,7 +503,7 @@ class Editor(object):
showInfo(_("Please add a cloze deletion model."), showInfo(_("Please add a cloze deletion model."),
help="ClozeDeletion") help="ClozeDeletion")
return return
f = self.fact._fields[self.currentField] f = self.fact.fields[self.currentField]
# find the highest existing cloze # find the highest existing cloze
m = re.findall("\{\{c(\d+)::", f) m = re.findall("\{\{c(\d+)::", f)
if m: if m:

View file

@ -238,7 +238,7 @@ title="%s">%s</button>''' % (
def onUpgrade(self, db): def onUpgrade(self, db):
self.upgrading = True self.upgrading = True
self.progress.setupDB(db) self.progress.setupDB(db)
self.progress.start(label=_("Upgrading...")) self.progress.start(label=_("Upgrading. Please be patient..."))
# Deck loading # Deck loading
########################################################################## ##########################################################################

View file

@ -6,6 +6,10 @@ import time
from PyQt4.QtGui import * from PyQt4.QtGui import *
from PyQt4.QtCore import * from PyQt4.QtCore import *
# fixme: if mw->subwindow opens a progress dialog with mw as the parent, mw
# gets raised on finish on compiz. perhaps we should be using the progress
# dialog as the parent?
# Progress info # Progress info
########################################################################## ##########################################################################

View file

@ -378,7 +378,7 @@ div#filler {
ord = self.typeAns() ord = self.typeAns()
try: try:
cor = self.mw.deck.media.strip( cor = self.mw.deck.media.strip(
stripHTML(self.card.fact()._fields[ord])) stripHTML(self.card.fact().fields[ord]))
except IndexError: except IndexError:
self.card.template()['typeAns'] = None self.card.template()['typeAns'] = None
self.card.model().flush() self.card.model().flush()