Add API for note browsing

This commit is contained in:
Alex Yatskov 2016-07-17 19:53:04 -07:00
parent 9420b66570
commit 654c47ceb6

View File

@ -286,9 +286,19 @@ class AnkiBridge:
return note return note
def browseNote(self, noteId): def browseNote(self, deckName, modelName, fields):
fields = self.modelFieldNames(modelName)
if fields is None:
return
fieldName = fields[0]
fieldValue = fields.get(fieldName)
if fieldValue is None:
return
browser = aqt.dialogs.open('Browser', self.window()) browser = aqt.dialogs.open('Browser', self.window())
browser.form.searchEdit.lineEdit().setText('nid:{0}'.format(noteId)) browser.form.searchEdit.lineEdit().setText('deck:{} {}:{}'.format(deckName, fieldName, fieldValue))
browser.onSearch() browser.onSearch()
@ -396,6 +406,14 @@ class AnkiConnect:
return results return results
def api_browseNote(self, note):
return self.anki.browseNote(
note['deckName'],
note['modelName'],
note['fields']
)
def api_features(self): def api_features(self):
features = {} features = {}
for name in dir(self): for name in dir(self):