mirror of
https://github.com/ankitects/anki.git
synced 2025-09-23 00:12:25 -04:00
remember tags & group on a per-model basis
This commit is contained in:
parent
a13b539819
commit
e26a735a49
3 changed files with 16 additions and 10 deletions
|
@ -40,9 +40,6 @@ class AddCards(QDialog):
|
||||||
self.open()
|
self.open()
|
||||||
self.setupNewFact()
|
self.setupNewFact()
|
||||||
|
|
||||||
def focusOutEvent(self, evt):
|
|
||||||
print "focus lost"
|
|
||||||
|
|
||||||
def setupEditor(self):
|
def setupEditor(self):
|
||||||
self.editor = aqt.editor.Editor(self.mw, self.form.fieldsArea, True)
|
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
|
# FIXME: need to make sure to clean up fact on exit
|
||||||
def setupNewFact(self, set=True):
|
def setupNewFact(self, set=True):
|
||||||
f = self.mw.deck.newFact()
|
f = self.mw.deck.newFact()
|
||||||
if self.editor.fact:
|
f.tags = f.model().conf['tags']
|
||||||
# keep tags?
|
|
||||||
f.tags = self.editor.fact.tags
|
|
||||||
if set:
|
if set:
|
||||||
self.editor.setFact(f)
|
self.editor.setFact(f)
|
||||||
return f
|
return f
|
||||||
|
|
|
@ -191,7 +191,12 @@ class DeckModel(QAbstractTableModel):
|
||||||
######################################################################
|
######################################################################
|
||||||
|
|
||||||
def columnType(self, column):
|
def columnType(self, column):
|
||||||
|
try:
|
||||||
type = self.activeCols[column]
|
type = self.activeCols[column]
|
||||||
|
except:
|
||||||
|
# debugging
|
||||||
|
print column, self.activeCols
|
||||||
|
return "factFld"
|
||||||
return type
|
return type
|
||||||
|
|
||||||
def columnData(self, index):
|
def columnData(self, index):
|
||||||
|
|
|
@ -187,12 +187,12 @@ $(function () {
|
||||||
|
|
||||||
# caller is responsible for resetting fact on reset
|
# caller is responsible for resetting fact on reset
|
||||||
class Editor(object):
|
class Editor(object):
|
||||||
def __init__(self, mw, widget, editableGroup=False):
|
def __init__(self, mw, widget, addMode=False):
|
||||||
self.widget = widget
|
self.widget = widget
|
||||||
self.mw = mw
|
self.mw = mw
|
||||||
self.fact = None
|
self.fact = None
|
||||||
self.stealFocus = True
|
self.stealFocus = True
|
||||||
self.editableGroup = editableGroup
|
self.addMode = addMode
|
||||||
self._loaded = False
|
self._loaded = False
|
||||||
self._keepButtons = False
|
self._keepButtons = False
|
||||||
# current card, for card layout
|
# current card, for card layout
|
||||||
|
@ -466,7 +466,7 @@ class Editor(object):
|
||||||
tb.setSpacing(12)
|
tb.setSpacing(12)
|
||||||
tb.setMargin(6)
|
tb.setMargin(6)
|
||||||
# group
|
# group
|
||||||
if self.editableGroup:
|
if self.addMode:
|
||||||
l = QLabel(_("Group"))
|
l = QLabel(_("Group"))
|
||||||
else:
|
else:
|
||||||
l = QLabel(_("Fact Group"))
|
l = QLabel(_("Fact Group"))
|
||||||
|
@ -501,6 +501,12 @@ class Editor(object):
|
||||||
return
|
return
|
||||||
self.fact.gid = self.mw.deck.groupId(unicode(self.group.text()))
|
self.fact.gid = self.mw.deck.groupId(unicode(self.group.text()))
|
||||||
self.fact.tags = parseTags(unicode(self.tags.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()
|
self.fact.flush()
|
||||||
runHook("tagsAndGroupUpdated", self.fact)
|
runHook("tagsAndGroupUpdated", self.fact)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue