예제 #1
0
파일: widgets.py 프로젝트: Hainish/calibre
 def paint(self, painter, option, index):
     QStyledItemDelegate.paint(self, painter, option, index)
     text, positions = index.data(Qt.UserRole).toPyObject()
     self.initStyleOption(option, index)
     painter.save()
     painter.setFont(option.font)
     p = option.palette
     c = p.HighlightedText if option.state & QStyle.State_Selected else p.Text
     group = (p.Active if option.state & QStyle.State_Active else p.Inactive)
     c = p.color(group, c)
     painter.setClipRect(option.rect)
     if positions is None or -1 in positions:
         painter.setPen(c)
         painter.drawText(option.rect, Qt.AlignLeft | Qt.AlignVCenter | Qt.TextSingleLine, text)
     else:
         to = QTextOption()
         to.setWrapMode(to.NoWrap)
         to.setAlignment(Qt.AlignLeft | Qt.AlignVCenter)
         positions = sorted(set(positions) - {-1}, reverse=True)
         text = '<body>%s</body>' % make_highlighted_text(Results.EMPH, text, positions)
         doc = QTextDocument()
         c = 'rgb(%d, %d, %d)'%c.getRgb()[:3]
         doc.setDefaultStyleSheet(' body { color: %s }'%c)
         doc.setHtml(text)
         doc.setDefaultFont(option.font)
         doc.setDocumentMargin(0.0)
         doc.setDefaultTextOption(to)
         height = doc.size().height()
         painter.translate(option.rect.left(), option.rect.top() + (max(0, option.rect.height() - height) // 2))
         doc.drawContents(painter)
     painter.restore()
예제 #2
0
 def paint(self, painter, option, index):
     item = index.data(Qt.UserRole).toPyObject()
     QStyledItemDelegate.paint(self, painter, option, index)
     widget = self.parent()
     style = QApplication.style() if widget is None else widget.style()
     self.initStyleOption(option, index)
     if item.boxed:
         r = style.subElementRect(style.SE_ItemViewItemFocusRect, option,
                                  widget)
         painter.save()
         painter.drawLine(r.bottomLeft(), r.bottomRight())
         painter.restore()
     if item.type != TagTreeItem.TAG:
         return
     if (item.tag.state == 0 and config['show_avg_rating']
             and item.tag.avg_rating is not None):
         r = style.subElementRect(style.SE_ItemViewItemDecoration, option,
                                  widget)
         icon = option.icon
         painter.save()
         rating = item.tag.avg_rating
         nr = r.adjusted(0, 0, 0, 0)
         nr.setBottom(r.bottom() - int(r.height() * (rating / 5.0)))
         painter.setClipRect(nr)
         bg = option.palette.window()
         if self.old_look:
             bg = (option.palette.alternateBase() if option.features
                   & option.Alternate else option.palette.base())
         painter.fillRect(r, bg)
         style.proxy().drawPrimitive(style.PE_PanelItemViewItem, option,
                                     painter, widget)
         painter.setOpacity(0.3)
         icon.paint(painter, r, option.decorationAlignment, icon.Normal,
                    icon.On)
         painter.restore()
예제 #3
0
 def paint(self, painter, option, index):
     QStyledItemDelegate.paint(self, painter, option, QModelIndex())
     painter.save()
     painter.setClipRect(QRectF(option.rect))
     painter.translate(option.rect.topLeft())
     self.to_doc(index, option).drawContents(painter)
     painter.restore()
예제 #4
0
 def paint(self, painter, option, index):
     # If we are looking at a method then draw a button
     # http://www.qtcentre.org/threads/26916-inserting-custom-Widget-to-listview?p=128623#post128623
     if not hasattr(self, "blue_button"):
         self.blue_button = QPushButton()
         self.blue_button.setStyleSheet("color: rgb(0, 0, 196)")
     if index.isValid() and \
             isinstance(index.internalPointer().data, Method):
         item = index.internalPointer()
         opt = QStyleOptionButton()
         style = QApplication.style()
         # If method is running, draw sunken
         if item.argvalue:
             opt.state |= QStyle.State_Enabled
             opt.state |= QStyle.State_Sunken
         # if method is allowed, draw blue
         elif self.method_allowed(item):
             opt.state |= QStyle.State_Enabled
             style = self.blue_button.style()
         # if we are hovering, draw highlight
         if option.state & QStyle.State_MouseOver:
             opt.state |= QStyle.State_MouseOver
         opt.rect = option.rect
         opt.text = index.internalPointer().name
         style.drawControl(QStyle.CE_PushButton, opt, painter,
                           self.blue_button)
     else:
         if option.state & QStyle.State_Selected:
             # Don't show delegates as highlighted
             option.state = option.state ^ QStyle.State_Selected
         QStyledItemDelegate.paint(self, painter, option, index)
예제 #5
0
 def paint(self, painter, option, index):
     QStyledItemDelegate.paint(self, painter, option, self.dummy_index)
     painter.save()
     painter.setClipRect(QRectF(option.rect))
     painter.translate(option.rect.topLeft())
     self.to_doc(index, option).drawContents(painter)
     painter.restore()
예제 #6
0
 def paint(self, painter, option, index):
     # If we are looking at a method then draw a button
     # http://www.qtcentre.org/threads/26916-inserting-custom-Widget-to-listview?p=128623#post128623
     if self.is_method_button(index):
         item = index.internalPointer()
         opt = QStyleOptionButton()
         style = QApplication.style()
         # If method is running, draw sunken
         if item.get_state() == item.RUNNING:
             opt.state |= QStyle.State_Enabled
             opt.state |= QStyle.State_Sunken
         # if method is allowed, draw blue
         elif item.get_writeable():
             opt.state |= QStyle.State_Enabled
         # if we are hovering, draw highlight
         if option.state & QStyle.State_MouseOver:
             opt.state |= QStyle.State_MouseOver
         opt.rect = option.rect
         opt.text = item.get_label()
         style.drawControl(QStyle.CE_PushButton, opt, painter, QPushButton())
     else:
         if option.state & QStyle.State_Selected:
             # Don't show delegates as highlighted
             option.state = option.state ^ QStyle.State_Selected
         QStyledItemDelegate.paint(self, painter, option, index)
예제 #7
0
 def paint(self, painter, option, index):
     top_level = not index.parent().isValid()
     hover = option.state & QStyle.State_MouseOver
     if hover:
         if top_level:
             suffix = '%s(%d)' % (NBSP, index.model().rowCount(index))
         else:
             try:
                 suffix = NBSP + human_readable(
                     current_container().filesize(
                         unicode(index.data(NAME_ROLE).toString())))
             except EnvironmentError:
                 suffix = NBSP + human_readable(0)
         br = painter.boundingRect(option.rect,
                                   Qt.AlignRight | Qt.AlignVCenter, suffix)
     if top_level and index.row() > 0:
         option.rect.adjust(0, 5, 0, 0)
         painter.drawLine(option.rect.topLeft(), option.rect.topRight())
         option.rect.adjust(0, 1, 0, 0)
     if hover:
         option.rect.adjust(0, 0, -br.width(), 0)
     QStyledItemDelegate.paint(self, painter, option, index)
     if hover:
         option.rect.adjust(0, 0, br.width(), 0)
         painter.drawText(option.rect, Qt.AlignRight | Qt.AlignVCenter,
                          suffix)
예제 #8
0
파일: view.py 프로젝트: hashken/calibre
 def paint(self, painter, option, index):
     item = index.data(Qt.UserRole).toPyObject()
     QStyledItemDelegate.paint(self, painter, option, index)
     widget = self.parent()
     style = QApplication.style() if widget is None else widget.style()
     self.initStyleOption(option, index)
     if item.boxed:
         r = style.subElementRect(style.SE_ItemViewItemFocusRect, option, widget)
         painter.save()
         painter.drawLine(r.bottomLeft(), r.bottomRight())
         painter.restore()
     if item.type != TagTreeItem.TAG:
         return
     if item.tag.state == 0 and config["show_avg_rating"] and item.tag.avg_rating is not None:
         r = style.subElementRect(style.SE_ItemViewItemDecoration, option, widget)
         icon = option.icon
         painter.save()
         rating = item.tag.avg_rating
         nr = r.adjusted(0, 0, 0, 0)
         nr.setBottom(r.bottom() - int(r.height() * (rating / 5.0)))
         painter.setClipRect(nr)
         bg = option.palette.window()
         if self.old_look:
             bg = option.palette.alternateBase() if option.features & option.Alternate else option.palette.base()
         painter.fillRect(r, bg)
         style.proxy().drawPrimitive(style.PE_PanelItemViewItem, option, painter, widget)
         painter.setOpacity(0.3)
         icon.paint(painter, r, option.decorationAlignment, icon.Normal, icon.On)
         painter.restore()
예제 #9
0
파일: widgets.py 프로젝트: dusual/calibre
 def paint(self, painter, option, index):
     QStyledItemDelegate.paint(self, painter, option, index)
     text, positions = index.data(Qt.UserRole).toPyObject()
     self.initStyleOption(option, index)
     painter.save()
     painter.setFont(option.font)
     p = option.palette
     c = p.HighlightedText if option.state & QStyle.State_Selected else p.Text
     group = (p.Active if option.state & QStyle.State_Active else p.Inactive)
     c = p.color(group, c)
     painter.setClipRect(option.rect)
     if positions is None or -1 in positions:
         painter.setPen(c)
         painter.drawText(option.rect, Qt.AlignLeft | Qt.AlignVCenter | Qt.TextSingleLine, text)
     else:
         to = QTextOption()
         to.setWrapMode(to.NoWrap)
         to.setAlignment(Qt.AlignLeft | Qt.AlignVCenter)
         positions = sorted(set(positions) - {-1}, reverse=True)
         text = '<body>%s</body>' % make_highlighted_text(Results.EMPH, text, positions)
         doc = QTextDocument()
         c = 'rgb(%d, %d, %d)'%c.getRgb()[:3]
         doc.setDefaultStyleSheet(' body { color: %s }'%c)
         doc.setHtml(text)
         doc.setDefaultFont(option.font)
         doc.setDocumentMargin(0.0)
         doc.setDefaultTextOption(to)
         height = doc.size().height()
         painter.translate(option.rect.left(), option.rect.top() + (max(0, option.rect.height() - height) // 2))
         doc.drawContents(painter)
     painter.restore()
예제 #10
0
 def paint(self, painter, option, index):
     QStyledItemDelegate.paint(self, painter, option, QModelIndex())
     painter.save()
     try:
         self.do_paint(painter, option, index)
     except:
         pass
     painter.restore()
예제 #11
0
 def paint(self, painter, option, index):
     QStyledItemDelegate.paint(self, painter, option, QModelIndex())
     painter.save()
     try:
         self.do_paint(painter, option, index)
     except:
         pass
     painter.restore()
예제 #12
0
 def paint(self, painter, option, index):
     QStyledItemDelegate.paint(self, painter, option, index)
     style = QApplication.style()
     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)))
예제 #13
0
 def paint(self, painter, option, index):
     QStyledItemDelegate.paint(self, painter, option, index)
     style = QApplication.style()
     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)))
