┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/dolphindetailsview.cpp
diff options
context:
space:
mode:
authorPeter Penz <[email protected]>2008-10-24 17:57:10 +0000
committerPeter Penz <[email protected]>2008-10-24 17:57:10 +0000
commit6f49557ceb76311973a850e421d7e7d29eabf47b (patch)
treecce8280d7a14a6cb247da49a14c2813beebf4e82 /src/dolphindetailsview.cpp
parente900b5a32e8cb068adbe4d3dc85c3c7ce491a3dc (diff)
performance improvement when selecting items
svn path=/trunk/KDE/kdebase/apps/; revision=875518
Diffstat (limited to 'src/dolphindetailsview.cpp')
-rw-r--r--src/dolphindetailsview.cpp14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/dolphindetailsview.cpp b/src/dolphindetailsview.cpp
index ffddb29c1..501108c01 100644
--- a/src/dolphindetailsview.cpp
+++ b/src/dolphindetailsview.cpp
@@ -474,8 +474,8 @@ void DolphinDetailsView::setSelection(const QRect &rect, QItemSelectionModel::Se
// Choose a sensible startIndex - a parentless index in the
// name column, as close to the top of the rect as we
// can find.
- QRect normalisedRect = rect.normalized();
- QModelIndex startIndex = QTreeView::indexAt(normalisedRect.topLeft());
+ const QRect normalizedRect = rect.normalized();
+ QModelIndex startIndex = QTreeView::indexAt(normalizedRect.topLeft());
if (startIndex.isValid()) {
while (startIndex.parent().isValid()) {
startIndex = startIndex.parent();
@@ -486,7 +486,7 @@ void DolphinDetailsView::setSelection(const QRect &rect, QItemSelectionModel::Se
}
startIndex = model()->index(startIndex.row(), KDirModel::Name);
clearSelection();
- setSelectionRecursive(startIndex, normalisedRect, command);
+ setSelectionRecursive(startIndex, normalizedRect, command);
}
}
@@ -754,6 +754,7 @@ void DolphinDetailsView::setSelectionRecursive(const QModelIndex& startIndex,
return;
}
+ QItemSelection selection;
// rect is assumed to be in viewport coordinates and normalized.
// Move down through the siblings of startIndex, exploring the children
// of any expanded nodes.
@@ -770,18 +771,19 @@ void DolphinDetailsView::setSelectionRecursive(const QModelIndex& startIndex,
}
}
- QRect itemContentRect = nameColumnRect(currIndex);
+ const QRect itemContentRect = nameColumnRect(currIndex);
if (itemContentRect.top() > rect.bottom()) {
// All remaining items will be below itemContentRect, so we may cull.
- return;
+ break;
}
if (itemContentRect.intersects(rect)) {
- selectionModel()->select(currIndex, QItemSelectionModel::Select);
+ selection.select(currIndex, currIndex);
}
currIndex = belowIndex;
} while (currIndex.isValid());
+ selectionModel()->select(selection, QItemSelectionModel::Select);
}
#include "dolphindetailsview.moc"