aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorRichard Moe Gustavsen <richard.gustavsen@qt.io>2022-01-17 17:02:06 +0100
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2022-01-24 16:05:01 +0000
commitc8b863b361b02c1c9e53b4e29a43f6f4577f213d (patch)
tree3b856b274c4b6c58878a5cdc433f88b55252d243 /tests
parentddfdf94dd290b6197e69ca230e499e9f2a6a5d06 (diff)
QQuickTreeView: be able to expand rows that are not yet visible in the view
If the app expands a row in TreeView, that row will for a brief moment be expanded in the proxy model, but not in the view, until the view is polished. For that reason, when determining if a row can be expanded or not, we should check the state of the proxy model, and not the view. Note: if the application needs the state of the view to reflect the state of the proxy model immediataly after a call to expand, forcePolish() is always possible. Task-number: QTBUG-91374 Change-Id: I5b85e0b5c3b32d17f93409153041df3fc2437424 Reviewed-by: Andy Shaw <andy.shaw@qt.io> (cherry picked from commit a43912865e294f2014f03eb7073ecd9ecf387623) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/quick/qquicktreeview/tst_qquicktreeview.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/auto/quick/qquicktreeview/tst_qquicktreeview.cpp b/tests/auto/quick/qquicktreeview/tst_qquicktreeview.cpp
index c1ba0a62a5..abba5fced6 100644
--- a/tests/auto/quick/qquicktreeview/tst_qquicktreeview.cpp
+++ b/tests/auto/quick/qquicktreeview/tst_qquicktreeview.cpp
@@ -93,6 +93,7 @@ private slots:
void expandAndCollapseRoot();
void toggleExpanded();
void expandAndCollapseChildren();
+ void expandChildPendingToBeVisible();
void requiredPropertiesRoot();
void requiredPropertiesChildren();
void emptyModel();
@@ -359,6 +360,30 @@ void tst_qquicktreeview::insertRows()
QCOMPARE(treeView->rows(), 9);
}
+void tst_qquicktreeview::expandChildPendingToBeVisible()
+{
+ // Check that if we expand a row r1, and that row has a child r2 that can
+ // be expanded, we can continue to expand c2 immediately, even if r1 is
+ // still pending to be shown as expanded in the view.
+ LOAD_TREEVIEW("normaltreeview.qml");
+ treeView->expand(0);
+ QVERIFY(treeView->isExpanded(0));
+ // The view has not yet been updated at this point to show
+ // the newly expanded children, so it still has only one row.
+ QCOMPARE(treeView->rows(), 1);
+ // ...but we still expand row 5, which is a child that has children
+ // in the proxy model
+ treeView->expand(4);
+ QVERIFY(treeView->isExpanded(4));
+ QCOMPARE(treeView->rows(), 1);
+
+ WAIT_UNTIL_POLISHED;
+
+ // Now the view have updated to show
+ // all the rows that has been expanded.
+ QCOMPARE(treeView->rows(), 9);
+}
+
QTEST_MAIN(tst_qquicktreeview)
#include "tst_qquicktreeview.moc"