Add uses of search_for
This commit is contained in:
parent
2d65e81b13
commit
54dc97825e
@ -760,10 +760,8 @@ class Browser(QMainWindow):
|
||||
self.form.searchEdit.addItems(
|
||||
[self._searchPrompt] + self.mw.pm.profile["searchHistory"]
|
||||
)
|
||||
self._lastSearchTxt = "is:current"
|
||||
self.search()
|
||||
self.search_for("is:current")
|
||||
# then replace text for easily showing the deck
|
||||
self.form.searchEdit.lineEdit().setText(self._searchPrompt)
|
||||
self.form.searchEdit.lineEdit().selectAll()
|
||||
self.form.searchEdit.setFocus()
|
||||
|
||||
@ -772,12 +770,14 @@ class Browser(QMainWindow):
|
||||
self.editor.saveNow(self._onSearchActivated)
|
||||
|
||||
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
|
||||
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
|
||||
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
|
||||
# refreshing, rather than whatever is currently in the search field
|
||||
self._lastSearchTxt = txt
|
||||
self.search()
|
||||
self.search_for(txt)
|
||||
|
||||
def search_for(self, search: str, prompt: Optional[str] = None) -> None:
|
||||
self._lastSearchTxt = search
|
||||
@ -1802,13 +1801,13 @@ where id in %s"""
|
||||
|
||||
def _selectNotes(self):
|
||||
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
|
||||
tv = self.form.tableView
|
||||
tv.selectionModel().clear()
|
||||
self.search()
|
||||
|
||||
search = "nid:" + ",".join([str(x) for x in nids])
|
||||
self.search_for(search)
|
||||
|
||||
tv.selectAll()
|
||||
|
||||
def invertSelection(self):
|
||||
@ -2031,10 +2030,7 @@ where id in %s"""
|
||||
tooltip(_("Notes tagged."))
|
||||
|
||||
def dupeLinkClicked(self, link):
|
||||
self.form.searchEdit.lineEdit().setText(link)
|
||||
# manually, because we've already saved
|
||||
self._lastSearchTxt = link
|
||||
self.search()
|
||||
self.search_for(link)
|
||||
self.onNote()
|
||||
|
||||
# Jumping
|
||||
|
Loading…
Reference in New Issue
Block a user