summaryrefslogtreecommitdiffstats
path: root/tests/auto/gui
diff options
context:
space:
mode:
authorDavid Faure <david.faure@kdab.com>2013-11-18 18:52:26 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-12-05 16:40:06 +0100
commitd270bd8673505d8325ce25fa8476c8f8bc5a075b (patch)
treed73c1ac63c0663f4cb7ce8fb63465e0b417313a9 /tests/auto/gui
parentd443eff5b67fdf51cb3f1aca763bd3c407158720 (diff)
QTextEngine: fix layouting of inline objects in right-aligned tabs.
(same thing for center- and delimiter-aligned tabs) The width of the inline object wasn't taken into account, the code in QTextEngine::calculateTabWidth only looked at glyph widths. Change-Id: I303a6561c67870ff2094a685698e642fc1b53b12 Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com> Reviewed-by: Allan Sandfeld Jensen <allan.jensen@digia.com>
Diffstat (limited to 'tests/auto/gui')
-rw-r--r--tests/auto/gui/text/qtextdocumentlayout/tst_qtextdocumentlayout.cpp36
1 files changed, 36 insertions, 0 deletions
diff --git a/tests/auto/gui/text/qtextdocumentlayout/tst_qtextdocumentlayout.cpp b/tests/auto/gui/text/qtextdocumentlayout/tst_qtextdocumentlayout.cpp
index 2d122125e0..3c5ba884f7 100644
--- a/tests/auto/gui/text/qtextdocumentlayout/tst_qtextdocumentlayout.cpp
+++ b/tests/auto/gui/text/qtextdocumentlayout/tst_qtextdocumentlayout.cpp
@@ -74,6 +74,7 @@ private slots:
void inlineImage();
void clippedTableCell();
void floatingTablePageBreak();
+ void imageAtRightAlignedTab();
private:
QTextDocument *doc;
@@ -283,6 +284,41 @@ void tst_QTextDocumentLayout::floatingTablePageBreak()
QCOMPARE(doc->pageCount(), 2);
}
+void tst_QTextDocumentLayout::imageAtRightAlignedTab()
+{
+ doc->clear();
+
+ QTextFrameFormat fmt = doc->rootFrame()->frameFormat();
+ fmt.setMargin(0);
+ doc->rootFrame()->setFrameFormat(fmt);
+
+ QTextCursor cursor(doc);
+ QTextBlockFormat blockFormat;
+ QList<QTextOption::Tab> tabs;
+ QTextOption::Tab tab;
+ tab.position = 300;
+ tab.type = QTextOption::RightTab;
+ tabs.append(tab);
+ blockFormat.setTabPositions(tabs);
+
+ // First block: text, some of it right-aligned
+ cursor.insertBlock(blockFormat);
+ cursor.insertText("first line\t");
+ cursor.insertText("right-aligned text");
+
+ // Second block: text, then right-aligned image
+ cursor.insertBlock(blockFormat);
+ cursor.insertText("second line\t");
+ QImage img(48, 48, QImage::Format_RGB32);
+ const QString name = QString::fromLatin1("image");
+ doc->addResource(QTextDocument::ImageResource, QUrl(name), img);
+ QTextImageFormat imgFormat;
+ imgFormat.setName(name);
+ cursor.insertImage(imgFormat);
+
+ // Everything should fit into the 300 pixels
+ QCOMPARE(doc->idealWidth(), 300.0);
+}
QTEST_MAIN(tst_QTextDocumentLayout)
#include "tst_qtextdocumentlayout.moc"