Changeset 846 for trunk/src/gui/itemviews/qtableview.cpp
- Timestamp:
- May 5, 2011, 5:36:53 AM (14 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:mergeinfo changed
/branches/vendor/nokia/qt/4.7.2 (added) merged: 845 /branches/vendor/nokia/qt/current merged: 844 /branches/vendor/nokia/qt/4.6.3 removed
- Property svn:mergeinfo changed
-
trunk/src/gui/itemviews/qtableview.cpp
r769 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 115 115 } else if (old_height > span->height()) { 116 116 //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 useful lif height is 0117 Index::iterator it_y = index.lowerBound(-qMax(span->bottom(), span->top())); //qMax useful if height is 0 118 118 Q_ASSERT(it_y != index.end()); //it_y must exist since the span is in the list 119 119 while (-it_y.key() <= span->top() + old_height -1) { … … 1412 1412 1413 1413 if (showGrid) { 1414 // Find the bottom right (the last rows/col oumns might be hidden)1414 // Find the bottom right (the last rows/columns might be hidden) 1415 1415 while (verticalHeader->isSectionHidden(verticalHeader->logicalIndex(bottom))) --bottom; 1416 1416 QPen old = painter.pen(); … … 1847 1847 } 1848 1848 } else { // nothing moved 1849 selection.append(QItemSelectionRange(tl, br)); 1849 QItemSelectionRange range(tl, br); 1850 if (!range.isEmpty()) 1851 selection.append(range); 1850 1852 } 1851 1853 … … 1858 1860 Returns the rectangle from the viewport of the items in the given 1859 1861 \a selection. 1862 1863 Since 4.7, the returned region only contains rectangles intersecting 1864 (or included in) the viewport. 1860 1865 */ 1861 1866 QRegion QTableView::visualRegionForSelection(const QItemSelection &selection) const … … 1867 1872 1868 1873 QRegion selectionRegion; 1874 const QRect &viewportRect = d->viewport->rect(); 1869 1875 bool verticalMoved = verticalHeader()->sectionsMoved(); 1870 1876 bool horizontalMoved = horizontalHeader()->sectionsMoved(); … … 1876 1882 continue; 1877 1883 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 } 1880 1889 } 1881 1890 } else if (horizontalMoved) { … … 1889 1898 qSwap<int>(top, bottom); 1890 1899 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 } 1894 1905 } 1895 1906 } else if (verticalMoved) { … … 1903 1914 qSwap<int>(left, right); 1904 1915 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 } 1908 1921 } 1909 1922 } else { // nothing moved … … 1926 1939 rright = columnViewportPosition(range.left()) + columnWidth(range.left()); 1927 1940 } 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; 1929 1944 if (d->hasSpans()) { 1930 1945 foreach (QSpanCollection::Span *s, 1931 1946 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 } 1934 1952 } 1935 1953 } … … 1968 1986 { 1969 1987 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(); 1976 1989 } 1977 1990 … … 2133 2146 ensurePolished(); 2134 2147 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()); 2137 2150 if (right == -1) // the table don't have enough columns to fill the viewport 2138 2151 right = d->model->columnCount(d->root) - 1; … … 2192 2205 ensurePolished(); 2193 2206 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()); 2196 2209 if (!isVisible() || bottom == -1) // the table don't have enough rows to fill the viewport 2197 2210 bottom = d->model->rowCount(d->root) - 1;
Note:
See TracChangeset
for help on using the changeset viewer.