Refresh cache on metadata edits

This commit is contained in:
Kovid Goyal 2008-06-15 23:02:25 -07:00
parent 3b95fa8575
commit d85fd5b737
2 changed files with 18 additions and 5 deletions

View File

@ -124,6 +124,9 @@ class BooksModel(QAbstractTableModel):
def refresh_ids(self, ids, current_row=-1):
rows = self.db.refresh_ids(ids)
for row in rows:
if self.cover_cache:
id = self.db.id(row)
self.cover_cache.refresh(id)
if row == current_row:
self.emit(SIGNAL('new_bookdisplay_data(PyQt_PyObject)'),
self.get_book_display_info(row))

View File

@ -132,6 +132,16 @@ class CoverCache(QThread):
self.cache = {}
self.cache_lock.unlock()
def refresh(self, ids):
self.cache_lock.lockForWrite()
for id in ids:
self.cache.pop(id, None)
self.cache_lock.unlock()
self.load_queue_lock.lockForWrite()
for id in ids:
self.load_queue.append_left(id)
self.load_queue_lock.unlock()
class Concatenate(object):
'''String concatenation aggregator for sqlite'''
def __init__(self, sep=','):