mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Cover grid: Show text under books that have no cover as well. Fixes #1880558 [Calibre not showing rating when no picture of the book](https://bugs.launchpad.net/calibre/+bug/1880558)
This commit is contained in:
parent
f2c96802a3
commit
e92b93ba80
@ -546,6 +546,10 @@ class CoverDelegate(QStyledItemDelegate):
|
|||||||
if self.emblem_size > 0:
|
if self.emblem_size > 0:
|
||||||
self.paint_emblems(painter, rect, emblems)
|
self.paint_emblems(painter, rect, emblems)
|
||||||
orect = QRect(rect)
|
orect = QRect(rect)
|
||||||
|
trect = QRect(rect)
|
||||||
|
if self.title_height != 0:
|
||||||
|
rect.setBottom(rect.bottom() - self.title_height)
|
||||||
|
trect.setTop(trect.bottom() - self.title_height + 5)
|
||||||
if cdata is None or cdata is False:
|
if cdata is None or cdata is False:
|
||||||
title = db.field_for('title', book_id, default_value='')
|
title = db.field_for('title', book_id, default_value='')
|
||||||
authors = ' & '.join(db.field_for('authors', book_id, default_value=()))
|
authors = ' & '.join(db.field_for('authors', book_id, default_value=()))
|
||||||
@ -553,10 +557,9 @@ class CoverDelegate(QStyledItemDelegate):
|
|||||||
painter.drawText(rect, Qt.AlignCenter|Qt.TextWordWrap, '%s\n\n%s' % (title, authors))
|
painter.drawText(rect, Qt.AlignCenter|Qt.TextWordWrap, '%s\n\n%s' % (title, authors))
|
||||||
if cdata is False:
|
if cdata is False:
|
||||||
self.render_queue.put(book_id)
|
self.render_queue.put(book_id)
|
||||||
else:
|
|
||||||
if self.title_height != 0:
|
if self.title_height != 0:
|
||||||
trect = QRect(rect)
|
self.paint_title(painter, trect, db, book_id)
|
||||||
rect.setBottom(rect.bottom() - self.title_height)
|
else:
|
||||||
if self.animating is not None and self.animating.row() == index.row():
|
if self.animating is not None and self.animating.row() == index.row():
|
||||||
cdata = cdata.scaled(cdata.size() * self._animated_size)
|
cdata = cdata.scaled(cdata.size() * self._animated_size)
|
||||||
dpr = cdata.devicePixelRatio()
|
dpr = cdata.devicePixelRatio()
|
||||||
@ -567,16 +570,7 @@ class CoverDelegate(QStyledItemDelegate):
|
|||||||
rect.adjust(dx, dy, -dx, 0)
|
rect.adjust(dx, dy, -dx, 0)
|
||||||
painter.drawPixmap(rect, cdata)
|
painter.drawPixmap(rect, cdata)
|
||||||
if self.title_height != 0:
|
if self.title_height != 0:
|
||||||
rect = trect
|
self.paint_title(painter, trect, db, book_id)
|
||||||
rect.setTop(rect.bottom() - self.title_height + 5)
|
|
||||||
painter.setRenderHint(QPainter.TextAntialiasing, True)
|
|
||||||
title, is_stars = self.render_field(db, book_id)
|
|
||||||
if is_stars:
|
|
||||||
painter.setFont(self.rating_font)
|
|
||||||
metrics = painter.fontMetrics()
|
|
||||||
painter.setPen(self.highlight_color)
|
|
||||||
painter.drawText(rect, Qt.AlignCenter|Qt.TextSingleLine,
|
|
||||||
metrics.elidedText(title, Qt.ElideRight, rect.width()))
|
|
||||||
if self.emblem_size > 0:
|
if self.emblem_size > 0:
|
||||||
return # We dont draw embossed emblems as the ondevice/marked emblems are drawn in the gutter
|
return # We dont draw embossed emblems as the ondevice/marked emblems are drawn in the gutter
|
||||||
if marked:
|
if marked:
|
||||||
@ -595,6 +589,16 @@ class CoverDelegate(QStyledItemDelegate):
|
|||||||
finally:
|
finally:
|
||||||
painter.restore()
|
painter.restore()
|
||||||
|
|
||||||
|
def paint_title(self, painter, rect, db, book_id):
|
||||||
|
painter.setRenderHint(QPainter.TextAntialiasing, True)
|
||||||
|
title, is_stars = self.render_field(db, book_id)
|
||||||
|
if is_stars:
|
||||||
|
painter.setFont(self.rating_font)
|
||||||
|
metrics = painter.fontMetrics()
|
||||||
|
painter.setPen(self.highlight_color)
|
||||||
|
painter.drawText(rect, Qt.AlignCenter|Qt.TextSingleLine,
|
||||||
|
metrics.elidedText(title, Qt.ElideRight, rect.width()))
|
||||||
|
|
||||||
def paint_emblems(self, painter, rect, emblems):
|
def paint_emblems(self, painter, rect, emblems):
|
||||||
gutter = self.emblem_size + self.MARGIN
|
gutter = self.emblem_size + self.MARGIN
|
||||||
grect = QRect(rect)
|
grect = QRect(rect)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user