diff --git a/aqt/addcards.py b/aqt/addcards.py index 9a43136c7..141851056 100644 --- a/aqt/addcards.py +++ b/aqt/addcards.py @@ -40,9 +40,6 @@ class AddCards(QDialog): self.open() self.setupNewFact() - def focusOutEvent(self, evt): - print "focus lost" - def setupEditor(self): self.editor = aqt.editor.Editor(self.mw, self.form.fieldsArea, True) @@ -82,9 +79,7 @@ class AddCards(QDialog): # FIXME: need to make sure to clean up fact on exit def setupNewFact(self, set=True): f = self.mw.deck.newFact() - if self.editor.fact: - # keep tags? - f.tags = self.editor.fact.tags + f.tags = f.model().conf['tags'] if set: self.editor.setFact(f) return f diff --git a/aqt/browser.py b/aqt/browser.py index 64e01d955..332d1e4c2 100644 --- a/aqt/browser.py +++ b/aqt/browser.py @@ -191,7 +191,12 @@ class DeckModel(QAbstractTableModel): ###################################################################### def columnType(self, column): - type = self.activeCols[column] + try: + type = self.activeCols[column] + except: + # debugging + print column, self.activeCols + return "factFld" return type def columnData(self, index): diff --git a/aqt/editor.py b/aqt/editor.py index e7f278b4d..1c145f40b 100644 --- a/aqt/editor.py +++ b/aqt/editor.py @@ -187,12 +187,12 @@ $(function () { # caller is responsible for resetting fact on reset class Editor(object): - def __init__(self, mw, widget, editableGroup=False): + def __init__(self, mw, widget, addMode=False): self.widget = widget self.mw = mw self.fact = None self.stealFocus = True - self.editableGroup = editableGroup + self.addMode = addMode self._loaded = False self._keepButtons = False # current card, for card layout @@ -466,7 +466,7 @@ class Editor(object): tb.setSpacing(12) tb.setMargin(6) # group - if self.editableGroup: + if self.addMode: l = QLabel(_("Group")) else: l = QLabel(_("Fact Group")) @@ -501,6 +501,12 @@ class Editor(object): return self.fact.gid = self.mw.deck.groupId(unicode(self.group.text())) self.fact.tags = parseTags(unicode(self.tags.text())) + if self.addMode: + # save group and tags to model + m = self.fact.model() + m.conf['gid'] = self.fact.gid + m.conf['tags'] = self.fact.tags + m.flush() self.fact.flush() runHook("tagsAndGroupUpdated", self.fact)