mirror of
https://github.com/ankitects/anki.git
synced 2025-09-20 06:52:21 -04:00
force search updates if not triggered by user
This commit is contained in:
parent
985da34a58
commit
ee6eaeeaa6
1 changed files with 7 additions and 5 deletions
|
@ -103,7 +103,7 @@ class DeckModel(QAbstractTableModel):
|
||||||
# Filtering
|
# Filtering
|
||||||
######################################################################
|
######################################################################
|
||||||
|
|
||||||
def showMatching(self):
|
def showMatching(self, force=True):
|
||||||
if not self.sortKey:
|
if not self.sortKey:
|
||||||
self.cards = []
|
self.cards = []
|
||||||
return
|
return
|
||||||
|
@ -112,7 +112,8 @@ class DeckModel(QAbstractTableModel):
|
||||||
ads = ""
|
ads = ""
|
||||||
self.lastSearch = ""
|
self.lastSearch = ""
|
||||||
else:
|
else:
|
||||||
if self.searchStr.strip() == self.lastSearch.strip():
|
if (self.searchStr.strip() == self.lastSearch.strip()
|
||||||
|
and not force):
|
||||||
# just whitespace
|
# just whitespace
|
||||||
return
|
return
|
||||||
QApplication.instance().processEvents()
|
QApplication.instance().processEvents()
|
||||||
|
@ -463,17 +464,18 @@ class EditDeck(QMainWindow):
|
||||||
self.filterTimer = QTimer(self)
|
self.filterTimer = QTimer(self)
|
||||||
self.filterTimer.setSingleShot(True)
|
self.filterTimer.setSingleShot(True)
|
||||||
self.filterTimer.start(interval)
|
self.filterTimer.start(interval)
|
||||||
self.connect(self.filterTimer, SIGNAL("timeout()"), self.updateSearch)
|
self.connect(self.filterTimer, SIGNAL("timeout()"),
|
||||||
|
lambda: self.updateSearch(force=False))
|
||||||
|
|
||||||
def showFilterNow(self):
|
def showFilterNow(self):
|
||||||
if self.filterTimer:
|
if self.filterTimer:
|
||||||
self.filterTimer.stop()
|
self.filterTimer.stop()
|
||||||
self.updateSearch()
|
self.updateSearch()
|
||||||
|
|
||||||
def updateSearch(self):
|
def updateSearch(self, force=True):
|
||||||
idx = self.dialog.tableView.currentIndex()
|
idx = self.dialog.tableView.currentIndex()
|
||||||
self.model.searchStr = unicode(self.dialog.filterEdit.text())
|
self.model.searchStr = unicode(self.dialog.filterEdit.text())
|
||||||
self.model.showMatching()
|
self.model.showMatching(force)
|
||||||
self.updateFilterLabel()
|
self.updateFilterLabel()
|
||||||
self.onEvent()
|
self.onEvent()
|
||||||
self.filterTimer = None
|
self.filterTimer = None
|
||||||
|
|
Loading…
Reference in a new issue