mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Search box now indicates successfully parsed queries
This commit is contained in:
parent
8443a11abe
commit
6ac009886c
@ -244,12 +244,15 @@ class BooksModel(QAbstractTableModel):
|
|||||||
try:
|
try:
|
||||||
self.db.search(text)
|
self.db.search(text)
|
||||||
except ParseException:
|
except ParseException:
|
||||||
self.emit(SIGNAL('parse_exception()'))
|
self.emit(SIGNAL('searched(PyQt_PyObject)'), False)
|
||||||
return
|
return
|
||||||
self.last_search = text
|
self.last_search = text
|
||||||
if reset:
|
if reset:
|
||||||
self.clear_caches()
|
self.clear_caches()
|
||||||
self.reset()
|
self.reset()
|
||||||
|
if self.last_search:
|
||||||
|
self.emit(SIGNAL('searched(PyQt_PyObject)'), True)
|
||||||
|
|
||||||
|
|
||||||
def sort(self, col, order, reset=True):
|
def sort(self, col, order, reset=True):
|
||||||
if not self.db:
|
if not self.db:
|
||||||
@ -743,14 +746,20 @@ class BooksView(TableView):
|
|||||||
def set_editable(self, editable):
|
def set_editable(self, editable):
|
||||||
self._model.set_editable(editable)
|
self._model.set_editable(editable)
|
||||||
|
|
||||||
def connect_to_search_box(self, sb):
|
def connect_to_search_box(self, sb, search_done):
|
||||||
QObject.connect(sb, SIGNAL('search(PyQt_PyObject, PyQt_PyObject)'),
|
QObject.connect(sb, SIGNAL('search(PyQt_PyObject, PyQt_PyObject)'),
|
||||||
self._model.search)
|
self._model.search)
|
||||||
|
self._search_done = search_done
|
||||||
|
self.connect(self._model, SIGNAL('searched(PyQt_PyObject)'),
|
||||||
|
self.search_done)
|
||||||
|
|
||||||
def connect_to_book_display(self, bd):
|
def connect_to_book_display(self, bd):
|
||||||
QObject.connect(self._model, SIGNAL('new_bookdisplay_data(PyQt_PyObject)'),
|
QObject.connect(self._model, SIGNAL('new_bookdisplay_data(PyQt_PyObject)'),
|
||||||
bd)
|
bd)
|
||||||
|
|
||||||
|
def search_done(self, ok):
|
||||||
|
self._search_done(self, ok)
|
||||||
|
|
||||||
|
|
||||||
class DeviceBooksView(BooksView):
|
class DeviceBooksView(BooksView):
|
||||||
|
|
||||||
@ -864,7 +873,7 @@ class DeviceBooksModel(BooksModel):
|
|||||||
try:
|
try:
|
||||||
matches = self.search_engine.parse(text)
|
matches = self.search_engine.parse(text)
|
||||||
except ParseException:
|
except ParseException:
|
||||||
self.emit(SIGNAL('parse_exception()'))
|
self.emit(SIGNAL('searched(PyQt_PyObject)'), False)
|
||||||
return
|
return
|
||||||
|
|
||||||
self.map = []
|
self.map = []
|
||||||
@ -875,6 +884,9 @@ class DeviceBooksModel(BooksModel):
|
|||||||
if reset:
|
if reset:
|
||||||
self.reset()
|
self.reset()
|
||||||
self.last_search = text
|
self.last_search = text
|
||||||
|
if self.last_search:
|
||||||
|
self.emit(SIGNAL('searched(PyQt_PyObject)'), True)
|
||||||
|
|
||||||
|
|
||||||
def resort(self, reset):
|
def resort(self, reset):
|
||||||
self.sort(self.sorted_on[0], self.sorted_on[1], reset=reset)
|
self.sort(self.sorted_on[0], self.sorted_on[1], reset=reset)
|
||||||
@ -1068,11 +1080,15 @@ class SearchBox(QLineEdit):
|
|||||||
self.setText(self.help_text)
|
self.setText(self.help_text)
|
||||||
self.home(False)
|
self.home(False)
|
||||||
self.initial_state = True
|
self.initial_state = True
|
||||||
|
self.setStyleSheet("background-color: white")
|
||||||
|
|
||||||
def clear(self):
|
def clear(self):
|
||||||
self.clear_to_help()
|
self.clear_to_help()
|
||||||
self.emit(SIGNAL('search(PyQt_PyObject, PyQt_PyObject)'), '', False)
|
self.emit(SIGNAL('search(PyQt_PyObject, PyQt_PyObject)'), '', False)
|
||||||
|
|
||||||
|
def search_done(self, ok):
|
||||||
|
col = 'rgba(0,255,0,25%)' if ok else 'rgb(255,0,0,25%)'
|
||||||
|
self.setStyleSheet('background-color: '+col)
|
||||||
|
|
||||||
def keyPressEvent(self, event):
|
def keyPressEvent(self, event):
|
||||||
if self.initial_state:
|
if self.initial_state:
|
||||||
|
@ -394,13 +394,14 @@ class Main(MainWindow, Ui_MainWindow, DeviceGUI):
|
|||||||
QObject.connect(self.library_view,
|
QObject.connect(self.library_view,
|
||||||
SIGNAL('files_dropped(PyQt_PyObject)'),
|
SIGNAL('files_dropped(PyQt_PyObject)'),
|
||||||
self.files_dropped, Qt.QueuedConnection)
|
self.files_dropped, Qt.QueuedConnection)
|
||||||
for func, target in [
|
for func, args in [
|
||||||
('connect_to_search_box', self.search),
|
('connect_to_search_box', (self.search,
|
||||||
|
self.search_done)),
|
||||||
('connect_to_book_display',
|
('connect_to_book_display',
|
||||||
self.status_bar.book_info.show_data),
|
(self.status_bar.book_info.show_data,)),
|
||||||
]:
|
]:
|
||||||
for view in (self.library_view, self.memory_view, self.card_a_view, self.card_b_view):
|
for view in (self.library_view, self.memory_view, self.card_a_view, self.card_b_view):
|
||||||
getattr(view, func)(target)
|
getattr(view, func)(*args)
|
||||||
|
|
||||||
self.memory_view.connect_dirtied_signal(self.upload_booklists)
|
self.memory_view.connect_dirtied_signal(self.upload_booklists)
|
||||||
self.card_a_view.connect_dirtied_signal(self.upload_booklists)
|
self.card_a_view.connect_dirtied_signal(self.upload_booklists)
|
||||||
@ -631,6 +632,10 @@ class Main(MainWindow, Ui_MainWindow, DeviceGUI):
|
|||||||
self.match_any.setVisible(False)
|
self.match_any.setVisible(False)
|
||||||
self.popularity.setVisible(False)
|
self.popularity.setVisible(False)
|
||||||
|
|
||||||
|
def search_done(self, view, ok):
|
||||||
|
if view is self.current_view():
|
||||||
|
self.search.search_done(ok)
|
||||||
|
|
||||||
def sync_cf_to_listview(self, index, *args):
|
def sync_cf_to_listview(self, index, *args):
|
||||||
if not hasattr(index, 'row') and \
|
if not hasattr(index, 'row') and \
|
||||||
self.library_view.currentIndex().row() != index:
|
self.library_view.currentIndex().row() != index:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user