summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorGiulio Camuffo <giulio.camuffo@kdab.com>2020-05-19 15:02:22 +0200
committerGiulio Camuffo <giulio.camuffo@kdab.com>2020-05-26 15:11:40 +0200
commit7db527dbdd911c79f31425d099d1fc9c63e42453 (patch)
treeafab1783ca289ea44e9be7555f8436df24a5cfe5 /tests
parent3197932e6fb03fb9c0ff669af858cb94e3836d79 (diff)
Add a property to QSFPM to show children of accepted items
[ChangeLog][QtCore][QSortFilterProxyModel] Add a 'autoAcceptChildRows' property to always show children rows of accepted rows. Change-Id: I2402469ece438179d0f19888b9775cc27cf5c749 Reviewed-by: David Faure <david.faure@kdab.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/corelib/itemmodels/qsortfilterproxymodel_recursive/tst_qsortfilterproxymodel_recursive.cpp32
1 files changed, 32 insertions, 0 deletions
diff --git a/tests/auto/corelib/itemmodels/qsortfilterproxymodel_recursive/tst_qsortfilterproxymodel_recursive.cpp b/tests/auto/corelib/itemmodels/qsortfilterproxymodel_recursive/tst_qsortfilterproxymodel_recursive.cpp
index dbafedbb5d..35ae7f4a7f 100644
--- a/tests/auto/corelib/itemmodels/qsortfilterproxymodel_recursive/tst_qsortfilterproxymodel_recursive.cpp
+++ b/tests/auto/corelib/itemmodels/qsortfilterproxymodel_recursive/tst_qsortfilterproxymodel_recursive.cpp
@@ -715,6 +715,38 @@ private Q_SLOTS:
}
+ void testChildrenFiltering_data()
+ {
+ QTest::addColumn<QString>("sourceStr");
+ QTest::addColumn<QString>("noChildrenProxyStr");
+ QTest::addColumn<QString>("childrenProxyStr");
+ QTest::addColumn<QString>("noParentProxyStr");
+
+ QTest::newRow("filter_parent") << "[1*[1.1 1.2[1.2.1]]]" << "[1*]" << "[1*[1.1 1.2[1.2.1]]]" << "[1*[1.1 1.2[1.2.1]]]";
+ QTest::newRow("filter_child") << "[1[1.1 1.2*[1.2.1]]]" << "[1[1.2*]]" << "[1[1.2*[1.2.1]]]" << "";
+
+ }
+
+ void testChildrenFiltering()
+ {
+ QFETCH(QString, sourceStr);
+ QFETCH(QString, noChildrenProxyStr);
+ QFETCH(QString, childrenProxyStr);
+ QFETCH(QString, noParentProxyStr);
+
+ QStandardItemModel model;
+ fillModel(model, sourceStr);
+
+ TestModel proxy(&model);
+ QCOMPARE(treeAsString(proxy), noChildrenProxyStr);
+
+ proxy.setAutoAcceptChildRows(true);
+ QCOMPARE(treeAsString(proxy), childrenProxyStr);
+
+ proxy.setRecursiveFilteringEnabled(false);
+ QCOMPARE(treeAsString(proxy), noParentProxyStr);
+ }
+
private:
QStandardItem *itemByText(const QStandardItemModel& model, const QString &text) const {
QModelIndexList list = model.match(model.index(0, 0), Qt::DisplayRole, text, 1, Qt::MatchRecursive);