QmlOutline: Only show first line of annotation

Fix the artifacts when the annotations contain a multi-line string.

Task-number: QTCREATORBUG-2889
Reviewed-by: erikv
This commit is contained in:
Kai Koehne
2010-11-11 12:05:01 +01:00
parent fb46c31934
commit 74f13467c1

View File

@@ -36,13 +36,21 @@ void QmlJSOutlineItemDelegate::paint(QPainter *painter, const QStyleOptionViewIt
painter->fillRect(opt.rect, option.palette.highlight());
const QString typeString = index.data(Qt::DisplayRole).toString();
const QString annotationString = index.data(QmlOutlineModel::AnnotationRole).toString();
QString annotationString = index.data(QmlOutlineModel::AnnotationRole).toString();
QStyle *style = QApplication::style();
style->drawControl(QStyle::CE_ItemViewItem, &opt, painter, 0);
if (!annotationString.isEmpty()) {
int newlinePos = annotationString.indexOf(QLatin1Char('\n'));
if (newlinePos != -1) {
// print first line with '...' at end
const QChar ellipsisChar(0x2026);
annotationString = annotationString.left(newlinePos) + ellipsisChar;
}
QPalette::ColorRole textColorRole = QPalette::Text;
if (option.state & QStyle::State_Selected) {
textColorRole = QPalette::HighlightedText;