diff options
author | Thierry Bastian <thierry.bastian@nokia.com> | 2009-05-12 14:13:40 (GMT) |
---|---|---|
committer | Thierry Bastian <thierry.bastian@nokia.com> | 2009-05-12 14:14:54 (GMT) |
commit | 0c3d59a34c404ba1cec1ab6dbe88e4bf0664538b (patch) | |
tree | 6862ee8f61f50454d2a70aad3cafff2bcc237adf /tests | |
parent | 8c4aee1be1e50bd49207aee61ac41613e07e0605 (diff) | |
download | Qt-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 'tests')
-rw-r--r-- | tests/auto/qlistview/tst_qlistview.cpp | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/auto/qlistview/tst_qlistview.cpp b/tests/auto/qlistview/tst_qlistview.cpp index 791a472..f70db14 100644 --- a/tests/auto/qlistview/tst_qlistview.cpp +++ b/tests/auto/qlistview/tst_qlistview.cpp @@ -106,6 +106,7 @@ private slots: void task228566_infiniteRelayout(); void task248430_crashWith0SizedItem(); void task250446_scrollChanged(); + void task196118_visualRegionForSelection(); void keyboardSearch(); }; @@ -1556,6 +1557,29 @@ void tst_QListView::task250446_scrollChanged() QCOMPARE(view.currentIndex(), index); } +void tst_QListView::task196118_visualRegionForSelection() +{ + class MyListView : public QListView + { + public: + QRegion visualRegionForSelection() const + { return QListView::visualRegionForSelection( selectionModel()->selection()); } + } view; + + QStandardItemModel model; + QStandardItem top1("top1"); + QStandardItem sub1("sub1"); + top1.appendRow(QList<QStandardItem*>() << &sub1); + model.appendColumn(QList<QStandardItem*>() << &top1); + view.setModel(&model); + view.setRootIndex(top1.index()); + + view.selectionModel()->select(top1.index(), QItemSelectionModel::Select); + + QCOMPARE(view.selectionModel()->selectedIndexes().count(), 1); + QVERIFY(view.visualRegionForSelection().isEmpty()); +} + void tst_QListView::keyboardSearch() { QStringList items; |