mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Show a busy cursor when running the search in the match books dialog
This commit is contained in:
parent
37eacf65b0
commit
9e775f3cb7
@ -9,7 +9,7 @@ __docformat__ = 'restructuredtext en'
|
|||||||
|
|
||||||
|
|
||||||
from PyQt5.Qt import (Qt, QDialog, QAbstractItemView, QTableWidgetItem,
|
from PyQt5.Qt import (Qt, QDialog, QAbstractItemView, QTableWidgetItem,
|
||||||
QByteArray)
|
QByteArray, QApplication, QCursor)
|
||||||
|
|
||||||
from calibre.gui2 import gprefs, error_dialog
|
from calibre.gui2 import gprefs, error_dialog
|
||||||
from calibre.gui2.dialogs.match_books_ui import Ui_MatchBooks
|
from calibre.gui2.dialogs.match_books_ui import Ui_MatchBooks
|
||||||
@ -129,25 +129,31 @@ class MatchBooks(QDialog, Ui_MatchBooks):
|
|||||||
_('You must enter a search expression into the search box'))
|
_('You must enter a search expression into the search box'))
|
||||||
d.exec_()
|
d.exec_()
|
||||||
return
|
return
|
||||||
books = self.library_db.data.search(query, return_matches=True)
|
try:
|
||||||
self.books_table.setRowCount(len(books))
|
self.search_button.setEnabled(False)
|
||||||
|
QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
|
||||||
|
books = self.library_db.data.search(query, return_matches=True)
|
||||||
|
self.books_table.setRowCount(len(books))
|
||||||
|
|
||||||
self.books_table.setSortingEnabled(False)
|
self.books_table.setSortingEnabled(False)
|
||||||
for row, b in enumerate(books):
|
for row, b in enumerate(books):
|
||||||
mi = self.library_db.get_metadata(b, index_is_id=True, get_user_categories=False)
|
mi = self.library_db.get_metadata(b, index_is_id=True, get_user_categories=False)
|
||||||
a = TableItem(mi.title, mi.title_sort)
|
a = TableItem(mi.title, mi.title_sort)
|
||||||
a.setData(Qt.UserRole, b)
|
a.setData(Qt.UserRole, b)
|
||||||
self.books_table.setItem(row, 0, a)
|
self.books_table.setItem(row, 0, a)
|
||||||
a = TableItem(' & '.join(mi.authors), mi.author_sort)
|
a = TableItem(' & '.join(mi.authors), mi.author_sort)
|
||||||
self.books_table.setItem(row, 1, a)
|
self.books_table.setItem(row, 1, a)
|
||||||
series = mi.format_field('series')[1]
|
series = mi.format_field('series')[1]
|
||||||
if series is None:
|
if series is None:
|
||||||
series = ''
|
series = ''
|
||||||
a = TableItem(series, mi.series, mi.series_index)
|
a = TableItem(series, mi.series, mi.series_index)
|
||||||
self.books_table.setItem(row, 2, a)
|
self.books_table.setItem(row, 2, a)
|
||||||
self.books_table.setRowHeight(row, self.books_table_row_height)
|
self.books_table.setRowHeight(row, self.books_table_row_height)
|
||||||
|
|
||||||
self.books_table.setSortingEnabled(True)
|
self.books_table.setSortingEnabled(True)
|
||||||
|
finally:
|
||||||
|
self.search_button.setEnabled(True)
|
||||||
|
QApplication.restoreOverrideCursor()
|
||||||
|
|
||||||
# Deal with sizing the table columns. Done here because the numbers are not
|
# Deal with sizing the table columns. Done here because the numbers are not
|
||||||
# correct until the first paint.
|
# correct until the first paint.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user