diff --git a/src/calibre/gui2/library/views.py b/src/calibre/gui2/library/views.py index f88dfc5346..d90bfc1c14 100644 --- a/src/calibre/gui2/library/views.py +++ b/src/calibre/gui2/library/views.py @@ -1054,7 +1054,7 @@ class BooksView(QTableView): # {{{ self.select_rows([id_to_select], using_ids=True) elif self._model.highlight_only: self.clearSelection() - if self.isVisible(): + if self.isVisible() and getattr(txt, 'as_you_type', False) is not True: self.setFocus(Qt.OtherFocusReason) def connect_to_search_box(self, sb, search_done): diff --git a/src/calibre/gui2/search_box.py b/src/calibre/gui2/search_box.py index 6e82b9aeb0..cf36c21bc2 100644 --- a/src/calibre/gui2/search_box.py +++ b/src/calibre/gui2/search_box.py @@ -19,6 +19,13 @@ from calibre.gui2.dialogs.confirm_delete import confirm from calibre.gui2.dialogs.saved_search_editor import SavedSearchEditor from calibre.gui2.dialogs.search import SearchDialog +class AsYouType(unicode): + + def __new__(cls, text): + self = unicode.__new__(cls, text) + self.as_you_type = True + return self + class SearchLineEdit(QLineEdit): # {{{ key_pressed = pyqtSignal(object) select_on_mouse_press = None @@ -189,17 +196,19 @@ class SearchBox2(QComboBox): # {{{ self.normalize_state() def timer_event(self): - self.do_search() + self._do_search(as_you_type=True) def history_selected(self, text): self.changed.emit() self.do_search() - def _do_search(self, store_in_history=True): + def _do_search(self, store_in_history=True, as_you_type=False): self.hide_completer_popup() text = unicode(self.currentText()).strip() if not text: return self.clear() + if as_you_type: + text = AsYouType(text) self.search.emit(text) if store_in_history: