aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--examples/quick/scenegraph/metaltextureimport/doc/src/metaltextureimport.qdoc2
-rw-r--r--examples/quick/scenegraph/rendernode/customrenderitem.cpp4
-rw-r--r--src/imports/labsmodels/plugin.cpp2
-rw-r--r--src/imports/layouts/qquicklinearlayout.cpp18
-rw-r--r--src/imports/models/plugin.cpp17
-rw-r--r--src/imports/testlib/TestCase.qml8
-rw-r--r--src/particles/qquickparticleextruder.cpp2
-rw-r--r--src/qml/doc/qtqml.qdocconf12
-rw-r--r--src/qml/doc/src/qmlfunctions.qdoc1
-rw-r--r--src/qml/jsruntime/qv4runtime.cpp9
-rw-r--r--src/qml/qml/qqmlengine.cpp12
-rw-r--r--src/qml/qml/qqmlextensionplugin.cpp2
-rw-r--r--src/qml/qml/qqmlinfo.cpp3
-rw-r--r--src/qml/qml/qqmlmetatype.cpp8
-rw-r--r--src/qml/qml/qqmltype.cpp36
-rw-r--r--src/qml/qml/qqmltype_p.h1
-rw-r--r--src/qml/qml/qqmltype_p_p.h12
-rw-r--r--src/qml/qml/qqmlvmemetaobject.cpp55
-rw-r--r--src/qml/qml/qqmlvmemetaobject_p.h18
-rw-r--r--src/qml/qmldirparser/qqmldirparser_p.h2
-rw-r--r--src/qmlmodels/doc/images/listmodel-nested.png (renamed from src/qml/doc/images/listmodel-nested.png)bin7493 -> 7493 bytes
-rw-r--r--src/qmlmodels/doc/images/listmodel.png (renamed from src/qml/doc/images/listmodel.png)bin3407 -> 3407 bytes
-rw-r--r--src/qmlmodels/doc/images/objectmodel.png (renamed from src/qml/doc/images/objectmodel.png)bin347 -> 347 bytes
-rw-r--r--src/qmlmodels/doc/qtqmlmodels.qdocconf13
-rw-r--r--src/qmlmodels/qqmldelegatemodel.cpp8
-rw-r--r--src/qmlmodels/qqmldelegatemodel_p_p.h2
-rw-r--r--src/qmlmodels/qqmllistmodel.cpp4
-rw-r--r--src/qmlmodels/qqmltableinstancemodel.cpp6
-rw-r--r--src/qmlmodels/qqmltableinstancemodel_p.h3
-rw-r--r--src/qmlworkerscript/doc/qtqmlworkerscript.qdocconf6
-rw-r--r--src/qmlworkerscript/doc/snippets/qml/workerscript/script.mjs (renamed from src/qml/doc/snippets/qml/workerscript/script.mjs)0
-rw-r--r--src/qmlworkerscript/doc/snippets/qml/workerscript/workerscript.qml (renamed from src/qml/doc/snippets/qml/workerscript/workerscript.qml)0
-rw-r--r--src/quick/doc/qtquick.qdocconf5
-rw-r--r--src/quick/doc/snippets/cmake-macros/examples.cmake2
-rw-r--r--src/quick/doc/src/concepts/visualcanvas/adaptations.qdoc2
-rw-r--r--src/quick/doc/src/guidelines/qtquick-bestpractices.qdoc37
-rw-r--r--src/quick/handlers/qquickwheelhandler.cpp16
-rw-r--r--src/quick/items/qquickaccessibleattached.cpp13
-rw-r--r--src/quick/items/qquickaccessibleattached_p.h5
-rw-r--r--src/quick/items/qquickitem.cpp4
-rw-r--r--src/quick/items/qquickitemview.cpp6
-rw-r--r--src/quick/items/qquickitemview_p_p.h6
-rw-r--r--src/quick/items/qquicklistview.cpp3
-rw-r--r--src/quick/items/qquicktableview.cpp68
-rw-r--r--src/quick/items/qquicktableview_p_p.h6
-rw-r--r--src/quick/items/qquickview.cpp9
-rw-r--r--src/quick/items/qquickwindow.cpp2
-rw-r--r--src/quick/scenegraph/coreapi/qsgmaterialrhishader.cpp2
-rw-r--r--src/quick/scenegraph/coreapi/qsgtexture.cpp4
-rw-r--r--src/quick/scenegraph/shaders/outlinedtext.vert4
-rw-r--r--src/quick/scenegraph/shaders/outlinedtext_core.vert4
-rw-r--r--src/quick/scenegraph/shaders/styledtext.vert3
-rw-r--r--src/quick/scenegraph/shaders/styledtext_core.vert3
-rw-r--r--src/quick/scenegraph/shaders/textmask.vert3
-rw-r--r--src/quick/scenegraph/shaders/textmask_core.vert3
-rw-r--r--src/quick/util/qquickpath.cpp8
-rw-r--r--tests/auto/qmltest/events/tst_drag.qml132
-rw-r--r--tests/auto/quick/qquickaccessible/tst_qquickaccessible.cpp34
-rw-r--r--tests/auto/quick/qquicklayouts/data/tst_gridlayout.qml33
-rw-r--r--tests/auto/quick/qquicktableview/data/plaintableview.qml1
-rw-r--r--tests/auto/quick/qquicktableview/qquicktableview.pro2
-rw-r--r--tests/auto/quick/qquicktableview/testmodel.h33
-rw-r--r--tests/auto/quick/qquicktableview/tst_qquicktableview.cpp87
-rw-r--r--tests/auto/quick/qquicktextedit/BLACKLIST4
-rw-r--r--tests/libfuzzer/qml/jsapi/evaluate/main.cpp2
-rw-r--r--tests/manual/scenegraph_lancelot/data/text/text_style2.qml37
-rw-r--r--tests/manual/scenegraph_lancelot/scenegrabber/scenegrabber.pro1
-rw-r--r--tests/manual/scenegraph_lancelot/scenegraph/scenegraph.pro4
-rw-r--r--tests/manual/scenegraph_lancelot/scenegraph/tst_scenegraph.cpp14
69 files changed, 684 insertions, 184 deletions
diff --git a/examples/quick/scenegraph/metaltextureimport/doc/src/metaltextureimport.qdoc b/examples/quick/scenegraph/metaltextureimport/doc/src/metaltextureimport.qdoc
index 2a584c26cc..55cbcd8f2e 100644
--- a/examples/quick/scenegraph/metaltextureimport/doc/src/metaltextureimport.qdoc
+++ b/examples/quick/scenegraph/metaltextureimport/doc/src/metaltextureimport.qdoc
@@ -29,7 +29,7 @@
\example scenegraph/metaltextureimport
\title Scene Graph - Metal Texture Import
\ingroup qtquickexamples
- \brief Shows how to use a texture created directly with Metal
+ \brief Shows how to use a texture created directly with Metal.
\image metaltextureimport-example.jpg
diff --git a/examples/quick/scenegraph/rendernode/customrenderitem.cpp b/examples/quick/scenegraph/rendernode/customrenderitem.cpp
index e55cf0a2f4..5f51522c47 100644
--- a/examples/quick/scenegraph/rendernode/customrenderitem.cpp
+++ b/examples/quick/scenegraph/rendernode/customrenderitem.cpp
@@ -53,8 +53,12 @@
#include <QSGRendererInterface>
#include "openglrenderer.h"
+#ifdef Q_OS_MACOS
#include "metalrenderer.h"
+#endif
+#if QT_CONFIG(d3d12)
#include "d3d12renderer.h"
+#endif
#include "softwarerenderer.h"
//! [1]
diff --git a/src/imports/labsmodels/plugin.cpp b/src/imports/labsmodels/plugin.cpp
index f1d1dd20b0..8458133c79 100644
--- a/src/imports/labsmodels/plugin.cpp
+++ b/src/imports/labsmodels/plugin.cpp
@@ -56,7 +56,7 @@ QT_BEGIN_NAMESPACE
\qmlmodule Qt.labs.qmlmodels 1.0
\title Qt QML Models experimental QML Types
\ingroup qmlmodules
- \brief Provides QML experimental types for data models
+ \brief Provides QML experimental types for data models.
\since 5.12
This QML module contains experimental QML types related to data models.
diff --git a/src/imports/layouts/qquicklinearlayout.cpp b/src/imports/layouts/qquicklinearlayout.cpp
index 2e3b12064b..c8d2ac5eb2 100644
--- a/src/imports/layouts/qquicklinearlayout.cpp
+++ b/src/imports/layouts/qquicklinearlayout.cpp
@@ -645,6 +645,7 @@ void QQuickGridLayout::insertLayoutItems()
int &nextColumn = nextCellPos[0];
int &nextRow = nextCellPos[1];
+ const QSize gridSize(columns(), rows());
const int flowOrientation = flow();
int &flowColumn = nextCellPos[flowOrientation];
int &flowRow = nextCellPos[1 - flowOrientation];
@@ -677,8 +678,21 @@ void QQuickGridLayout::insertLayoutItems()
// the unspecified component of the cell position should default to 0
// The getters do this for us, as they will return 0 for an
// unset (or negative) value.
- row = info->row();
- column = info->column();
+ // In addition, if \a rows is less than Layout.row, treat Layout.row as if it was not set
+ // This will basically make it find the next available cell (potentially wrapping to
+ // the next line). Likewise for an invalid Layout.column
+
+ if (gridSize.height() >= 0 && row >= gridSize.height()) {
+ qmlWarning(child) << QString::fromLatin1("Layout: row (%1) should be less than the number of rows (%2)").arg(info->row()).arg(rows());
+ } else {
+ row = info->row();
+ }
+
+ if (gridSize.width() >= 0 && info->column() >= gridSize.width()) {
+ qmlWarning(child) << QString::fromLatin1("Layout: column (%1) should be less than the number of columns (%2)").arg(info->column()).arg(columns());
+ } else {
+ column = info->column();
+ }
}
rowSpan = info->rowSpan();
columnSpan = info->columnSpan();
diff --git a/src/imports/models/plugin.cpp b/src/imports/models/plugin.cpp
index 9fe63412f3..319321013e 100644
--- a/src/imports/models/plugin.cpp
+++ b/src/imports/models/plugin.cpp
@@ -59,8 +59,23 @@ QT_BEGIN_NAMESPACE
import QtQml.Models 2.\1
\endqml
- Note that QtQml.Models module started at version 2.1 to match the version
+ \note QtQml.Models module started at version 2.1 to match the version
of the parent module, \l{Qt QML}.
+
+ In addition, Qt.labs.qmlmodels provides experimental QML types for models.
+ To use these experimental types, import the module with the following line:
+
+ \qml
+ import Qt.labs.qmlmodels 1.0
+ \endqml
+
+ \section1 QML Types
+ \generatelist qmltypesbymodule QtQml.Models
+
+ \section1 Experimental QML Types
+ \generatelist qmltypesbymodule Qt.labs.qmlmodels
+
+ \noautolist
*/
diff --git a/src/imports/testlib/TestCase.qml b/src/imports/testlib/TestCase.qml
index 6e075d8792..fff375b49a 100644
--- a/src/imports/testlib/TestCase.qml
+++ b/src/imports/testlib/TestCase.qml
@@ -1425,8 +1425,12 @@ Item {
ddy = 0
mousePress(item, x, y, button, modifiers, delay)
- //trigger dragging
- mouseMove(item, x + util.dragThreshold + 1, y + util.dragThreshold + 1, moveDelay, button)
+
+ // Trigger dragging by dragging past the drag threshold, but making sure to only drag
+ // along a certain axis if a distance greater than zero was given for that axis.
+ var dragTriggerXDistance = dx > 0 ? (util.dragThreshold + 1) : 0
+ var dragTriggerYDistance = dy > 0 ? (util.dragThreshold + 1) : 0
+ mouseMove(item, x + dragTriggerXDistance, y + dragTriggerYDistance, moveDelay, button)
if (ddx > 0 || ddy > 0) {
mouseMove(item, x + ddx, y + ddy, moveDelay, button)
mouseMove(item, x + 2*ddx, y + 2*ddy, moveDelay, button)
diff --git a/src/particles/qquickparticleextruder.cpp b/src/particles/qquickparticleextruder.cpp
index f56e288e09..ea64a79563 100644
--- a/src/particles/qquickparticleextruder.cpp
+++ b/src/particles/qquickparticleextruder.cpp
@@ -43,7 +43,7 @@
QT_BEGIN_NAMESPACE
/*!
- \qmltype Shape
+ \qmltype ParticleExtruder
\instantiates QQuickParticleExtruder
\inqmlmodule QtQuick.Particles
\brief For specifying an area for affectors and emitters.
diff --git a/src/qml/doc/qtqml.qdocconf b/src/qml/doc/qtqml.qdocconf
index 74d0a3b27c..07ab974289 100644
--- a/src/qml/doc/qtqml.qdocconf
+++ b/src/qml/doc/qtqml.qdocconf
@@ -34,20 +34,14 @@ qhp.QtQml.subprojects.qmltypes.sortPages = true
tagfile = ../../../doc/qtqml/qtqml.tags
-depends += qtcore qtgui qtquick qtdoc qtlinguist qmake qtscript qtwidgets qtxmlpatterns qtquickcontrols
+depends += qtcore qtqmlmodels qtqmlworkerscript qtgui qtquick qtdoc qtlinguist qmake qtscript qtwidgets qtxmlpatterns qtquickcontrols
headerdirs += .. \
- ../../imports/models \
- ../../qmlmodels \
- ../../qml \
- ../../qmlworkerscript
+ ../../qml
sourcedirs += .. \
- ../../imports/models \
../../imports/statemachine \
- ../../qmlmodels \
- ../../qml \
- ../../qmlworkerscript
+ ../../qml
exampledirs += ../../../examples/qml \
../ \
diff --git a/src/qml/doc/src/qmlfunctions.qdoc b/src/qml/doc/src/qmlfunctions.qdoc
index b2d322465d..67c0f6bb25 100644
--- a/src/qml/doc/src/qmlfunctions.qdoc
+++ b/src/qml/doc/src/qmlfunctions.qdoc
@@ -275,6 +275,7 @@
/*!
\fn int qmlRegisterAnonymousType(const char *uri, int versionMajor)
+ \relates QQmlEngine
This template function registers the C++ type in the QML system as an anonymous type. The
resulting QML type does not have a name. Therefore, instances of this type cannot be created from
diff --git a/src/qml/jsruntime/qv4runtime.cpp b/src/qml/jsruntime/qv4runtime.cpp
index 21a0017728..e47a7a0b46 100644
--- a/src/qml/jsruntime/qv4runtime.cpp
+++ b/src/qml/jsruntime/qv4runtime.cpp
@@ -408,6 +408,15 @@ QV4::ReturnedValue Runtime::In::call(ExecutionEngine *engine, const Value &left,
double RuntimeHelpers::stringToNumber(const QString &string)
{
+ // The actual maximum valid length is certainly shorter, but due to the sheer number of
+ // different number formatting variants, we rather err on the side of caution here.
+ // For example, you can have up to 772 valid decimal digits left of the dot, as stated in the
+ // libdoubleconversion sources. The same maximum value would be represented by roughly 3.5 times
+ // as many binary digits.
+ const int excessiveLength = 16 * 1024;
+ if (string.length() > excessiveLength)
+ return qQNaN();
+
const QStringRef s = QStringRef(&string).trimmed();
if (s.startsWith(QLatin1Char('0'))) {
int base = -1;
diff --git a/src/qml/qml/qqmlengine.cpp b/src/qml/qml/qqmlengine.cpp
index b84a9b843c..1f4e5528c7 100644
--- a/src/qml/qml/qqmlengine.cpp
+++ b/src/qml/qml/qqmlengine.cpp
@@ -1624,6 +1624,9 @@ static QObject *resolveAttachedProperties(QQmlAttachedPropertiesFunc pf, QQmlDat
}
#if QT_DEPRECATED_SINCE(5, 14)
+QT_WARNING_PUSH
+QT_WARNING_DISABLE_DEPRECATED
+
QObject *qmlAttachedPropertiesObjectById(int id, const QObject *object, bool create)
{
QQmlData *data = QQmlData::get(object, create);
@@ -1634,7 +1637,9 @@ QObject *qmlAttachedPropertiesObjectById(int id, const QObject *object, bool cre
return nullptr;
QQmlEnginePrivate *engine = QQmlEnginePrivate::get(data->context);
- return resolveAttachedProperties(QQmlMetaType::attachedPropertiesFuncById(engine, id), data,
+
+ const QQmlType type = QQmlMetaType::qmlType(id, QQmlMetaType::TypeIdCategory::QmlType);
+ return resolveAttachedProperties(type.attachedPropertiesFunction(engine), data,
const_cast<QObject *>(object), create);
}
@@ -1651,6 +1656,8 @@ QObject *qmlAttachedPropertiesObject(int *idCache, const QObject *object,
return qmlAttachedPropertiesObjectById(*idCache, object, create);
}
+
+QT_WARNING_POP
#endif
QQmlAttachedPropertiesFunc qmlAttachedPropertiesFunction(QObject *object,
@@ -1679,6 +1686,8 @@ QObject *qmlAttachedPropertiesObject(QObject *object, QQmlAttachedPropertiesFunc
} // namespace QtQml
#if QT_DEPRECATED_SINCE(5, 1)
+QT_WARNING_PUSH
+QT_WARNING_DISABLE_DEPRECATED
// Also define symbols outside namespace to keep binary compatibility with Qt 5.0
@@ -1709,6 +1718,7 @@ Q_QML_EXPORT QObject *qmlAttachedPropertiesObject(int *idCache, const QObject *o
return QtQml::qmlAttachedPropertiesObject(idCache, object, attachedMetaObject, create);
}
+QT_WARNING_POP
#endif // QT_DEPRECATED_SINCE(5, 1)
class QQmlDataExtended {
diff --git a/src/qml/qml/qqmlextensionplugin.cpp b/src/qml/qml/qqmlextensionplugin.cpp
index 26364661a8..7a62c967e7 100644
--- a/src/qml/qml/qqmlextensionplugin.cpp
+++ b/src/qml/qml/qqmlextensionplugin.cpp
@@ -127,8 +127,6 @@ void QQmlExtensionPlugin::initializeEngine(QQmlEngine *engine, const char *uri)
}
/*!
- \fn void QQmlEngineExtensionPlugin::initializeEngine(QQmlEngine *engine, const char *uri)
-
Initializes the extension from the \a uri using the \a engine. Here an application
plugin might, for example, expose some data or objects to QML,
as context properties on the engine's root context.
diff --git a/src/qml/qml/qqmlinfo.cpp b/src/qml/qml/qqmlinfo.cpp
index 2bfd2d5bb4..dd401bdb20 100644
--- a/src/qml/qml/qqmlinfo.cpp
+++ b/src/qml/qml/qqmlinfo.cpp
@@ -57,7 +57,6 @@ QT_BEGIN_NAMESPACE
/*!
\fn QQmlInfo QtQml::qmlDebug(const QObject *object)
- \relates QtQml
\since 5.9
Prints debug messages that include the file and line number for the
@@ -91,7 +90,6 @@ QT_BEGIN_NAMESPACE
/*!
\fn QQmlInfo QtQml::qmlInfo(const QObject *object)
- \relates QtQml
Prints informational messages that include the file and line number for the
specified QML \a object.
@@ -119,7 +117,6 @@ QT_BEGIN_NAMESPACE
/*!
\fn QQmlInfo QtQml::qmlWarning(const QObject *object)
- \relates QtQml
\since 5.9
Prints warning messages that include the file and line number for the
diff --git a/src/qml/qml/qqmlmetatype.cpp b/src/qml/qml/qqmlmetatype.cpp
index b8c17c9374..14e49ed4eb 100644
--- a/src/qml/qml/qqmlmetatype.cpp
+++ b/src/qml/qml/qqmlmetatype.cpp
@@ -927,11 +927,11 @@ int QQmlMetaType::attachedPropertiesFuncId(QQmlEnginePrivate *engine, const QMet
for (auto it = data->metaObjectToType.constFind(mo), end = data->metaObjectToType.constEnd();
it != end && it.key() == mo; ++it) {
- const QQmlType type(it.value());
- if (type.attachedPropertiesFunction(engine))
- return type.attachedPropertiesId(engine);
+ if (const QQmlTypePrivate *type = it.value()) {
+ if (const QQmlTypePrivate *base = type->attachedPropertiesBase(engine))
+ return base->index;
+ }
}
-
return -1;
}
diff --git a/src/qml/qml/qqmltype.cpp b/src/qml/qml/qqmltype.cpp
index 874bcd4bca..4a211ffa53 100644
--- a/src/qml/qml/qqmltype.cpp
+++ b/src/qml/qml/qqmltype.cpp
@@ -618,28 +618,16 @@ int QQmlType::metaObjectRevision() const
QQmlAttachedPropertiesFunc QQmlType::attachedPropertiesFunction(QQmlEnginePrivate *engine) const
{
- if (!d)
- return nullptr;
- if (d->regType == CppType)
- return d->extraData.cd->attachedPropertiesFunc;
-
- QQmlType base;
- if (d->regType == CompositeType)
- base = d->resolveCompositeBaseType(engine);
- return base.attachedPropertiesFunction(engine);
+ if (const QQmlTypePrivate *base = d->attachedPropertiesBase(engine))
+ return base->extraData.cd->attachedPropertiesFunc;
+ return nullptr;
}
const QMetaObject *QQmlType::attachedPropertiesType(QQmlEnginePrivate *engine) const
{
- if (!d)
- return nullptr;
- if (d->regType == CppType)
- return d->extraData.cd->attachedPropertiesType;
-
- QQmlType base;
- if (d->regType == CompositeType)
- base = d->resolveCompositeBaseType(engine);
- return base.attachedPropertiesType(engine);
+ if (const QQmlTypePrivate *base = d->attachedPropertiesBase(engine))
+ return base->extraData.cd->attachedPropertiesType;
+ return nullptr;
}
#if QT_DEPRECATED_SINCE(5, 14)
@@ -650,15 +638,9 @@ Qt 4.7 and QtQuick 1.0).
*/
int QQmlType::attachedPropertiesId(QQmlEnginePrivate *engine) const
{
- if (!d)
- return -1;
- if (d->regType == CppType)
- return d->extraData.cd->attachedPropertiesType ? d->index : -1;
-
- QQmlType base;
- if (d->regType == CompositeType)
- base = d->resolveCompositeBaseType(engine);
- return base.attachedPropertiesId(engine);
+ if (const QQmlTypePrivate *base = d->attachedPropertiesBase(engine))
+ return base->index;
+ return -1;
}
#endif
diff --git a/src/qml/qml/qqmltype_p.h b/src/qml/qml/qqmltype_p.h
index ec27b38a73..af134b21f1 100644
--- a/src/qml/qml/qqmltype_p.h
+++ b/src/qml/qml/qqmltype_p.h
@@ -182,6 +182,7 @@ public:
};
private:
+ friend class QQmlTypePrivate;
friend uint qHash(const QQmlType &t, uint seed);
QQmlRefPointer<const QQmlTypePrivate> d;
};
diff --git a/src/qml/qml/qqmltype_p_p.h b/src/qml/qml/qqmltype_p_p.h
index 6a2d961de8..51f776178c 100644
--- a/src/qml/qml/qqmltype_p_p.h
+++ b/src/qml/qml/qqmltype_p_p.h
@@ -82,6 +82,18 @@ public:
}
}
+ const QQmlTypePrivate *attachedPropertiesBase(QQmlEnginePrivate *engine) const
+ {
+ for (const QQmlTypePrivate *d = this; d; d = d->resolveCompositeBaseType(engine).d.data()) {
+ if (d->regType == QQmlType::CppType)
+ return d->extraData.cd->attachedPropertiesType ? d : nullptr;
+
+ if (d->regType != QQmlType::CompositeType)
+ return nullptr;
+ }
+ return nullptr;
+ }
+
bool isComposite() const
{
return regType == QQmlType::CompositeType || regType == QQmlType::CompositeSingletonType;
diff --git a/src/qml/qml/qqmlvmemetaobject.cpp b/src/qml/qml/qqmlvmemetaobject.cpp
index 9b5490b6e5..4954ec7994 100644
--- a/src/qml/qml/qqmlvmemetaobject.cpp
+++ b/src/qml/qml/qqmlvmemetaobject.cpp
@@ -401,57 +401,20 @@ void QQmlVMEMetaObject::writeProperty(int id, double v)
void QQmlVMEMetaObject::writeProperty(int id, const QString& v)
{
QV4::MemberData *md = propertyAndMethodStorageAsMemberData();
- if (md)
- md->set(engine, id, engine->newString(v));
-}
-
-void QQmlVMEMetaObject::writeProperty(int id, const QUrl& v)
-{
- QV4::MemberData *md = propertyAndMethodStorageAsMemberData();
- if (md)
- md->set(engine, id, engine->newVariantObject(QVariant::fromValue(v)));
-}
-
-void QQmlVMEMetaObject::writeProperty(int id, const QDate& v)
-{
- QV4::MemberData *md = propertyAndMethodStorageAsMemberData();
- if (md)
- md->set(engine, id, engine->newVariantObject(QVariant::fromValue(v)));
-}
-
-void QQmlVMEMetaObject::writeProperty(int id, const QDateTime& v)
-{
- QV4::MemberData *md = propertyAndMethodStorageAsMemberData();
- if (md)
- md->set(engine, id, engine->newVariantObject(QVariant::fromValue(v)));
-}
-
-void QQmlVMEMetaObject::writeProperty(int id, const QPointF& v)
-{
- QV4::MemberData *md = propertyAndMethodStorageAsMemberData();
- if (md)
- md->set(engine, id, engine->newVariantObject(QVariant::fromValue(v)));
-}
-
-void QQmlVMEMetaObject::writeProperty(int id, const QSizeF& v)
-{
- QV4::MemberData *md = propertyAndMethodStorageAsMemberData();
- if (md)
- md->set(engine, id, engine->newVariantObject(QVariant::fromValue(v)));
-}
-
-void QQmlVMEMetaObject::writeProperty(int id, const QRectF& v)
-{
- QV4::MemberData *md = propertyAndMethodStorageAsMemberData();
- if (md)
- md->set(engine, id, engine->newVariantObject(QVariant::fromValue(v)));
+ if (md) {
+ QV4::Scope scope(engine);
+ QV4::Scoped<QV4::MemberData>(scope, md)->set(engine, id, engine->newString(v));
+ }
}
void QQmlVMEMetaObject::writeProperty(int id, QObject* v)
{
QV4::MemberData *md = propertyAndMethodStorageAsMemberData();
- if (md)
- md->set(engine, id, QV4::Value::fromReturnedValue(QV4::QObjectWrapper::wrap(engine, v)));
+ if (md) {
+ QV4::Scope scope(engine);
+ QV4::Scoped<QV4::MemberData>(scope, md)->set(engine, id, QV4::Value::fromReturnedValue(
+ QV4::QObjectWrapper::wrap(engine, v)));
+ }
QQmlVMEVariantQObjectPtr *guard = getQObjectGuardForProperty(id);
if (v && !guard) {
diff --git a/src/qml/qml/qqmlvmemetaobject_p.h b/src/qml/qml/qqmlvmemetaobject_p.h
index 5025987586..58332ff7a8 100644
--- a/src/qml/qml/qqmlvmemetaobject_p.h
+++ b/src/qml/qml/qqmlvmemetaobject_p.h
@@ -194,12 +194,18 @@ public:
void writeProperty(int id, bool v);
void writeProperty(int id, double v);
void writeProperty(int id, const QString& v);
- void writeProperty(int id, const QPointF& v);
- void writeProperty(int id, const QSizeF& v);
- void writeProperty(int id, const QUrl& v);
- void writeProperty(int id, const QDate& v);
- void writeProperty(int id, const QDateTime& v);
- void writeProperty(int id, const QRectF& v);
+
+ template<typename VariantCompatible>
+ void writeProperty(int id, const VariantCompatible &v)
+ {
+ QV4::MemberData *md = propertyAndMethodStorageAsMemberData();
+ if (md) {
+ QV4::Scope scope(engine);
+ QV4::Scoped<QV4::MemberData>(scope, md)->set(engine, id, engine->newVariantObject(
+ QVariant::fromValue(v)));
+ }
+ }
+
void writeProperty(int id, QObject *v);
void ensureQObjectWrapper();
diff --git a/src/qml/qmldirparser/qqmldirparser_p.h b/src/qml/qmldirparser/qqmldirparser_p.h
index c9d77532c8..0b2506d96d 100644
--- a/src/qml/qmldirparser/qqmldirparser_p.h
+++ b/src/qml/qmldirparser/qqmldirparser_p.h
@@ -75,7 +75,7 @@ public:
static void checkNonRelative(const char *item, const QString &typeName, const QString &fileName)
{
- if (fileName.startsWith(QLatin1Char('/')) || fileName.contains(QLatin1Char(':'))) {
+ if (fileName.startsWith(QLatin1Char('/'))) {
qWarning() << item << typeName
<< "is specified with non-relative URL" << fileName << "in a qmldir file."
<< "URLs in qmldir files should be relative to the qmldir file's directory.";
diff --git a/src/qml/doc/images/listmodel-nested.png b/src/qmlmodels/doc/images/listmodel-nested.png
index ee7ffba67a..ee7ffba67a 100644
--- a/src/qml/doc/images/listmodel-nested.png
+++ b/src/qmlmodels/doc/images/listmodel-nested.png
Binary files differ
diff --git a/src/qml/doc/images/listmodel.png b/src/qmlmodels/doc/images/listmodel.png
index 7ab1771f15..7ab1771f15 100644
--- a/src/qml/doc/images/listmodel.png
+++ b/src/qmlmodels/doc/images/listmodel.png
Binary files differ
diff --git a/src/qml/doc/images/objectmodel.png b/src/qmlmodels/doc/images/objectmodel.png
index 5e6d1325b2..5e6d1325b2 100644
--- a/src/qml/doc/images/objectmodel.png
+++ b/src/qmlmodels/doc/images/objectmodel.png
Binary files differ
diff --git a/src/qmlmodels/doc/qtqmlmodels.qdocconf b/src/qmlmodels/doc/qtqmlmodels.qdocconf
index a4153f4a53..3364988559 100644
--- a/src/qmlmodels/doc/qtqmlmodels.qdocconf
+++ b/src/qmlmodels/doc/qtqmlmodels.qdocconf
@@ -23,15 +23,18 @@ qhp.QtQmlModels.sortPages = true
tagfile = qtqmlmodels.tags
-depends += qtcore qtqml qtdoc
+depends += qtcore qtqml qtquick qtdoc qtqmlworkerscript qtquickcontrols qtxmlpatterns
-headerdirs += ..
+headerdirs += .. \
+ ../../imports/labsmodels
sourcedirs += .. \
- ../../imports/models
+ ../../imports/models \
+ ../../imports/labsmodels
-exampledirs += ../../../examples/qml \
- ../ \
+exampledirs += .. \
snippets
+imagedirs += images
+
navigation.qmltypespage = "Qt Qml Models QML Types"
diff --git a/src/qmlmodels/qqmldelegatemodel.cpp b/src/qmlmodels/qqmldelegatemodel.cpp
index e3c01d040a..47cbe427e7 100644
--- a/src/qmlmodels/qqmldelegatemodel.cpp
+++ b/src/qmlmodels/qqmldelegatemodel.cpp
@@ -2234,7 +2234,7 @@ void QQmlDelegateModelItem::Dispose()
delete this;
}
-void QQmlDelegateModelItem::setModelIndex(int idx, int newRow, int newColumn)
+void QQmlDelegateModelItem::setModelIndex(int idx, int newRow, int newColumn, bool alwaysEmit)
{
const int prevIndex = index;
const int prevRow = row;
@@ -2244,11 +2244,11 @@ void QQmlDelegateModelItem::setModelIndex(int idx, int newRow, int newColumn)
row = newRow;
column = newColumn;
- if (idx != prevIndex)
+ if (idx != prevIndex || alwaysEmit)
emit modelIndexChanged();
- if (row != prevRow)
+ if (row != prevRow || alwaysEmit)
emit rowChanged();
- if (column != prevColumn)
+ if (column != prevColumn || alwaysEmit)
emit columnChanged();
}
diff --git a/src/qmlmodels/qqmldelegatemodel_p_p.h b/src/qmlmodels/qqmldelegatemodel_p_p.h
index 06365a212f..286e124f2f 100644
--- a/src/qmlmodels/qqmldelegatemodel_p_p.h
+++ b/src/qmlmodels/qqmldelegatemodel_p_p.h
@@ -129,7 +129,7 @@ public:
int modelRow() const { return row; }
int modelColumn() const { return column; }
int modelIndex() const { return index; }
- virtual void setModelIndex(int idx, int newRow, int newColumn);
+ virtual void setModelIndex(int idx, int newRow, int newColumn, bool alwaysEmit = false);
virtual QV4::ReturnedValue get() { return QV4::QObjectWrapper::wrap(v4, this); }
diff --git a/src/qmlmodels/qqmllistmodel.cpp b/src/qmlmodels/qqmllistmodel.cpp
index e0a66e7170..f79910204a 100644
--- a/src/qmlmodels/qqmllistmodel.cpp
+++ b/src/qmlmodels/qqmllistmodel.cpp
@@ -1905,11 +1905,11 @@ void DynamicRoleModelNodeMetaObject::propertyWritten(int index)
Here is an example that uses WorkerScript to periodically append the
current time to a list model:
- \snippet ../quick/threading/threadedlistmodel/timedisplay.qml 0
+ \snippet ../../examples/quick/threading/threadedlistmodel/timedisplay.qml 0
The included file, \tt dataloader.mjs, looks like this:
- \snippet ../quick/threading/threadedlistmodel/dataloader.mjs 0
+ \snippet ../../examples/quick/threading/threadedlistmodel/dataloader.mjs 0
The timer in the main example sends messages to the worker script by calling
\l WorkerScript::sendMessage(). When this message is received,
diff --git a/src/qmlmodels/qqmltableinstancemodel.cpp b/src/qmlmodels/qqmltableinstancemodel.cpp
index a538ae4a1f..3597af8b27 100644
--- a/src/qmlmodels/qqmltableinstancemodel.cpp
+++ b/src/qmlmodels/qqmltableinstancemodel.cpp
@@ -342,9 +342,13 @@ void QQmlTableInstanceModel::reuseItem(QQmlDelegateModelItem *item, int newModel
{
// Update the context properties index, row and column on
// the delegate item, and inform the application about it.
+ // Note that we set alwaysEmit to true, to force all bindings
+ // to be reevaluated, even if the index didn't change (since
+ // the model can have changed size since last usage).
+ const bool alwaysEmit = true;
const int newRow = m_adaptorModel.rowAt(newModelIndex);
const int newColumn = m_adaptorModel.columnAt(newModelIndex);
- item->setModelIndex(newModelIndex, newRow, newColumn);
+ item->setModelIndex(newModelIndex, newRow, newColumn, alwaysEmit);
// Notify the application that all 'dynamic'/role-based context data has
// changed as well (their getter function will use the updated index).
diff --git a/src/qmlmodels/qqmltableinstancemodel_p.h b/src/qmlmodels/qqmltableinstancemodel_p.h
index ce5a37bc98..1ea5ee7401 100644
--- a/src/qmlmodels/qqmltableinstancemodel_p.h
+++ b/src/qmlmodels/qqmltableinstancemodel_p.h
@@ -103,6 +103,9 @@ public:
bool isValid() const override { return true; }
+ bool canFetchMore() const { return m_adaptorModel.canFetchMore(); }
+ void fetchMore() { m_adaptorModel.fetchMore(); }
+
QVariant model() const;
void setModel(const QVariant &model);
diff --git a/src/qmlworkerscript/doc/qtqmlworkerscript.qdocconf b/src/qmlworkerscript/doc/qtqmlworkerscript.qdocconf
index bb883cf39f..e56e1759b3 100644
--- a/src/qmlworkerscript/doc/qtqmlworkerscript.qdocconf
+++ b/src/qmlworkerscript/doc/qtqmlworkerscript.qdocconf
@@ -23,15 +23,13 @@ qhp.QtQmlWorkerScript.sortPages = true
tagfile = qtqmlworkerscript.tags
-depends += qtcore qtqml qtdoc
+depends += qtcore qtqml qtquick qtdoc
headerdirs += ..
sourcedirs += .. \
../../imports/workerscript
-exampledirs += ../../../examples/qml \
- ../ \
- snippets
+exampledirs += snippets
navigation.qmltypespage = "Qt Qml WorkerScript QML Types"
diff --git a/src/qml/doc/snippets/qml/workerscript/script.mjs b/src/qmlworkerscript/doc/snippets/qml/workerscript/script.mjs
index f55dee3507..f55dee3507 100644
--- a/src/qml/doc/snippets/qml/workerscript/script.mjs
+++ b/src/qmlworkerscript/doc/snippets/qml/workerscript/script.mjs
diff --git a/src/qml/doc/snippets/qml/workerscript/workerscript.qml b/src/qmlworkerscript/doc/snippets/qml/workerscript/workerscript.qml
index cc637d34cf..cc637d34cf 100644
--- a/src/qml/doc/snippets/qml/workerscript/workerscript.qml
+++ b/src/qmlworkerscript/doc/snippets/qml/workerscript/workerscript.qml
diff --git a/src/quick/doc/qtquick.qdocconf b/src/quick/doc/qtquick.qdocconf
index 91458527dd..0d46e3408d 100644
--- a/src/quick/doc/qtquick.qdocconf
+++ b/src/quick/doc/qtquick.qdocconf
@@ -38,7 +38,7 @@ qhp.QtQuick.subprojects.examples.selectors = fake:example
tagfile = ../../../doc/qtquick/qtquick.tags
-depends += qtcore qtqml qtqmltest qtgui qtlinguist qtquickcontrols qtquickcontrols1 qtdoc qtquickdialogs qtsensors qtwidgets qmake qtmultimedia qtgraphicaleffects qtsql qtxmlpatterns
+depends += qtcore qtqml qtqmlmodels qtqmltest qtgui qtlinguist qtquickcontrols qtquickcontrols1 qtdoc qtquickdialogs qtsensors qtwidgets qmake qtmultimedia qtgraphicaleffects qtsql qtxmlpatterns
headerdirs += ..\
../../quick \
@@ -70,6 +70,9 @@ sourcedirs += ../../plugins
#exclude certain directories
excludedirs += ../../imports/models \
+ ../../imports/labsmodels \
+ ../../imports/testlib \
+ ../../imports/workerscript \
../../imports/statemachine
excludefiles += ../util/qquickpropertychanges_p.h
diff --git a/src/quick/doc/snippets/cmake-macros/examples.cmake b/src/quick/doc/snippets/cmake-macros/examples.cmake
index 8ca6180f9b..cecc59debc 100644
--- a/src/quick/doc/snippets/cmake-macros/examples.cmake
+++ b/src/quick/doc/snippets/cmake-macros/examples.cmake
@@ -3,4 +3,4 @@ find_package(Qt5 COMPONENTS Quick QmlImportScanner)
add_executable(myapp main.cpp)
target_link_libraries(myapp Qt5::Quick)
qt5_import_qml_plugins(myapp)
-#! [qt5_import_plugins]
+#! [qt5_import_qml_plugins]
diff --git a/src/quick/doc/src/concepts/visualcanvas/adaptations.qdoc b/src/quick/doc/src/concepts/visualcanvas/adaptations.qdoc
index e83aa39734..88003b68d3 100644
--- a/src/quick/doc/src/concepts/visualcanvas/adaptations.qdoc
+++ b/src/quick/doc/src/concepts/visualcanvas/adaptations.qdoc
@@ -55,7 +55,7 @@ appropriate for the various graphics APIs.
Unlike \c software or \c d3d12, the RHI-based renderer is not an additional
adaptation, and is always built-in. As of Qt 5.14 it can be enabled by setting
the environment variable \c{QSG_RHI} to a non-zero value before starting the
-application, or via \l QQuickWindow::setScenegraphBackend() in combination with
+application, or via \l QQuickWindow::setSceneGraphBackend() in combination with
\l QSGRendererInterface::GraphicsApi. When none of this is done, OpenGL is used
directly like in previous versions.
diff --git a/src/quick/doc/src/guidelines/qtquick-bestpractices.qdoc b/src/quick/doc/src/guidelines/qtquick-bestpractices.qdoc
index f4a1616943..abfff7cc11 100644
--- a/src/quick/doc/src/guidelines/qtquick-bestpractices.qdoc
+++ b/src/quick/doc/src/guidelines/qtquick-bestpractices.qdoc
@@ -402,6 +402,43 @@ property MyMenu optionsMenu
For information on performance in QML and Qt Quick,
see \l {Performance Considerations And Suggestions}.
+\section1 Prefer Declarative Bindings Over Imperative Assignments
+
+In QML, it's possible to use imperative JavaScript code to perform tasks
+such as responding to input events, send data over a network, and so on.
+Imperative code has an important place in QML, but it's also important
+to be aware of when not to use it.
+
+For example, consider the following imperative assignment:
+
+\code
+Rectangle {
+ Component.onCompleted: color = "red"
+}
+\endcode
+
+This has the following disadvantages:
+
+\list
+\li It's slow. The color property will first be evaluated with a
+ default-constructed value, and then again with "red" later on.
+\li It delays errors that could be found at build time to run time, slowing
+ down the development process.
+\li It overwrites any declarative binding that was in place. In most cases this
+ is intended, but sometimes it can be unintentional.
+ See \l {Debugging overwriting of bindings} for more information.
+\li It interferes with tooling; Qt Quick Designer, for example, doesn't support
+ JavaScript.
+\endlist
+
+The code can be rewritten to be a declarative binding instead:
+
+\code
+Rectangle {
+ color: "red"
+}
+\endcode
+
\section1 Tools and Utilities
For information on useful tools and utilies that make working with QML and
diff --git a/src/quick/handlers/qquickwheelhandler.cpp b/src/quick/handlers/qquickwheelhandler.cpp
index 90e4fef97e..aef2e8ebfb 100644
--- a/src/quick/handlers/qquickwheelhandler.cpp
+++ b/src/quick/handlers/qquickwheelhandler.cpp
@@ -49,6 +49,7 @@ Q_LOGGING_CATEGORY(lcWheelHandler, "qt.quick.handler.wheel")
/*!
\qmltype WheelHandler
\instantiates QQuickWheelHandler
+ \inherits SinglePointHandler
\inqmlmodule QtQuick
\ingroup qtquick-input-handlers
\brief Handler for the mouse wheel.
@@ -71,7 +72,7 @@ Q_LOGGING_CATEGORY(lcWheelHandler, "qt.quick.handler.wheel")
\snippet pointerHandlers/handlerFlick.qml 0
- Alternatively if \l targetProperty is not set or \l target is null,
+ Alternatively, if \l property is not set or \l target is null,
WheelHandler will not automatically manipulate anything; but the
\l rotation property can be used in a binding to manipulate another
property, or you can implement \c onWheel and handle the wheel event
@@ -79,15 +80,16 @@ Q_LOGGING_CATEGORY(lcWheelHandler, "qt.quick.handler.wheel")
WheelHandler handles only a rotating mouse wheel by default.
Optionally it can handle smooth-scrolling events from touchpad gestures,
- by setting \l acceptedDevices to \c{PointerDevice.Mouse | PointerDevice.TouchPad}.
+ by setting \l {QtQuick::PointerDeviceHandler::}{acceptedDevices} to
+ \c{PointerDevice.Mouse | PointerDevice.TouchPad}.
\note Some non-mouse hardware (such as a touch-sensitive Wacom tablet, or
a Linux laptop touchpad) generates real wheel events from gestures.
WheelHandler will respond to those events as wheel events regardless of the
- setting of the \l acceptedDevices property.
+ setting of the \l {QtQuick::PointerDeviceHandler::}{acceptedDevices}
+ property.
- \sa MouseArea
- \sa Flickable
+ \sa MouseArea, Flickable
*/
QQuickWheelHandler::QQuickWheelHandler(QQuickItem *parent)
@@ -125,13 +127,13 @@ void QQuickWheelHandler::setOrientation(Qt::Orientation orientation)
\qmlproperty bool QtQuick::WheelHandler::invertible
Whether or not to reverse the direction of property change if
- \l QQuickPointerScrollEvent::inverted is true. The default is \c true.
+ QQuickPointerScrollEvent::inverted is true. The default is \c true.
If the operating system has a "natural scrolling" setting that causes
scrolling to be in the same direction as the finger movement, then if this
property is set to \c true, and WheelHandler is directly setting a property
on \l target, the direction of movement will correspond to the system setting.
- If this property is set to \l false, it will invert the \l rotation so that
+ If this property is set to \c false, it will invert the \l rotation so that
the direction of motion is always the same as the direction of finger movement.
*/
bool QQuickWheelHandler::isInvertible() const
diff --git a/src/quick/items/qquickaccessibleattached.cpp b/src/quick/items/qquickaccessibleattached.cpp
index c150e4efa2..2da01e9151 100644
--- a/src/quick/items/qquickaccessibleattached.cpp
+++ b/src/quick/items/qquickaccessibleattached.cpp
@@ -433,6 +433,19 @@ void QQuickAccessibleAttached::setRole(QAccessible::Role role)
}
}
+bool QQuickAccessibleAttached::wasNameExplicitlySet() const
+{
+ return m_nameExplicitlySet;
+}
+
+// Allows types to attach an accessible name to an item as a convenience,
+// so long as the user hasn't done so themselves.
+void QQuickAccessibleAttached::setNameImplicitly(const QString &name)
+{
+ setName(name);
+ m_nameExplicitlySet = false;
+}
+
QQuickAccessibleAttached *QQuickAccessibleAttached::qmlAttachedProperties(QObject *obj)
{
return new QQuickAccessibleAttached(obj);
diff --git a/src/quick/items/qquickaccessibleattached_p.h b/src/quick/items/qquickaccessibleattached_p.h
index 678c1361ba..b7254d6686 100644
--- a/src/quick/items/qquickaccessibleattached_p.h
+++ b/src/quick/items/qquickaccessibleattached_p.h
@@ -122,7 +122,10 @@ public:
return QString();
return m_name;
}
+
+ bool wasNameExplicitlySet() const;
void setName(const QString &name) {
+ m_nameExplicitlySet = true;
if (name != m_name) {
m_name = name;
Q_EMIT nameChanged();
@@ -130,6 +133,7 @@ public:
QAccessible::updateAccessibility(&ev);
}
}
+ void setNameImplicitly(const QString &name);
QString description() const { return m_description; }
void setDescription(const QString &description)
@@ -220,6 +224,7 @@ private:
QAccessible::State m_state;
QAccessible::State m_stateExplicitlySet;
QString m_name;
+ bool m_nameExplicitlySet = false;
QString m_description;
static QMetaMethod sigPress;
diff --git a/src/quick/items/qquickitem.cpp b/src/quick/items/qquickitem.cpp
index 4c20b7e2e1..3785abc450 100644
--- a/src/quick/items/qquickitem.cpp
+++ b/src/quick/items/qquickitem.cpp
@@ -2074,10 +2074,10 @@ void QQuickItemPrivate::updateSubFocusItem(QQuickItem *scope, bool focus)
in the GPU equal to \c {width x height x 4}. In memory constrained
configurations, large layers should be used with care.
- In the QPainter / QWidget world, it is some times favorable to
+ In the QPainter / QWidget world, it is sometimes favorable to
cache complex content in a pixmap, image or texture. In Qt Quick,
because of the techniques already applied by the \l {Qt Quick
- Scene Graph OpenGL Renderer} {scene graph renderer}, this will in most
+ Scene Graph Default Renderer} {scene graph renderer}, this will in most
cases not be the case. Excessive draw calls are already reduced
because of batching and a cache will in most cases end up blending
more pixels than the original content. The overhead of rendering
diff --git a/src/quick/items/qquickitemview.cpp b/src/quick/items/qquickitemview.cpp
index 661f19509a..7c74eafd3a 100644
--- a/src/quick/items/qquickitemview.cpp
+++ b/src/quick/items/qquickitemview.cpp
@@ -1790,6 +1790,7 @@ void QQuickItemViewPrivate::refill(qreal from, qreal to)
if (prevCount != itemCount)
emit q->countChanged();
} while (currentChanges.hasPendingChanges() || bufferedChanges.hasPendingChanges());
+ storeFirstVisibleItemPosition();
}
void QQuickItemViewPrivate::regenerate(bool orientationChanged)
@@ -1876,6 +1877,7 @@ void QQuickItemViewPrivate::layout()
updateSections();
layoutVisibleItems();
+ storeFirstVisibleItemPosition();
int lastIndexInView = findLastIndexInView();
refill();
@@ -1960,7 +1962,7 @@ bool QQuickItemViewPrivate::applyModelChanges(ChangeResult *totalInsertionResult
prevFirstItemInViewPos = prevFirstItemInView->position();
prevFirstItemInViewIndex = prevFirstItemInView->index;
}
- qreal prevVisibleItemsFirstPos = visibleItems.count() ? visibleItems.constFirst()->position() : 0.0;
+ qreal prevVisibleItemsFirstPos = visibleItems.count() ? firstVisibleItemPosition : 0.0;
totalInsertionResult->visiblePos = prevFirstItemInViewPos;
totalRemovalResult->visiblePos = prevFirstItemInViewPos;
@@ -2006,6 +2008,7 @@ bool QQuickItemViewPrivate::applyModelChanges(ChangeResult *totalInsertionResult
if (!insertions.isEmpty()) {
repositionFirstItem(prevVisibleItemsFirst, prevVisibleItemsFirstPos, prevFirstItemInView, &insertionResult, &removalResult);
layoutVisibleItems(removals.first().index);
+ storeFirstVisibleItemPosition();
}
}
@@ -2026,6 +2029,7 @@ bool QQuickItemViewPrivate::applyModelChanges(ChangeResult *totalInsertionResult
if (i < insertions.count() - 1) {
repositionFirstItem(prevVisibleItemsFirst, prevVisibleItemsFirstPos, prevFirstItemInView, &insertionResult, &removalResult);
layoutVisibleItems(insertions[i].index);
+ storeFirstVisibleItemPosition();
}
itemCount += insertions[i].count;
}
diff --git a/src/quick/items/qquickitemview_p_p.h b/src/quick/items/qquickitemview_p_p.h
index 6442fee27d..b31f53b2c0 100644
--- a/src/quick/items/qquickitemview_p_p.h
+++ b/src/quick/items/qquickitemview_p_p.h
@@ -260,6 +260,12 @@ public:
MovementReason moveReason;
QList<FxViewItem *> visibleItems;
+ qreal firstVisibleItemPosition = 0;
+ void storeFirstVisibleItemPosition() {
+ if (!visibleItems.isEmpty()) {
+ firstVisibleItemPosition = visibleItems.constFirst()->position();
+ }
+ }
int visibleIndex;
int currentIndex;
FxViewItem *currentItem;
diff --git a/src/quick/items/qquicklistview.cpp b/src/quick/items/qquicklistview.cpp
index 725d35f325..778f28bdd5 100644
--- a/src/quick/items/qquicklistview.cpp
+++ b/src/quick/items/qquicklistview.cpp
@@ -808,6 +808,7 @@ void QQuickListViewPrivate::layoutVisibleItems(int fromModelIndex)
FxViewItem *firstItem = *visibleItems.constBegin();
bool fixedCurrent = currentItem && firstItem->item == currentItem->item;
+ firstVisibleItemPosition = firstItem->position();
qreal sum = firstItem->size();
qreal pos = firstItem->position() + firstItem->size() + spacing;
firstItem->setVisible(firstItem->endPosition() >= from && firstItem->position() <= to);
@@ -2095,7 +2096,7 @@ QQuickListView::~QQuickListView()
highlight item is \c 0.
\sa highlightItem, highlightFollowsCurrentItem,
- {Qt Quick Examples - Views#Highlight}{ListView highlight example},
+ {Qt Quick Examples - Views#Using Highlight}{ListView Highlight Example},
{Stacking Order in ListView}
*/
diff --git a/src/quick/items/qquicktableview.cpp b/src/quick/items/qquicktableview.cpp
index 295c6898bc..89839c8aab 100644
--- a/src/quick/items/qquicktableview.cpp
+++ b/src/quick/items/qquicktableview.cpp
@@ -871,17 +871,13 @@ void QQuickTableViewPrivate::syncLoadedTableRectFromLoadedTable()
loadedTableInnerRect = QRectF(topLeftRect.bottomRight(), bottomRightRect.topLeft());
}
-void QQuickTableViewPrivate::forceLayout()
+QQuickTableViewPrivate::RebuildOptions QQuickTableViewPrivate::checkForVisibilityChanges()
{
- if (loadedItems.isEmpty())
- return;
-
- clearEdgeSizeCache();
- RebuildOptions rebuildOptions = RebuildOption::LayoutOnly;
-
// Go through all columns from first to last, find the columns that used
// to be hidden and not loaded, and check if they should become visible
// (and vice versa). If there is a change, we need to rebuild.
+ RebuildOptions rebuildOptions = RebuildOption::None;
+
for (int column = leftColumn(); column <= rightColumn(); ++column) {
const bool wasVisibleFromBefore = loadedColumns.contains(column);
const bool isVisibleNow = !qFuzzyIsNull(getColumnWidth(column));
@@ -916,6 +912,28 @@ void QQuickTableViewPrivate::forceLayout()
break;
}
+ return rebuildOptions;
+}
+
+void QQuickTableViewPrivate::forceLayout()
+{
+ if (loadedItems.isEmpty())
+ return;
+
+ clearEdgeSizeCache();
+ RebuildOptions rebuildOptions = RebuildOption::None;
+
+ const QSize actualTableSize = calculateTableSize();
+ if (tableSize != actualTableSize) {
+ // This can happen if the app is calling forceLayout while
+ // the model is updated, but before we're notified about it.
+ rebuildOptions = RebuildOption::All;
+ } else {
+ rebuildOptions = checkForVisibilityChanges();
+ if (!rebuildOptions)
+ rebuildOptions = RebuildOption::LayoutOnly;
+ }
+
scheduleRebuildTable(rebuildOptions);
auto rootView = rootSyncView();
@@ -1183,19 +1201,14 @@ qreal QQuickTableViewPrivate::sizeHintForRow(int row)
return rowHeight;
}
-void QQuickTableViewPrivate::calculateTableSize()
+void QQuickTableViewPrivate::updateTableSize()
{
// tableSize is the same as row and column count, and will always
// be the same as the number of rows and columns in the model.
Q_Q(QQuickTableView);
- QSize prevTableSize = tableSize;
- if (tableModel)
- tableSize = QSize(tableModel->columns(), tableModel->rows());
- else if (model)
- tableSize = QSize(1, model->count());
- else
- tableSize = QSize(0, 0);
+ const QSize prevTableSize = tableSize;
+ tableSize = calculateTableSize();
if (prevTableSize.width() != tableSize.width())
emit q->columnsChanged();
@@ -1203,6 +1216,16 @@ void QQuickTableViewPrivate::calculateTableSize()
emit q->rowsChanged();
}
+QSize QQuickTableViewPrivate::calculateTableSize()
+{
+ if (tableModel)
+ return QSize(tableModel->columns(), tableModel->rows());
+ else if (model)
+ return QSize(1, model->count());
+
+ return QSize(0, 0);
+}
+
qreal QQuickTableViewPrivate::getColumnLayoutWidth(int column)
{
// Return the column width specified by the application, or go
@@ -1755,7 +1778,7 @@ void QQuickTableViewPrivate::calculateTopLeft(QPoint &topLeftCell, QPointF &topL
void QQuickTableViewPrivate::beginRebuildTable()
{
- calculateTableSize();
+ updateTableSize();
QPoint topLeft;
QPointF topLeftPos;
@@ -2291,6 +2314,7 @@ void QQuickTableViewPrivate::syncSyncView()
void QQuickTableViewPrivate::connectToModel()
{
+ Q_Q(QQuickTableView);
Q_TABLEVIEW_ASSERT(model, "");
QObjectPrivate::connect(model, &QQmlInstanceModel::createdItem, this, &QQuickTableViewPrivate::itemCreatedCallback);
@@ -2300,6 +2324,8 @@ void QQuickTableViewPrivate::connectToModel()
const auto tm = tableModel.data();
QObjectPrivate::connect(tm, &QQmlTableInstanceModel::itemPooled, this, &QQuickTableViewPrivate::itemPooledCallback);
QObjectPrivate::connect(tm, &QQmlTableInstanceModel::itemReused, this, &QQuickTableViewPrivate::itemReusedCallback);
+ // Connect atYEndChanged to a function that fetches data if more is available
+ QObjectPrivate::connect(q, &QQuickTableView::atYEndChanged, this, &QQuickTableViewPrivate::fetchMoreData);
}
if (auto const aim = model->abstractItemModel()) {
@@ -2323,6 +2349,7 @@ void QQuickTableViewPrivate::connectToModel()
void QQuickTableViewPrivate::disconnectFromModel()
{
+ Q_Q(QQuickTableView);
Q_TABLEVIEW_ASSERT(model, "");
QObjectPrivate::disconnect(model, &QQmlInstanceModel::createdItem, this, &QQuickTableViewPrivate::itemCreatedCallback);
@@ -2332,6 +2359,7 @@ void QQuickTableViewPrivate::disconnectFromModel()
const auto tm = tableModel.data();
QObjectPrivate::disconnect(tm, &QQmlTableInstanceModel::itemPooled, this, &QQuickTableViewPrivate::itemPooledCallback);
QObjectPrivate::disconnect(tm, &QQmlTableInstanceModel::itemReused, this, &QQuickTableViewPrivate::itemReusedCallback);
+ QObjectPrivate::disconnect(q, &QQuickTableView::atYEndChanged, this, &QQuickTableViewPrivate::fetchMoreData);
}
if (auto const aim = model->abstractItemModel()) {
@@ -2413,6 +2441,14 @@ void QQuickTableViewPrivate::layoutChangedCallback(const QList<QPersistentModelI
scheduleRebuildTable(RebuildOption::ViewportOnly);
}
+void QQuickTableViewPrivate::fetchMoreData()
+{
+ if (tableModel && tableModel->canFetchMore()) {
+ tableModel->fetchMore();
+ scheduleRebuildTable(RebuildOption::ViewportOnly);
+ }
+}
+
void QQuickTableViewPrivate::modelResetCallback()
{
scheduleRebuildTable(RebuildOption::All);
diff --git a/src/quick/items/qquicktableview_p_p.h b/src/quick/items/qquicktableview_p_p.h
index b66ac66dec..ec043f5e7e 100644
--- a/src/quick/items/qquicktableview_p_p.h
+++ b/src/quick/items/qquicktableview_p_p.h
@@ -322,7 +322,8 @@ public:
qreal sizeHintForColumn(int column);
qreal sizeHintForRow(int row);
- void calculateTableSize();
+ QSize calculateTableSize();
+ void updateTableSize();
inline bool isColumnHidden(int column);
inline bool isRowHidden(int row);
@@ -351,6 +352,7 @@ public:
void updateContentWidth();
void updateContentHeight();
void updateAverageEdgeSize();
+ RebuildOptions checkForVisibilityChanges();
void forceLayout();
void updateExtents();
@@ -424,6 +426,8 @@ public:
void setLocalViewportY(qreal contentY);
void syncViewportPosRecursive();
+ void fetchMoreData();
+
void _q_componentFinalized();
void registerCallbackWhenBindingsAreEvaluated();
diff --git a/src/quick/items/qquickview.cpp b/src/quick/items/qquickview.cpp
index 17fc16d44b..2110d4caba 100644
--- a/src/quick/items/qquickview.cpp
+++ b/src/quick/items/qquickview.cpp
@@ -240,13 +240,12 @@ void QQuickView::setSource(const QUrl& url)
}
/*!
- Sets the initial properties with which the QML component gets initialized after
- calling \l QQuickView::setSource.
+ Sets the initial properties \a initialProperties with which the QML
+ component gets initialized after calling \l QQuickView::setSource().
+ \note You can only use this function to initialize top-level properties.
- Note that you can only use this function to initialize toplevel properties.
-
- \sa QQmlComponent::createWithInitialProperties
+ \sa QQmlComponent::createWithInitialProperties()
\since 5.14
*/
void QQuickView::setInitialProperties(const QVariantMap &initialProperties)
diff --git a/src/quick/items/qquickwindow.cpp b/src/quick/items/qquickwindow.cpp
index 905241989e..fec70191ca 100644
--- a/src/quick/items/qquickwindow.cpp
+++ b/src/quick/items/qquickwindow.cpp
@@ -4603,7 +4603,7 @@ QSGTexture *QQuickWindow::createTextureFromId(uint id, const QSize &size, Create
\a nativeLayout is only used for APIs like Vulkan. When applicable, it must
specify the current image layout, such as, a VkImageLayout value.
- \sa sceneGraphInitialized(), QSGTextures
+ \sa sceneGraphInitialized(), QSGTexture
\since 5.14
*/
diff --git a/src/quick/scenegraph/coreapi/qsgmaterialrhishader.cpp b/src/quick/scenegraph/coreapi/qsgmaterialrhishader.cpp
index 117d477f9a..77593591bd 100644
--- a/src/quick/scenegraph/coreapi/qsgmaterialrhishader.cpp
+++ b/src/quick/scenegraph/coreapi/qsgmaterialrhishader.cpp
@@ -319,7 +319,7 @@ bool QSGMaterialRhiShader::updateUniformData(RenderState &state,
each variable in the material's shaders'
\l{QShaderDescription::combinedImageSamplers()}.
- When \c{*texture} is null, it must be set to a QSGTexture pointer before
+ When *\a{texture} is null, it must be set to a QSGTexture pointer before
returning. When non-null, it is up to the material to decide if a new
\c{QSGTexture *} is stored to it, or if it updates some parameters on the
already known QSGTexture. The ownership of the QSGTexture is not
diff --git a/src/quick/scenegraph/coreapi/qsgtexture.cpp b/src/quick/scenegraph/coreapi/qsgtexture.cpp
index edcee96bdb..dfbe4d3ffd 100644
--- a/src/quick/scenegraph/coreapi/qsgtexture.cpp
+++ b/src/quick/scenegraph/coreapi/qsgtexture.cpp
@@ -701,8 +701,8 @@ void QSGTexture::updateBindOptions(bool force) // legacy (GL-only)
data (for example, because there was no setImage() since the last call to
this function), the function does nothing.
- Materials involving textures are expected to call this function from their
- updateSampledImage() implementation, typically without any conditions.
+ Materials involving \a rhi textures are expected to call this function from
+ their updateSampledImage() implementation, typically without any conditions.
\note This function is only used when running the graphics API independent
rendering path of the scene graph.
diff --git a/src/quick/scenegraph/shaders/outlinedtext.vert b/src/quick/scenegraph/shaders/outlinedtext.vert
index ced8afd034..9df832de3c 100644
--- a/src/quick/scenegraph/shaders/outlinedtext.vert
+++ b/src/quick/scenegraph/shaders/outlinedtext.vert
@@ -1,6 +1,7 @@
uniform highp mat4 matrix;
uniform highp vec2 textureScale;
uniform highp vec2 shift;
+uniform highp float dpr;
attribute highp vec4 vCoord;
attribute highp vec2 tCoord;
@@ -18,5 +19,6 @@ void main()
sCoordDown = (tCoord - vec2(0.0, 1.0)) * textureScale;
sCoordLeft = (tCoord - vec2(-1.0, 0.0)) * textureScale;
sCoordRight = (tCoord - vec2(1.0, 0.0)) * textureScale;
- gl_Position = matrix * vCoord;
+ vec3 dprSnapPos = floor(vCoord.xyz * dpr + 0.5) / dpr;
+ gl_Position = matrix * vec4(dprSnapPos, vCoord.w);
} \ No newline at end of file
diff --git a/src/quick/scenegraph/shaders/outlinedtext_core.vert b/src/quick/scenegraph/shaders/outlinedtext_core.vert
index 4aa13101fd..ae945b013a 100644
--- a/src/quick/scenegraph/shaders/outlinedtext_core.vert
+++ b/src/quick/scenegraph/shaders/outlinedtext_core.vert
@@ -12,6 +12,7 @@ out vec2 sCoordRight;
uniform mat4 matrix;
uniform vec2 textureScale;
uniform vec2 shift;
+uniform float dpr;
void main()
{
@@ -20,5 +21,6 @@ void main()
sCoordDown = (tCoord - vec2(0.0, 1.0)) * textureScale;
sCoordLeft = (tCoord - vec2(-1.0, 0.0)) * textureScale;
sCoordRight = (tCoord - vec2(1.0, 0.0)) * textureScale;
- gl_Position = matrix * vCoord;
+ vec3 dprSnapPos = round(vCoord.xyz * dpr + 0.5) / dpr;
+ gl_Position = matrix * vec4(dprSnapPos, vCoord.w);
} \ No newline at end of file
diff --git a/src/quick/scenegraph/shaders/styledtext.vert b/src/quick/scenegraph/shaders/styledtext.vert
index 7001bbc262..29c9902609 100644
--- a/src/quick/scenegraph/shaders/styledtext.vert
+++ b/src/quick/scenegraph/shaders/styledtext.vert
@@ -13,5 +13,6 @@ void main()
{
sampleCoord = tCoord * textureScale;
shiftedSampleCoord = (tCoord - shift) * textureScale;
- gl_Position = matrix * floor(vCoord * dpr + 0.5) / dpr;
+ vec3 dprSnapPos = floor(vCoord.xyz * dpr + 0.5) / dpr;
+ gl_Position = matrix * vec4(dprSnapPos, vCoord.w);
}
diff --git a/src/quick/scenegraph/shaders/styledtext_core.vert b/src/quick/scenegraph/shaders/styledtext_core.vert
index c522877bb3..7e313eb797 100644
--- a/src/quick/scenegraph/shaders/styledtext_core.vert
+++ b/src/quick/scenegraph/shaders/styledtext_core.vert
@@ -15,5 +15,6 @@ void main()
{
sampleCoord = tCoord * textureScale;
shiftedSampleCoord = (tCoord - shift) * textureScale;
- gl_Position = matrix * round(vCoord * dpr) / dpr;
+ vec3 dprSnapPos = round(vCoord.xyz * dpr + 0.5) / dpr;
+ gl_Position = matrix * vec4(dprSnapPos, vCoord.w);
}
diff --git a/src/quick/scenegraph/shaders/textmask.vert b/src/quick/scenegraph/shaders/textmask.vert
index 4c678270d0..1692159d2c 100644
--- a/src/quick/scenegraph/shaders/textmask.vert
+++ b/src/quick/scenegraph/shaders/textmask.vert
@@ -10,5 +10,6 @@ varying highp vec2 sampleCoord;
void main()
{
sampleCoord = tCoord * textureScale;
- gl_Position = matrix * floor(vCoord * dpr + 0.5) / dpr;
+ vec3 dprSnapPos = floor(vCoord.xyz * dpr + 0.5) / dpr;
+ gl_Position = matrix * vec4(dprSnapPos, vCoord.w);
}
diff --git a/src/quick/scenegraph/shaders/textmask_core.vert b/src/quick/scenegraph/shaders/textmask_core.vert
index f996040f70..5c510a2d23 100644
--- a/src/quick/scenegraph/shaders/textmask_core.vert
+++ b/src/quick/scenegraph/shaders/textmask_core.vert
@@ -12,5 +12,6 @@ uniform float dpr;
void main()
{
sampleCoord = tCoord * textureScale;
- gl_Position = matrix * round(vCoord * dpr) / dpr;
+ vec3 dprSnapPos = round(vCoord.xyz * dpr + 0.5) / dpr;
+ gl_Position = matrix * vec4(dprSnapPos, vCoord.w);
}
diff --git a/src/quick/util/qquickpath.cpp b/src/quick/util/qquickpath.cpp
index 61319c388c..24b22f00c1 100644
--- a/src/quick/util/qquickpath.cpp
+++ b/src/quick/util/qquickpath.cpp
@@ -918,7 +918,7 @@ QPointF QQuickPath::backwardsPointAt(const QPainterPath &path, const qreal &path
When curves are present, the percentage argument is mapped to the \c t
parameter of the Bezier equations.
- \sa QPainterPath::pointAt
+ \sa QPainterPath::pointAtPercent()
\since QtQuick 2.14
*/
@@ -2370,8 +2370,8 @@ void QQuickPathPercent::setValue(qreal value)
The example below creates a triangular path consisting of four vertices
on the edge of the containing Shape's bounding box.
- Through the containing shape's \l scale property, the path will be
- rescaled together with its containing shape.
+ Through the containing shape's \l {QtQuick::Path::}{scale} property,
+ the path will be rescaled together with its containing shape.
\qml
PathPolyline {
@@ -2488,7 +2488,7 @@ void QQuickPathPolyline::addToPath(QPainterPath &path, const QQuickPathData &/*d
The example below creates a high voltage symbol by adding each path
of the symbol to the list of paths.
The coordinates of the vertices are normalized, and through the containing shape's
- \l scale property, the path will be rescaled together with its containing shape.
+ \l {QtQuick::Path::}{scale} property, the path will be rescaled together with its containing shape.
\qml
PathMultiline {
diff --git a/tests/auto/qmltest/events/tst_drag.qml b/tests/auto/qmltest/events/tst_drag.qml
index ae77247a41..2653848adc 100644
--- a/tests/auto/qmltest/events/tst_drag.qml
+++ b/tests/auto/qmltest/events/tst_drag.qml
@@ -113,6 +113,43 @@ Rectangle{
}
}
+ Component {
+ id: nestedFlickableComponent
+
+ Flickable {
+ objectName: "outerFlickable"
+ width: parent.width
+ height: parent.height
+ contentWidth: 400
+ contentHeight: 400
+
+ property alias innerFlickable: innerFlickable
+
+ Flickable {
+ id: innerFlickable
+ objectName: "innerFlickable"
+ width: parent.width
+ height: parent.height
+ contentWidth: 400
+ contentHeight: 400
+
+ Rectangle {
+ width: 400
+ height: 400
+ gradient: Gradient {
+ GradientStop { position: 0; color: "salmon" }
+ GradientStop { position: 0; color: "navajowhite" }
+ }
+ }
+ }
+ }
+ }
+
+ Component {
+ id: signalSpyComponent
+ SignalSpy {}
+ }
+
TestCase {
name:"mouserelease"
when:windowShown
@@ -163,5 +200,100 @@ Rectangle{
compare(spyX.count, 0)
compare(spyY.count, 1)
}
+
+ function test_dragAxis_data() {
+ return [
+ { tag: "horizontal" },
+ { tag: "vertical" }
+ ]
+ }
+
+ // mouseDrag() should not drag along an axis if the distance passed in for
+ // that axis was 0. Doing so can interfere with tests for an item that e.g.
+ // handles horizontal flicks which is within e.g. a Flickable that handles
+ // vertical flicks.
+ function test_dragAxis(data) {
+ let horizontal = data.tag === "horizontal"
+
+ let outerFlickable = createTemporaryObject(nestedFlickableComponent, root)
+ verify(outerFlickable)
+ // We want the outer flickable to use the opposite flick direction of the inner one,
+ // as the inner one has the direction that we're interested in testing.
+ outerFlickable.flickableDirection = horizontal ? Flickable.VerticalFlick : Flickable.HorizontalFlick
+
+ let innerFlickable = outerFlickable.innerFlickable
+ verify(innerFlickable)
+ let horizontalFlickable = null
+ let verticalFlickable = null
+ if (horizontal) {
+ innerFlickable.flickableDirection = Flickable.HorizontalFlick
+ horizontalFlickable = innerFlickable
+ verticalFlickable = outerFlickable
+ } else {
+ innerFlickable.flickableDirection = Flickable.VerticalFlick
+ horizontalFlickable = outerFlickable
+ verticalFlickable = innerFlickable
+ }
+
+ let movingHorizontallySpy = createTemporaryObject(signalSpyComponent, root,
+ { target: horizontalFlickable, signalName: "movingHorizontallyChanged" })
+ verify(movingHorizontallySpy)
+ verify(movingHorizontallySpy.valid)
+
+ let movingVerticallySpy = createTemporaryObject(signalSpyComponent, root,
+ { target: verticalFlickable, signalName: "movingVerticallyChanged" })
+ verify(movingVerticallySpy)
+ verify(movingVerticallySpy.valid)
+
+ let flickingHorizontallySpy = createTemporaryObject(signalSpyComponent, root,
+ { target: horizontalFlickable, signalName: "flickingHorizontallyChanged" })
+ verify(flickingHorizontallySpy)
+ verify(flickingHorizontallySpy.valid)
+
+ let flickingVerticallySpy = createTemporaryObject(signalSpyComponent, root,
+ { target: verticalFlickable, signalName: "flickingVerticallyChanged" })
+ verify(flickingVerticallySpy)
+ verify(flickingVerticallySpy.valid)
+
+ let contentXSpy = createTemporaryObject(signalSpyComponent, root,
+ { target: horizontalFlickable, signalName: "contentXChanged" })
+ verify(contentXSpy)
+ verify(contentXSpy.valid)
+
+ let contentYSpy = createTemporaryObject(signalSpyComponent, root,
+ { target: verticalFlickable, signalName: "contentYChanged" })
+ verify(contentYSpy)
+ verify(contentYSpy.valid)
+
+ // Dragging only horizontally should not result in movement on the Y axis, and vice versa.
+ let horizontalDragDistance = horizontal ? innerFlickable.width - 10 : 0
+ let verticalDragDistance = horizontal ? 0 : innerFlickable.height - 10
+ mouseDrag(innerFlickable, 10, 10, horizontalDragDistance, verticalDragDistance)
+
+ // Wait for it to stop moving.
+ if (horizontal) {
+ tryCompare(horizontalFlickable, "movingHorizontally", false)
+ tryCompare(horizontalFlickable, "flickingHorizontally", false)
+ } else {
+ tryCompare(verticalFlickable, "movingVertically", false)
+ tryCompare(verticalFlickable, "flickingVertically", false)
+ }
+
+ // 2 because it should change to true then false.
+ compare(movingHorizontallySpy.count, horizontal ? 2 : 0)
+ compare(movingVerticallySpy.count, horizontal ? 0 : 2)
+ compare(flickingHorizontallySpy.count, horizontal ? 2 : 0)
+ compare(flickingVerticallySpy.count, horizontal ? 0 : 2)
+
+ if (horizontal)
+ verify(contentXSpy.count > 0)
+ else
+ compare(contentXSpy.count, 0)
+
+ if (horizontal)
+ compare(contentYSpy.count, 0)
+ else
+ verify(contentYSpy.count > 0)
+ }
}
}
diff --git a/tests/auto/quick/qquickaccessible/tst_qquickaccessible.cpp b/tests/auto/quick/qquickaccessible/tst_qquickaccessible.cpp
index d1f6d67aa1..061d5f8a1a 100644
--- a/tests/auto/quick/qquickaccessible/tst_qquickaccessible.cpp
+++ b/tests/auto/quick/qquickaccessible/tst_qquickaccessible.cpp
@@ -185,7 +185,8 @@ void tst_QQuickAccessible::quickAttachedProperties()
QObject *object = component.create();
QVERIFY(object != nullptr);
- QObject *attachedObject = QQuickAccessibleAttached::attachedProperties(object);
+ const auto attachedObject = qobject_cast<QQuickAccessibleAttached*>(
+ QQuickAccessibleAttached::attachedProperties(object));
QVERIFY(attachedObject);
if (attachedObject) {
QVariant p = attachedObject->property("role");
@@ -195,6 +196,7 @@ void tst_QQuickAccessible::quickAttachedProperties()
QCOMPARE(p.isNull(), true);
p = attachedObject->property("description");
QCOMPARE(p.isNull(), true);
+ QCOMPARE(attachedObject->wasNameExplicitlySet(), false);
}
delete object;
}
@@ -211,7 +213,8 @@ void tst_QQuickAccessible::quickAttachedProperties()
QObject *object = component.create();
QVERIFY(object != nullptr);
- QObject *attachedObject = QQuickAccessibleAttached::attachedProperties(object);
+ const auto attachedObject = qobject_cast<QQuickAccessibleAttached*>(
+ QQuickAccessibleAttached::attachedProperties(object));
QVERIFY(attachedObject);
if (attachedObject) {
QVariant p = attachedObject->property("role");
@@ -223,6 +226,7 @@ void tst_QQuickAccessible::quickAttachedProperties()
p = attachedObject->property("description");
QCOMPARE(p.isNull(), false);
QCOMPARE(p.toString(), QLatin1String("Duck"));
+ QCOMPARE(attachedObject->wasNameExplicitlySet(), true);
}
delete object;
}
@@ -292,6 +296,32 @@ void tst_QQuickAccessible::quickAttachedProperties()
}
delete object;
}
+ // Check that a name can be implicitly set.
+ {
+ QQmlEngine engine;
+ QQmlComponent component(&engine);
+ component.setData(R"(
+ import QtQuick 2.0
+ Text {
+ Accessible.role: Accessible.Button
+ Accessible.description: "Text Button"
+ })", QUrl());
+ QScopedPointer<QObject> object(component.create());
+ QVERIFY(object);
+
+ const auto attachedObject = qobject_cast<QQuickAccessibleAttached*>(
+ QQuickAccessibleAttached::attachedProperties(object.data()));
+ QVERIFY(attachedObject);
+ QVERIFY(!attachedObject->wasNameExplicitlySet());
+
+ attachedObject->setNameImplicitly(QLatin1String("Implicit"));
+ QCOMPARE(attachedObject->name(), QLatin1String("Implicit"));
+ QVERIFY(!attachedObject->wasNameExplicitlySet());
+
+ attachedObject->setName(QLatin1String("Explicit"));
+ QCOMPARE(attachedObject->name(), QLatin1String("Explicit"));
+ QVERIFY(attachedObject->wasNameExplicitlySet());
+ }
QTestAccessibility::clearEvents();
}
diff --git a/tests/auto/quick/qquicklayouts/data/tst_gridlayout.qml b/tests/auto/quick/qquicklayouts/data/tst_gridlayout.qml
index e8b3960486..be94fca8d4 100644
--- a/tests/auto/quick/qquicklayouts/data/tst_gridlayout.qml
+++ b/tests/auto/quick/qquicklayouts/data/tst_gridlayout.qml
@@ -1073,5 +1073,38 @@ Item {
layout[propName] = data.value
compare(layout.spy.count, 1)
}
+
+ Component {
+ id: layout_columnIsOutsideGrid_Component
+ GridLayout {
+ columns: 2
+ Item {
+ Layout.row: 0
+ Layout.column: 1
+ }
+ Item {
+ implicitWidth: 10
+ implicitHeight: 10
+ Layout.row: 0
+ Layout.column: 2
+ }
+ Item {
+ Layout.columnSpan: 2
+ Layout.fillWidth: true
+ Layout.fillHeight: true
+ }
+ }
+ }
+
+ function test_columnIsOutsideGrid()
+ {
+ ignoreWarning(/QML Item: Layout: column \(2\) should be less than the number of columns \(2\)/);
+ var layout = layout_columnIsOutsideGrid_Component.createObject(container);
+ layout.width = layout.implicitWidth
+ layout.height = layout.implicitHeight
+ waitForRendering(layout);
+ layout.destroy()
+ }
+
}
}
diff --git a/tests/auto/quick/qquicktableview/data/plaintableview.qml b/tests/auto/quick/qquicktableview/data/plaintableview.qml
index 90271eda71..33db6f6d02 100644
--- a/tests/auto/quick/qquicktableview/data/plaintableview.qml
+++ b/tests/auto/quick/qquicktableview/data/plaintableview.qml
@@ -70,6 +70,7 @@ Item {
color: "lightgray"
border.width: 1
+ property string modelDataFromIndex: tableView.model.dataFromSerializedIndex(index)
property string modelDataBinding: modelData
Text {
diff --git a/tests/auto/quick/qquicktableview/qquicktableview.pro b/tests/auto/quick/qquicktableview/qquicktableview.pro
index da0c0b01d0..735c728fc6 100644
--- a/tests/auto/quick/qquicktableview/qquicktableview.pro
+++ b/tests/auto/quick/qquicktableview/qquicktableview.pro
@@ -13,3 +13,5 @@ TESTDATA = data/*
QT += core-private gui-private qml-private quick-private testlib qmlmodels-private
+DISTFILES +=
+
diff --git a/tests/auto/quick/qquicktableview/testmodel.h b/tests/auto/quick/qquicktableview/testmodel.h
index 50f434019e..2697b1e801 100644
--- a/tests/auto/quick/qquicktableview/testmodel.h
+++ b/tests/auto/quick/qquicktableview/testmodel.h
@@ -46,6 +46,13 @@ public:
, m_columns(columns)
{}
+ TestModel(int rows, int columns, bool dataCanBeFetched, QObject *parent = nullptr)
+ : QAbstractTableModel(parent)
+ , m_rows(rows)
+ , m_columns(columns)
+ , m_dataCanBeFetched(dataCanBeFetched)
+ {}
+
int rowCount(const QModelIndex & = QModelIndex()) const override { return m_rows; }
void setRowCount(int count) { beginResetModel(); m_rows = count; emit rowCountChanged(); endResetModel(); }
@@ -63,6 +70,13 @@ public:
return QStringLiteral("%1").arg(index.row());
}
+ Q_INVOKABLE QVariant dataFromSerializedIndex(int index) const
+ {
+ if (modelData.contains(index))
+ return modelData.value(index);
+ return QString();
+ }
+
QHash<int, QByteArray> roleNames() const override
{
return { {Qt::DisplayRole, "display"} };
@@ -102,6 +116,12 @@ public:
beginRemoveRows(parent, row, row + count - 1);
m_rows -= count;
+ for (int c = 0; c < m_columns; ++c) {
+ for (int r = 0; r < count; ++r) {
+ const int serializedIndex = (row + r) + (c * m_rows);
+ modelData.remove(serializedIndex);
+ }
+ }
endRemoveRows();
return true;
}
@@ -128,6 +148,12 @@ public:
return true;
}
+ bool canFetchMore(const QModelIndex &parent) const override
+ {
+ Q_UNUSED(parent)
+ return m_dataCanBeFetched;
+ }
+
void swapRows(int row1, int row2)
{
layoutAboutToBeChanged();
@@ -139,6 +165,12 @@ public:
layoutChanged();
}
+ void fetchMore(const QModelIndex &parent) override
+ {
+ Q_UNUSED(parent)
+ addRow(m_rows - 1);
+ }
+
void clear() {
beginResetModel();
m_rows = 0;
@@ -159,6 +191,7 @@ signals:
private:
int m_rows = 0;
int m_columns = 0;
+ bool m_dataCanBeFetched = false;
QHash<int, QString> modelData;
};
diff --git a/tests/auto/quick/qquicktableview/tst_qquicktableview.cpp b/tests/auto/quick/qquicktableview/tst_qquicktableview.cpp
index 230dcc9446..6ae095a7d6 100644
--- a/tests/auto/quick/qquicktableview/tst_qquicktableview.cpp
+++ b/tests/auto/quick/qquicktableview/tst_qquicktableview.cpp
@@ -60,7 +60,7 @@ Q_DECLARE_METATYPE(QMarginsF);
auto PROPNAME = view->rootObject()->property(#PROPNAME).value<QQuickTableView *>(); \
QVERIFY(PROPNAME); \
auto PROPNAME ## Private = QQuickTableViewPrivate::get(PROPNAME); \
- Q_UNUSED(PROPNAME ## Private)
+ Q_UNUSED(PROPNAME ## Private) void()
#define LOAD_TABLEVIEW(fileName) \
view->setSource(testFileUrl(fileName)); \
@@ -120,6 +120,7 @@ private slots:
void checkRowHeightProviderNotCallable();
void checkForceLayoutFunction();
void checkForceLayoutEndUpDoingALayout();
+ void checkForceLayoutDuringModelChange();
void checkContentWidthAndHeight();
void checkPageFlicking();
void checkExplicitContentWidthAndHeight();
@@ -159,6 +160,7 @@ private slots:
void checkContextPropertiesQQmlListProperyModel_data();
void checkContextPropertiesQQmlListProperyModel();
void checkRowAndColumnChangedButNotIndex();
+ void checkThatWeAlwaysEmitChangedUponItemReused();
void checkChangingModelFromDelegate();
void checkRebuildViewportOnly();
void useDelegateChooserWithoutDefault();
@@ -174,6 +176,7 @@ private slots:
void checkSyncView_connect_late_data();
void checkSyncView_connect_late();
void delegateWithRequiredProperties();
+ void checkThatFetchMoreIsCalledWhenScrolledToTheEndOfTable();
};
tst_QQuickTableView::tst_QQuickTableView()
@@ -588,6 +591,29 @@ void tst_QQuickTableView::checkForceLayoutEndUpDoingALayout()
QCOMPARE(fxItem->item->height(), newDelegateSize);
}
+void tst_QQuickTableView::checkForceLayoutDuringModelChange()
+{
+ // Check that TableView doesn't assert if we call
+ // forceLayout() in the middle of a model change.
+ LOAD_TABLEVIEW("plaintableview.qml");
+
+ const int initialRowCount = 10;
+ TestModel model(initialRowCount, 10);
+ tableView->setModel(QVariant::fromValue(&model));
+
+ connect(&model, &QAbstractItemModel::rowsInserted, [=](){
+ QCOMPARE(tableView->rows(), initialRowCount);
+ tableView->forceLayout();
+ QCOMPARE(tableView->rows(), initialRowCount + 1);
+ });
+
+ WAIT_UNTIL_POLISHED;
+
+ QCOMPARE(tableView->rows(), initialRowCount);
+ model.addRow(0);
+ QCOMPARE(tableView->rows(), initialRowCount + 1);
+}
+
void tst_QQuickTableView::checkContentWidthAndHeight()
{
// Check that contentWidth/Height reports the correct size of the
@@ -2060,6 +2086,41 @@ void tst_QQuickTableView::checkRowAndColumnChangedButNotIndex()
QCOMPARE(contextColumn, 1);
}
+void tst_QQuickTableView::checkThatWeAlwaysEmitChangedUponItemReused()
+{
+ // Check that we always emit changes to index when we reuse an item, even
+ // if it doesn't change. This is needed since the model can have changed
+ // row or column count while the item was in the pool, which means that
+ // any data referred to by the index property inside the delegate
+ // will change too. So we need to refresh any bindings to index.
+ // QTBUG-79209
+ LOAD_TABLEVIEW("plaintableview.qml");
+
+ TestModel model(1, 1);
+ tableView->setModel(QVariant::fromValue(&model));
+ model.setModelData(QPoint(0, 0), QSize(1, 1), "old value");
+
+ WAIT_UNTIL_POLISHED;
+
+ const auto reuseItem = tableViewPrivate->loadedTableItem(QPoint(0, 0))->item;
+ const auto context = qmlContext(reuseItem.data());
+
+ // Remove the cell/row that has "old value" as model data, and
+ // add a new one right after. The new cell will have the same
+ // index, but with no model data assigned.
+ // This change will not be detected by items in the pool. But since
+ // we emit indexChanged when the item is reused, it will be updated then.
+ model.removeRow(0);
+ model.insertRow(0);
+
+ WAIT_UNTIL_POLISHED;
+
+ QCOMPARE(context->contextProperty("index").toInt(), 0);
+ QCOMPARE(context->contextProperty("row").toInt(), 0);
+ QCOMPARE(context->contextProperty("column").toInt(), 0);
+ QCOMPARE(context->contextProperty("modelDataFromIndex").toString(), "");
+}
+
void tst_QQuickTableView::checkChangingModelFromDelegate()
{
// Check that we don't restart a rebuild of the table
@@ -2617,7 +2678,27 @@ void tst_QQuickTableView::checkSyncView_connect_late()
QCOMPARE(tableViewVPrivate->loadedTableOuterRect.left(), 0);
QCOMPARE(tableViewHVPrivate->loadedTableOuterRect, tableViewPrivate->loadedTableOuterRect);
+}
+
+void tst_QQuickTableView::checkThatFetchMoreIsCalledWhenScrolledToTheEndOfTable()
+{
+ LOAD_TABLEVIEW("plaintableview.qml");
+
+ auto model = TestModelAsVariant(5, 5, true);
+ tableView->setModel(model);
+ WAIT_UNTIL_POLISHED;
+
+ QCOMPARE(tableView->rows(), 5);
+ QCOMPARE(tableView->columns(), 5);
+
+ // Flick table out of view on top
+ tableView->setContentX(0);
+ tableView->setContentY(-tableView->height() - 10);
+ tableView->polish();
+ WAIT_UNTIL_POLISHED;
+ QCOMPARE(tableView->rows(), 6);
+ QCOMPARE(tableView->columns(), 5);
}
void tst_QQuickTableView::delegateWithRequiredProperties()
@@ -2648,7 +2729,7 @@ void tst_QQuickTableView::delegateWithRequiredProperties()
auto model = QVariant::fromValue(QSharedPointer<MyTable>(new MyTable));
{
QTest::ignoreMessage(QtMsgType::QtInfoMsg, "success");
- LOAD_TABLEVIEW("delegateWithRequired.qml")
+ LOAD_TABLEVIEW("delegateWithRequired.qml");
QVERIFY(tableView);
tableView->setModel(model);
WAIT_UNTIL_POLISHED;
@@ -2656,7 +2737,7 @@ void tst_QQuickTableView::delegateWithRequiredProperties()
}
{
QTest::ignoreMessage(QtMsgType::QtWarningMsg, QRegularExpression(R"|(TableView: failed loading index: \d)|"));
- LOAD_TABLEVIEW("delegatewithRequiredUnset.qml")
+ LOAD_TABLEVIEW("delegatewithRequiredUnset.qml");
QVERIFY(tableView);
tableView->setModel(model);
WAIT_UNTIL_POLISHED;
diff --git a/tests/auto/quick/qquicktextedit/BLACKLIST b/tests/auto/quick/qquicktextedit/BLACKLIST
index 9df9c7d75a..36c7f0042f 100644
--- a/tests/auto/quick/qquicktextedit/BLACKLIST
+++ b/tests/auto/quick/qquicktextedit/BLACKLIST
@@ -1,2 +1,6 @@
[mouseSelection]
opensuse-leap
+
+# QTBUG-78846
+[mouseSelectionMode]
+opensuse-leap
diff --git a/tests/libfuzzer/qml/jsapi/evaluate/main.cpp b/tests/libfuzzer/qml/jsapi/evaluate/main.cpp
index 9e90ba7cbd..82b9847bca 100644
--- a/tests/libfuzzer/qml/jsapi/evaluate/main.cpp
+++ b/tests/libfuzzer/qml/jsapi/evaluate/main.cpp
@@ -32,7 +32,7 @@
// libfuzzer test for QJSEngine::evaluate()
extern "C" int LLVMFuzzerTestOneInput(const char *Data, size_t Size) {
- const QByteArray ba(Data, Size);
+ const QByteArray ba = QByteArray::fromRawData(Data, Size);
// avoid potential endless loops
if (ba.contains("for") || ba.contains("while"))
return 1;
diff --git a/tests/manual/scenegraph_lancelot/data/text/text_style2.qml b/tests/manual/scenegraph_lancelot/data/text/text_style2.qml
new file mode 100644
index 0000000000..984ca6a1ed
--- /dev/null
+++ b/tests/manual/scenegraph_lancelot/data/text/text_style2.qml
@@ -0,0 +1,37 @@
+import QtQuick 2.0
+
+//vary font style
+
+Item {
+ width: 320
+ height: 480
+
+ Column {
+ anchors.fill: parent
+ Repeater {
+ model: [Text.Normal, Text.Outline, Text.Raised, Text.Sunken]
+ Text {
+ renderType: Text.QtRendering
+ width: parent.width
+ wrapMode: Text.Wrap
+ font.pointSize: 10
+ style: modelData
+ styleColor: "green"
+ text: "The quick fox jumps in style " + modelData
+ }
+ }
+
+ Repeater {
+ model: [Text.Normal, Text.Outline, Text.Raised, Text.Sunken]
+ Text {
+ renderType: Text.NativeRendering
+ width: parent.width
+ wrapMode: Text.Wrap
+ font.pointSize: 10
+ style: modelData
+ styleColor: "green"
+ text: "The quick fox jumps in style " + modelData
+ }
+ }
+ }
+}
diff --git a/tests/manual/scenegraph_lancelot/scenegrabber/scenegrabber.pro b/tests/manual/scenegraph_lancelot/scenegrabber/scenegrabber.pro
index 24f0f8a315..704acd0aca 100644
--- a/tests/manual/scenegraph_lancelot/scenegrabber/scenegrabber.pro
+++ b/tests/manual/scenegraph_lancelot/scenegrabber/scenegrabber.pro
@@ -1,6 +1,5 @@
TARGET = qmlscenegrabber
DESTDIR=..
-macx:CONFIG -= app_bundle
CONFIG += console
QT += quick
diff --git a/tests/manual/scenegraph_lancelot/scenegraph/scenegraph.pro b/tests/manual/scenegraph_lancelot/scenegraph/scenegraph.pro
index dd0ef268b1..9deb46427e 100644
--- a/tests/manual/scenegraph_lancelot/scenegraph/scenegraph.pro
+++ b/tests/manual/scenegraph_lancelot/scenegraph/scenegraph.pro
@@ -10,6 +10,8 @@ SOURCES += tst_scenegraph.cpp
# Assuming that we are in a normal Qt5 source code tree
include(../../../../../qtbase/tests/baselineserver/shared/qbaselinetest.pri)
-TEST_HELPER_INSTALLS += .././qmlscenegrabber
+win32: TEST_HELPER_INSTALLS += .././qmlscenegrabber.exe
+else: macos: TEST_HELPER_INSTALLS += .././qmlscenegrabber.app
+else: TEST_HELPER_INSTALLS += .././qmlscenegrabber
TESTDATA += ../data
diff --git a/tests/manual/scenegraph_lancelot/scenegraph/tst_scenegraph.cpp b/tests/manual/scenegraph_lancelot/scenegraph/tst_scenegraph.cpp
index 40b17ec2a2..465e2a7d54 100644
--- a/tests/manual/scenegraph_lancelot/scenegraph/tst_scenegraph.cpp
+++ b/tests/manual/scenegraph_lancelot/scenegraph/tst_scenegraph.cpp
@@ -69,6 +69,7 @@ private:
quint16 checksumFileOrDir(const QString &path);
QString testSuitePath;
+ QString grabberPath;
int consecutiveErrors; // Not test failures (image mismatches), but system failures (so no image at all)
bool aborted; // This run given up because of too many system failures
};
@@ -90,6 +91,16 @@ void tst_Scenegraph::initTestCase()
QSKIP("Test suite data directory missing or unreadable: " + fi.canonicalFilePath().toLatin1());
testSuitePath = fi.canonicalFilePath();
+#if defined(Q_OS_WIN)
+ grabberPath = QFINDTESTDATA("qmlscenegrabber.exe");
+#elif defined(Q_OS_DARWIN)
+ grabberPath = QFINDTESTDATA("qmlscenegrabber.app/Contents/MacOS/qmlscenegrabber");
+#else
+ grabberPath = QFINDTESTDATA("qmlscenegrabber");
+#endif
+ if (grabberPath.isEmpty())
+ grabberPath = QCoreApplication::applicationDirPath() + "/qmlscenegrabber";
+
const char *backendVarName = "QT_QUICK_BACKEND";
const QString backend = qEnvironmentVariable(backendVarName, QString::fromLatin1("default"));
QBaselineTest::addClientProperty(QString::fromLatin1(backendVarName), backend);
@@ -201,11 +212,10 @@ bool tst_Scenegraph::renderAndGrab(const QString& qmlFile, const QStringList& ex
{
bool usePipe = true; // Whether to transport the grabbed image using temp. file or pipe. TBD: cmdline option
QProcess grabber;
- QString cmd = QCoreApplication::applicationDirPath() + "/qmlscenegrabber";
QStringList args = extraArgs;
QString tmpfile = usePipe ? QString("-") : QString("/tmp/qmlscenegrabber-%1-out.ppm").arg(QCoreApplication::applicationPid());
args << qmlFile << "-o" << tmpfile;
- grabber.start(cmd, args, QIODevice::ReadOnly);
+ grabber.start(grabberPath, args, QIODevice::ReadOnly);
grabber.waitForFinished(17000); //### hardcoded, must be larger than the scene timeout in qmlscenegrabber
if (grabber.state() != QProcess::NotRunning) {
grabber.terminate();