diff options
author | Thorbjørn Martsum <tmartsum@gmail.com> | 2013-08-26 20:26:07 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-08-30 21:07:46 +0200 |
commit | 2c916d47ef1338403cf14b4a2684159d865aa4fc (patch) | |
tree | c6fe82e6f84bd336320463bb7c86a3fb6bbbb2db /tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp | |
parent | 427037c75d7c915b9fc61cadd0a4fb5c20875547 (diff) |
QTreeView - fix next focus when there is no current index
Before we went through non hidden indexes, but we never considered
the visual order. This patch fixes that issue.
Though it was wrong before, it probably never was a big problem
since it was unlikely that the tree (on logical index 0) was
swapped or hidden, but
658e42e77a00596b63823482c9b77644556b647c
makes it more likely that problems with wrong focus could occur.
Change-Id: Ic7b6cd2df1f8638be1a7c9e6df27f428685869fc
Reviewed-by: Stephen Kelly <stephen.kelly@kdab.com>
Diffstat (limited to 'tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp')
-rw-r--r-- | tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp b/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp index dcda9f7fd7..8d31fcdf13 100644 --- a/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp +++ b/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp @@ -259,6 +259,7 @@ private slots: void taskQTBUG_25333_adjustViewOptionsForIndex(); void taskQTBUG_18539_emitLayoutChanged(); void taskQTBUG_8176_emitOnExpandAll(); + void testInitialFocus(); }; class QtTestModel: public QAbstractItemModel @@ -4239,6 +4240,20 @@ void tst_QTreeView::taskQTBUG_8176_emitOnExpandAll() QCOMPARE(spy2.size(), 1); // item2 is collapsed } +void tst_QTreeView::testInitialFocus() +{ + QTreeWidget treeWidget; + treeWidget.setColumnCount(5); + new QTreeWidgetItem(&treeWidget, QStringList(QString("1;2;3;4;5").split(";"))); + treeWidget.setTreePosition(2); + treeWidget.header()->hideSection(0); // make sure we skip hidden section(s) + treeWidget.header()->swapSections(1, 2); // make sure that we look for first visual index (and not first logical) + treeWidget.show(); + QTest::qWaitForWindowExposed(&treeWidget); + QApplication::processEvents(); + QCOMPARE(treeWidget.currentIndex().column(), 2); +} + #ifndef QT_NO_ANIMATION void tst_QTreeView::quickExpandCollapse() { |