mirror of
https://github.com/ankitects/anki.git
synced 2025-09-24 08:46:37 -04:00
Add browser_search helper in mw
This commit is contained in:
parent
251fe50660
commit
f04228990d
6 changed files with 14 additions and 19 deletions
|
@ -161,9 +161,7 @@ class AddCards(QDialog):
|
|||
m.exec_(self.historyButton.mapToGlobal(QPoint(0, 0)))
|
||||
|
||||
def editHistory(self, nid):
|
||||
browser = aqt.dialogs.open("Browser", self.mw)
|
||||
browser.form.searchEdit.lineEdit().setText(self.mw.col.search_string(nids=[nid]))
|
||||
browser.onSearchActivated()
|
||||
self.mw.browser_search(nids=[nid])
|
||||
|
||||
def addNote(self, note) -> Optional[Note]:
|
||||
note.model()["did"] = self.deckChooser.selectedId()
|
||||
|
|
|
@ -1637,13 +1637,6 @@ where id in %s"""
|
|||
# Edit: finding dupes
|
||||
######################################################################
|
||||
|
||||
# filter called by the editor
|
||||
def search_dupe(self, mid: int, text: str):
|
||||
self.form.searchEdit.lineEdit().setText(
|
||||
self.col.search_string(dupe=(mid, text))
|
||||
)
|
||||
self.onSearchActivated()
|
||||
|
||||
def onFindDupes(self):
|
||||
self.editor.saveNow(self._onFindDupes)
|
||||
|
||||
|
|
|
@ -539,8 +539,7 @@ class Editor:
|
|||
self.web.eval("setBackgrounds(%s);" % json.dumps(cols))
|
||||
|
||||
def showDupes(self):
|
||||
browser = aqt.dialogs.open("Browser", self.mw)
|
||||
browser.search_dupe(self.note.model()["id"], self.note.fields[0])
|
||||
self.mw.browser_search(dupe=(self.note.model()["id"], self.note.fields[0]))
|
||||
|
||||
def fieldsAreBlank(self, previousNote=None):
|
||||
if not self.note:
|
||||
|
|
|
@ -66,9 +66,7 @@ class EmptyCardsDialog(QDialog):
|
|||
self._delete_button.clicked.connect(self._on_delete)
|
||||
|
||||
def _on_note_link_clicked(self, link):
|
||||
browser = aqt.dialogs.open("Browser", self.mw)
|
||||
browser.form.searchEdit.lineEdit().setText(link)
|
||||
browser.onSearchActivated()
|
||||
self.mw.browser_search(searches=[link])
|
||||
|
||||
def _on_delete(self):
|
||||
self.mw.progress.start()
|
||||
|
|
|
@ -1617,3 +1617,13 @@ title="%s" %s>%s</button>""" % (
|
|||
|
||||
def serverURL(self) -> str:
|
||||
return "http://127.0.0.1:%d/" % self.mediaServer.getPort()
|
||||
|
||||
# Helpers for all windows
|
||||
##########################################################################
|
||||
|
||||
# Wrapper for col.search_string() to look up the result in the browser.
|
||||
def browser_search(self, **kwargs) -> None:
|
||||
search = self.col.search_string(**kwargs)
|
||||
browser = aqt.dialogs.open("Browser", self)
|
||||
browser.form.searchEdit.lineEdit().setText(search)
|
||||
browser.onSearchActivated()
|
||||
|
|
|
@ -145,10 +145,7 @@ class MediaChecker:
|
|||
|
||||
if out is not None:
|
||||
nid, err = out
|
||||
browser = aqt.dialogs.open("Browser", self.mw)
|
||||
search = self.mw.col.search_string(nids=[nid])
|
||||
browser.form.searchEdit.lineEdit().setText(search)
|
||||
browser.onSearchActivated()
|
||||
self.mw.browser_search(nids=[nid])
|
||||
showText(err, type="html")
|
||||
else:
|
||||
tooltip(tr(TR.MEDIA_CHECK_ALL_LATEX_RENDERED))
|
||||
|
|
Loading…
Reference in a new issue