newdb: Fix refreshdb not working in GUI

Fix calibredb not updating the running calibre instance properly.
Fixes #1218177 [Running app does not refresh list when book added with calibredb add](https://bugs.launchpad.net/calibre/+bug/1218177)
This commit is contained in:
Kovid Goyal 2013-08-29 11:24:17 +05:30
parent f4de88d780
commit 746c268928
2 changed files with 7 additions and 7 deletions

View File

@ -335,14 +335,14 @@ class View(object):
# be shared by multiple views. This is not ideal, but...
self.cache.clear_search_caches(old_marked_ids | set(self.marked_ids))
def refresh(self, field=None, ascending=True, clear_caches=True):
def refresh(self, field=None, ascending=True, clear_caches=True, do_search=True):
self._map = tuple(sorted(self.cache.all_book_ids()))
self._map_filtered = tuple(self._map)
if clear_caches:
self.cache.clear_caches()
if field is not None:
self.sort(field, ascending)
if self.search_restriction or self.base_restriction:
if do_search and self.search_restriction or self.base_restriction:
self.search('', return_matches=False)
def refresh_ids(self, ids):

View File

@ -543,12 +543,12 @@ class Main(MainWindow, MainWindowMixin, DeviceMixin, EmailMixin, # {{{
self.raise_()
self.activateWindow()
elif msg.startswith('refreshdb:'):
db = self.library_view.model().db
db.new_api.reload_from_db()
self.library_view.model().resort()
self.library_view.model().research()
m = self.library_view.model()
m.db.new_api.reload_from_db()
m.db.data.refresh(clear_caches=False, do_search=False)
m.resort()
m.research()
self.tags_view.recount()
self.library_view.model().db.refresh_format_cache()
elif msg.startswith('shutdown:'):
self.quit(confirm_quit=False)
else: