From 9e110eeec8e1d0507dc5bd4f36c0105af9ebbb5b Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 21 May 2010 20:36:57 -0600 Subject: [PATCH] Fix bugs in searchbox as you type implementation --- src/calibre/gui2/library/models.py | 2 +- src/calibre/gui2/search_box.py | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/calibre/gui2/library/models.py b/src/calibre/gui2/library/models.py index 0fc2c7f7ed..bc0367b766 100644 --- a/src/calibre/gui2/library/models.py +++ b/src/calibre/gui2/library/models.py @@ -883,7 +883,7 @@ class DeviceBooksModel(BooksModel): # {{{ self.reset() self.last_search = text if self.last_search: - self.searched.emit(False) + self.searched.emit(True) def sort(self, col, order, reset=True): diff --git a/src/calibre/gui2/search_box.py b/src/calibre/gui2/search_box.py index 230debd598..8627802ef4 100644 --- a/src/calibre/gui2/search_box.py +++ b/src/calibre/gui2/search_box.py @@ -135,13 +135,12 @@ class SearchBox2(QComboBox): def text_edited_slot(self, text): if self.as_you_type: - text = unicode(text) - self.prev_text = text self.timer = self.startTimer(self.__class__.INTERVAL) def timerEvent(self, event): self.killTimer(event.timerId()) if event.timerId() == self.timer: + self.timer = None self.do_search() @property @@ -190,6 +189,9 @@ class SearchBox2(QComboBox): def set_search_string(self, txt): self.normalize_state() self.setEditText(txt) + if self.timer is not None: # Turn off any timers that got started in setEditText + self.killTimer(self.timer) + self.timer = None self.search.emit(txt, False) self.line_edit.end(False) self.initial_state = False