diff options
author | Frank Reininghaus <frank78ac@googlemail.com> | 2009-06-13 10:23:35 (GMT) |
---|---|---|
committer | Olivier Goffart <ogoffart@trolltech.com> | 2009-07-17 17:02:28 (GMT) |
commit | 5539b4ab311501821eb0e971432d769a25000032 (patch) | |
tree | 7f7940f13821e4a68a711c573b59475363edd357 /src/gui/itemviews | |
parent | c0a9fe18baec3c0ea1f37326ef5a7f527511c33c (diff) | |
download | Qt-5539b4ab311501821eb0e971432d769a25000032.zip Qt-5539b4ab311501821eb0e971432d769a25000032.tar.gz Qt-5539b4ab311501821eb0e971432d769a25000032.tar.bz2 |
Fix for selection with Shift-Arrow/Shift-Click in QListView's IconMode
This addresses the selection of items using Shift-Arrow or Shift-Click
in QListView's IconMode if the items are in a grid layout. In the case
that the items do not have the same size (e.g., because their text is
wrapped), this commit prevents the unexpected selection of additional
items. New unit tests are included.
Merge-request: 666
Reviewed-by: Olivier Goffart
Diffstat (limited to 'src/gui/itemviews')
-rw-r--r-- | src/gui/itemviews/qlistview.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/gui/itemviews/qlistview.cpp b/src/gui/itemviews/qlistview.cpp index 40f28d4..148d204 100644 --- a/src/gui/itemviews/qlistview.cpp +++ b/src/gui/itemviews/qlistview.cpp @@ -1563,7 +1563,10 @@ void QListView::setSelection(const QRect &rect, QItemSelectionModel::SelectionFl } // middle rectangle if (top.bottom() < bottom.top()) { - middle.setTop(top.bottom() + 1); + if (gridSize().isValid() && !gridSize().isNull()) + middle.setTop(top.top() + gridSize().height()); + else + middle.setTop(top.bottom() + 1); middle.setLeft(qMin(top.left(), bottom.left())); middle.setBottom(bottom.top() - 1); middle.setRight(qMax(top.right(), bottom.right())); @@ -1590,7 +1593,10 @@ void QListView::setSelection(const QRect &rect, QItemSelectionModel::SelectionFl // only set middle if the middle.setTop(0); middle.setBottom(ch); - middle.setLeft(left.right() + 1); + if (gridSize().isValid() && !gridSize().isNull()) + middle.setLeft(left.left() + gridSize().width()); + else + middle.setLeft(left.right() + 1); middle.setRight(right.left() - 1); } else if (left.bottom() < right.top()) { left.setBottom(right.top() - 1); |