예제 #14
0
 def paint(self, painter, option, index):
     QStyledItemDelegate.paint(self, painter, option, index)
     charcode, ok = index.data(Qt.UserRole).toInt()
     if not ok:
         return
     painter.save()
     try:
         if charcode in non_printing:
             self.paint_non_printing(painter, option, charcode)
         else:
             self.paint_normal(painter, option, charcode)
     finally:
         painter.restore()
예제 #15
0
 def paint(self, painter, option, index):
     QStyledItemDelegate.paint(self, painter, option, index)
     charcode, ok = index.data(Qt.UserRole).toInt()
     if not ok:
         return
     painter.save()
     try:
         if charcode in non_printing:
             self.paint_non_printing(painter, option, charcode)
         else:
             self.paint_normal(painter, option, charcode)
     finally:
         painter.restore()
예제 #16
0
 def paint(self, painter, option, index):
     QStyledItemDelegate.paint(self, painter, option, QModelIndex())  # draw the hover and selection highlights
     m = index.model()
     db = m.db
     try:
         book_id = db.id(index.row())
     except (ValueError, IndexError, KeyError):
         return
     if book_id in m.ids_to_highlight_set:
         painter.save()
         try:
             painter.setPen(self.highlight_color)
             painter.setRenderHint(QPainter.Antialiasing, True)
             painter.drawRoundedRect(option.rect, 10, 10, Qt.RelativeSize)
         finally:
             painter.restore()
     db = db.new_api
     cdata = self.cover_cache[book_id]
     painter.save()
     try:
         rect = option.rect
         rect.adjust(self.MARGIN, self.MARGIN, -self.MARGIN, -self.MARGIN)
         if cdata is None or cdata is False:
             title = db.field_for('title', book_id, default_value='')
             authors = ' & '.join(db.field_for('authors', book_id, default_value=()))
             painter.setRenderHint(QPainter.TextAntialiasing, True)
             painter.drawText(rect, Qt.AlignCenter|Qt.TextWordWrap, '%s\n\n%s' % (title, authors))
             if cdata is False:
                 self.render_queue.put(book_id)
         else:
             if self.title_height != 0:
                 orect = QRect(rect)
                 rect.setBottom(rect.bottom() - self.title_height)
             if self.animating is not None and self.animating.row() == index.row():
                 cdata = cdata.scaled(cdata.size() * self._animated_size)
             dx = max(0, int((rect.width() - cdata.width())/2.0))
             dy = max(0, rect.height() - cdata.height())
             rect.adjust(dx, dy, -dx, 0)
             painter.drawPixmap(rect, cdata)
             if self.title_height != 0:
                 rect = orect
                 rect.setTop(rect.bottom() - self.title_height + 5)
                 painter.setRenderHint(QPainter.TextAntialiasing, True)
                 title = db.field_for('title', book_id, default_value='')
                 metrics = painter.fontMetrics()
                 painter.drawText(rect, Qt.AlignCenter|Qt.TextSingleLine,
                                  metrics.elidedText(title, Qt.ElideRight, rect.width()))
     finally:
         painter.restore()
