forked from qt-creator/qt-creator
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:
@@ -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;
|
||||||
|
|||||||
Reference in New Issue
Block a user