mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Improve performance of ui.library_moved(). Changes remove multiple calls to tags_view.recount().
This commit is contained in:
parent
d894473de9
commit
f979f0d357
@ -436,14 +436,15 @@ class SavedSearchBoxMixin(object): # {{{
|
||||
b = getattr(self, x+'_search_button')
|
||||
b.setStatusTip(b.toolTip())
|
||||
|
||||
def saved_searches_changed(self, set_restriction=None):
|
||||
def saved_searches_changed(self, set_restriction=None, recount=True):
|
||||
p = sorted(saved_searches().names(), key=sort_key)
|
||||
if set_restriction is None:
|
||||
set_restriction = unicode(self.search_restriction.currentText())
|
||||
# rebuild the restrictions combobox using current saved searches
|
||||
self.search_restriction.clear()
|
||||
self.search_restriction.addItem('')
|
||||
self.tags_view.recount()
|
||||
if recount:
|
||||
self.tags_view.recount()
|
||||
for s in p:
|
||||
self.search_restriction.addItem(s)
|
||||
if set_restriction: # redo the search restriction if there was one
|
||||
|
@ -25,8 +25,9 @@ class SearchRestrictionMixin(object):
|
||||
r = self.search_restriction.findText(name)
|
||||
if r < 0:
|
||||
r = 0
|
||||
self.search_restriction.setCurrentIndex(r)
|
||||
self.apply_search_restriction(r)
|
||||
if r != self.search_restriction.currentIndex():
|
||||
self.search_restriction.setCurrentIndex(r)
|
||||
self.apply_search_restriction(r)
|
||||
|
||||
def apply_search_restriction(self, i):
|
||||
r = unicode(self.search_restriction.currentText())
|
||||
|
@ -446,12 +446,13 @@ class Main(MainWindow, MainWindowMixin, DeviceMixin, EmailMixin, # {{{
|
||||
self.search.clear()
|
||||
self.saved_search.clear()
|
||||
self.book_details.reset_info()
|
||||
self.library_view.model().count_changed()
|
||||
prefs['library_path'] = self.library_path
|
||||
#self.library_view.model().count_changed()
|
||||
db = self.library_view.model().db
|
||||
self.iactions['Choose Library'].count_changed(db.count())
|
||||
self.set_window_title()
|
||||
self.apply_named_search_restriction('') # reset restriction to null
|
||||
self.saved_searches_changed() # reload the search restrictions combo box
|
||||
self.saved_searches_changed(recount=False) # reload the search restrictions combo box
|
||||
self.apply_named_search_restriction(db.prefs['gui_restriction'])
|
||||
for action in self.iactions.values():
|
||||
action.library_changed(db)
|
||||
|
Loading…
x
Reference in New Issue
Block a user