summaryrefslogtreecommitdiffstats
path: root/src/gui/itemviews
diff options
context:
space:
mode:
authorFrank Reininghaus <frank78ac@googlemail.com>2009-09-07 10:57:50 (GMT)
committerOlivier Goffart <ogoffart@trolltech.com>2009-09-07 10:59:41 (GMT)
commit807185d250fd8f5152cafdb416f28abe4438275f (patch)
treed612e4cb2dce33a67004192effd0ee291341dc5c /src/gui/itemviews
parent3a275174d9a61f7f6451b1da39da82fd8286f9f7 (diff)
downloadQt-807185d250fd8f5152cafdb416f28abe4438275f.zip
Qt-807185d250fd8f5152cafdb416f28abe4438275f.tar.gz
Qt-807185d250fd8f5152cafdb416f28abe4438275f.tar.bz2
Fix some issues with Shift-selection in QAbstractItemView
This commit fixes some issues which occur when pressing the Shift key while selecting items (new unit tests included): 1. The offset of the visible area is missing at one point in QAbstractItemView::keyPressEvent, causing Shift-Arrow selection to fail if the view is scrolled down. 2. Shift-click and Shift-Arrow selection fail after a rubberband selection because d->pressedPosition does not correspond to a valid QModelIndex. The problems have been found in Dolphin: http://bugs.kde.org/show_bug.cgi?id=163451 Merge-request: 1426 Reviewed-by: Olivier Goffart <ogoffart@trolltech.com>
Diffstat (limited to 'src/gui/itemviews')
-rw-r--r--src/gui/itemviews/qabstractitemview.cpp7
1 files changed, 3 insertions, 4 deletions
diff --git a/src/gui/itemviews/qabstractitemview.cpp b/src/gui/itemviews/qabstractitemview.cpp
index ea98cb2..52529ff 100644
--- a/src/gui/itemviews/qabstractitemview.cpp
+++ b/src/gui/itemviews/qabstractitemview.cpp
@@ -1537,8 +1537,7 @@ void QAbstractItemView::mousePressEvent(QMouseEvent *event)
QPoint offset = d->offset();
if ((command & QItemSelectionModel::Current) == 0)
d->pressedPosition = pos + offset;
-
- if (d->pressedPosition == QPoint(-1, -1))
+ else if (!indexAt(d->pressedPosition).isValid())
d->pressedPosition = visualRect(currentIndex()).center() + offset;
if (edit(index, NoEditTriggers, event))
@@ -2089,8 +2088,8 @@ void QAbstractItemView::keyPressEvent(QKeyEvent *event)
// note that we don't check if the new current index is enabled because moveCursor() makes sure it is
if (command & QItemSelectionModel::Current) {
d->selectionModel->setCurrentIndex(newCurrent, QItemSelectionModel::NoUpdate);
- if (d->pressedPosition == QPoint(-1, -1))
- d->pressedPosition = visualRect(oldCurrent).center();
+ if (!indexAt(d->pressedPosition).isValid())
+ d->pressedPosition = visualRect(oldCurrent).center() + d->offset();
QRect rect(d->pressedPosition - d->offset(), visualRect(newCurrent).center());
setSelection(rect, command);
} else {