diff options
author | Olivier Goffart <olivier.goffart@nokia.com> | 2010-06-16 09:00:15 (GMT) |
---|---|---|
committer | Qt Commercial Integration <QtCommercial@digia.com> | 2012-01-31 10:25:00 (GMT) |
commit | 9d465dd8333bd74f6f8976b76d1c4ccf95ae1586 (patch) | |
tree | 192350cdf4b5e2169b4c72d89f04ea85e78e69ba /src/gui/itemviews/qlistview.cpp | |
parent | 6a6fcd8c8b6cdbfd35730b0d30d59bbfdb45ace5 (diff) | |
download | Qt-9d465dd8333bd74f6f8976b76d1c4ccf95ae1586.zip Qt-9d465dd8333bd74f6f8976b76d1c4ccf95ae1586.tar.gz Qt-9d465dd8333bd74f6f8976b76d1c4ccf95ae1586.tar.bz2 |
QListView: speedup QListView::setRowHidden()
Basically the same optimisation that had been made long ago in the tree view:
Use the right data structure for QListViewPrivate::hiddenRows
(QSet instead of QVector)
Task-number: QTBUG-11438
Reviewed-by: Gabriel
Diffstat (limited to 'src/gui/itemviews/qlistview.cpp')
-rw-r--r-- | src/gui/itemviews/qlistview.cpp | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/src/gui/itemviews/qlistview.cpp b/src/gui/itemviews/qlistview.cpp index e64bebe..bdcc53b 100644 --- a/src/gui/itemviews/qlistview.cpp +++ b/src/gui/itemviews/qlistview.cpp @@ -756,10 +756,13 @@ void QListView::rowsAboutToBeRemoved(const QModelIndex &parent, int start, int e // if the parent is above d->root in the tree, nothing will happen QAbstractItemView::rowsAboutToBeRemoved(parent, start, end); if (parent == d->root) { - for (int i = d->hiddenRows.count() - 1; i >= 0; --i) { - int hiddenRow = d->hiddenRows.at(i).row(); + QSet<QPersistentModelIndex>::iterator it = d->hiddenRows.begin(); + while (it != d->hiddenRows.end()) { + int hiddenRow = it->row(); if (hiddenRow >= start && hiddenRow <= end) { - d->hiddenRows.remove(i); + it = d->hiddenRows.erase(it); + } else { + ++it; } } } @@ -1842,12 +1845,12 @@ QAbstractItemView::DropIndicatorPosition QListViewPrivate::position(const QPoint void QCommonListViewBase::appendHiddenRow(int row) { - dd->hiddenRows.append(dd->model->index(row, 0, qq->rootIndex())); + dd->hiddenRows.insert(dd->model->index(row, 0, qq->rootIndex())); } void QCommonListViewBase::removeHiddenRow(int row) { - dd->hiddenRows.remove(dd->hiddenRows.indexOf(dd->model->index(row, 0, qq->rootIndex()))); + dd->hiddenRows.remove(dd->model->index(row, 0, qq->rootIndex())); } void QCommonListViewBase::updateHorizontalScrollBar(const QSize &step) |