summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
authorLeonard Lee <leonard.lee@digia.com>2013-05-24 09:17:17 (GMT)
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-07-08 12:30:50 (GMT)
commitb12e459ea17f083b01ad0676ee552b96aff14b59 (patch)
tree80bbb34f0c1d3bc735529e9c78fbe47133de264a /src/gui
parent3d4d48b6a59ad3cbafd2ee7cdc7a57792384556f (diff)
downloadQt-b12e459ea17f083b01ad0676ee552b96aff14b59.zip
Qt-b12e459ea17f083b01ad0676ee552b96aff14b59.tar.gz
Qt-b12e459ea17f083b01ad0676ee552b96aff14b59.tar.bz2
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: I0de01f4d6b833289948ac29e38dd3cc8ab9bca9e (cherry picked from commit qtbase/ad443dfb1d8e9096c4913686aa2ed0bc9b3f5de7) Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@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 29945b7..2a17881 100644
--- a/src/gui/text/qtextdocumentlayout.cpp
+++ b/src/gui/text/qtextdocumentlayout.cpp
@@ -1403,7 +1403,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();