mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Refresh cache on metadata edits
This commit is contained in:
parent
3b95fa8575
commit
d85fd5b737
@ -117,17 +117,20 @@ class BooksModel(QAbstractTableModel):
|
|||||||
def set_database(self, db):
|
def set_database(self, db):
|
||||||
if isinstance(db, (QString, basestring)):
|
if isinstance(db, (QString, basestring)):
|
||||||
if isinstance(db, QString):
|
if isinstance(db, QString):
|
||||||
db = qstring_to_unicode(db)
|
db = qstring_to_unicode(db)
|
||||||
db = LibraryDatabase(os.path.expanduser(db))
|
db = LibraryDatabase(os.path.expanduser(db))
|
||||||
self.db = db
|
self.db = db
|
||||||
|
|
||||||
def refresh_ids(self, ids, current_row=-1):
|
def refresh_ids(self, ids, current_row=-1):
|
||||||
rows = self.db.refresh_ids(ids)
|
rows = self.db.refresh_ids(ids)
|
||||||
for row in rows:
|
for row in rows:
|
||||||
|
if self.cover_cache:
|
||||||
|
id = self.db.id(row)
|
||||||
|
self.cover_cache.refresh(id)
|
||||||
if row == current_row:
|
if row == current_row:
|
||||||
self.emit(SIGNAL('new_bookdisplay_data(PyQt_PyObject)'),
|
self.emit(SIGNAL('new_bookdisplay_data(PyQt_PyObject)'),
|
||||||
self.get_book_display_info(row))
|
self.get_book_display_info(row))
|
||||||
self.emit(SIGNAL('dataChanged(QModelIndex,QModelIndex)'),
|
self.emit(SIGNAL('dataChanged(QModelIndex,QModelIndex)'),
|
||||||
self.index(row, 0), self.index(row, self.columnCount(None)-1))
|
self.index(row, 0), self.index(row, self.columnCount(None)-1))
|
||||||
|
|
||||||
def close(self):
|
def close(self):
|
||||||
@ -136,7 +139,7 @@ class BooksModel(QAbstractTableModel):
|
|||||||
self.reset()
|
self.reset()
|
||||||
|
|
||||||
def add_books(self, paths, formats, metadata, uris=[], add_duplicates=False):
|
def add_books(self, paths, formats, metadata, uris=[], add_duplicates=False):
|
||||||
return self.db.add_books(paths, formats, metadata, uris,
|
return self.db.add_books(paths, formats, metadata, uris,
|
||||||
add_duplicates=add_duplicates)
|
add_duplicates=add_duplicates)
|
||||||
|
|
||||||
def row_indices(self, index):
|
def row_indices(self, index):
|
||||||
|
@ -130,7 +130,17 @@ class CoverCache(QThread):
|
|||||||
def clear_cache(self):
|
def clear_cache(self):
|
||||||
self.cache_lock.lockForWrite()
|
self.cache_lock.lockForWrite()
|
||||||
self.cache = {}
|
self.cache = {}
|
||||||
self.cache_lock.unlock()
|
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):
|
class Concatenate(object):
|
||||||
'''String concatenation aggregator for sqlite'''
|
'''String concatenation aggregator for sqlite'''
|
||||||
|
Loading…
x
Reference in New Issue
Block a user