mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 22:12:21 -04:00
Add uses of search_for
This commit is contained in:
parent
2d65e81b13
commit
54dc97825e
1 changed files with 14 additions and 18 deletions
|
@ -760,10 +760,8 @@ class Browser(QMainWindow):
|
||||||
self.form.searchEdit.addItems(
|
self.form.searchEdit.addItems(
|
||||||
[self._searchPrompt] + self.mw.pm.profile["searchHistory"]
|
[self._searchPrompt] + self.mw.pm.profile["searchHistory"]
|
||||||
)
|
)
|
||||||
self._lastSearchTxt = "is:current"
|
self.search_for("is:current")
|
||||||
self.search()
|
|
||||||
# then replace text for easily showing the deck
|
# then replace text for easily showing the deck
|
||||||
self.form.searchEdit.lineEdit().setText(self._searchPrompt)
|
|
||||||
self.form.searchEdit.lineEdit().selectAll()
|
self.form.searchEdit.lineEdit().selectAll()
|
||||||
self.form.searchEdit.setFocus()
|
self.form.searchEdit.setFocus()
|
||||||
|
|
||||||
|
@ -772,12 +770,14 @@ class Browser(QMainWindow):
|
||||||
self.editor.saveNow(self._onSearchActivated)
|
self.editor.saveNow(self._onSearchActivated)
|
||||||
|
|
||||||
def _onSearchActivated(self):
|
def _onSearchActivated(self):
|
||||||
# convert guide text before we save history
|
|
||||||
if self.form.searchEdit.lineEdit().text() == self._searchPrompt:
|
|
||||||
self.form.searchEdit.lineEdit().setText("deck:current ")
|
|
||||||
|
|
||||||
# grab search text and normalize
|
# grab search text and normalize
|
||||||
txt = self.form.searchEdit.lineEdit().text()
|
prompt = self.form.searchEdit.lineEdit().text()
|
||||||
|
|
||||||
|
# convert guide text before we save history
|
||||||
|
if prompt == self._searchPrompt:
|
||||||
|
txt = "deck:current "
|
||||||
|
else:
|
||||||
|
txt = prompt
|
||||||
|
|
||||||
# update history
|
# update history
|
||||||
sh = self.mw.pm.profile["searchHistory"]
|
sh = self.mw.pm.profile["searchHistory"]
|
||||||
|
@ -791,8 +791,7 @@ class Browser(QMainWindow):
|
||||||
|
|
||||||
# keep track of search string so that we reuse identical search when
|
# keep track of search string so that we reuse identical search when
|
||||||
# refreshing, rather than whatever is currently in the search field
|
# refreshing, rather than whatever is currently in the search field
|
||||||
self._lastSearchTxt = txt
|
self.search_for(txt)
|
||||||
self.search()
|
|
||||||
|
|
||||||
def search_for(self, search: str, prompt: Optional[str] = None) -> None:
|
def search_for(self, search: str, prompt: Optional[str] = None) -> None:
|
||||||
self._lastSearchTxt = search
|
self._lastSearchTxt = search
|
||||||
|
@ -1802,13 +1801,13 @@ where id in %s"""
|
||||||
|
|
||||||
def _selectNotes(self):
|
def _selectNotes(self):
|
||||||
nids = self.selectedNotes()
|
nids = self.selectedNotes()
|
||||||
# bypass search history
|
|
||||||
self._lastSearchTxt = "nid:" + ",".join([str(x) for x in nids])
|
|
||||||
self.form.searchEdit.lineEdit().setText(self._lastSearchTxt)
|
|
||||||
# clear the selection so we don't waste energy preserving it
|
# clear the selection so we don't waste energy preserving it
|
||||||
tv = self.form.tableView
|
tv = self.form.tableView
|
||||||
tv.selectionModel().clear()
|
tv.selectionModel().clear()
|
||||||
self.search()
|
|
||||||
|
search = "nid:" + ",".join([str(x) for x in nids])
|
||||||
|
self.search_for(search)
|
||||||
|
|
||||||
tv.selectAll()
|
tv.selectAll()
|
||||||
|
|
||||||
def invertSelection(self):
|
def invertSelection(self):
|
||||||
|
@ -2031,10 +2030,7 @@ where id in %s"""
|
||||||
tooltip(_("Notes tagged."))
|
tooltip(_("Notes tagged."))
|
||||||
|
|
||||||
def dupeLinkClicked(self, link):
|
def dupeLinkClicked(self, link):
|
||||||
self.form.searchEdit.lineEdit().setText(link)
|
self.search_for(link)
|
||||||
# manually, because we've already saved
|
|
||||||
self._lastSearchTxt = link
|
|
||||||
self.search()
|
|
||||||
self.onNote()
|
self.onNote()
|
||||||
|
|
||||||
# Jumping
|
# Jumping
|
||||||
|
|
Loading…
Reference in a new issue