commit
9f54e92ee4
|
@ -17,7 +17,7 @@ void ResultViewDelegate::setSearchKeyword(const QString ®FindKeyWords)
|
|||
QSize ResultViewDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const
|
||||
{
|
||||
QSize size = QStyledItemDelegate::sizeHint(option,index);
|
||||
size.setHeight(size.height() + 10);
|
||||
size.setHeight(size.height() + 50);
|
||||
return size;
|
||||
}
|
||||
|
||||
|
@ -35,7 +35,7 @@ void ResultViewDelegate::paint(QPainter *painter, const QStyleOptionViewItem &op
|
|||
|
||||
QRect textRect = style->subElementRect(QStyle::SE_ItemViewItemText, &opt, opt.widget);
|
||||
QFontMetrics fontMetrics(opt.font);
|
||||
text = fontMetrics.elidedText(text, Qt::ElideRight, textRect.width() - 5); //富余5px的宽度
|
||||
text = fontMetrics.elidedText(text, Qt::ElideRight, textRect.width() - m_textDoc->documentMargin() - 1); //富余5px的宽度
|
||||
opt.text = text;
|
||||
|
||||
painter->save();
|
||||
|
@ -44,11 +44,13 @@ void ResultViewDelegate::paint(QPainter *painter, const QStyleOptionViewItem &op
|
|||
} else {
|
||||
m_hightLightEffectHelper->setTextColor(QBrush(opt.palette.text().color()));
|
||||
}
|
||||
painter->translate(textRect.topLeft());
|
||||
|
||||
|
||||
m_textDoc->setPlainText(text);
|
||||
m_hightLightEffectHelper->setDocument(m_textDoc);
|
||||
m_hightLightEffectHelper->rehighlight();
|
||||
|
||||
painter->translate(textRect.x(), textRect.y() + (textRect.height() - fontMetrics.height()) / 2 - m_textDoc->documentMargin());
|
||||
m_textDoc->drawContents(painter);
|
||||
painter->restore();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue