mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix search restriction behavior when switching libraries
This commit is contained in:
commit
80a0725a0f
@ -382,8 +382,7 @@ class SearchBoxMixin(object):
|
|||||||
|
|
||||||
class SavedSearchBoxMixin(object):
|
class SavedSearchBoxMixin(object):
|
||||||
|
|
||||||
def __init__(self, db):
|
def __init__(self):
|
||||||
self.db = db
|
|
||||||
self.connect(self.saved_search, SIGNAL('changed()'), self.saved_searches_changed)
|
self.connect(self.saved_search, SIGNAL('changed()'), self.saved_searches_changed)
|
||||||
self.saved_searches_changed()
|
self.saved_searches_changed()
|
||||||
self.connect(self.clear_button, SIGNAL('clicked()'), self.saved_search.clear_to_help)
|
self.connect(self.clear_button, SIGNAL('clicked()'), self.saved_search.clear_to_help)
|
||||||
@ -402,10 +401,6 @@ class SavedSearchBoxMixin(object):
|
|||||||
b = getattr(self, x+'_search_button')
|
b = getattr(self, x+'_search_button')
|
||||||
b.setStatusTip(b.toolTip())
|
b.setStatusTip(b.toolTip())
|
||||||
|
|
||||||
def set_database(self, db):
|
|
||||||
self.db = db
|
|
||||||
self.saved_searches_changed()
|
|
||||||
|
|
||||||
def saved_searches_changed(self):
|
def saved_searches_changed(self):
|
||||||
p = saved_searches().names()
|
p = saved_searches().names()
|
||||||
p.sort()
|
p.sort()
|
||||||
@ -415,13 +410,8 @@ class SavedSearchBoxMixin(object):
|
|||||||
self.tags_view.recount()
|
self.tags_view.recount()
|
||||||
for s in p:
|
for s in p:
|
||||||
self.search_restriction.addItem(s)
|
self.search_restriction.addItem(s)
|
||||||
if t:
|
if t: # redo the search restriction if there was one
|
||||||
if t in p: # redo the current restriction, if there was one
|
self.apply_named_search_restriction(t)
|
||||||
self.search_restriction.setCurrentIndex(self.search_restriction.findText(t))
|
|
||||||
# self.tags_view.set_search_restriction(t)
|
|
||||||
else:
|
|
||||||
self.search_restriction.setCurrentIndex(0)
|
|
||||||
self.apply_search_restriction('')
|
|
||||||
|
|
||||||
def do_saved_search_edit(self, search):
|
def do_saved_search_edit(self, search):
|
||||||
d = SavedSearchEditor(self, search)
|
d = SavedSearchEditor(self, search)
|
||||||
|
@ -29,6 +29,16 @@ class SearchRestrictionMixin(object):
|
|||||||
if self.restriction_in_effect:
|
if self.restriction_in_effect:
|
||||||
self.set_number_of_books_shown()
|
self.set_number_of_books_shown()
|
||||||
|
|
||||||
|
def apply_named_search_restriction(self, name):
|
||||||
|
if not name:
|
||||||
|
r = 0
|
||||||
|
else:
|
||||||
|
r = self.search_restriction.findText(name)
|
||||||
|
if r < 0:
|
||||||
|
r = 0
|
||||||
|
self.search_restriction.setCurrentIndex(r)
|
||||||
|
self.apply_search_restriction(r)
|
||||||
|
|
||||||
def apply_search_restriction(self, i):
|
def apply_search_restriction(self, i):
|
||||||
r = unicode(self.search_restriction.currentText())
|
r = unicode(self.search_restriction.currentText())
|
||||||
if r is not None and r != '':
|
if r is not None and r != '':
|
||||||
|
@ -195,7 +195,7 @@ class Main(MainWindow, MainWindowMixin, DeviceMixin, # {{{
|
|||||||
UpdateMixin.__init__(self, opts)
|
UpdateMixin.__init__(self, opts)
|
||||||
|
|
||||||
####################### Search boxes ########################
|
####################### Search boxes ########################
|
||||||
SavedSearchBoxMixin.__init__(self, db)
|
SavedSearchBoxMixin.__init__(self)
|
||||||
SearchBoxMixin.__init__(self)
|
SearchBoxMixin.__init__(self)
|
||||||
|
|
||||||
####################### Library view ########################
|
####################### Library view ########################
|
||||||
@ -371,6 +371,8 @@ class Main(MainWindow, MainWindowMixin, DeviceMixin, # {{{
|
|||||||
for action in self.iactions.values():
|
for action in self.iactions.values():
|
||||||
action.library_changed(db)
|
action.library_changed(db)
|
||||||
self.set_window_title()
|
self.set_window_title()
|
||||||
|
self.apply_named_search_restriction('') # reset restriction to null
|
||||||
|
self.saved_searches_changed() # reload the search restrictions combo box
|
||||||
|
|
||||||
def set_window_title(self):
|
def set_window_title(self):
|
||||||
self.setWindowTitle(__appname__ + u' - ||%s||'%self.iactions['Choose Library'].library_name())
|
self.setWindowTitle(__appname__ + u' - ||%s||'%self.iactions['Choose Library'].library_name())
|
||||||
|
Loading…
x
Reference in New Issue
Block a user