Improve performance of ui.library_moved(). Changes remove multiple calls to tags_view.recount().

This commit is contained in:
Charles Haley 2011-04-11 14:49:54 +01:00
parent d894473de9
commit f979f0d357
3 changed files with 9 additions and 6 deletions

View File

@ -436,13 +436,14 @@ 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('')
if recount:
self.tags_view.recount()
for s in p:
self.search_restriction.addItem(s)

View File

@ -25,6 +25,7 @@ class SearchRestrictionMixin(object):
r = self.search_restriction.findText(name)
if r < 0:
r = 0
if r != self.search_restriction.currentIndex():
self.search_restriction.setCurrentIndex(r)
self.apply_search_restriction(r)

View File

@ -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)