예제 #17
0
    def paint(self, painter, option, index):
        QStyledItemDelegate.paint(
            self, painter, option,
            QModelIndex())  # draw the hover and selection highlights
        name = unicode(index.data(Qt.DisplayRole).toString())
        cover = self.cover_cache.get(name, None)
        if cover is None:
            cover = self.cover_cache[name] = QPixmap()
            try:
                raw = current_container().raw_data(name, decode=False)
            except:
                pass
            else:
                cover.loadFromData(raw)
                if not cover.isNull():
                    scaled, width, height = fit_image(cover.width(),
                                                      cover.height(),
                                                      self.cover_size.width(),
                                                      self.cover_size.height())
                    if scaled:
                        cover = self.cover_cache[name] = cover.scaled(
                            width,
                            height,
                            transformMode=Qt.SmoothTransformation)

        painter.save()
        try:
            rect = option.rect
            rect.adjust(self.MARGIN, self.MARGIN, -self.MARGIN, -self.MARGIN)
            trect = QRect(rect)
            rect.setBottom(rect.bottom() - self.title_height)
            if not cover.isNull():
                dx = max(0, int((rect.width() - cover.width()) / 2.0))
                dy = max(0, rect.height() - cover.height())
                rect.adjust(dx, dy, -dx, 0)
                painter.drawPixmap(rect, cover)
            rect = trect
            rect.setTop(rect.bottom() - self.title_height + 5)
            painter.setRenderHint(QPainter.TextAntialiasing, True)
            metrics = painter.fontMetrics()
            painter.drawText(
                rect, Qt.AlignCenter | Qt.TextSingleLine,
                metrics.elidedText(name, Qt.ElideLeft, rect.width()))
        finally:
            painter.restore()
