diff options
author | Thierry Bastian <thierry.bastian@nokia.com> | 2009-05-06 11:54:57 (GMT) |
---|---|---|
committer | Thierry Bastian <thierry.bastian@nokia.com> | 2009-05-06 11:57:40 (GMT) |
commit | 8cd19116ae81c99fe28fbf91aa7f4c1c08163fe0 (patch) | |
tree | 23e66cc7f17e94d6bfc02039075745ce5e15c955 /tests | |
parent | e13aab33bc1aa68bcf5a18e2d77b2db7f9f44e1e (diff) | |
download | Qt-8cd19116ae81c99fe28fbf91aa7f4c1c08163fe0.zip Qt-8cd19116ae81c99fe28fbf91aa7f4c1c08163fe0.tar.gz Qt-8cd19116ae81c99fe28fbf91aa7f4c1c08163fe0.tar.bz2 |
QTreeView could be not correctly updated when the 1st column is hidden.
The problem was that we were not always storing the modelindex in
column 0 for each QTreeViewItem. That was causing inconsistencies.
Now it is always the case. It allowed to remove some calls to
QModelIndex::sibling.
Task-number: 239271
Reviewed-by: ogoffart
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/qtreeview/tst_qtreeview.cpp | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/tests/auto/qtreeview/tst_qtreeview.cpp b/tests/auto/qtreeview/tst_qtreeview.cpp index 37cb5b0..71d7b4d 100644 --- a/tests/auto/qtreeview/tst_qtreeview.cpp +++ b/tests/auto/qtreeview/tst_qtreeview.cpp @@ -226,6 +226,7 @@ private slots: void task244304_clickOnDecoration(); void task246536_scrollbarsNotWorking(); void task250683_wrongSectionSize(); + void task239271_addRowsWithFirstColumnHidden(); }; class QtTestModel: public QAbstractItemModel @@ -3289,6 +3290,45 @@ void tst_QTreeView::task250683_wrongSectionSize() QCOMPARE(treeView.header()->sectionSize(0) + treeView.header()->sectionSize(1), treeView.viewport()->width()); } +void tst_QTreeView::task239271_addRowsWithFirstColumnHidden() +{ + class MyDelegate : public QStyledItemDelegate + { + public: + void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index ) const + { + paintedIndexes << index; + QStyledItemDelegate::paint(painter, option, index); + } + + mutable QSet<QModelIndex> paintedIndexes; + }; + + QTreeView view; + QStandardItemModel model; + view.setModel(&model); + MyDelegate delegate; + view.setItemDelegate(&delegate); + QStandardItem root0("root0"), root1("root1"); + model.invisibleRootItem()->appendRow(QList<QStandardItem*>() << &root0 << &root1); + QStandardItem sub0("sub0"), sub00("sub00"); + root0.appendRow(QList<QStandardItem*>() << &sub0 << &sub00); + view.expand(root0.index()); + + view.hideColumn(0); + view.show(); + QTest::qWait(200); + delegate.paintedIndexes.clear(); + QStandardItem sub1("sub1"), sub11("sub11"); + root0.appendRow(QList<QStandardItem*>() << &sub1 << &sub11); + + QTest::qWait(200); + //items in the 2nd column should have been painted + QVERIFY(delegate.paintedIndexes.contains(sub00.index())); + QVERIFY(delegate.paintedIndexes.contains(sub11.index())); +} + + QTEST_MAIN(tst_QTreeView) #include "tst_qtreeview.moc" |