summaryrefslogtreecommitdiffstats
path: root/src/gui/itemviews/qlistview.cpp
diff options
context:
space:
mode:
authorThierry Bastian <thierry.bastian@nokia.com>2009-07-11 14:56:28 (GMT)
committerThierry Bastian <thierry.bastian@nokia.com>2009-07-11 14:56:28 (GMT)
commita701175aef8912b69afe61d23749dcfca765a231 (patch)
treeb0b383440a2d1a31fb82030f80f80f13d7efd4ec /src/gui/itemviews/qlistview.cpp
parentc9122b19bfd86005080631da8b8f69a01d1ab7e8 (diff)
downloadQt-a701175aef8912b69afe61d23749dcfca765a231.zip
Qt-a701175aef8912b69afe61d23749dcfca765a231.tar.gz
Qt-a701175aef8912b69afe61d23749dcfca765a231.tar.bz2
ItemViews: make dragging faster when lots of items are selected
QListView know exactly what they have on their viewport and we only paint items clipped to the viewport. So we don't need to ask for each item its visualRect. NB: QTreeView and QTableView probably deservee the same treatment
Diffstat (limited to 'src/gui/itemviews/qlistview.cpp')
-rw-r--r--src/gui/itemviews/qlistview.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/gui/itemviews/qlistview.cpp b/src/gui/itemviews/qlistview.cpp
index 6ff516a..44bcf6f 100644
--- a/src/gui/itemviews/qlistview.cpp
+++ b/src/gui/itemviews/qlistview.cpp
@@ -709,6 +709,32 @@ void QListViewPrivate::selectAll(QItemSelectionModel::SelectionFlags command)
selectionModel->select(selection, command);
}
+/*!
+ \reimp
+
+ We have a QListView way of knowing what elements are on the viewport
+ through the intersectingSet function
+*/
+QItemViewPaintPairs QListViewPrivate::draggablePaintPairs(const QModelIndexList &indexes, QRect *r) const
+{
+ Q_ASSERT(r);
+ Q_Q(const QListView);
+ QRect &rect = *r;
+ const QRect viewportRect = viewport->rect();
+ QItemViewPaintPairs ret;
+ intersectingSet(viewportRect);
+ const QSet<QModelIndex> visibleIndexes = intersectVector.toList().toSet();
+ for (int i = 0; i < indexes.count(); ++i) {
+ const QModelIndex &index = indexes.at(i);
+ if (visibleIndexes.contains(index)) {
+ const QRect current = q->visualRect(index);
+ ret += qMakePair(current, index);
+ rect |= current;
+ }
+ }
+ rect &= viewportRect;
+ return ret;
+}
/*!
\internal