diff options
author | Gabriel de Dietrich <gabriel.dietrich-de@nokia.com> | 2010-01-11 09:44:55 (GMT) |
---|---|---|
committer | Gabriel de Dietrich <gabriel.dietrich-de@nokia.com> | 2010-01-11 09:44:55 (GMT) |
commit | 8b42e57fe2946f2cd17f538d0dec2ba6edc06a11 (patch) | |
tree | 4a09610e86e7e581de3b30cbe8d06cea79e810aa /tests/auto/qtreeview | |
parent | 8d76de98d93421395306941e59d136f1e7395d15 (diff) | |
download | Qt-8b42e57fe2946f2cd17f538d0dec2ba6edc06a11.zip Qt-8b42e57fe2946f2cd17f538d0dec2ba6edc06a11.tar.gz Qt-8b42e57fe2946f2cd17f538d0dec2ba6edc06a11.tar.bz2 |
QTreeView::selectAll() wouldn't work when first column hidden
QTreeView::selectAll() called QTreeView::select() on the first column, first
and last rows, and rows selection flags. As the first row was hidden, this
range spanned to void. We now pass the upper-left and lower-right indices to
select(). Auto-test included.
Reviewed-by: Olivier
Task-number: QTBUG-6450
Diffstat (limited to 'tests/auto/qtreeview')
-rw-r--r-- | tests/auto/qtreeview/tst_qtreeview.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/auto/qtreeview/tst_qtreeview.cpp b/tests/auto/qtreeview/tst_qtreeview.cpp index 4fc6dd3..06bc93e 100644 --- a/tests/auto/qtreeview/tst_qtreeview.cpp +++ b/tests/auto/qtreeview/tst_qtreeview.cpp @@ -236,6 +236,7 @@ private slots: void task248022_changeSelection(); void task245654_changeModelAndExpandAll(); void doubleClickedWithSpans(); + void taskQTBUG_6450_selectAllWith1stColumnHidden(); }; class QtTestModel: public QAbstractItemModel @@ -3678,5 +3679,26 @@ void tst_QTreeView::doubleClickedWithSpans() QTRY_COMPARE(spy.count(), 2); } +void tst_QTreeView::taskQTBUG_6450_selectAllWith1stColumnHidden() +{ + QTreeWidget tree; + tree.setSelectionMode(QAbstractItemView::MultiSelection); + tree.setColumnCount(2); + QList<QTreeWidgetItem *> items; + const int nrRows = 10; + for (int i = 0; i < nrRows; ++i) { + items.append(new QTreeWidgetItem((QTreeWidget*)0, QStringList(QString("item: %1").arg(i)))); + items.last()->setText(1, QString("is an item")); + } + tree.insertTopLevelItems(0, items); + + tree.hideColumn(0); + tree.selectAll(); + + QVERIFY(tree.selectionModel()->hasSelection()); + for (int i = 0; i < nrRows; ++i) + QVERIFY(tree.selectionModel()->isRowSelected(i, QModelIndex())); +} + QTEST_MAIN(tst_QTreeView) #include "tst_qtreeview.moc" |