From 65118f0f420227d123cbcdf48aa621fd7a1b3f3b Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 22 Apr 2011 14:28:00 -0600 Subject: [PATCH] A more efficient delegate for cover viewing --- src/calibre/gui2/metadata/single_download.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/calibre/gui2/metadata/single_download.py b/src/calibre/gui2/metadata/single_download.py index 7aae502040..06ea8cf76a 100644 --- a/src/calibre/gui2/metadata/single_download.py +++ b/src/calibre/gui2/metadata/single_download.py @@ -113,14 +113,17 @@ class CoverDelegate(QStyledItemDelegate): # {{{ def paint(self, painter, option, index): QStyledItemDelegate.paint(self, painter, option, index) - # Ensure the cover is rendered over any selection rect style = QApplication.style() - style.drawItemPixmap(painter, option.rect, Qt.AlignTop|Qt.AlignHCenter, - QPixmap(index.data(Qt.DecorationRole))) - if self.timer.isActive() and index.data(Qt.UserRole).toBool(): + waiting = self.timer.isActive() and index.data(Qt.UserRole).toBool() + if waiting: rect = QRect(0, 0, self.spinner_width, self.spinner_width) rect.moveCenter(option.rect.center()) self.draw_spinner(painter, rect) + else: + # Ensure the cover is rendered over any selection rect + style.drawItemPixmap(painter, option.rect, Qt.AlignTop|Qt.AlignHCenter, + QPixmap(index.data(Qt.DecorationRole))) + # }}} class ResultsModel(QAbstractTableModel): # {{{ @@ -946,7 +949,7 @@ class CoverFetch(QDialog): # {{{ # }}} if __name__ == '__main__': - #DEBUG_DIALOG = True + DEBUG_DIALOG = True app = QApplication([]) d = FullFetch() d.start(title='great gatsby', authors=['fitzgerald'])