summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorVolker Hilsheimer <volker.hilsheimer@qt.io>2021-11-24 19:14:26 +0100
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2021-12-01 20:23:14 +0000
commit4716a9693d7afb2add8e88968acd8c8fa2b51732 (patch)
treed62febce52bd92ac35d6eb7cd9ca0bfac2f656dc /tests
parent976d22c29d5e400c2dbfa524cc27b81c88e7a733 (diff)
Don't shrink a column when it spans multiple columns
If a cell spans multiple columns, then the merged cells' starting column's maximum width should never become smaller than what was calculated from previous rows. Otherwise, we'd distribute the space of the column that has a span across all merged columns, resulting in unnecessary line breaks esp if WrapAnywhere is enabled. Add a test case. Fixes: QTBUG-91691 Fixes: QTBUG-95240 Change-Id: Ic27dbdb128071e50fba049de85c9f23ba2f059b3 Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io> (cherry picked from commit 9538c7ca73e75ab8219e43b36b49200f27164dbb) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/gui/text/qtexttable/tst_qtexttable.cpp28
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/auto/gui/text/qtexttable/tst_qtexttable.cpp b/tests/auto/gui/text/qtexttable/tst_qtexttable.cpp
index dabe51f833..5d8d47491a 100644
--- a/tests/auto/gui/text/qtexttable/tst_qtexttable.cpp
+++ b/tests/auto/gui/text/qtexttable/tst_qtexttable.cpp
@@ -44,6 +44,7 @@
#include <QPainter>
#include <QPaintEngine>
#endif
+#include <private/qtextdocumentlayout_p.h>
#include <private/qpagedpaintdevice_p.h>
typedef QList<int> IntList;
@@ -100,6 +101,10 @@ private slots:
void checkBorderAttributes_data();
void checkBorderAttributes();
+#ifndef QT_NO_WIDGETS
+ void columnWidthWithSpans();
+#endif
+
private:
QTextTable *create2x2Table();
QTextTable *create4x4Table();
@@ -1278,5 +1283,28 @@ void tst_QTextTable::checkBorderAttributes()
}
}
+#ifndef QT_NO_WIDGETS
+void tst_QTextTable::columnWidthWithSpans()
+{
+ cleanup();
+ init();
+ QTextTable *table = cursor.insertTable(4, 4);
+ QTextEdit textEdit;
+ textEdit.setDocument(doc);
+ textEdit.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&textEdit));
+
+ for (int i = 0; i < table->columns(); ++i)
+ table->cellAt(0, i).firstCursorPosition().insertText(QString("Header %1").arg(i));
+
+ QTextBlock block = table->cellAt(0, 0).firstCursorPosition().block();
+ const QRectF beforeRect = table->document()->documentLayout()->blockBoundingRect(block);
+ table->mergeCells(1, 0, 1, table->columns());
+ block = table->cellAt(0, 0).firstCursorPosition().block();
+ const QRectF afterRect = table->document()->documentLayout()->blockBoundingRect(block);
+ QCOMPARE(afterRect, beforeRect);
+}
+#endif
+
QTEST_MAIN(tst_QTextTable)
#include "tst_qtexttable.moc"