diff options
author | Olivier Goffart <ogoffart@trolltech.com> | 2009-10-29 15:25:56 (GMT) |
---|---|---|
committer | Olivier Goffart <ogoffart@trolltech.com> | 2009-10-30 12:42:09 (GMT) |
commit | 79a7c969983eafeef67cce28724c3981cf3af1ea (patch) | |
tree | fdb46034f8e021d8b12f38134be46c4834f3eb80 /tests/auto/qtreeview | |
parent | d025ebb1a8163cd1f03151927486cf62c5e77957 (diff) | |
download | Qt-79a7c969983eafeef67cce28724c3981cf3af1ea.zip Qt-79a7c969983eafeef67cce28724c3981cf3af1ea.tar.gz Qt-79a7c969983eafeef67cce28724c3981cf3af1ea.tar.bz2 |
QTreeView: fix drawing branches of model that adds or remove rows dynamically
The lasts commits in the treeview did put the flags weither
item has child or is the last in cache in the viewItem vector.
But the cache was not updated while the model is modified.
Reviewed-by: Thierry
Diffstat (limited to 'tests/auto/qtreeview')
-rw-r--r-- | tests/auto/qtreeview/tst_qtreeview.cpp | 101 |
1 files changed, 101 insertions, 0 deletions
diff --git a/tests/auto/qtreeview/tst_qtreeview.cpp b/tests/auto/qtreeview/tst_qtreeview.cpp index 75c02e9..90e6c5c 100644 --- a/tests/auto/qtreeview/tst_qtreeview.cpp +++ b/tests/auto/qtreeview/tst_qtreeview.cpp @@ -2892,6 +2892,8 @@ void tst_QTreeView::styleOptionViewItem() QVERIFY(!opt.text.isEmpty()); QCOMPARE(opt.index, index); + //qDebug() << index << opt.text; + if (allCollapsed) QCOMPARE(!(opt.features & QStyleOptionViewItemV2::Alternate), !(index.row() % 2)); QCOMPARE(!(opt.features & QStyleOptionViewItemV2::HasCheckIndicator), !opt.text.contains("Checkable")); @@ -2979,9 +2981,108 @@ void tst_QTreeView::styleOptionViewItem() view.expandAll(); QApplication::processEvents(); QTRY_VERIFY(delegate.count >= 13); + delegate.count = 0; view.collapse(par2->index()); QApplication::processEvents(); QTRY_VERIFY(delegate.count >= 4); + + + //test dynamic models + { + delegate.count = 0; + QStandardItemModel model2; + QStandardItem *item0 = new QStandardItem("OnlyOne Last"); + model2.appendRow(QList<QStandardItem*>() << item0); + view.setModel(&model2); + QApplication::processEvents(); + QTRY_VERIFY(delegate.count >= 1); + QApplication::processEvents(); + + QStandardItem *item00 = new QStandardItem("OnlyOne Last"); + item0->appendRow(QList<QStandardItem*>() << item00); + item0->setText("OnlyOne Last HasChildren"); + QApplication::processEvents(); + delegate.count = 0; + view.expandAll(); + QApplication::processEvents(); + QTRY_VERIFY(delegate.count >= 2); + QApplication::processEvents(); + + QStandardItem *item1 = new QStandardItem("OnlyOne Last"); + delegate.count = 0; + item0->setText("OnlyOne HasChildren"); + model2.appendRow(QList<QStandardItem*>() << item1); + QApplication::processEvents(); + QTRY_VERIFY(delegate.count >= 3); + QApplication::processEvents(); + + QStandardItem *item01 = new QStandardItem("OnlyOne Last"); + delegate.count = 0; + item00->setText("OnlyOne"); + item0->appendRow(QList<QStandardItem*>() << item01); + QApplication::processEvents(); + QTRY_VERIFY(delegate.count >= 4); + QApplication::processEvents(); + + QStandardItem *item000 = new QStandardItem("OnlyOne Last"); + delegate.count = 0; + item00->setText("OnlyOne HasChildren"); + item00->appendRow(QList<QStandardItem*>() << item000); + QApplication::processEvents(); + QTRY_VERIFY(delegate.count >= 5); + QApplication::processEvents(); + + delegate.count = 0; + item0->removeRow(0); + QApplication::processEvents(); + QTRY_VERIFY(delegate.count >= 3); + QApplication::processEvents(); + + item00 = new QStandardItem("OnlyOne"); + item0->insertRow(0, QList<QStandardItem*>() << item00); + QApplication::processEvents(); + delegate.count = 0; + view.expandAll(); + QApplication::processEvents(); + QTRY_VERIFY(delegate.count >= 4); + QApplication::processEvents(); + + delegate.count = 0; + item0->removeRow(1); + item00->setText("OnlyOne Last"); + QApplication::processEvents(); + QTRY_VERIFY(delegate.count >= 3); + QApplication::processEvents(); + + delegate.count = 0; + item0->removeRow(0); + item0->setText("OnlyOne"); + QApplication::processEvents(); + QTRY_VERIFY(delegate.count >= 2); + QApplication::processEvents(); + + //with hidden items + item0->setText("OnlyOne HasChildren"); + item00 = new QStandardItem("OnlyOne"); + item0->appendRow(QList<QStandardItem*>() << item00); + item01 = new QStandardItem("Assert"); + item0->appendRow(QList<QStandardItem*>() << item01); + view.setRowHidden(1, item0->index(), true); + view.expandAll(); + QStandardItem *item02 = new QStandardItem("OnlyOne Last"); + item0->appendRow(QList<QStandardItem*>() << item02); + delegate.count = 0; + QApplication::processEvents(); + QTRY_VERIFY(delegate.count >= 4); + QApplication::processEvents(); + + item0->removeRow(2); + item00->setText("OnlyOne Last"); + delegate.count = 0; + QApplication::processEvents(); + QTRY_VERIFY(delegate.count >= 3); + QApplication::processEvents(); + } } class task174627_TreeView : public QTreeView |