diff --git a/yomi_base/anki_host.py b/yomi_base/anki_host.py
index d28bcb6..3de445b 100644
--- a/yomi_base/anki_host.py
+++ b/yomi_base/anki_host.py
@@ -23,50 +23,50 @@ import re
class Anki:
- def addFact(self, fields, tags=unicode()):
- fact = self.createFact(fields, tags)
- if not fact:
+ def addNote(self, fields, tags=unicode()):
+ note = self.createNote(fields, tags)
+ if not note:
return None
action = lang._('Add')
- deck = self.deck()
- deck.setUndoStart(action)
- deck.addFact(fact, False)
- deck.setUndoEnd(action)
- deck.rebuildCounts()
+ collection = self.collection()
+ collection.setUndoStart(action)
+ collection.addNote(note, False)
+ collection.setUndoEnd(action)
+ collection.rebuildCounts()
ankiqt.mw.updateTitleBar()
ankiqt.mw.statusView.redraw()
- return fact.id
+ return note.id
- def canAddFact(self, fields):
- return bool(self.createFact(fields))
+ def canAddNote(self, fields):
+ return bool(self.createNote(fields))
- def createFact(self, fields, tags=unicode()):
- deck = self.deck()
- fact = deck.newFact()
- fact.tags = self.cleanupTags(tags)
+ def createNote(self, fields, tags=unicode()):
+ collection = self.collection()
+ note = collection.newnote()
+ note.tags = self.cleanupTags(tags)
try:
- for field in fact.fields:
+ for field in note.fields:
field.value = fields.get(field.getName()) or unicode()
- if not fact.fieldValid(field) or not fact.fieldUnique(field, deck.s):
+ if not note.fieldValid(field) or not note.fieldUnique(field, collection.s):
return None
except KeyError:
return None
- return fact
+ return note
- def browseFact(self, factId):
+ def browseNote(self, noteId):
browser = ui.dialogs.get('CardList', self.window())
- browser.dialog.filterEdit.setText('fid:' + str(factId))
+ browser.dialog.filterEdit.setText('fid:' + str(noteId))
browser.updateSearch()
- browser.onFact()
+ browser.onnote()
def cleanupTags(self, tags):
@@ -74,30 +74,28 @@ class Anki:
def fields(self):
- return [
- (field.name, field.required, field.unique) for field in self.model().fieldModels
- ]
-
-
- def deck(self):
- return self.window().deck
-
-
- def model(self):
- return self.deck().currentModel
+ return [field['name'] for field in self.currentModel()['flds']]
def window(self):
return aqt.mw
+ def form(self):
+ return self.window().form
+
+
def toolsMenu(self):
- return self.window().form.menuTools
+ return self.form().menuTools
- def addHook(self, name, callback):
- hooks.addHook(name, callback)
+ def collection(self):
+ return self.window().col
- def removeHook(self, name, callback):
- hooks.removeHook(name, callback)
+ def models(self):
+ return self.collection().models
+
+
+ def currentModel(self):
+ return self.models().current()
diff --git a/yomi_base/preference_data.py b/yomi_base/preference_data.py
index d809d15..473b233 100644
--- a/yomi_base/preference_data.py
+++ b/yomi_base/preference_data.py
@@ -97,8 +97,6 @@ class Preferences:
self.searchGroupByExp = self.readAttrBool(search, 'groupByExp', self.searchGroupByExp)
for anki in root.getElementsByTagName('anki'):
- self.ankiShowIcon = self.readAttrBool(anki, 'showIcon', self.ankiShowIcon)
-
for tag in anki.getElementsByTagName('tag'):
value = self.readAttrStr(tag, 'value', unicode())
self.ankiTags.append(value)
@@ -164,7 +162,6 @@ class Preferences:
anki = doc.createElement('anki')
root.appendChild(anki)
- self.writeAttrBool(anki, 'showIcon', self.ankiShowIcon)
for value in self.ankiTags:
tag = doc.createElement('tag')
diff --git a/yomi_base/preferences.py b/yomi_base/preferences.py
index 63b5e16..87bbfc5 100644
--- a/yomi_base/preferences.py
+++ b/yomi_base/preferences.py
@@ -51,8 +51,7 @@ class DialogPreferences(QtGui.QDialog):
self.spinSearchResultMax.setValue(self.preferences.searchResultMax)
self.checkSearchGroupByExp.setChecked(self.preferences.searchGroupByExp)
- self.checkAnkiShowIcon.setChecked(self.preferences.ankiShowIcon)
- self.tabAnki.setEnabled(bool(self.anki))
+ self.tabAnki.setEnabled(self.anki is not None)
if self.anki:
self.setAnkiFields(self.anki.fields(), self.preferences.ankiFields)
@@ -66,7 +65,6 @@ class DialogPreferences(QtGui.QDialog):
self.preferences.searchResultMax = self.spinSearchResultMax.value()
self.preferences.searchGroupByExp = self.checkSearchGroupByExp.isChecked()
- self.preferences.ankiShowIcon = self.checkAnkiShowIcon.isChecked()
if self.anki:
self.preferences.ankiFields = self.ankiFields()
@@ -86,7 +84,7 @@ class DialogPreferences(QtGui.QDialog):
def setAnkiFields(self, fieldsAnki, fieldsPrefs):
self.tableAnkiFields.setRowCount(len(fieldsAnki))
- for i, (name, required, unique) in enumerate(fieldsAnki):
+ for i, name in enumerate(fieldsAnki):
columns = list()
itemName = QtGui.QTableWidgetItem(name)
@@ -96,16 +94,6 @@ class DialogPreferences(QtGui.QDialog):
itemValue = QtGui.QTableWidgetItem(fieldsPrefs.get(name, unicode()))
columns.append(itemValue)
- itemRequired = QtGui.QTableWidgetItem()
- itemRequired.setFlags(QtCore.Qt.ItemIsUserCheckable)
- itemRequired.setCheckState(QtCore.Qt.Checked if required else QtCore.Qt.Unchecked)
- columns.append(itemRequired)
-
- itemUnique = QtGui.QTableWidgetItem()
- itemUnique.setFlags(QtCore.Qt.ItemIsUserCheckable)
- itemUnique.setCheckState(QtCore.Qt.Checked if unique else QtCore.Qt.Unchecked)
- columns.append(itemUnique)
-
for j, column in enumerate(columns):
self.tableAnkiFields.setItem(i, j, column)
diff --git a/yomi_base/ui/preferences.ui b/yomi_base/ui/preferences.ui
index 42b14e5..acb30ff 100644
--- a/yomi_base/ui/preferences.ui
+++ b/yomi_base/ui/preferences.ui
@@ -193,16 +193,6 @@
Value
-
-
- Required
-
-
-
-
- Unique
-
-
-
@@ -320,13 +310,6 @@
- -
-
-
- Show icon in toolbar
-
-
-