mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fixed bug #5477. Also fixed some oddities when searching while a device is connected.
This commit is contained in:
parent
f604ee58a4
commit
35e9d8d387
@ -74,6 +74,7 @@ class SearchBox2(QComboBox):
|
||||
self.setMaxCount(self.MAX_COUNT)
|
||||
self.setSizeAdjustPolicy(self.AdjustToMinimumContentsLengthWithIcon)
|
||||
self.setMinimumContentsLength(25)
|
||||
self._in_a_search = False
|
||||
|
||||
def initialize(self, opt_name, colorize=False,
|
||||
help_text=_('Search')):
|
||||
@ -93,6 +94,7 @@ class SearchBox2(QComboBox):
|
||||
self.help_state = False
|
||||
|
||||
def clear_to_help(self):
|
||||
self._in_a_search = False
|
||||
self.setEditText(self.help_text)
|
||||
self.line_edit.home(False)
|
||||
self.help_state = True
|
||||
@ -111,6 +113,7 @@ class SearchBox2(QComboBox):
|
||||
def search_done(self, ok):
|
||||
if not unicode(self.currentText()).strip():
|
||||
return self.clear_to_help()
|
||||
self._in_a_search = ok
|
||||
col = 'rgba(0,255,0,20%)' if ok else 'rgb(255,0,0,20%)'
|
||||
if not self.colorize:
|
||||
col = self.normal_background
|
||||
@ -184,6 +187,8 @@ class SearchBox2(QComboBox):
|
||||
def search_as_you_type(self, enabled):
|
||||
self.as_you_type = enabled
|
||||
|
||||
def in_a_search(self):
|
||||
return self._in_a_search
|
||||
|
||||
class SavedSearchBox(QComboBox):
|
||||
|
||||
|
@ -835,20 +835,20 @@ class Main(MainWindow, Ui_MainWindow, DeviceGUI):
|
||||
self.restriction_count_of_books_in_view += c - self.restriction_count_of_books_in_library
|
||||
self.restriction_count_of_books_in_library = c
|
||||
if self.restriction_in_effect:
|
||||
self.set_number_of_books_shown(all='not used', compute_count=False)
|
||||
self.set_number_of_books_shown(compute_count=False)
|
||||
|
||||
def mark_restriction_set(self, r):
|
||||
self.restriction_in_effect = False if r is None or not r else True
|
||||
|
||||
def set_number_of_books_shown(self, all, compute_count):
|
||||
if self.restriction_in_effect:
|
||||
def set_number_of_books_shown(self, compute_count):
|
||||
if self.current_view() == self.library_view and self.restriction_in_effect:
|
||||
if compute_count:
|
||||
self.restriction_count_of_books_in_view = self.current_view().row_count()
|
||||
t = _("({0} of {1})").format(self.current_view().row_count(),
|
||||
self.restriction_count_of_books_in_view)
|
||||
self.search_count.setStyleSheet('QLabel { border-radius: 8px; background-color: yellow; }')
|
||||
else: # No restriction
|
||||
if all == 'yes':
|
||||
else: # No restriction or not library view
|
||||
if not self.search.in_a_search():
|
||||
t = _("(all books)")
|
||||
else:
|
||||
t = _("({0} of all)").format(self.current_view().row_count())
|
||||
@ -857,18 +857,18 @@ class Main(MainWindow, Ui_MainWindow, DeviceGUI):
|
||||
self.search_count.setText(t)
|
||||
|
||||
def search_box_cleared(self):
|
||||
self.set_number_of_books_shown(all='yes', compute_count=True)
|
||||
self.set_number_of_books_shown(compute_count=True)
|
||||
self.tags_view.clear()
|
||||
self.saved_search.clear_to_help()
|
||||
|
||||
def search_clear(self):
|
||||
self.set_number_of_books_shown(all='yes', compute_count=True)
|
||||
self.set_number_of_books_shown(compute_count=True)
|
||||
self.search.clear()
|
||||
|
||||
def search_done(self, view, ok):
|
||||
if view is self.current_view():
|
||||
self.set_number_of_books_shown(all='no', compute_count=False)
|
||||
self.search.search_done(ok)
|
||||
self.set_number_of_books_shown(compute_count=False)
|
||||
|
||||
def sync_cf_to_listview(self, current, previous):
|
||||
if self.cover_flow_sync_flag and self.cover_flow.isVisible() and \
|
||||
@ -2297,6 +2297,7 @@ class Main(MainWindow, Ui_MainWindow, DeviceGUI):
|
||||
self.view_menu.actions()[1].setEnabled(True)
|
||||
self.action_open_containing_folder.setEnabled(True)
|
||||
self.action_sync.setEnabled(True)
|
||||
self.search_restriction.setEnabled(True)
|
||||
for action in list(self.delete_menu.actions())[1:]:
|
||||
action.setEnabled(True)
|
||||
else:
|
||||
@ -2306,8 +2307,10 @@ class Main(MainWindow, Ui_MainWindow, DeviceGUI):
|
||||
self.view_menu.actions()[1].setEnabled(False)
|
||||
self.action_open_containing_folder.setEnabled(False)
|
||||
self.action_sync.setEnabled(False)
|
||||
self.search_restriction.setEnabled(False)
|
||||
for action in list(self.delete_menu.actions())[1:]:
|
||||
action.setEnabled(False)
|
||||
self.set_number_of_books_shown(compute_count=False)
|
||||
|
||||
|
||||
def device_job_exception(self, job):
|
||||
|
Loading…
x
Reference in New Issue
Block a user