Added a book_edited event

This commit is contained in:
Kovid Goyal 2021-08-10 16:49:23 +05:30
parent 9b33a033bf
commit b5ae66ee06
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
3 changed files with 5 additions and 0 deletions

View File

@ -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

View File

@ -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:

View File

@ -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()