summaryrefslogtreecommitdiffstats
path: root/src/gui/text
diff options
context:
space:
mode:
authorBradley T. Hughes <bradley.hughes@nokia.com>2009-05-06 15:33:32 (GMT)
committerBradley T. Hughes <bradley.hughes@nokia.com>2009-05-06 15:33:32 (GMT)
commit0822e845b2678ab626cd5fe9919364188c06a70e (patch)
tree552f9e9a285330d3682c8fe645b74e3a56d379a0 /src/gui/text
parent7a5da4486708b096084fdaf83aba88f5d1b83e00 (diff)
parent2eb0312c96ab828809158802d4cb7e0980227389 (diff)
downloadQt-0822e845b2678ab626cd5fe9919364188c06a70e.zip
Qt-0822e845b2678ab626cd5fe9919364188c06a70e.tar.gz
Qt-0822e845b2678ab626cd5fe9919364188c06a70e.tar.bz2
Merge branch 'master' of git@scm.dev.nokia.troll.no:qt/qt into windows-7-multitouch
Diffstat (limited to 'src/gui/text')
-rw-r--r--src/gui/text/qtextlayout.cpp39
1 files changed, 25 insertions, 14 deletions
diff --git a/src/gui/text/qtextlayout.cpp b/src/gui/text/qtextlayout.cpp
index 3222237..fa624ef 100644
--- a/src/gui/text/qtextlayout.cpp
+++ b/src/gui/text/qtextlayout.cpp
@@ -1145,7 +1145,7 @@ void QTextLayout::draw(QPainter *p, const QPointF &pos, const QVector<FormatRang
}
QPainterPath excludedRegion;
- QPainterPath needsTextButNoBackground;
+ QPainterPath textDoneRegion;
for (int i = 0; i < selections.size(); ++i) {
FormatRange selection = selections.at(i);
const QBrush bg = selection.format.background();
@@ -1205,18 +1205,25 @@ void QTextLayout::draw(QPainter *p, const QPointF &pos, const QVector<FormatRang
}
- p->save();
- p->setClipPath(region, Qt::IntersectClip);
- selection.format.setProperty(ObjectSelectionBrush, selection.format.property(QTextFormat::BackgroundBrush));
- // don't just clear the property, set an empty brush that overrides a potential
- // background brush specified in the text
- selection.format.setProperty(QTextFormat::BackgroundBrush, QBrush());
- selection.format.clearProperty(QTextFormat::OutlinePen);
+ bool hasText = (selection.format.foreground().style() != Qt::NoBrush);
+ bool hasBackground= (selection.format.background().style() != Qt::NoBrush);
+
+ if (hasBackground) {
+ selection.format.setProperty(ObjectSelectionBrush, selection.format.property(QTextFormat::BackgroundBrush));
+ // don't just clear the property, set an empty brush that overrides a potential
+ // background brush specified in the text
+ selection.format.setProperty(QTextFormat::BackgroundBrush, QBrush());
+ selection.format.clearProperty(QTextFormat::OutlinePen);
+ }
- bool noText = (selection.format.foreground().style() == Qt::NoBrush);
+ selection.format.setProperty(SuppressText, !hasText);
+
+ if (hasText && !hasBackground && !(textDoneRegion & region).isEmpty())
+ continue;
- selection.format.setProperty(SuppressText, noText);
+ p->save();
+ p->setClipPath(region, Qt::IntersectClip);
for (int line = firstLine; line < lastLine; ++line) {
QTextLine l(line, d);
@@ -1224,13 +1231,17 @@ void QTextLayout::draw(QPainter *p, const QPointF &pos, const QVector<FormatRang
}
p->restore();
- if (noText)
- needsTextButNoBackground += region;
- else
- needsTextButNoBackground -= region;
+ if (hasText) {
+ textDoneRegion += region;
+ } else {
+ if (hasBackground)
+ textDoneRegion -= region;
+ }
+
excludedRegion += region;
}
+ QPainterPath needsTextButNoBackground = excludedRegion - textDoneRegion;
if (!needsTextButNoBackground.isEmpty()){
p->save();
p->setClipPath(needsTextButNoBackground, Qt::IntersectClip);