예제 #18
0
 def paint(self, painter, option, index):
     top_level = not index.parent().isValid()
     hover = option.state & QStyle.State_MouseOver
     if hover:
         if top_level:
             suffix = '%s(%d)' % (NBSP, index.model().rowCount(index))
         else:
             suffix = NBSP + human_readable(current_container().filesize(unicode(index.data(NAME_ROLE).toString())))
         br = painter.boundingRect(option.rect, Qt.AlignRight|Qt.AlignVCenter, suffix)
     if top_level and index.row() > 0:
         option.rect.adjust(0, 5, 0, 0)
         painter.drawLine(option.rect.topLeft(), option.rect.topRight())
         option.rect.adjust(0, 1, 0, 0)
     if hover:
         option.rect.adjust(0, 0, -br.width(), 0)
     QStyledItemDelegate.paint(self, painter, option, index)
     if hover:
         option.rect.adjust(0, 0, br.width(), 0)
         painter.drawText(option.rect, Qt.AlignRight|Qt.AlignVCenter, suffix)
예제 #19
0
    def paint(self, painter, option, index):
        QStyledItemDelegate.paint(self, painter, option, QModelIndex())  # draw the hover and selection highlights
        name = unicode(index.data(Qt.DisplayRole).toString())
        cover = self.cover_cache.get(name, None)
        if cover is None:
            cover = self.cover_cache[name] = QPixmap()
            try:
                raw = current_container().raw_data(name, decode=False)
            except:
                pass
            else:
                cover.loadFromData(raw)
                if not cover.isNull():
                    scaled, width, height = fit_image(
                        cover.width(), cover.height(), self.cover_size.width(), self.cover_size.height()
                    )
                    if scaled:
                        cover = self.cover_cache[name] = cover.scaled(
                            width, height, transformMode=Qt.SmoothTransformation
                        )

        painter.save()
        try:
            rect = option.rect
            rect.adjust(self.MARGIN, self.MARGIN, -self.MARGIN, -self.MARGIN)
            trect = QRect(rect)
            rect.setBottom(rect.bottom() - self.title_height)
            if not cover.isNull():
                dx = max(0, int((rect.width() - cover.width()) / 2.0))
                dy = max(0, rect.height() - cover.height())
                rect.adjust(dx, dy, -dx, 0)
                painter.drawPixmap(rect, cover)
            rect = trect
            rect.setTop(rect.bottom() - self.title_height + 5)
            painter.setRenderHint(QPainter.TextAntialiasing, True)
            metrics = painter.fontMetrics()
            painter.drawText(
                rect, Qt.AlignCenter | Qt.TextSingleLine, metrics.elidedText(name, Qt.ElideLeft, rect.width())
            )
        finally:
            painter.restore()
예제 #20
0
 def paint(self, painter, option, index):
     option.font = self.rf
     option.textElideMode = self.em
     return QStyledItemDelegate.paint(self, painter, option, index)
예제 #21
0
 def paint(self, p, opt, idx):
     copy = QStyleOptionViewItem(opt)
     copy.showDecorationSelected = True
     if self.view.currentIndex() == idx:
         copy.state |= QStyle.State_HasFocus
     QStyledItemDelegate.paint(self, p, copy, idx)
예제 #22
0
 def paint(self, painter, option, index):
     option.font = self.rf
     option.textElideMode = self.em
     return QStyledItemDelegate.paint(self, painter, option, index)
예제 #23
0
 def paint(self, painter, option, index):
     QStyledItemDelegate.paint(
         self, painter, option,
         QModelIndex())  # draw the hover and selection highlights
     m = index.model()
     db = m.db
     try:
         book_id = db.id(index.row())
     except (ValueError, IndexError, KeyError):
         return
     if book_id in m.ids_to_highlight_set:
         painter.save()
         try:
             painter.setPen(self.highlight_color)
             painter.setRenderHint(QPainter.Antialiasing, True)
             painter.drawRoundedRect(option.rect, 10, 10, Qt.RelativeSize)
         finally:
             painter.restore()
     marked = db.data.get_marked(book_id)
     db = db.new_api
     cdata = self.cover_cache[book_id]
     device_connected = self.parent().gui.device_connected is not None
     on_device = device_connected and db.field_for('ondevice', book_id)
     painter.save()
     right_adjust = 0
     try:
         rect = option.rect
         rect.adjust(self.MARGIN, self.MARGIN, -self.MARGIN, -self.MARGIN)
         orect = QRect(rect)
         if cdata is None or cdata is False:
             title = db.field_for('title', book_id, default_value='')
             authors = ' & '.join(
                 db.field_for('authors', book_id, default_value=()))
             painter.setRenderHint(QPainter.TextAntialiasing, True)
             painter.drawText(rect, Qt.AlignCenter | Qt.TextWordWrap,
                              '%s\n\n%s' % (title, authors))
             if cdata is False:
                 self.render_queue.put(book_id)
         else:
             if self.title_height != 0:
                 trect = QRect(rect)
                 rect.setBottom(rect.bottom() - self.title_height)
             if self.animating is not None and self.animating.row(
             ) == index.row():
                 cdata = cdata.scaled(cdata.size() * self._animated_size)
             dx = max(0, int((rect.width() - cdata.width()) / 2.0))
             dy = max(0, rect.height() - cdata.height())
             right_adjust = dx
             rect.adjust(dx, dy, -dx, 0)
             painter.drawPixmap(rect, cdata)
             if self.title_height != 0:
                 rect = trect
                 rect.setTop(rect.bottom() - self.title_height + 5)
                 painter.setRenderHint(QPainter.TextAntialiasing, True)
                 title = self.render_field(db, book_id)
                 metrics = painter.fontMetrics()
                 painter.setPen(self.highlight_color)
                 painter.drawText(
                     rect, Qt.AlignCenter | Qt.TextSingleLine,
                     metrics.elidedText(title, Qt.ElideRight, rect.width()))
         if marked:
             try:
                 p = self.marked_emblem
             except AttributeError:
                 p = self.marked_emblem = m.marked_icon.pixmap(48, 48)
             drect = QRect(orect)
             drect.setLeft(drect.left() + right_adjust)
             drect.setRight(drect.left() + p.width())
             drect.setBottom(drect.bottom() - self.title_height)
             drect.setTop(drect.bottom() - p.height())
             painter.drawPixmap(drect, p)
         if on_device:
             try:
                 p = self.on_device_emblem
             except AttributeError:
                 p = self.on_device_emblem = QPixmap(I('ok.png')).scaled(
                     48, 48, transformMode=Qt.SmoothTransformation)
             drect = QRect(orect)
             drect.setRight(drect.right() - right_adjust)
             drect.setBottom(drect.bottom() - self.title_height)
             drect.setTop(drect.bottom() - p.height() + 1)
             drect.setLeft(drect.right() - p.width() + 1)
             painter.drawPixmap(drect, p)
     finally:
         painter.restore()
