Skip to content
Snippets Groups Projects
Commit 74f13467 authored by Kai Koehne's avatar Kai Koehne
Browse files

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
parent fb46c319
No related merge requests found
...@@ -36,13 +36,21 @@ void QmlJSOutlineItemDelegate::paint(QPainter *painter, const QStyleOptionViewIt ...@@ -36,13 +36,21 @@ void QmlJSOutlineItemDelegate::paint(QPainter *painter, const QStyleOptionViewIt
painter->fillRect(opt.rect, option.palette.highlight()); painter->fillRect(opt.rect, option.palette.highlight());
const QString typeString = index.data(Qt::DisplayRole).toString(); 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(); QStyle *style = QApplication::style();
style->drawControl(QStyle::CE_ItemViewItem, &opt, painter, 0); style->drawControl(QStyle::CE_ItemViewItem, &opt, painter, 0);
if (!annotationString.isEmpty()) { 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; QPalette::ColorRole textColorRole = QPalette::Text;
if (option.state & QStyle::State_Selected) { if (option.state & QStyle::State_Selected) {
textColorRole = QPalette::HighlightedText; textColorRole = QPalette::HighlightedText;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment