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/itemviews/qtableview.cpp

    r769 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)
     
    115115    } else if (old_height > span->height()) {
    116116        //remove the span from all the subspans lists that intersect the columns not covered anymore
    117         Index::iterator it_y = index.lowerBound(-qMax(span->bottom(), span->top())); //qMax usefull if height is 0
     117        Index::iterator it_y = index.lowerBound(-qMax(span->bottom(), span->top())); //qMax useful if height is 0
    118118        Q_ASSERT(it_y != index.end()); //it_y must exist since the span is in the list
    119119        while (-it_y.key() <= span->top() + old_height -1) {
     
    14121412
    14131413        if (showGrid) {
    1414             // Find the bottom right (the last rows/coloumns might be hidden)
     1414            // Find the bottom right (the last rows/columns might be hidden)
    14151415            while (verticalHeader->isSectionHidden(verticalHeader->logicalIndex(bottom))) --bottom;
    14161416            QPen old = painter.pen();
     
    18471847        }
    18481848    } else { // nothing moved
    1849         selection.append(QItemSelectionRange(tl, br));
     1849        QItemSelectionRange range(tl, br);
     1850        if (!range.isEmpty())
     1851            selection.append(range);
    18501852    }
    18511853
     
    18581860    Returns the rectangle from the viewport of the items in the given
    18591861    \a selection.
     1862
     1863    Since 4.7, the returned region only contains rectangles intersecting
     1864    (or included in) the viewport.
    18601865*/
    18611866QRegion QTableView::visualRegionForSelection(const QItemSelection &selection) const
     
    18671872
    18681873    QRegion selectionRegion;
     1874    const QRect &viewportRect = d->viewport->rect();
    18691875    bool verticalMoved = verticalHeader()->sectionsMoved();
    18701876    bool horizontalMoved = horizontalHeader()->sectionsMoved();
     
    18761882                continue;
    18771883            for (int r = range.top(); r <= range.bottom(); ++r)
    1878                 for (int c = range.left(); c <= range.right(); ++c)
    1879                     selectionRegion += QRegion(visualRect(d->model->index(r, c, d->root)));
     1884                for (int c = range.left(); c <= range.right(); ++c) {
     1885                    const QRect &rangeRect = visualRect(d->model->index(r, c, d->root));
     1886                    if (viewportRect.intersects(rangeRect))
     1887                        selectionRegion += rangeRect;
     1888                }
    18801889        }
    18811890    } else if (horizontalMoved) {
     
    18891898                qSwap<int>(top, bottom);
    18901899            int height = bottom - top;
    1891             for (int c = range.left(); c <= range.right(); ++c)
    1892                 selectionRegion += QRegion(QRect(columnViewportPosition(c), top,
    1893                                                  columnWidth(c), height));
     1900            for (int c = range.left(); c <= range.right(); ++c) {
     1901                const QRect rangeRect(columnViewportPosition(c), top, columnWidth(c), height);
     1902                if (viewportRect.intersects(rangeRect))
     1903                    selectionRegion += rangeRect;
     1904            }
    18941905        }
    18951906    } else if (verticalMoved) {
     
    19031914                qSwap<int>(left, right);
    19041915            int width = right - left;
    1905             for (int r = range.top(); r <= range.bottom(); ++r)
    1906                 selectionRegion += QRegion(QRect(left, rowViewportPosition(r),
    1907                                                  width, rowHeight(r)));
     1916            for (int r = range.top(); r <= range.bottom(); ++r) {
     1917                const QRect rangeRect(left, rowViewportPosition(r), width, rowHeight(r));
     1918                if (viewportRect.intersects(rangeRect))
     1919                    selectionRegion += rangeRect;
     1920            }
    19081921        }
    19091922    } else { // nothing moved
     
    19261939                rright = columnViewportPosition(range.left()) + columnWidth(range.left());
    19271940            }
    1928             selectionRegion += QRect(QPoint(rleft, rtop), QPoint(rright - 1 - gridAdjust, rbottom - 1 - gridAdjust));
     1941            const QRect rangeRect(QPoint(rleft, rtop), QPoint(rright - 1 - gridAdjust, rbottom - 1 - gridAdjust));
     1942            if (viewportRect.intersects(rangeRect))
     1943                selectionRegion += rangeRect;
    19291944            if (d->hasSpans()) {
    19301945                foreach (QSpanCollection::Span *s,
    19311946                         d->spans.spansInRect(range.left(), range.top(), range.width(), range.height())) {
    1932                     if (range.contains(s->top(), s->left(), range.parent()))
    1933                         selectionRegion += d->visualSpanRect(*s);
     1947                    if (range.contains(s->top(), s->left(), range.parent())) {
     1948                        const QRect &visualSpanRect = d->visualSpanRect(*s);
     1949                        if (viewportRect.intersects(visualSpanRect))
     1950                            selectionRegion += visualSpanRect;
     1951                    }
    19341952                }
    19351953            }
     
    19681986{
    19691987    Q_D(QTableView);
    1970     updateGeometries();
    1971     if (verticalScrollMode() == QAbstractItemView::ScrollPerItem)
    1972         d->verticalHeader->setOffsetToSectionPosition(verticalScrollBar()->value());
    1973     else
    1974         d->verticalHeader->setOffset(verticalScrollBar()->value());
    1975     d->viewport->update();
     1988    d->doDelayedItemsLayout();
    19761989}
    19771990
     
    21332146    ensurePolished();
    21342147
    2135     int left = qMax(0, columnAt(0));
    2136     int right = columnAt(d->viewport->width());
     2148    int left = qMax(0, d->horizontalHeader->visualIndexAt(0));
     2149    int right = d->horizontalHeader->visualIndexAt(d->viewport->width());
    21372150    if (right == -1) // the table don't have enough columns to fill the viewport
    21382151        right = d->model->columnCount(d->root) - 1;
     
    21922205    ensurePolished();
    21932206
    2194     int top = qMax(0, rowAt(0));
    2195     int bottom = rowAt(d->viewport->height());
     2207    int top = qMax(0, d->verticalHeader->visualIndexAt(0));
     2208    int bottom = d->verticalHeader->visualIndexAt(d->viewport->height());
    21962209    if (!isVisible() || bottom == -1) // the table don't have enough rows to fill the viewport
    21972210        bottom = d->model->rowCount(d->root) - 1;
Note: See TracChangeset for help on using the changeset viewer.