Blame SOURCES/0019-Show-a-tableview-even-if-the-syncView-has-an-empty-m.patch

383017
From 1241e4f3c3ec010ae121f5d56c3e9405ec43231f Mon Sep 17 00:00:00 2001
383017
From: Andy Shaw <andy.shaw@qt.io>
383017
Date: Fri, 6 Nov 2020 13:30:12 +0100
383017
Subject: [PATCH 19/28] Show a tableview even if the syncView has an empty
383017
 model
383017
383017
By showing the tableview, we can be sure that headerviews will be
383017
visible even in the syncView has an empty model.
383017
383017
Fixes: QTBUG-87526
383017
Change-Id: I68c8b119122a2d2f88c2afbeb2d6c71a83a3ce33
383017
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
383017
(cherry picked from commit 27c254203b3e7dd6d3a4445feb205fbe98c32d30)
383017
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
383017
---
383017
 src/quick/items/qquicktableview.cpp           |  7 +--
383017
 .../qquicktableview/tst_qquicktableview.cpp   | 43 +++++++++++++++++++
383017
 2 files changed, 45 insertions(+), 5 deletions(-)
383017
383017
diff --git a/src/quick/items/qquicktableview.cpp b/src/quick/items/qquicktableview.cpp
383017
index 7b73fcb393..1349d308d7 100644
383017
--- a/src/quick/items/qquicktableview.cpp
383017
+++ b/src/quick/items/qquicktableview.cpp
383017
@@ -1760,11 +1760,8 @@ void QQuickTableViewPrivate::calculateTopLeft(QPoint &topLeftCell, QPointF &topL
383017
         const auto syncView_d = syncView->d_func();
383017
 
383017
         if (syncView_d->loadedItems.isEmpty()) {
383017
-            // The sync view contains no loaded items. This probably means
383017
-            // that it has not been rebuilt yet. Which also means that
383017
-            // we cannot rebuild anything before this happens.
383017
-            topLeftCell.rx() = kEdgeIndexNotSet;
383017
-            topLeftCell.ry() = kEdgeIndexNotSet;
383017
+            topLeftCell.rx() = 0;
383017
+            topLeftCell.ry() = 0;
383017
             return;
383017
         }
383017
 
383017
diff --git a/tests/auto/quick/qquicktableview/tst_qquicktableview.cpp b/tests/auto/quick/qquicktableview/tst_qquicktableview.cpp
383017
index 54f73c6e0c..d489a873e4 100644
383017
--- a/tests/auto/quick/qquicktableview/tst_qquicktableview.cpp
383017
+++ b/tests/auto/quick/qquicktableview/tst_qquicktableview.cpp
383017
@@ -176,6 +176,7 @@ private slots:
383017
     void checkSyncView_connect_late_data();
383017
     void checkSyncView_connect_late();
383017
     void checkSyncView_pageFlicking();
383017
+    void checkSyncView_emptyModel();
383017
     void delegateWithRequiredProperties();
383017
     void checkThatFetchMoreIsCalledWhenScrolledToTheEndOfTable();
383017
     void replaceModel();
383017
@@ -2731,6 +2732,48 @@ void tst_QQuickTableView::checkSyncView_pageFlicking()
383017
     QVERIFY(tableViewPrivate->scheduledRebuildOptions & QQuickTableViewPrivate::RebuildOption::CalculateNewTopLeftRow);
383017
 }
383017
 
383017
+void tst_QQuickTableView::checkSyncView_emptyModel()
383017
+{
383017
+    // When a tableview has a syncview with an empty model then it should still be
383017
+    // showing the tableview without depending on the syncview. This is particularly
383017
+    // important for headerviews for example
383017
+    LOAD_TABLEVIEW("syncviewsimple.qml");
383017
+    GET_QML_TABLEVIEW(tableViewH);
383017
+    GET_QML_TABLEVIEW(tableViewV);
383017
+    GET_QML_TABLEVIEW(tableViewHV);
383017
+    QQuickTableView *views[] = {tableViewH, tableViewV, tableViewHV};
383017
+
383017
+    auto model = TestModelAsVariant(100, 100);
383017
+
383017
+    for (auto view : views)
383017
+        view->setModel(model);
383017
+
383017
+    WAIT_UNTIL_POLISHED_ARG(tableViewHV);
383017
+
383017
+    // Check that geometry properties are mirrored
383017
+    QCOMPARE(tableViewH->columnSpacing(), tableView->columnSpacing());
383017
+    QCOMPARE(tableViewH->rowSpacing(), 0);
383017
+    QCOMPARE(tableViewH->contentWidth(), tableView->contentWidth());
383017
+    QVERIFY(tableViewH->contentHeight() > 0);
383017
+    QCOMPARE(tableViewV->columnSpacing(), 0);
383017
+    QCOMPARE(tableViewV->rowSpacing(), tableView->rowSpacing());
383017
+    QCOMPARE(tableViewV->contentHeight(), tableView->contentHeight());
383017
+    QVERIFY(tableViewV->contentWidth() > 0);
383017
+
383017
+    QCOMPARE(tableViewH->contentX(), tableView->contentX());
383017
+    QCOMPARE(tableViewH->contentY(), 0);
383017
+    QCOMPARE(tableViewV->contentX(), 0);
383017
+    QCOMPARE(tableViewV->contentY(), tableView->contentY());
383017
+    QCOMPARE(tableViewHV->contentX(), tableView->contentX());
383017
+    QCOMPARE(tableViewHV->contentY(), tableView->contentY());
383017
+
383017
+    QCOMPARE(tableViewHPrivate->loadedTableOuterRect.left(), tableViewPrivate->loadedTableOuterRect.left());
383017
+    QCOMPARE(tableViewHPrivate->loadedTableOuterRect.top(), 0);
383017
+
383017
+    QCOMPARE(tableViewVPrivate->loadedTableOuterRect.top(), tableViewPrivate->loadedTableOuterRect.top());
383017
+    QCOMPARE(tableViewVPrivate->loadedTableOuterRect.left(), 0);
383017
+}
383017
+
383017
 void tst_QQuickTableView::checkThatFetchMoreIsCalledWhenScrolledToTheEndOfTable()
383017
 {
383017
     LOAD_TABLEVIEW("plaintableview.qml");
383017
-- 
383017
2.31.1
383017