mirror of
https://github.com/ankitects/anki.git
synced 2025-11-14 00:27:13 -05:00
Factor out drawField
This commit is contained in:
parent
f3b81d0024
commit
c0003c4c03
1 changed files with 33 additions and 27 deletions
|
|
@ -370,25 +370,13 @@ class FactEditor(object):
|
||||||
self.fieldsFrame.setLayout(self.fieldsGrid)
|
self.fieldsFrame.setLayout(self.fieldsGrid)
|
||||||
self.fieldsGrid.setMargin(0)
|
self.fieldsGrid.setMargin(0)
|
||||||
|
|
||||||
def drawFields(self, noFocus=False, check=False):
|
def drawField(self, field, n):
|
||||||
self.parent.setUpdatesEnabled(False)
|
|
||||||
self._makeGrid()
|
|
||||||
# add entries for each field
|
|
||||||
fields = self.fact.fields
|
|
||||||
self.fields = {}
|
|
||||||
self.widgets = {}
|
|
||||||
self.labels = []
|
|
||||||
n = 0
|
|
||||||
first = True
|
|
||||||
last = None
|
|
||||||
for field in fields:
|
|
||||||
# label
|
# label
|
||||||
l = QLabel(field.name)
|
l = QLabel(field.name)
|
||||||
self.labels.append(l)
|
self.labels.append(l)
|
||||||
self.fieldsGrid.addWidget(l, n, 0)
|
self.fieldsGrid.addWidget(l, n, 0)
|
||||||
# edit widget
|
# edit widget
|
||||||
w = FactEdit(self)
|
w = FactEdit(self)
|
||||||
last = w
|
|
||||||
w.setTabChangesFocus(True)
|
w.setTabChangesFocus(True)
|
||||||
w.setAcceptRichText(True)
|
w.setAcceptRichText(True)
|
||||||
w.setMinimumSize(20, 60)
|
w.setMinimumSize(20, 60)
|
||||||
|
|
@ -410,10 +398,28 @@ class FactEditor(object):
|
||||||
self.onTextChanged)
|
self.onTextChanged)
|
||||||
w.connect(w, SIGNAL("currentCharFormatChanged(QTextCharFormat)"),
|
w.connect(w, SIGNAL("currentCharFormatChanged(QTextCharFormat)"),
|
||||||
lambda w=w: self.formatChanged(w))
|
lambda w=w: self.formatChanged(w))
|
||||||
|
return w
|
||||||
|
|
||||||
|
def drawFields(self, noFocus=False, check=False):
|
||||||
|
self.parent.setUpdatesEnabled(False)
|
||||||
|
self._makeGrid()
|
||||||
|
# add entries for each field
|
||||||
|
fields = self.fact.fields
|
||||||
|
self.fields = {}
|
||||||
|
self.widgets = {}
|
||||||
|
self.labels = []
|
||||||
|
n = 0
|
||||||
|
first = True
|
||||||
|
last = None
|
||||||
|
|
||||||
|
for field in fields:
|
||||||
|
w = self.drawField(field, n)
|
||||||
|
last = w
|
||||||
if first:
|
if first:
|
||||||
self.focusTarget = w
|
self.focusTarget = w
|
||||||
first = False
|
first = False
|
||||||
n += 1
|
n += 1
|
||||||
|
|
||||||
# update available tags
|
# update available tags
|
||||||
self.tags.setDeck(self.deck)
|
self.tags.setDeck(self.deck)
|
||||||
# update fields
|
# update fields
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue