def sizeHint(self, option, index):
     sizeHint = QStyledItemDelegate.sizeHint(self, option, index)
     if self.parent() != None:
         # QItemDelegate добавляет 2 * ширину рамки (хотя мы её и не рисуем), плюс нужно учесть
         # ширину скроллбара.
         style = QApplication.style()
         ff = style.pixelMetric(QStyle.PM_FocusFrameHMargin, option)
         sb = style.pixelMetric(QStyle.PM_ScrollBarExtent, option)
         sizeHint.setWidth(min(sizeHint.width(), self.parent().width()) - 2 * ff - sb)
     if settings.oneLineEntry() or not index.parent().isValid():
         sizeHint.setHeight(sizeHint.height() + 2 * settings.entryTopBottomMargin())
         return sizeHint
     else:
         return QSize(sizeHint.width(), 2 * sizeHint.height())
 def _drawEntryRow(self, painter, option, index):
     """ Отрисовка строки с записью """
     fontColor = Qt.black
     if option.state & QStyle.State_Selected:
         painter.fillRect(option.rect, option.palette.highlight())
         fontColor = Qt.white
     elif settings.useAlternateRowColors() and index.row() % 2 == 1:
         painter.fillRect(option.rect, QColor('#DDEBFF'))
     indexIsNotLastInCategory = index.sibling(index.row() + 1, index.column()).isValid()
     if indexIsNotLastInCategory:
         painter.setPen(QColor(250, 250, 250))
         painter.drawLine(option.rect.bottomLeft(), option.rect.bottomRight())
     iconHeight = settings.entryIconHeight()
     if settings.oneLineEntry():
         y = (option.rect.height() - iconHeight) / 2
     else:
         y = settings.entryTopBottomMargin()
     iconPoint = QPoint(option.rect.left(), option.rect.top() + y)
     if index.data(Qt.CheckStateRole):
         painter.drawPixmap(iconPoint, QPixmap(":/icons/interesting.svg"))
     else:
         painter.drawPixmap(iconPoint, QPixmap(":/icons/boring.svg"))
     painter.setFont(index.data(Qt.FontRole))
     painter.setPen(fontColor)
     baseLine = (option.rect.height() + option.fontMetrics.ascent()) / 2
     blog, title = tuple(i.strip() for i in index.data().split("/", 1))
     fontMetrics = QFontMetrics(index.data(Qt.FontRole))
     totalWidth = option.rect.width()
     iconWidth = settings.entryIconWidth() + settings.entryLeftMargin()
     blogWidth = fontMetrics.width(blog)
     titleWidth = totalWidth - iconWidth - blogWidth
     if settings.oneLineEntry():
         textY = blogY = option.rect.top() + baseLine
         textX = option.rect.left() + iconWidth
         blogX = option.rect.right() - blogWidth
         elidedTitle = fontMetrics.elidedText(title, Qt.ElideRight, titleWidth)
     else:
         textX = blogX = option.rect.left() + iconWidth
         textY = option.rect.top() + 2 * fontMetrics.ascent()
         blogY = option.rect.top() + fontMetrics.ascent()
         elidedTitle = fontMetrics.elidedText(title, Qt.ElideRight, totalWidth - iconWidth)
     painter.drawText(textX, textY, elidedTitle)
     painter.setPen(Qt.lightGray)
     painter.drawText(blogX, blogY, blog)