diff options
author | Jani Honkonen <jani.honkonen@digia.com> | 2012-02-03 17:11:01 +0200 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-02-09 16:23:50 +0100 |
commit | b0601630dd0ddabfaa3b97d042ee02b981d95988 (patch) | |
tree | e0b3c6d329c25b5db751f95fe32614991f687267 /src/gui/itemviews | |
parent | a13b2a248e5091ddf21e3c5ac08c9ddf0b940b5b (diff) | |
download | qt4-tools-b0601630dd0ddabfaa3b97d042ee02b981d95988.tar.gz |
Fix QListView::scrollTo() when there are hidden rows
QListView does not consider hidden rows when scrolling to an item.
If there are hidden rows (or columns) before the selected item then
the visual index of an item is not the same as the row index
from the model. So scrolling will be off by the number of hidden
rows before the selected item.
Added a autotest for this also.
Task-number: QTBUG-21115
Change-Id: I49c39033d83f80d4405b59510617096029ee6d3b
Reviewed-by: Stephen Kelly <stephen.kelly@kdab.com>
Diffstat (limited to 'src/gui/itemviews')
-rw-r--r-- | src/gui/itemviews/qlistview.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/gui/itemviews/qlistview.cpp b/src/gui/itemviews/qlistview.cpp index 34bead3251..6b0ea7feb1 100644 --- a/src/gui/itemviews/qlistview.cpp +++ b/src/gui/itemviews/qlistview.cpp @@ -3216,7 +3216,12 @@ int QListView::visualIndex(const QModelIndex &index) const Q_D(const QListView); d->executePostedLayout(); QListViewItem itm = d->indexToListViewItem(index); - return d->commonListView->itemIndex(itm); + int visualIndex = d->commonListView->itemIndex(itm); + for (int row = 0; row <= index.row() && visualIndex >= 0; row++) { + if (d->isHidden(row)) + visualIndex--; + } + return visualIndex; } QT_END_NAMESPACE |