Make imageAt and formatAt more robus against different font metrics

Don't try to locate the text by coordinates at the edge of the text but
simply aim at the center vertically _and_ horizontally.

Task-number: QTBUG-52991
Change-Id: Ia9e84fc5d12491840e739c4eea730fe13058f3c7
Reviewed-by: Simo Fält <simo.falt@theqtcompany.com>
This commit is contained in:
Simon Hausmann 2016-08-11 10:48:17 +02:00 committed by Simon Hausmann
parent 7833f7bc06
commit 8e29d463dc
2 changed files with 2 additions and 9 deletions

View File

@ -1,7 +0,0 @@
#QTBUG-53648
[imageAt]
opensuse-42.1
rhel-7.2
#QTBUG-52991
[formatAt]
opensuse-42.1

View File

@ -194,7 +194,7 @@ void tst_QAbstractTextDocumentLayout::imageAt()
QCOMPARE(documentLayout->anchorAt(imagePoint), QString("link"));
// imageAt on start returns nothing (there's the "foo" text)
QPointF fooPoint(fooBr.width() + blockStart.x(), (fooBr.height() / 2) + blockStart.y());
QPointF fooPoint(blockStart.x() + (fooBr.width() / 2), (fooBr.height() / 2) + blockStart.y());
QCOMPARE(documentLayout->imageAt(fooPoint), QString());
}
@ -221,7 +221,7 @@ void tst_QAbstractTextDocumentLayout::formatAt()
QVERIFY(format.isImageFormat());
// move over the unformatted "foo" text)
QPointF fooPoint(fooBr.width() + blockStart.x(), (fooBr.height() / 2) + blockStart.y());
QPointF fooPoint(blockStart.x() + (fooBr.width() / 2), (fooBr.height() / 2) + blockStart.y());
format = documentLayout->formatAt(fooPoint);
QVERIFY(format.isCharFormat());
QVERIFY(!format.toCharFormat().isAnchor());