diff options
author | Gabriel de Dietrich <gabriel.dietrich-de@nokia.com> | 2009-12-14 13:09:36 (GMT) |
---|---|---|
committer | Gabriel de Dietrich <gabriel.dietrich-de@nokia.com> | 2009-12-15 10:03:30 (GMT) |
commit | d6cd6c59dae36b2890baae98f0bf94b23e5509da (patch) | |
tree | 84ee23490fac7ab40f2788095b463b35e6d07b55 /tests/auto/qabstractitemview/tst_qabstractitemview.cpp | |
parent | c5ae0ffd52ee3f2964404bf85dee55712fb6bd8c (diff) | |
download | Qt-d6cd6c59dae36b2890baae98f0bf94b23e5509da.zip Qt-d6cd6c59dae36b2890baae98f0bf94b23e5509da.tar.gz Qt-d6cd6c59dae36b2890baae98f0bf94b23e5509da.tar.bz2 |
Clicking on a selected item wouldn't reset the selection anymore.
Before commit 88ecc8c8250505129ccff2660c60412996e2fd85, this case was handled
during the mouse release event, but was responsible for selections being made
twice sometimes. We now check whether a selection actually happened during
the mouse press event. If not, we will try to select again during the mouse
release event. Auto-test included.
Reviewed-by: Thierry
Task-number: QTBUG-6753
Diffstat (limited to 'tests/auto/qabstractitemview/tst_qabstractitemview.cpp')
-rw-r--r-- | tests/auto/qabstractitemview/tst_qabstractitemview.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/auto/qabstractitemview/tst_qabstractitemview.cpp b/tests/auto/qabstractitemview/tst_qabstractitemview.cpp index 6479829..bf3af63 100644 --- a/tests/auto/qabstractitemview/tst_qabstractitemview.cpp +++ b/tests/auto/qabstractitemview/tst_qabstractitemview.cpp @@ -48,6 +48,7 @@ #include <qlistview.h> #include <qlistwidget.h> #include <qtableview.h> +#include <qtablewidget.h> #include <qtreeview.h> #include <qtreewidget.h> #include <qheaderview.h> @@ -226,6 +227,7 @@ private slots: void shiftSelectionAfterRubberbandSelection(); void ctrlRubberbandSelection(); void QTBUG6407_extendedSelection(); + void QTBUG6753_selectOnSelection(); }; class MyAbstractItemDelegate : public QAbstractItemDelegate @@ -1475,5 +1477,26 @@ void tst_QAbstractItemView::QTBUG6407_extendedSelection() } +void tst_QAbstractItemView::QTBUG6753_selectOnSelection() +{ + QTableWidget table(5, 5); + for (int i = 0; i < table.rowCount(); ++i) + for (int j = 0; j < table.columnCount(); ++j) + table.setItem(i, j, new QTableWidgetItem("choo-be-doo-wah")); + + table.show(); + table.setSelectionMode(QAbstractItemView::ExtendedSelection); + table.selectAll(); + QTest::qWaitForWindowShown(&table); + QModelIndex item = table.model()->index(1,1); + QRect itemRect = table.visualRect(item); + QTest::mouseMove(table.viewport(), itemRect.center()); + QTest::mouseClick(table.viewport(), Qt::LeftButton, Qt::NoModifier, itemRect.center()); + QTest::qWait(20); + + QCOMPARE(table.selectedItems().count(), 1); + QCOMPARE(table.selectedItems().first(), table.item(item.row(), item.column())); +} + QTEST_MAIN(tst_QAbstractItemView) #include "tst_qabstractitemview.moc" |