![]() |
#1 |
Zealot
![]() ![]() ![]() ![]() ![]() Posts: 109
Karma: 419
Join Date: Aug 2012
Location: Spain
Device: Kindle Touch
|
Refresh library view after inserting new books?
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 11:17 AM. Reason: Modify the title |
![]() |
![]() |
![]() |
#2 |
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 44,263
Karma: 23661992
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
Look at actions/add.py
|
![]() |
![]() |
Advert | |
|
![]() |
#3 |
Zealot
![]() ![]() ![]() ![]() ![]() Posts: 109
Karma: 419
Join Date: Aug 2012
Location: Spain
Device: Kindle Touch
|
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? |
![]() |
![]() |
![]() |
#4 |
Calibre Plugins Developer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 4,667
Karma: 2162246
Join Date: Oct 2010
Location: Australia
Device: Kindle Oasis
|
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:
self.gui.library_view.model().books_added(num) self.gui.tags_view.recount() And there is also a call you can do for model().books_deleted() as well. |
![]() |
![]() |
![]() |
#5 |
Zealot
![]() ![]() ![]() ![]() ![]() Posts: 109
Karma: 419
Join Date: Aug 2012
Location: Spain
Device: Kindle Touch
|
Thanks you very much, kiwidude. Refresh the view was exactly what I wanted. I was looking at db objetc, but you're right, the db was ok, the key was the library_view object.
Thanks again for you help (and for your plugins, I'm learning a lot looking at your code) ![]() |
![]() |
![]() |
Advert | |
|
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
[Device View] vs [Library view], Why different? | papagelos | Library Management | 4 | 04-13-2012 11:08 AM |
Touch Changing the library view | Valatar | Barnes & Noble NOOK | 7 | 07-20-2011 11:52 AM |
Library View | Japes | PocketBook | 1 | 06-14-2011 09:16 PM |
Is it possible to view the Format of a book in Library view? | highwaykind | Calibre | 6 | 01-23-2010 06:28 PM |
Removing Deleted Files / Refresh the Library | pragmortal | Calibre | 4 | 09-23-2009 04:51 AM |