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,14 +436,15 @@ class SavedSearchBoxMixin(object): # {{{
b = getattr(self, x+'_search_button') b = getattr(self, x+'_search_button')
b.setStatusTip(b.toolTip()) 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) p = sorted(saved_searches().names(), key=sort_key)
if set_restriction is None: if set_restriction is None:
set_restriction = unicode(self.search_restriction.currentText()) set_restriction = unicode(self.search_restriction.currentText())
# rebuild the restrictions combobox using current saved searches # rebuild the restrictions combobox using current saved searches
self.search_restriction.clear() self.search_restriction.clear()
self.search_restriction.addItem('') self.search_restriction.addItem('')
self.tags_view.recount() if recount:
self.tags_view.recount()
for s in p: for s in p:
self.search_restriction.addItem(s) self.search_restriction.addItem(s)
if set_restriction: # redo the search restriction if there was one if set_restriction: # redo the search restriction if there was one

View File

@ -25,8 +25,9 @@ class SearchRestrictionMixin(object):
r = self.search_restriction.findText(name) r = self.search_restriction.findText(name)
if r < 0: if r < 0:
r = 0 r = 0
self.search_restriction.setCurrentIndex(r) if r != self.search_restriction.currentIndex():
self.apply_search_restriction(r) 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())

View File

@ -446,12 +446,13 @@ class Main(MainWindow, MainWindowMixin, DeviceMixin, EmailMixin, # {{{
self.search.clear() self.search.clear()
self.saved_search.clear() self.saved_search.clear()
self.book_details.reset_info() self.book_details.reset_info()
self.library_view.model().count_changed()
prefs['library_path'] = self.library_path prefs['library_path'] = self.library_path
#self.library_view.model().count_changed()
db = self.library_view.model().db db = self.library_view.model().db
self.iactions['Choose Library'].count_changed(db.count())
self.set_window_title() self.set_window_title()
self.apply_named_search_restriction('') # reset restriction to null 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']) self.apply_named_search_restriction(db.prefs['gui_restriction'])
for action in self.iactions.values(): for action in self.iactions.values():
action.library_changed(db) action.library_changed(db)