mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
A more efficient delegate for cover viewing
This commit is contained in:
parent
9055c9e5ff
commit
65118f0f42
@ -113,14 +113,17 @@ class CoverDelegate(QStyledItemDelegate): # {{{
|
|||||||
|
|
||||||
def paint(self, painter, option, index):
|
def paint(self, painter, option, index):
|
||||||
QStyledItemDelegate.paint(self, painter, option, index)
|
QStyledItemDelegate.paint(self, painter, option, index)
|
||||||
# Ensure the cover is rendered over any selection rect
|
|
||||||
style = QApplication.style()
|
style = QApplication.style()
|
||||||
style.drawItemPixmap(painter, option.rect, Qt.AlignTop|Qt.AlignHCenter,
|
waiting = self.timer.isActive() and index.data(Qt.UserRole).toBool()
|
||||||
QPixmap(index.data(Qt.DecorationRole)))
|
if waiting:
|
||||||
if self.timer.isActive() and index.data(Qt.UserRole).toBool():
|
|
||||||
rect = QRect(0, 0, self.spinner_width, self.spinner_width)
|
rect = QRect(0, 0, self.spinner_width, self.spinner_width)
|
||||||
rect.moveCenter(option.rect.center())
|
rect.moveCenter(option.rect.center())
|
||||||
self.draw_spinner(painter, rect)
|
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): # {{{
|
class ResultsModel(QAbstractTableModel): # {{{
|
||||||
@ -946,7 +949,7 @@ class CoverFetch(QDialog): # {{{
|
|||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
#DEBUG_DIALOG = True
|
DEBUG_DIALOG = True
|
||||||
app = QApplication([])
|
app = QApplication([])
|
||||||
d = FullFetch()
|
d = FullFetch()
|
||||||
d.start(title='great gatsby', authors=['fitzgerald'])
|
d.start(title='great gatsby', authors=['fitzgerald'])
|
||||||
|
Loading…
x
Reference in New Issue
Block a user