diff options
author | Thierry Bastian <thierry.bastian@nokia.com> | 2009-07-10 15:13:06 (GMT) |
---|---|---|
committer | Thierry Bastian <thierry.bastian@nokia.com> | 2009-07-10 15:57:56 (GMT) |
commit | 4d31527417419d4f7c1417b9360ef91d72469aa0 (patch) | |
tree | c46dc657470414129ed3463b4883697aac83aea6 /src/gui/itemviews/qlistview.cpp | |
parent | 577b3d7efc56f23dcf2b377816caa7d1aa3c7f88 (diff) | |
download | Qt-4d31527417419d4f7c1417b9360ef91d72469aa0.zip Qt-4d31527417419d4f7c1417b9360ef91d72469aa0.tar.gz Qt-4d31527417419d4f7c1417b9360ef91d72469aa0.tar.bz2 |
QListView: improve performance on QListView::selectedIndexes
Task-number: 233342
Diffstat (limited to 'src/gui/itemviews/qlistview.cpp')
-rw-r--r-- | src/gui/itemviews/qlistview.cpp | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/src/gui/itemviews/qlistview.cpp b/src/gui/itemviews/qlistview.cpp index 4652b91..6ff516a 100644 --- a/src/gui/itemviews/qlistview.cpp +++ b/src/gui/itemviews/qlistview.cpp @@ -1633,14 +1633,16 @@ QRegion QListView::visualRegionForSelection(const QItemSelection &selection) con QModelIndexList QListView::selectedIndexes() const { Q_D(const QListView); - QModelIndexList viewSelected; - QModelIndexList modelSelected; - if (d->selectionModel) - modelSelected = d->selectionModel->selectedIndexes(); - for (int i = 0; i < modelSelected.count(); ++i) { - QModelIndex index = modelSelected.at(i); + if (!d->selectionModel) + return QModelIndexList(); + + QModelIndexList viewSelected = d->selectionModel->selectedIndexes(); + for (int i = 0; i < viewSelected.count(); ++i) { + const QModelIndex &index = viewSelected.at(i); if (!isIndexHidden(index) && index.parent() == d->root && index.column() == d->column) - viewSelected.append(index); + ++i; + else + viewSelected.removeAt(i); } return viewSelected; } |