summaryrefslogtreecommitdiffstats
path: root/src/gui/text/qtexttable.cpp
diff options
context:
space:
mode:
authorRohan McGovern <rohan.mcgovern@nokia.com>2010-07-17 23:31:36 (GMT)
committerRohan McGovern <rohan.mcgovern@nokia.com>2010-07-17 23:31:36 (GMT)
commit8d545a21b6aa89675b404a9d7bf08b7499d26e5e (patch)
tree761c900e05538a337517435d5337392f7fc8931d /src/gui/text/qtexttable.cpp
parent571b85896ee3663479b4a10d2418e2e19b3639f3 (diff)
parentd61c74faef2ed787aacc53c03b8361fa57bccc8e (diff)
downloadQt-8d545a21b6aa89675b404a9d7bf08b7499d26e5e.zip
Qt-8d545a21b6aa89675b404a9d7bf08b7499d26e5e.tar.gz
Qt-8d545a21b6aa89675b404a9d7bf08b7499d26e5e.tar.bz2
Merge remote branch 'origin/4.7' into 4.7-from-4.6
Conflicts: tests/auto/qtexttable/tst_qtexttable.cpp
Diffstat (limited to 'src/gui/text/qtexttable.cpp')
-rw-r--r--src/gui/text/qtexttable.cpp28
1 files changed, 24 insertions, 4 deletions
diff --git a/src/gui/text/qtexttable.cpp b/src/gui/text/qtexttable.cpp
index ada18c8..c291f25 100644
--- a/src/gui/text/qtexttable.cpp
+++ b/src/gui/text/qtexttable.cpp
@@ -754,19 +754,39 @@ void QTextTable::insertColumns(int pos, int num)
QTextFormatCollection *c = p->formatCollection();
p->beginEditBlock();
+ QList<int> extendedSpans;
for (int i = 0; i < d->nRows; ++i) {
int cell;
if (i == d->nRows - 1 && pos == d->nCols)
cell = d->fragment_end;
else
cell = d->grid[i*d->nCols + pos];
- QTextDocumentPrivate::FragmentIterator it(&p->fragmentMap(), cell);
- QTextCharFormat fmt = c->charFormat(it->format);
if (pos > 0 && pos < d->nCols && cell == d->grid[i*d->nCols + pos - 1]) {
// cell spans the insertion place, extend it
- fmt.setTableCellColumnSpan(fmt.tableCellColumnSpan() + num);
- p->setCharFormat(it.position(), 1, fmt);
+ if (!extendedSpans.contains(cell)) {
+ QTextDocumentPrivate::FragmentIterator it(&p->fragmentMap(), cell);
+ QTextCharFormat fmt = c->charFormat(it->format);
+ fmt.setTableCellColumnSpan(fmt.tableCellColumnSpan() + num);
+ p->setCharFormat(it.position(), 1, fmt);
+ d->dirty = true;
+ extendedSpans << cell;
+ }
} else {
+ /* If the next cell is spanned from the row above, we need to find the right position
+ to insert to */
+ if (i > 0 && pos < d->nCols && cell == d->grid[(i-1) * d->nCols + pos]) {
+ int gridIndex = i*d->nCols + pos;
+ const int gridEnd = d->nRows * d->nCols - 1;
+ while (gridIndex < gridEnd && cell == d->grid[gridIndex]) {
+ ++gridIndex;
+ }
+ if (gridIndex == gridEnd)
+ cell = d->fragment_end;
+ else
+ cell = d->grid[gridIndex];
+ }
+ QTextDocumentPrivate::FragmentIterator it(&p->fragmentMap(), cell);
+ QTextCharFormat fmt = c->charFormat(it->format);
fmt.setTableCellRowSpan(1);
fmt.setTableCellColumnSpan(1);
Q_ASSERT(fmt.objectIndex() == objectIndex());