diff options
author | Lars Knoll <lars.knoll@qt.io> | 2019-01-23 14:12:47 +0100 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2019-02-09 08:01:08 +0000 |
commit | 4247d7c5a0c9a5133245b935eef017149f49de87 (patch) | |
tree | a9b5fede17d316979479cd42a1bba7aa2427918d /src/gui/text | |
parent | c066656aff4841f9095e77754fa7533f7bbbb66a (diff) |
Fix QTextTable:insertRows() for tables with spanning cells
Don't resize the height of cells spanning several columns
multiple times.
Fixes: QTBUG-36713
Change-Id: I5eb45892f2008e6a4f85745b56efd04323e25673
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
Diffstat (limited to 'src/gui/text')
-rw-r--r-- | src/gui/text/qtexttable.cpp | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/gui/text/qtexttable.cpp b/src/gui/text/qtexttable.cpp index 9639c18d2b..39f26d5d42 100644 --- a/src/gui/text/qtexttable.cpp +++ b/src/gui/text/qtexttable.cpp @@ -696,18 +696,22 @@ void QTextTable::insertRows(int pos, int num) int extended = 0; int insert_before = 0; if (pos > 0 && pos < d->nRows) { + int lastCell = -1; for (int i = 0; i < d->nCols; ++i) { int cell = d->grid[pos*d->nCols + i]; if (cell == d->grid[(pos-1)*d->nCols+i]) { // cell spans the insertion place, extend it - QTextDocumentPrivate::FragmentIterator it(&p->fragmentMap(), cell); - QTextCharFormat fmt = c->charFormat(it->format); - fmt.setTableCellRowSpan(fmt.tableCellRowSpan() + num); - p->setCharFormat(it.position(), 1, fmt); + if (cell != lastCell) { + QTextDocumentPrivate::FragmentIterator it(&p->fragmentMap(), cell); + QTextCharFormat fmt = c->charFormat(it->format); + fmt.setTableCellRowSpan(fmt.tableCellRowSpan() + num); + p->setCharFormat(it.position(), 1, fmt); + } extended++; } else if (!insert_before) { insert_before = cell; } + lastCell = cell; } } else { insert_before = (pos == 0 ? d->grid[0] : d->fragment_end); |