summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorThierry Bastian <thierry.bastian@nokia.com>2009-05-12 14:13:40 (GMT)
committerThierry Bastian <thierry.bastian@nokia.com>2009-05-12 14:14:54 (GMT)
commit0c3d59a34c404ba1cec1ab6dbe88e4bf0664538b (patch)
tree6862ee8f61f50454d2a70aad3cafff2bcc237adf /src
parent8c4aee1be1e50bd49207aee61ac41613e07e0605 (diff)
downloadQt-0c3d59a34c404ba1cec1ab6dbe88e4bf0664538b.zip
Qt-0c3d59a34c404ba1cec1ab6dbe88e4bf0664538b.tar.gz
Qt-0c3d59a34c404ba1cec1ab6dbe88e4bf0664538b.tar.bz2
QListView was assuming that selected indexes were always children of
their root. This can be different. ...especially if one manages the selection by program or if you share the selection model with a treeview. Task-number: 196118 Reviewed-by: ogoffart
Diffstat (limited to 'src')
-rw-r--r--src/gui/itemviews/qlistview.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/gui/itemviews/qlistview.cpp b/src/gui/itemviews/qlistview.cpp
index 3e00cd0..1071c1d 100644
--- a/src/gui/itemviews/qlistview.cpp
+++ b/src/gui/itemviews/qlistview.cpp
@@ -1608,6 +1608,10 @@ QRegion QListView::visualRegionForSelection(const QItemSelection &selection) con
if (!selection.at(i).isValid())
continue;
QModelIndex parent = selection.at(i).topLeft().parent();
+ //we only display the children of the root in a listview
+ //we're not interested in the other model indexes
+ if (parent != d->root)
+ continue;
int t = selection.at(i).topLeft().row();
int b = selection.at(i).bottomRight().row();
if (d->viewMode == IconMode || d->isWrapping()) { // in non-static mode, we have to go through all selected items
@@ -1616,8 +1620,8 @@ QRegion QListView::visualRegionForSelection(const QItemSelection &selection) con
} else { // in static mode, we can optimize a bit
while (t <= b && d->isHidden(t)) ++t;
while (b >= t && d->isHidden(b)) --b;
- const QModelIndex top = d->model->index(t, c, d->root);
- const QModelIndex bottom = d->model->index(b, c, d->root);
+ const QModelIndex top = d->model->index(t, c, parent);
+ const QModelIndex bottom = d->model->index(b, c, parent);
QRect rect(visualRect(top).topLeft(),
visualRect(bottom).bottomRight());
selectionRegion += QRegion(rect);