summaryrefslogtreecommitdiffstats
path: root/src/gui/itemviews
diff options
context:
space:
mode:
authorOlivier Goffart <ogoffart@trolltech.com>2009-03-31 17:43:43 (GMT)
committerOlivier Goffart <ogoffart@trolltech.com>2009-04-06 08:52:12 (GMT)
commit718905c097a7f3bbf9805a2561cd855a0b2d8f59 (patch)
treeb5dce02e53756538d2c57f79391f6d830a82322d /src/gui/itemviews
parentdb8dfc29de6bde8d4a4c65d8d5f7d3d579b859bb (diff)
downloadQt-718905c097a7f3bbf9805a2561cd855a0b2d8f59.zip
Qt-718905c097a7f3bbf9805a2561cd855a0b2d8f59.tar.gz
Qt-718905c097a7f3bbf9805a2561cd855a0b2d8f59.tar.bz2
Speed up selectAll in QTreeView with spans
When we had spans, in order to have the selection rect, we took the slow path in all cases, even if the header section did not move. Now, take the fast path if the sections did not move. This requires few adjustement to the code: we cannot call visualRect anymore since the index may be within a span. Task-number: 244651 Reviewed-by: Marius Bugge Monsen
Diffstat (limited to 'src/gui/itemviews')
-rw-r--r--src/gui/itemviews/qtableview.cpp18
1 files changed, 14 insertions, 4 deletions
diff --git a/src/gui/itemviews/qtableview.cpp b/src/gui/itemviews/qtableview.cpp
index 8756dce..757ecf2 100644
--- a/src/gui/itemviews/qtableview.cpp
+++ b/src/gui/itemviews/qtableview.cpp
@@ -1344,7 +1344,7 @@ QRegion QTableView::visualRegionForSelection(const QItemSelection &selection) co
bool verticalMoved = verticalHeader()->sectionsMoved();
bool horizontalMoved = horizontalHeader()->sectionsMoved();
- if ((verticalMoved && horizontalMoved) || d->hasSpans()) {
+ if ((verticalMoved && horizontalMoved) || (d->hasSpans() && (verticalMoved || horizontalMoved))) {
for (int i = 0; i < selection.count(); ++i) {
QItemSelectionRange range = selection.at(i);
if (range.parent() != d->root || !range.isValid())
@@ -1387,9 +1387,19 @@ QRegion QTableView::visualRegionForSelection(const QItemSelection &selection) co
if (range.parent() != d->root || !range.isValid())
continue;
d->trimHiddenSelections(&range);
- QRect tl = visualRect(range.topLeft());
- QRect br = visualRect(range.bottomRight());
- selectionRegion += QRegion(tl|br);
+
+ const int rtop = rowViewportPosition(range.top());
+ const int rbottom = rowViewportPosition(range.bottom()) + rowHeight(range.bottom());
+ const int rleft = columnViewportPosition(range.left());
+ const int rright = columnViewportPosition(range.right()) + columnWidth(range.right());
+ selectionRegion += QRect(QPoint(rleft, rtop), QPoint(rright, rbottom));
+ if (d->hasSpans()) {
+ foreach (QSpanCollection::Span *s,
+ d->spans.spansInRect(range.left(), range.top(), range.width(), range.height())) {
+ if (range.contains(s->top(), s->left(), range.parent()))
+ selectionRegion += d->visualSpanRect(*s);
+ }
+ }
}
}