browser now works
This commit is contained in:
parent
21a99a0dd5
commit
863e36d4a7
@ -17,7 +17,7 @@
|
||||
|
||||
|
||||
import aqt
|
||||
import anki.hooks
|
||||
import anki
|
||||
|
||||
|
||||
class Anki:
|
||||
@ -28,6 +28,7 @@ class Anki:
|
||||
collection.addNote(note)
|
||||
collection.autosave()
|
||||
self.startEditing()
|
||||
return note.id
|
||||
|
||||
|
||||
def canAddNote(self, deckName, modelName, fields):
|
||||
@ -50,14 +51,14 @@ class Anki:
|
||||
for name, value in fields.items():
|
||||
note[name] = value
|
||||
|
||||
return None if note.dupeOrEmpty() else note
|
||||
if not note.dupeOrEmpty():
|
||||
return note
|
||||
|
||||
|
||||
def browseNote(self, noteId):
|
||||
browser = ui.dialogs.get('CardList', self.window())
|
||||
browser.dialog.filterEdit.setText('fid:' + str(noteId))
|
||||
browser.updateSearch()
|
||||
browser.onnote()
|
||||
browser = aqt.dialogs.open('Browser', self.window())
|
||||
browser.form.searchEdit.lineEdit().setText('nid:{0}'.format(noteId))
|
||||
browser.onSearch()
|
||||
|
||||
|
||||
def startEditing(self):
|
||||
@ -90,7 +91,8 @@ class Anki:
|
||||
|
||||
def modelFieldNames(self, modelName):
|
||||
model = self.models().byName(modelName)
|
||||
return None if model is None else [field['name'] for field in model['flds']]
|
||||
if model is not None:
|
||||
return [field['name'] for field in model['flds']]
|
||||
|
||||
|
||||
def decks(self):
|
||||
|
@ -259,7 +259,6 @@ class MainWindowReader(QtGui.QMainWindow):
|
||||
definition.sentence
|
||||
)
|
||||
self.ankiAddFact(markup)
|
||||
self.updateDefinitions()
|
||||
if command == 'addFactReading':
|
||||
markup = reader_util.buildFactMarkupReading(
|
||||
definition.reading,
|
||||
@ -267,7 +266,6 @@ class MainWindowReader(QtGui.QMainWindow):
|
||||
definition.sentence
|
||||
)
|
||||
self.ankiAddFact(markup)
|
||||
self.updateDefinitions()
|
||||
elif command == 'copyDefinition':
|
||||
reader_util.copyDefinitions([definition])
|
||||
|
||||
@ -295,7 +293,7 @@ class MainWindowReader(QtGui.QMainWindow):
|
||||
|
||||
|
||||
def onUpdaterSearchResult(self, result):
|
||||
if result and result > constants['version']:
|
||||
if result is not None and result > constants['version']:
|
||||
QtGui.QMessageBox.information(
|
||||
self,
|
||||
'Yomichan',
|
||||
@ -358,21 +356,18 @@ class MainWindowReader(QtGui.QMainWindow):
|
||||
|
||||
self.updateArchiveFiles(filename, names)
|
||||
|
||||
if len(files) == 0:
|
||||
content = unicode()
|
||||
elif len(files) == 1:
|
||||
if len(files) == 1:
|
||||
fp = tp.extractfile(files[0])
|
||||
content = fp.read()
|
||||
fp.close()
|
||||
else:
|
||||
elif len(files) > 1:
|
||||
index, ok = self.selectFileName(names)
|
||||
if ok:
|
||||
fp = tp.extractfile(files[index])
|
||||
content = fp.read()
|
||||
fp.close()
|
||||
self.state.archiveIndex = index
|
||||
else:
|
||||
content = unicode()
|
||||
else:
|
||||
self.state.archiveIndex = None
|
||||
with open(filename, 'rb') as fp:
|
||||
@ -383,7 +378,7 @@ class MainWindowReader(QtGui.QMainWindow):
|
||||
|
||||
def selectFileName(self, names):
|
||||
if self.state.archiveIndex is not None:
|
||||
return (self.state.archiveIndex, True)
|
||||
return self.state.archiveIndex, True
|
||||
|
||||
item, ok = QtGui.QInputDialog.getItem(
|
||||
self,
|
||||
|
Loading…
Reference in New Issue
Block a user