From b5ae66ee0658aff387cf93d14ba119d54054732f Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 10 Aug 2021 16:49:23 +0530 Subject: [PATCH] Added a book_edited event --- src/calibre/db/cache.py | 1 + src/calibre/db/listeners.py | 3 +++ src/calibre/gui2/ui.py | 1 + 3 files changed, 5 insertions(+) diff --git a/src/calibre/db/cache.py b/src/calibre/db/cache.py index 0434d923f3..a48a910bcb 100644 --- a/src/calibre/db/cache.py +++ b/src/calibre/db/cache.py @@ -137,6 +137,7 @@ class Cache(object): All table reading/sorting/searching/caching logic is re-implemented. This was necessary for maximum performance and flexibility. ''' + EventType = EventType def __init__(self, backend): self.backend = backend diff --git a/src/calibre/db/listeners.py b/src/calibre/db/listeners.py index b772842f8f..9857b15ae0 100644 --- a/src/calibre/db/listeners.py +++ b/src/calibre/db/listeners.py @@ -38,6 +38,9 @@ class EventType(Enum): #: Arguments: (field_name, affected book ids, ids of removed items) items_removed = auto() + #: When a book format is edited, with arguments: (book_id, fmt) + book_edited = auto() + class EventDispatcher: diff --git a/src/calibre/gui2/ui.py b/src/calibre/gui2/ui.py index 5c1218e615..e1a44b7e43 100644 --- a/src/calibre/gui2/ui.py +++ b/src/calibre/gui2/ui.py @@ -793,6 +793,7 @@ class Main(MainWindow, MainWindowMixin, DeviceMixin, EmailMixin, # {{{ db.format_metadata(book_id, fmt, allow_cache=False, update_db=True) db.update_last_modified((book_id,)) m.refresh_ids((book_id,)) + db.event_dispatcher(db.EventType.book_edited, book_id, fmt) except Exception: import traceback traceback.print_exc()