Quote:
Originally Posted by fidvo
I'm trying to create a module that adds an empty book and fills in some default metadata. Everything works except that the book doesn't show up in the book list until I reload the library (for example by restarting Calibre or switching to a different library and back). Here is my code:
Code:
from calibre_plugins.action_chains.actions.base import ChainAction
from calibre.ebooks.metadata.book.base import Metadata
class TestAddEmpty(ChainAction):
name = 'Add Empty'
def run(self, gui, settings, chain):
db = gui.current_db
ids, duplicates = db.new_api.add_books([(Metadata(None), {})])
# What do I put here?
newid = ids[0]
gui.library_view.select_rows([newid])
I assume I have to add something at the # What do I put here? marker in order to make the new book show up, but I don't know what it is. Any ideas?
Thanks.
|
I have no idea why this is happening. I tried adding either one of these two lines, to no avail:
Code:
gui.iactions['Add Books'].refresh_gui(1,set_current_row=0)
Code:
gui.library_view.model().books_added(1)
Maybe if you post this in the development forum Kovid of chaley can help.