summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
authorLeonard Lee <leonard.lee@digia.com>2013-05-03 13:06:03 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-05-23 12:49:39 +0200
commitad443dfb1d8e9096c4913686aa2ed0bc9b3f5de7 (patch)
tree85c9efa0be031c72f68a15f6cfeecea1560e528d /src/gui
parent5d07a4d9448f60139c711e592cbf3ac47d4df3d7 (diff)
Fix clipping of QTextList decorators.
List decorators may be clipped if you set a large font size and/or small indent for a QTextList. This fix is to prevent clipping by moving list decorators and items to left (or to right in case of right to left layouts) so that the list decorator is always painted inside the layout. This commit fixes painting related issue, so auto test is not needed. The manual test program can be used for verification purposes. Task-number: QTBUG-5111 Change-Id: I7fdd92399445d33fe9eaf525a05fe5cd860b57c6 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@digia.com> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/text/qtextdocumentlayout.cpp15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/gui/text/qtextdocumentlayout.cpp b/src/gui/text/qtextdocumentlayout.cpp
index 4902a42cd7..6156f56ae1 100644
--- a/src/gui/text/qtextdocumentlayout.cpp
+++ b/src/gui/text/qtextdocumentlayout.cpp
@@ -1425,7 +1425,20 @@ void QTextDocumentLayoutPrivate::drawListItem(const QPointF &offset, QPainter *p
qreal xoff = fontMetrics.width(QLatin1Char(' '));
if (dir == Qt::LeftToRight)
xoff = -xoff - size.width();
- r.translate( xoff, (fontMetrics.height() / 2 - size.height() / 2));
+ r.translate( xoff, (fontMetrics.height() / 2) - (size.height() / 2));
+
+ // Prevent clipping the left side of the list decorator (on left to
+ // right layouts) and clipping the right side of the list
+ // decorator (on right to left layouts).
+ if ((r.left() < 0) && (dir == Qt::LeftToRight)) {
+ int horizontalOffset = -r.left();
+ r.translate(horizontalOffset, 0);
+ layout->setPosition(layout->position() + QPointF(horizontalOffset, 0));
+ } else if ((r.right() > document->pageSize().width()) && (dir == Qt::RightToLeft)) {
+ int horizontalOffset = r.right() - document->pageSize().width();
+ r.translate(-horizontalOffset, 0);
+ layout->setPosition(layout->position() - QPointF(horizontalOffset, 0));
+ }
painter->save();