Blame SOURCES/qtdeclarative-5.15.0-FixMaxXMaxYExtent.patch

72ccf7
Parent:     f5a4e984 (QQuickTextInputPrivate: refactor getImplicitWidth() to calculateImplicitWidth())
72ccf7
Author:     David Redondo <qt@david-redondo.de>
72ccf7
AuthorDate: 2020-05-13 11:04:23 +0200
72ccf7
Commit:     Mitch Curtis <mitch.curtis@qt.io>
72ccf7
CommitDate: 2020-05-25 10:58:35 +0200
72ccf7
72ccf7
QQuickItemView: Fix max(X/Y)Extent()
72ccf7
72ccf7
QQuickFlickable maxXExtent() and maxYExtent() return the amount of space
72ccf7
that is not shown when inside a ScrollView. QQuickItemView however just
72ccf7
returned width() if vertical and height() if horizontal. In these cases
72ccf7
just defer to the QQuickFlickable base implementation like minXExtent()
72ccf7
and minYExtent() already do.
72ccf7
72ccf7
This change also adds tst_qquicklistview2 to speed up development.
72ccf7
tst_QQuickListView is almost 9000 lines long, and compiling it
72ccf7
is slow. In addition, a similar approach (creating a second test to
72ccf7
avoid the slowness of a massive one) already exists for QQuickItem
72ccf7
tests.
72ccf7
72ccf7
Fixes: QTBUG-83890
72ccf7
Pick-to: 5.15
72ccf7
Change-Id: I7f4060c2f46ae07611bedceca0d322c5f7f6affb
72ccf7
========================================================================================================================
72ccf7
Index: qtdeclarative-everywhere-src-5.15.2/src/quick/items/qquickitemview.cpp
72ccf7
===================================================================
72ccf7
--- qtdeclarative-everywhere-src-5.15.2.orig/src/quick/items/qquickitemview.cpp
72ccf7
+++ qtdeclarative-everywhere-src-5.15.2/src/quick/items/qquickitemview.cpp
72ccf7
@@ -1393,7 +1393,7 @@ qreal QQuickItemView::maxYExtent() const
72ccf7
 {
72ccf7
     Q_D(const QQuickItemView);
72ccf7
     if (d->layoutOrientation() == Qt::Horizontal)
72ccf7
-        return height();
72ccf7
+        return QQuickFlickable::maxYExtent();
72ccf7
 
72ccf7
     if (d->vData.maxExtentDirty) {
72ccf7
         d->maxExtent = d->maxExtentForAxis(d->vData, false);
72ccf7
@@ -1421,7 +1421,7 @@ qreal QQuickItemView::maxXExtent() const
72ccf7
 {
72ccf7
     Q_D(const QQuickItemView);
72ccf7
     if (d->layoutOrientation() == Qt::Vertical)
72ccf7
-        return width();
72ccf7
+        return QQuickFlickable::maxXExtent();
72ccf7
 
72ccf7
     if (d->hData.maxExtentDirty) {
72ccf7
         d->maxExtent = d->maxExtentForAxis(d->hData, true);
72ccf7
Index: qtdeclarative-everywhere-src-5.15.2/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp
72ccf7
===================================================================
72ccf7
--- qtdeclarative-everywhere-src-5.15.2.orig/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp
72ccf7
+++ qtdeclarative-everywhere-src-5.15.2/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp
72ccf7
@@ -73,6 +73,8 @@ public:
72ccf7
     tst_QQuickListView();
72ccf7
 
72ccf7
 private slots:
72ccf7
+    // WARNING: please add new tests to tst_qquicklistview2; this file is too slow to work with.
72ccf7
+
72ccf7
     void init();
72ccf7
     void cleanupTestCase();
72ccf7
     // Test QAbstractItemModel model types
72ccf7
@@ -299,6 +301,8 @@ private slots:
72ccf7
     void requiredObjectListModel();
72ccf7
     void clickHeaderAndFooterWhenClip();
72ccf7
 
72ccf7
+    // WARNING: please add new tests to tst_qquicklistview2; this file is too slow to work with.
72ccf7
+
72ccf7
 private:
72ccf7
     template <class T> void items(const QUrl &source);
72ccf7
     template <class T> void changed(const QUrl &source);
72ccf7
@@ -10094,6 +10098,8 @@ void tst_QQuickListView::clickHeaderAndF
72ccf7
     QVERIFY(root->property("footerPressed").toBool());
72ccf7
 }
72ccf7
 
72ccf7
+// WARNING: please add new tests to tst_qquicklistview2; this file is too slow to work with.
72ccf7
+
72ccf7
 QTEST_MAIN(tst_QQuickListView)
72ccf7
 
72ccf7
 #include "tst_qquicklistview.moc"
72ccf7
Index: qtdeclarative-everywhere-src-5.15.2/tests/auto/quick/qquicklistview2/data/maxXExtent.qml
72ccf7
===================================================================
72ccf7
--- /dev/null
72ccf7
+++ qtdeclarative-everywhere-src-5.15.2/tests/auto/quick/qquicklistview2/data/maxXExtent.qml
72ccf7
@@ -0,0 +1,54 @@
72ccf7
+/****************************************************************************
72ccf7
+**
72ccf7
+** Copyright (C) 2020 The Qt Company Ltd.
72ccf7
+** Contact: https://www.qt.io/licensing/
72ccf7
+**
72ccf7
+** This file is part of the test suite of the Qt Toolkit.
72ccf7
+**
72ccf7
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
72ccf7
+** Commercial License Usage
72ccf7
+** Licensees holding valid commercial Qt licenses may use this file in
72ccf7
+** accordance with the commercial license agreement provided with the
72ccf7
+** Software or, alternatively, in accordance with the terms contained in
72ccf7
+** a written agreement between you and The Qt Company. For licensing terms
72ccf7
+** and conditions see https://www.qt.io/terms-conditions. For further
72ccf7
+** information use the contact form at https://www.qt.io/contact-us.
72ccf7
+**
72ccf7
+** GNU General Public License Usage
72ccf7
+** Alternatively, this file may be used under the terms of the GNU
72ccf7
+** General Public License version 3 as published by the Free Software
72ccf7
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
72ccf7
+** included in the packaging of this file. Please review the following
72ccf7
+** information to ensure the GNU General Public License requirements will
72ccf7
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
72ccf7
+**
72ccf7
+** $QT_END_LICENSE$
72ccf7
+**
72ccf7
+****************************************************************************/
72ccf7
+
72ccf7
+import QtQuick 2.15
72ccf7
+
72ccf7
+Item {
72ccf7
+    property alias view: view
72ccf7
+
72ccf7
+    ListView {
72ccf7
+        id: view
72ccf7
+        model: 10
72ccf7
+        width: 200
72ccf7
+        height: 200
72ccf7
+
72ccf7
+        Rectangle {
72ccf7
+            anchors.fill: parent
72ccf7
+            color: "transparent"
72ccf7
+            border.color: "darkorange"
72ccf7
+        }
72ccf7
+
72ccf7
+        delegate: Rectangle {
72ccf7
+            width: 100
72ccf7
+            height: 100
72ccf7
+            Text {
72ccf7
+                text: modelData
72ccf7
+            }
72ccf7
+        }
72ccf7
+    }
72ccf7
+}
72ccf7
Index: qtdeclarative-everywhere-src-5.15.2/tests/auto/quick/qquicklistview2/data/maxYExtent.qml
72ccf7
===================================================================
72ccf7
--- /dev/null
72ccf7
+++ qtdeclarative-everywhere-src-5.15.2/tests/auto/quick/qquicklistview2/data/maxYExtent.qml
72ccf7
@@ -0,0 +1,55 @@
72ccf7
+/****************************************************************************
72ccf7
+**
72ccf7
+** Copyright (C) 2020 The Qt Company Ltd.
72ccf7
+** Contact: https://www.qt.io/licensing/
72ccf7
+**
72ccf7
+** This file is part of the test suite of the Qt Toolkit.
72ccf7
+**
72ccf7
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
72ccf7
+** Commercial License Usage
72ccf7
+** Licensees holding valid commercial Qt licenses may use this file in
72ccf7
+** accordance with the commercial license agreement provided with the
72ccf7
+** Software or, alternatively, in accordance with the terms contained in
72ccf7
+** a written agreement between you and The Qt Company. For licensing terms
72ccf7
+** and conditions see https://www.qt.io/terms-conditions. For further
72ccf7
+** information use the contact form at https://www.qt.io/contact-us.
72ccf7
+**
72ccf7
+** GNU General Public License Usage
72ccf7
+** Alternatively, this file may be used under the terms of the GNU
72ccf7
+** General Public License version 3 as published by the Free Software
72ccf7
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
72ccf7
+** included in the packaging of this file. Please review the following
72ccf7
+** information to ensure the GNU General Public License requirements will
72ccf7
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
72ccf7
+**
72ccf7
+** $QT_END_LICENSE$
72ccf7
+**
72ccf7
+****************************************************************************/
72ccf7
+
72ccf7
+import QtQuick 2.15
72ccf7
+
72ccf7
+Item {
72ccf7
+    property alias view: view
72ccf7
+
72ccf7
+    ListView {
72ccf7
+        id: view
72ccf7
+        model: 10
72ccf7
+        width: 200
72ccf7
+        height: 200
72ccf7
+        orientation: ListView.Horizontal
72ccf7
+
72ccf7
+        Rectangle {
72ccf7
+            anchors.fill: parent
72ccf7
+            color: "transparent"
72ccf7
+            border.color: "darkorange"
72ccf7
+        }
72ccf7
+
72ccf7
+        delegate: Rectangle {
72ccf7
+            width: 100
72ccf7
+            height: 100
72ccf7
+            Text {
72ccf7
+                text: modelData
72ccf7
+            }
72ccf7
+        }
72ccf7
+    }
72ccf7
+}
72ccf7
Index: qtdeclarative-everywhere-src-5.15.2/tests/auto/quick/qquicklistview2/qquicklistview2.pro
72ccf7
===================================================================
72ccf7
--- /dev/null
72ccf7
+++ qtdeclarative-everywhere-src-5.15.2/tests/auto/quick/qquicklistview2/qquicklistview2.pro
72ccf7
@@ -0,0 +1,12 @@
72ccf7
+CONFIG += testcase
72ccf7
+TARGET = tst_qquicklistview2
72ccf7
+macos:CONFIG -= app_bundle
72ccf7
+
72ccf7
+SOURCES += tst_qquicklistview2.cpp
72ccf7
+
72ccf7
+include (../../shared/util.pri)
72ccf7
+include (../shared/util.pri)
72ccf7
+
72ccf7
+TESTDATA = data/*
72ccf7
+
72ccf7
+QT += core-private gui-private qml-private quick-private testlib qmltest
72ccf7
Index: qtdeclarative-everywhere-src-5.15.2/tests/auto/quick/qquicklistview2/tst_qquicklistview2.cpp
72ccf7
===================================================================
72ccf7
--- /dev/null
72ccf7
+++ qtdeclarative-everywhere-src-5.15.2/tests/auto/quick/qquicklistview2/tst_qquicklistview2.cpp
72ccf7
@@ -0,0 +1,114 @@
72ccf7
+/****************************************************************************
72ccf7
+**
72ccf7
+** Copyright (C) 2020 The Qt Company Ltd.
72ccf7
+** Contact: https://www.qt.io/licensing/
72ccf7
+**
72ccf7
+** This file is part of the test suite of the Qt Toolkit.
72ccf7
+**
72ccf7
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
72ccf7
+** Commercial License Usage
72ccf7
+** Licensees holding valid commercial Qt licenses may use this file in
72ccf7
+** accordance with the commercial license agreement provided with the
72ccf7
+** Software or, alternatively, in accordance with the terms contained in
72ccf7
+** a written agreement between you and The Qt Company. For licensing terms
72ccf7
+** and conditions see https://www.qt.io/terms-conditions. For further
72ccf7
+** information use the contact form at https://www.qt.io/contact-us.
72ccf7
+**
72ccf7
+** GNU General Public License Usage
72ccf7
+** Alternatively, this file may be used under the terms of the GNU
72ccf7
+** General Public License version 3 as published by the Free Software
72ccf7
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
72ccf7
+** included in the packaging of this file. Please review the following
72ccf7
+** information to ensure the GNU General Public License requirements will
72ccf7
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
72ccf7
+**
72ccf7
+** $QT_END_LICENSE$
72ccf7
+**
72ccf7
+****************************************************************************/
72ccf7
+
72ccf7
+#include <QtTest/QtTest>
72ccf7
+#include <QtQuickTest/QtQuickTest>
72ccf7
+#include <QtQml/qqmlapplicationengine.h>
72ccf7
+#include <QtQuick/qquickview.h>
72ccf7
+#include <QtQuick/private/qquicklistview_p.h>
72ccf7
+
72ccf7
+#include "../../shared/util.h"
72ccf7
+#include "../shared/viewtestutil.h"
72ccf7
+
72ccf7
+using namespace QQuickViewTestUtil;
72ccf7
+
72ccf7
+class tst_QQuickListView2 : public QQmlDataTest
72ccf7
+{
72ccf7
+    Q_OBJECT
72ccf7
+
72ccf7
+public:
72ccf7
+    tst_QQuickListView2();
72ccf7
+
72ccf7
+private slots:
72ccf7
+    void maxExtent_data();
72ccf7
+    void maxExtent();
72ccf7
+};
72ccf7
+
72ccf7
+tst_QQuickListView2::tst_QQuickListView2()
72ccf7
+{
72ccf7
+}
72ccf7
+
72ccf7
+class FriendlyItemView : public QQuickItemView
72ccf7
+{
72ccf7
+    friend class ItemViewAccessor;
72ccf7
+};
72ccf7
+
72ccf7
+class ItemViewAccessor
72ccf7
+{
72ccf7
+public:
72ccf7
+    ItemViewAccessor(QQuickItemView *itemView) :
72ccf7
+        mItemView(reinterpret_cast<FriendlyItemView*>(itemView))
72ccf7
+    {
72ccf7
+    }
72ccf7
+
72ccf7
+    qreal maxXExtent() const
72ccf7
+    {
72ccf7
+        return mItemView->maxXExtent();
72ccf7
+    }
72ccf7
+
72ccf7
+    qreal maxYExtent() const
72ccf7
+    {
72ccf7
+        return mItemView->maxYExtent();
72ccf7
+    }
72ccf7
+
72ccf7
+private:
72ccf7
+    FriendlyItemView *mItemView = nullptr;
72ccf7
+};
72ccf7
+
72ccf7
+void tst_QQuickListView2::maxExtent_data()
72ccf7
+{
72ccf7
+    QTest::addColumn<QString>("qmlFilePath");
72ccf7
+
72ccf7
+    QTest::addRow("maxXExtent") << "maxXExtent.qml";
72ccf7
+    QTest::addRow("maxYExtent") << "maxYExtent.qml";
72ccf7
+}
72ccf7
+
72ccf7
+void tst_QQuickListView2::maxExtent()
72ccf7
+{
72ccf7
+    QFETCH(QString, qmlFilePath);
72ccf7
+
72ccf7
+    QScopedPointer<QQuickView> window(createView());
72ccf7
+    QVERIFY(window);
72ccf7
+    window->setSource(testFileUrl(qmlFilePath));
72ccf7
+    QVERIFY2(window->status() == QQuickView::Ready, qPrintable(QDebug::toString(window->errors())));
72ccf7
+    window->resize(640, 480);
72ccf7
+    window->show();
72ccf7
+    QVERIFY(QTest::qWaitForWindowExposed(window.data()));
72ccf7
+
72ccf7
+    QQuickListView *view = window->rootObject()->property("view").value<QQuickListView*>();
72ccf7
+    QVERIFY(view);
72ccf7
+    ItemViewAccessor viewAccessor(view);
72ccf7
+    if (view->orientation() == QQuickListView::Vertical)
72ccf7
+        QCOMPARE(viewAccessor.maxXExtent(), 0);
72ccf7
+    else if (view->orientation() == QQuickListView::Horizontal)
72ccf7
+        QCOMPARE(viewAccessor.maxYExtent(), 0);
72ccf7
+}
72ccf7
+
72ccf7
+QTEST_MAIN(tst_QQuickListView2)
72ccf7
+
72ccf7
+#include "tst_qquicklistview2.moc"
72ccf7
Index: qtdeclarative-everywhere-src-5.15.2/tests/auto/quick/quick.pro
72ccf7
===================================================================
72ccf7
--- qtdeclarative-everywhere-src-5.15.2.orig/tests/auto/quick/quick.pro
72ccf7
+++ qtdeclarative-everywhere-src-5.15.2/tests/auto/quick/quick.pro
72ccf7
@@ -67,6 +67,7 @@ QUICKTESTS += \
72ccf7
     qquickitem2 \
72ccf7
     qquickitemlayer \
72ccf7
     qquicklistview \
72ccf7
+    qquicklistview2 \
72ccf7
     qquicktableview \
72ccf7
     qquickloader \
72ccf7
     qquickmousearea \