summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorOlivier Goffart <ogoffart@trolltech.com>2009-04-16 15:29:36 (GMT)
committerOlivier Goffart <ogoffart@trolltech.com>2009-04-16 15:40:35 (GMT)
commitd1221d84714a169e12192cfa073af11db61bfbcc (patch)
tree2ba6b2185a0b843271cbd7db8723e9c325575d33 /tests/auto
parent139265031939d676f049edd2c91918040e0659b4 (diff)
downloadQt-d1221d84714a169e12192cfa073af11db61bfbcc.zip
Qt-d1221d84714a169e12192cfa073af11db61bfbcc.tar.gz
Qt-d1221d84714a169e12192cfa073af11db61bfbcc.tar.bz2
QSortFilterProxyModel: In dynamic filter model, childs of temporarly
filtered items are not correctly updated. when filtering away a row, we should remove all the mapping of the children Task-number: 251296 Reviewed-by: Marius Bugge Monsen
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp42
1 files changed, 42 insertions, 0 deletions
diff --git a/tests/auto/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp b/tests/auto/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp
index 4a749f0..18aa5fc 100644
--- a/tests/auto/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp
+++ b/tests/auto/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp
@@ -132,6 +132,7 @@ private slots:
void task248868_staticSorting();
void task248868_dynamicSorting();
void task250023_fetchMore();
+ void task251296_hiddenChildren();
protected:
void buildHierarchy(const QStringList &data, QAbstractItemModel *model);
@@ -2675,6 +2676,47 @@ void tst_QSortFilterProxyModel::task250023_fetchMore()
QCOMPARE(proxy.columnCount(idx), 10);
}
+void tst_QSortFilterProxyModel::task251296_hiddenChildren()
+{
+ QStandardItemModel model;
+ QSortFilterProxyModel proxy;
+ proxy.setSourceModel(&model);
+ proxy.setDynamicSortFilter(true);
+
+ QStandardItem *itemA = new QStandardItem("A VISIBLE");
+ model.appendRow(itemA);
+ QStandardItem *itemB = new QStandardItem("B VISIBLE");
+ itemA->appendRow(itemB);
+ QStandardItem *itemC = new QStandardItem("C");
+ itemA->appendRow(itemC);
+ proxy.setFilterRegExp("VISIBLE");
+
+ QCOMPARE(proxy.rowCount(QModelIndex()) , 1);
+ QPersistentModelIndex indexA = proxy.index(0,0);
+ QCOMPARE(proxy.data(indexA).toString(), QString::fromLatin1("A VISIBLE"));
+
+ QCOMPARE(proxy.rowCount(indexA) , 1);
+ QPersistentModelIndex indexB = proxy.index(0, 0, indexA);
+ QCOMPARE(proxy.data(indexB).toString(), QString::fromLatin1("B VISIBLE"));
+
+ itemA->setText("A");
+ QCOMPARE(proxy.rowCount(QModelIndex()), 0);
+ QVERIFY(!indexA.isValid());
+ QVERIFY(!indexB.isValid());
+
+ itemB->setText("B");
+ itemA->setText("A VISIBLE");
+ itemC->setText("C VISIBLE");
+
+ QCOMPARE(proxy.rowCount(QModelIndex()), 1);
+ indexA = proxy.index(0,0);
+ QCOMPARE(proxy.data(indexA).toString(), QString::fromLatin1("A VISIBLE"));
+
+ QCOMPARE(proxy.rowCount(indexA) , 1);
+ QModelIndex indexC = proxy.index(0, 0, indexA);
+ QCOMPARE(proxy.data(indexC).toString(), QString::fromLatin1("C VISIBLE"));
+}
+
QTEST_MAIN(tst_QSortFilterProxyModel)
#include "tst_qsortfilterproxymodel.moc"