summaryrefslogtreecommitdiff
path: root/tests/auto/qlistview
diff options
context:
space:
mode:
authorThierry Bastian <thierry.bastian@nokia.com>2009-05-12 16:13:40 +0200
committerThierry Bastian <thierry.bastian@nokia.com>2009-05-12 16:14:54 +0200
commit0c3d59a34c404ba1cec1ab6dbe88e4bf0664538b (patch)
tree6862ee8f61f50454d2a70aad3cafff2bcc237adf /tests/auto/qlistview
parent8c4aee1be1e50bd49207aee61ac41613e07e0605 (diff)
downloadqt4-tools-0c3d59a34c404ba1cec1ab6dbe88e4bf0664538b.tar.gz
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/auto/qlistview')
-rw-r--r--tests/auto/qlistview/tst_qlistview.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/auto/qlistview/tst_qlistview.cpp b/tests/auto/qlistview/tst_qlistview.cpp
index 791a4723fb..f70db140fb 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;