From ee6eaeeaa6f800fcd769970543589704a6cf3acd Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Mon, 6 Apr 2009 23:23:49 +0900 Subject: [PATCH] force search updates if not triggered by user --- ankiqt/ui/cardlist.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/ankiqt/ui/cardlist.py b/ankiqt/ui/cardlist.py index 851ddab94..3add0945c 100644 --- a/ankiqt/ui/cardlist.py +++ b/ankiqt/ui/cardlist.py @@ -103,7 +103,7 @@ class DeckModel(QAbstractTableModel): # Filtering ###################################################################### - def showMatching(self): + def showMatching(self, force=True): if not self.sortKey: self.cards = [] return @@ -112,7 +112,8 @@ class DeckModel(QAbstractTableModel): ads = "" self.lastSearch = "" else: - if self.searchStr.strip() == self.lastSearch.strip(): + if (self.searchStr.strip() == self.lastSearch.strip() + and not force): # just whitespace return QApplication.instance().processEvents() @@ -463,17 +464,18 @@ class EditDeck(QMainWindow): self.filterTimer = QTimer(self) self.filterTimer.setSingleShot(True) 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): if self.filterTimer: self.filterTimer.stop() self.updateSearch() - def updateSearch(self): + def updateSearch(self, force=True): idx = self.dialog.tableView.currentIndex() self.model.searchStr = unicode(self.dialog.filterEdit.text()) - self.model.showMatching() + self.model.showMatching(force) self.updateFilterLabel() self.onEvent() self.filterTimer = None