I'm working in a plugin to insert, delete or update books in my library.

The updating works ok, but when I insert new books (or delete it) using db.add_books() (or db.delete_book()), changes don't reflect in the main library window. I need to manually change sorting order for see last inserted books (pressing the top of the columns).

I tried using db.refresh() after insert, but nothing happens. I also tried using db.refresh_ids() with the last id inserted, but then I get an error. ¿?

How can I do to refresh the main windows view after inserting or deleting books?

Last edited by Pepin33; 08-30-2012 at 12:17 PM.
Reason: Modify the title

Thanks, kovidgoyal. But I was looking at the file, and the AddAction class, and I can't find what I am looking for (or maybe I don't know what's exactly the thing I'm looking for).

I was looking at library/cli.py for adding, deleting and updating format books, and using the same objetcs and functions the command line uses for this. It works OK, but I don't know how to refresh the main library window. When I update a book (removing old format and adding a new one), or I update metadata, it refresh correctly. But when I add a book, or remove it, it doesn't.

Maybe db.add_books() and db.delete_books() are not the functions I need to use?

If you want to refresh the view - you need to be looking at code for the view object - i.e. self.gui.library_view. You also need to remember to refresh the tag browser as well. So if you are adding books, it is something like: