Ignore:
Timestamp:
May 5, 2011, 5:36:53 AM (14 years ago)
Author:
Dmitry A. Kuminov
Message:

trunk: Merged in qt 4.7.2 sources from branches/vendor/nokia/qt.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/src/gui/text/qtexttable.cpp

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    755755    p->beginEditBlock();
    756756
     757    QList<int> extendedSpans;
    757758    for (int i = 0; i < d->nRows; ++i) {
    758759        int cell;
     
    761762        else
    762763            cell = d->grid[i*d->nCols + pos];
    763         QTextDocumentPrivate::FragmentIterator it(&p->fragmentMap(), cell);
    764         QTextCharFormat fmt = c->charFormat(it->format);
    765764        if (pos > 0 && pos < d->nCols && cell == d->grid[i*d->nCols + pos - 1]) {
    766765            // cell spans the insertion place, extend it
    767             fmt.setTableCellColumnSpan(fmt.tableCellColumnSpan() + num);
    768             p->setCharFormat(it.position(), 1, fmt);
     766            if (!extendedSpans.contains(cell)) {
     767                QTextDocumentPrivate::FragmentIterator it(&p->fragmentMap(), cell);
     768                QTextCharFormat fmt = c->charFormat(it->format);
     769                fmt.setTableCellColumnSpan(fmt.tableCellColumnSpan() + num);
     770                p->setCharFormat(it.position(), 1, fmt);
     771                d->dirty = true;
     772                extendedSpans << cell;
     773            }
    769774        } else {
     775            /* If the next cell is spanned from the row above, we need to find the right position
     776            to insert to */
     777            if (i > 0 && pos < d->nCols && cell == d->grid[(i-1) * d->nCols + pos]) {
     778                int gridIndex = i*d->nCols + pos;
     779                const int gridEnd = d->nRows * d->nCols - 1;
     780                while (gridIndex < gridEnd && cell == d->grid[gridIndex]) {
     781                    ++gridIndex;
     782                }
     783                if (gridIndex == gridEnd)
     784                    cell = d->fragment_end;
     785                else
     786                    cell = d->grid[gridIndex];
     787            }
     788            QTextDocumentPrivate::FragmentIterator it(&p->fragmentMap(), cell);
     789            QTextCharFormat fmt = c->charFormat(it->format);
    770790            fmt.setTableCellRowSpan(1);
    771791            fmt.setTableCellColumnSpan(1);
     
    916936        for (int c = pos; c < pos + num; ++c) {
    917937            int cell = d->grid[r*d->nCols + c];
    918             if (touchedCells.contains(cell))
    919                 continue;
    920             touchedCells << cell;
    921938            QTextDocumentPrivate::FragmentIterator it(&p->fragmentMap(), cell);
    922939            QTextCharFormat fmt = collection->charFormat(it->format);
    923940            int span = fmt.tableCellColumnSpan();
     941            if (touchedCells.contains(cell) && span <= 1)
     942                continue;
     943            touchedCells << cell;
     944
    924945            if (span > 1) {
    925946                fmt.setTableCellColumnSpan(span - 1);
Note: See TracChangeset for help on using the changeset viewer.