summaryrefslogtreecommitdiffstats
path: root/tests/auto/qabstractitemview/tst_qabstractitemview.cpp
diff options
context:
space:
mode:
authorOlivier Goffart <ogoffart@trolltech.com>2009-12-03 16:20:03 (GMT)
committerOlivier Goffart <ogoffart@trolltech.com>2009-12-03 16:26:30 (GMT)
commit2263a796ac6fc84002ff075eb6cbc67e0ec27802 (patch)
tree1a79679417b213e2528512b37ecb8c32a92371a1 /tests/auto/qabstractitemview/tst_qabstractitemview.cpp
parent5cab18e5e3946b0dc14d678c8a317522d25e3003 (diff)
downloadQt-2263a796ac6fc84002ff075eb6cbc67e0ec27802.zip
Qt-2263a796ac6fc84002ff075eb6cbc67e0ec27802.tar.gz
Qt-2263a796ac6fc84002ff075eb6cbc67e0ec27802.tar.bz2
Fixes broken selection with Shift and extended selection
ItemAt() is in viewport coordinate. Pressed index is in coordinate relative to the whole view (regression since Qt 4.5) Reviewed-by: thierry Task-number: QTBUG-6407
Diffstat (limited to 'tests/auto/qabstractitemview/tst_qabstractitemview.cpp')
-rw-r--r--tests/auto/qabstractitemview/tst_qabstractitemview.cpp42
1 files changed, 42 insertions, 0 deletions
diff --git a/tests/auto/qabstractitemview/tst_qabstractitemview.cpp b/tests/auto/qabstractitemview/tst_qabstractitemview.cpp
index db840f4..6479829 100644
--- a/tests/auto/qabstractitemview/tst_qabstractitemview.cpp
+++ b/tests/auto/qabstractitemview/tst_qabstractitemview.cpp
@@ -46,6 +46,7 @@
#include <qstandarditemmodel.h>
#include <qapplication.h>
#include <qlistview.h>
+#include <qlistwidget.h>
#include <qtableview.h>
#include <qtreeview.h>
#include <qtreewidget.h>
@@ -224,6 +225,7 @@ private slots:
void shiftArrowSelectionAfterScrolling();
void shiftSelectionAfterRubberbandSelection();
void ctrlRubberbandSelection();
+ void QTBUG6407_extendedSelection();
};
class MyAbstractItemDelegate : public QAbstractItemDelegate
@@ -1433,5 +1435,45 @@ void tst_QAbstractItemView::ctrlRubberbandSelection()
QVERIFY(selected.contains(index2));
}
+void tst_QAbstractItemView::QTBUG6407_extendedSelection()
+{
+ QListWidget view;
+ view.setSelectionMode(QAbstractItemView::ExtendedSelection);
+ for(int i = 0; i < 50; ++i)
+ view.addItem(QString::number(i));
+
+ view.resize(200,200);
+
+ view.show();
+ QApplication::setActiveWindow(&view);
+ QTest::qWaitForWindowShown(&view);
+ QTRY_COMPARE(static_cast<QWidget *>(&view), QApplication::activeWindow());
+
+ view.verticalScrollBar()->setValue(view.verticalScrollBar()->maximum());
+ QTest::qWait(20);
+
+ QModelIndex index49 = view.model()->index(49,0);
+ QPoint p = view.visualRect(index49).center();
+ QVERIFY(view.viewport()->rect().contains(p));
+ QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, p);
+ QCOMPARE(view.currentIndex(), index49);
+ QCOMPARE(view.selectedItems().count(), 1);
+
+ QModelIndex index47 = view.model()->index(47,0);
+ p = view.visualRect(index47).center();
+ QVERIFY(view.viewport()->rect().contains(p));
+ QTest::mouseClick(view.viewport(), Qt::LeftButton, Qt::ShiftModifier, p);
+ QCOMPARE(view.currentIndex(), index47);
+ QCOMPARE(view.selectedItems().count(), 3); //49, 48, 47;
+
+ QModelIndex index44 = view.model()->index(44,0);
+ p = view.visualRect(index44).center();
+ QVERIFY(view.viewport()->rect().contains(p));
+ QTest::mouseClick(view.viewport(), Qt::LeftButton, Qt::ShiftModifier, p);
+ QCOMPARE(view.currentIndex(), index44);
+ QCOMPARE(view.selectedItems().count(), 6); //49 .. 44;
+
+}
+
QTEST_MAIN(tst_QAbstractItemView)
#include "tst_qabstractitemview.moc"