summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Stenger <christian.stenger@theqtcompany.com>2015-03-18 16:11:00 +0100
committerChristian Stenger <christian.stenger@theqtcompany.com>2015-03-30 12:21:34 +0300
commitd0de2fdbbc10a916567e1fc332f307e64f18e306 (patch)
treee9633b528de671886f9107c5fed3ccb73cc55677
parentadb40d4bd56e7378210a32fdc4f1f63ae21f9183 (diff)
downloadqt-creator-d0de2fdbbc10a916567e1fc332f307e64f18e306.tar.gz
Fix results output for long output
For non-selected output use elided text if necessary and for selected add additional line breaks to make sure the text fits into the width of the output area. Additionally removed different style of lines coming after the first one as it does not make sense at all. Change-Id: Ifdd8cb076151ce3e0d895c702921d8f4d2a2b15a Reviewed-by: David Schulz <david.schulz@theqtcompany.com>
-rw-r--r--plugins/autotest/testresultdelegate.cpp38
1 files changed, 15 insertions, 23 deletions
diff --git a/plugins/autotest/testresultdelegate.cpp b/plugins/autotest/testresultdelegate.cpp
index 32aa33df5e..51226270e7 100644
--- a/plugins/autotest/testresultdelegate.cpp
+++ b/plugins/autotest/testresultdelegate.cpp
@@ -119,25 +119,16 @@ void TestResultDelegate::paint(QPainter *painter, const QStyleOptionViewItem &op
output = output.split(QLatin1Char('\n')).first();
}
- QColor mix;
- mix.setRgb( static_cast<int>(0.7 * foreground.red() + 0.3 * background.red()),
- static_cast<int>(0.7 * foreground.green() + 0.3 * background.green()),
- static_cast<int>(0.7 * foreground.blue() + 0.3 * background.blue()));
-
if (selected) {
int height = 0;
int leading = fm.leading();
- int firstLineBreak = output.indexOf(QLatin1Char('\n'));
+ int fontHeight = fm.height();
output.replace(QLatin1Char('\n'), QChar::LineSeparator);
QTextLayout tl(output);
- if (firstLineBreak != -1) {
- QTextLayout::FormatRange fr;
- fr.start = firstLineBreak;
- fr.length = output.length() - firstLineBreak;
- fr.format.setFontStyleHint(QFont::Monospace);
- fr.format.setForeground(mix);
- tl.setAdditionalFormats(QList<QTextLayout::FormatRange>() << fr);
- }
+ tl.setFont(painter->font());
+ QTextOption txtOption;
+ txtOption.setWrapMode(QTextOption::WrapAtWordBoundaryOrAnywhere);
+ tl.setTextOption(txtOption);
tl.beginLayout();
while (true) {
QTextLine tLine = tl.createLine();
@@ -146,18 +137,14 @@ void TestResultDelegate::paint(QPainter *painter, const QStyleOptionViewItem &op
tLine.setLineWidth(positions.textAreaWidth());
height += leading;
tLine.setPosition(QPoint(0, height));
- height += fm.ascent() + fm.descent();
+ height += fontHeight;
}
tl.endLayout();
tl.draw(painter, QPoint(positions.textAreaLeft(), positions.top()));
-
- painter->setPen(mix);
-
- int bottomLine = positions.top() + fm.ascent() + height + leading;
- painter->drawText(positions.textAreaLeft(), bottomLine, testResult.fileName());
} else {
painter->setClipRect(positions.textArea());
- painter->drawText(positions.textAreaLeft(), positions.top() + fm.ascent(), output);
+ painter->drawText(positions.textAreaLeft(), positions.top() + fm.ascent(),
+ fm.elidedText(output, Qt::ElideRight, positions.textAreaWidth()));
}
QString file = testResult.fileName();
@@ -236,18 +223,23 @@ QSize TestResultDelegate::sizeHint(const QStyleOptionViewItem &option, const QMo
int height = 0;
int leading = fm.leading();
QTextLayout tl(output);
+ tl.setFont(opt.font);
+ QTextOption txtOption;
+ txtOption.setWrapMode(QTextOption::WrapAtWordBoundaryOrAnywhere);
+ tl.setTextOption(txtOption);
tl.beginLayout();
while (true) {
QTextLine line = tl.createLine();
if (!line.isValid())
break;
+ line.setLineWidth(positions.textAreaWidth());
height += leading;
line.setPosition(QPoint(0, height));
- height += fm.ascent() + fm.descent();
+ height += fontHeight;
}
tl.endLayout();
- s.setHeight(height + leading + 3 + (testResult.fileName().isEmpty() ? 0 : fontHeight));
+ s.setHeight(height + 3);
} else {
s.setHeight(fontHeight + 3);
}