View Single Post
Old 07-20-2014, 12:40 PM   #15
DiapDealer
Grand Sorcerer
DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.
 
DiapDealer's Avatar
 
Posts: 27,465
Karma: 192992430
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
Quote:
Originally Posted by kovidgoyal View Post
To fully update the GUI after adding new books you would need to do

db.data.books_added(book_ids)
self.gui.library_view.model().books_added(num)
self.gui.db_images.reset()
self.gui.tags_view.recount()

This updates all the various components of the GUI.
This works fine for me when adding new books, but if my plugin adds a format to the book that happens to be the current selection, none of the above makes that new format show up (without selecting something else and coming back). It's very possible it's supposed to work that way, which is why I'm checking.

Would there be any downside to adding the following code to your suggested snippet in a general "GUI refresh" utility-method within a plugin?:
Code:
current_idx = self.gui.library_view.currentIndex()
if current_idx.isValid():
    self.gui.library_view.model().current_changed(current_idx, current_idx)
Or is there another/better way to refresh that currently selected book's details in the gui?
(Using the new api's "add_format" method if that's relevant)

Last edited by DiapDealer; 07-20-2014 at 12:52 PM.
DiapDealer is offline   Reply With Quote