mirror of
https://github.com/ankitects/anki.git
synced 2025-09-24 16:56:36 -04:00
remember search history
This commit is contained in:
parent
dd0a6563e7
commit
612fefc347
2 changed files with 13 additions and 0 deletions
|
@ -424,10 +424,22 @@ class Browser(QMainWindow):
|
||||||
SIGNAL("returnPressed()"),
|
SIGNAL("returnPressed()"),
|
||||||
self.onSearch)
|
self.onSearch)
|
||||||
self.setTabOrder(self.form.searchEdit, self.form.tableView)
|
self.setTabOrder(self.form.searchEdit, self.form.tableView)
|
||||||
|
self.compModel = QStringListModel()
|
||||||
|
self.compModel.setStringList(QStringList(self.mw.config['searchHistory']))
|
||||||
|
self.searchComp = QCompleter(self.compModel, self.form.searchEdit)
|
||||||
|
self.searchComp.setCompletionMode(QCompleter.UnfilteredPopupCompletion)
|
||||||
|
self.searchComp.setCaseSensitivity(Qt.CaseInsensitive)
|
||||||
|
self.form.searchEdit.setCompleter(self.searchComp)
|
||||||
|
|
||||||
def onSearch(self, reset=True):
|
def onSearch(self, reset=True):
|
||||||
"Careful: if reset is true, the current fact is saved."
|
"Careful: if reset is true, the current fact is saved."
|
||||||
txt = unicode(self.form.searchEdit.text()).strip()
|
txt = unicode(self.form.searchEdit.text()).strip()
|
||||||
|
sh = self.mw.config['searchHistory']
|
||||||
|
if txt not in sh:
|
||||||
|
sh.insert(0, txt)
|
||||||
|
sh = sh[:30]
|
||||||
|
self.compModel.setStringList(QStringList(sh))
|
||||||
|
self.mw.config['searchHistory'] = sh
|
||||||
self.model.search(txt, reset)
|
self.model.search(txt, reset)
|
||||||
if not self.model.cards:
|
if not self.model.cards:
|
||||||
# no row change will fire
|
# no row change will fire
|
||||||
|
|
|
@ -24,6 +24,7 @@ defaultConf = {
|
||||||
'fullSearch': False,
|
'fullSearch': False,
|
||||||
|
|
||||||
'autoplaySounds': True,
|
'autoplaySounds': True,
|
||||||
|
'searchHistory': [],
|
||||||
'checkForUpdates': True,
|
'checkForUpdates': True,
|
||||||
'created': time.time(),
|
'created': time.time(),
|
||||||
'deleteMedia': False,
|
'deleteMedia': False,
|
||||||
|
|
Loading…
Reference in a new issue