예제 #24
0
파일: tweaks.py 프로젝트: 089git/calibre
 def paint(self, p, opt, idx):
     copy = QStyleOptionViewItem(opt)
     copy.showDecorationSelected = True
     if self.view.currentIndex() == idx:
         copy.state |= QStyle.State_HasFocus
     QStyledItemDelegate.paint(self, p, copy, idx)
예제 #25
0
 def paint(self, painter, option, index):
     QStyledItemDelegate.paint(self, painter, option, QModelIndex())  # draw the hover and selection highlights
     m = index.model()
     db = m.db
     try:
         book_id = db.id(index.row())
     except (ValueError, IndexError, KeyError):
         return
     if book_id in m.ids_to_highlight_set:
         painter.save()
         try:
             painter.setPen(self.highlight_color)
             painter.setRenderHint(QPainter.Antialiasing, True)
             painter.drawRoundedRect(option.rect, 10, 10, Qt.RelativeSize)
         finally:
             painter.restore()
     marked = db.data.get_marked(book_id)
     db = db.new_api
     cdata = self.cover_cache[book_id]
     device_connected = self.parent().gui.device_connected is not None
     on_device = device_connected and db.field_for('ondevice', book_id)
     painter.save()
     right_adjust = 0
     try:
         rect = option.rect
         rect.adjust(self.MARGIN, self.MARGIN, -self.MARGIN, -self.MARGIN)
         orect = QRect(rect)
         if cdata is None or cdata is False:
             title = db.field_for('title', book_id, default_value='')
             authors = ' & '.join(db.field_for('authors', book_id, default_value=()))
             painter.setRenderHint(QPainter.TextAntialiasing, True)
             painter.drawText(rect, Qt.AlignCenter|Qt.TextWordWrap, '%s\n\n%s' % (title, authors))
             if cdata is False:
                 self.render_queue.put(book_id)
         else:
             if self.title_height != 0:
                 trect = QRect(rect)
                 rect.setBottom(rect.bottom() - self.title_height)
             if self.animating is not None and self.animating.row() == index.row():
                 cdata = cdata.scaled(cdata.size() * self._animated_size)
             dx = max(0, int((rect.width() - cdata.width())/2.0))
             dy = max(0, rect.height() - cdata.height())
             right_adjust = dx
             rect.adjust(dx, dy, -dx, 0)
             painter.drawPixmap(rect, cdata)
             if self.title_height != 0:
                 rect = trect
                 rect.setTop(rect.bottom() - self.title_height + 5)
                 painter.setRenderHint(QPainter.TextAntialiasing, True)
                 title = db.field_for('title', book_id, default_value='')
                 metrics = painter.fontMetrics()
                 painter.drawText(rect, Qt.AlignCenter|Qt.TextSingleLine,
                                  metrics.elidedText(title, Qt.ElideRight, rect.width()))
         if marked:
             try:
                 p = self.marked_emblem
             except AttributeError:
                 p = self.marked_emblem = QPixmap(I('rating.png')).scaled(48, 48, transformMode=Qt.SmoothTransformation)
             drect = QRect(orect)
             drect.setLeft(drect.left() + right_adjust)
             drect.setRight(drect.left() + p.width())
             drect.setBottom(drect.bottom() - self.title_height)
             drect.setTop(drect.bottom() - p.height())
             painter.drawPixmap(drect, p)
         if on_device:
             try:
                 p = self.on_device_emblem
             except AttributeError:
                 p = self.on_device_emblem = QPixmap(I('ok.png')).scaled(48, 48, transformMode=Qt.SmoothTransformation)
             drect = QRect(orect)
             drect.setRight(drect.right() - right_adjust)
             drect.setBottom(drect.bottom() - self.title_height)
             drect.setTop(drect.bottom() - p.height() + 1)
             drect.setLeft(drect.right() - p.width() + 1)
             painter.drawPixmap(drect, p)
     finally:
         painter.restore()