Register Guidelines E-Books Search Today's Posts Mark Forums Read

Go Back   MobileRead Forums > E-Book Software > Calibre > Development

Notices

Reply
 
Thread Tools Search this Thread
Old 08-30-2012, 10:00 AM   #1
Pepin33
Zealot
Pepin33 has a complete set of Star Wars action figures.Pepin33 has a complete set of Star Wars action figures.Pepin33 has a complete set of Star Wars action figures.Pepin33 has a complete set of Star Wars action figures.Pepin33 has a complete set of Star Wars action figures.
 
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
Pepin33 is offline   Reply With Quote
Old 08-30-2012, 11:47 AM   #2
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 26,136
Karma: 5381911
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
Look at actions/add.py
kovidgoyal is offline   Reply With Quote
 
Enthusiast
Old 08-30-2012, 01:12 PM   #3
Pepin33
Zealot
Pepin33 has a complete set of Star Wars action figures.Pepin33 has a complete set of Star Wars action figures.Pepin33 has a complete set of Star Wars action figures.Pepin33 has a complete set of Star Wars action figures.Pepin33 has a complete set of Star Wars action figures.
 
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?
Pepin33 is offline   Reply With Quote
Old 08-30-2012, 02:04 PM   #4
kiwidude
calibre/Sigil Developer
kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.
 
Posts: 4,228
Karma: 1334002
Join Date: Oct 2010
Location: London, UK
Device: Kindle Paperwhite 3G, iPad 3, iPad Air
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.
kiwidude is offline   Reply With Quote
Old 08-31-2012, 05:18 AM   #5
Pepin33
Zealot
Pepin33 has a complete set of Star Wars action figures.Pepin33 has a complete set of Star Wars action figures.Pepin33 has a complete set of Star Wars action figures.Pepin33 has a complete set of Star Wars action figures.Pepin33 has a complete set of Star Wars action figures.
 
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)
Pepin33 is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
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


All times are GMT -4. The time now is 06:02 AM.


MobileRead.com is a privately owned, operated and funded community.