NF: factorize browser.current_search

I was looking at search code and find out that's already slightly more clear/short even if NF
This commit is contained in:
Arthur Milchior 2021-04-14 10:42:26 +02:00
parent 7b2b4528b3
commit be44d4eeed
2 changed files with 3 additions and 5 deletions

View File

@ -281,7 +281,7 @@ class Browser(QMainWindow):
# search triggered by user
@ensure_editor_saved
def onSearchActivated(self) -> None:
text = self.form.searchEdit.lineEdit().text()
text = self.current_search()
try:
normed = self.col.build_search_string(text)
except Exception as err:
@ -580,7 +580,7 @@ where id in %s"""
ChangeModel(self, nids)
def createFilteredDeck(self) -> None:
search = self.form.searchEdit.lineEdit().text()
search = self.current_search()
if self.mw.col.schedVer() != 1 and KeyboardModifiersPressed().alt:
aqt.dialogs.open("FilteredDeckConfigDialog", self.mw, search_2=search)
else:

View File

@ -933,9 +933,7 @@ class SidebarTreeView(QTreeView):
def _get_current_search(self) -> Optional[str]:
try:
return self.col.build_search_string(
self.browser.form.searchEdit.lineEdit().text()
)
return self.col.build_search_string(self.browser.current_search())
except Exception as e:
showWarning(str(e))
return None