mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Improve performance when polishing large numbers of books in a large library by debouncing Tag browser refreshes
This commit is contained in:
parent
481013d23f
commit
caad54863b
@ -434,6 +434,14 @@ class PolishAction(InterfaceAction):
|
||||
def genesis(self):
|
||||
self.qaction.triggered.connect(self.polish_books)
|
||||
self.report = Report(self.gui)
|
||||
self.to_be_refreshed = set()
|
||||
self.refresh_debounce_timer = t = QTimer(self.gui)
|
||||
t.setSingleShot(True)
|
||||
t.setInterval(1000)
|
||||
t.timeout.connect(self.refresh_after_polish)
|
||||
|
||||
def shutting_down(self):
|
||||
self.refresh_debounce_timer.stop()
|
||||
|
||||
def location_selected(self, loc):
|
||||
enabled = loc == 'library'
|
||||
@ -528,14 +536,21 @@ class PolishAction(InterfaceAction):
|
||||
os.rmdir(parent)
|
||||
except:
|
||||
pass
|
||||
self.gui.tags_view.recount()
|
||||
self.to_be_refreshed.add(book_id)
|
||||
self.refresh_debounce_timer.start()
|
||||
if show_reports:
|
||||
self.report(db.title(book_id, index_is_id=True), book_id, fmts, job, job.result)
|
||||
|
||||
def refresh_after_polish(self):
|
||||
self.refresh_debounce_timer.stop()
|
||||
book_ids = tuple(self.to_be_refreshed)
|
||||
self.to_be_refreshed = set()
|
||||
if self.gui.current_view() is self.gui.library_view:
|
||||
self.gui.library_view.model().refresh_ids((book_id,))
|
||||
self.gui.library_view.model().refresh_ids(book_ids)
|
||||
current = self.gui.library_view.currentIndex()
|
||||
if current.isValid():
|
||||
self.gui.library_view.model().current_changed(current, QModelIndex())
|
||||
if show_reports:
|
||||
self.report(db.title(book_id, index_is_id=True), book_id, fmts, job, job.result)
|
||||
self.gui.tags_view.recount()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
Loading…
x
Reference in New Issue
Block a user