Commit Graph

237 Commits

Author SHA1 Message Date
Volker Hilsheimer 77886b496d Quick item view tests: fix compile warning
Don't use QCOMPARE for a true/false test, use QVERIFY. This conveniently
fixes the (bogus, perhaps) compiler warning with MSVC about comparing
a quint32 (the underlying type of the polishScheduled bitfield) with a
bool.

Pick-to: 6.5
Change-Id: Ib273ee30906e09955e849e65af2b7ff8ce3e2512
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
2023-04-18 13:11:16 +02:00
Santhosh Kumar 3214689afd Fix content position of list view
The content position of list view is incorrect, if populate animation
is configured with BottomToTop or RightToLeft layout direction. This is
because, we are not setting internal position for first item in the
list view.

This patch will set correct internal postion to the first item in list
view.

Fixes: QTBUG-111050
Change-Id: I1a233a938e2c088d176d79871a08bcd2a8edd6b3
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2023-03-03 12:02:00 +01:00
Sami Shalayel e1cebe8128 QQuickMouseArea: do not overload pressed-signal
Renames the pressed() getter of the pressed property in QQuickMouseArea
to isPressed() to avoid overloading the pressed()-signal.
Signals should not be overloaded. Also, it makes code generation in
qmltc more complicated.

Task-number: QTBUG-110029
Change-Id: I2373f4fe97b1e955b815825003bc746f2eaf43be
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2023-01-24 13:41:45 +01:00
Shawn Rutledge 14321d2736 tst_QQuickListView::QTBUG_38209: QTRY_COMPARE_GE instead of QTRY_VERIFY
We need to see the values when it fails. It turns out that the movement
can be exactly 100 on macOS, and that's also "more than just a couple
pixels" so it should be ok.

Pick-to: 6.5
Change-Id: I4dcdf647886dd5dcc7267a32b1dd9858fdccf64d
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2023-01-11 20:13:18 +01:00
Shawn Rutledge 0461a51c8e tst_QQuickListView::flickBothDirections: flick more
If we make flickDeceleration's default value platform-dependent and
often larger, this test begins failing because it expects to flick
all the way to the end of the ListView. If we flick a longer distance
(starting at the lower-right instead of in the middle of the ListView)
in the same time, it's more likely to get to the end.

An alternative would be to set flickDeceleration back to the old value
in this test.

Pick-to: 6.5
Change-Id: If85d9502ceef9fbf6fc087240572cc98326453a5
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2023-01-05 06:04:29 +01:00
David Redondo 99047ae219 QQuickItemView: Fix max(X/Y)Extent()
QQuickFlickable maxXExtent() and maxYExtent() return the amount of space
that is not shown when inside a ScrollView. QQuickItemView however just
returned width() if vertical and height() if horizontal. In these cases
just defer to the QQuickFlickable base implementation like minXExtent()
and minYExtent() already do.

Fixes: QTBUG-83890
Pick-to: 6.2 6.4
Change-Id: I7f4060c2f46ae07611bedceca0d322c5f7f6affb
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2022-11-22 17:01:07 +01:00
Marc Mutz 5eb52b7255 Port from container::count() and length() to size() - V5
This is a semantic patch using ClangTidyTransformator as in
qtbase/df9d882d41b741fef7c5beeddb0abe9d904443d8, but extended to
handle typedefs and accesses through pointers, too:

    const std::string o = "object";

    auto hasTypeIgnoringPointer = [](auto type) { return anyOf(hasType(type), hasType(pointsTo(type))); };

    auto derivedFromAnyOfClasses = [&](ArrayRef<StringRef> classes) {
        auto exprOfDeclaredType = [&](auto decl) {
            return expr(hasTypeIgnoringPointer(hasUnqualifiedDesugaredType(recordType(hasDeclaration(decl))))).bind(o);
        };
        return exprOfDeclaredType(cxxRecordDecl(isSameOrDerivedFrom(hasAnyName(classes))));
    };

    auto renameMethod = [&] (ArrayRef<StringRef> classes,
                            StringRef from, StringRef to) {
        return makeRule(cxxMemberCallExpr(on(derivedFromAnyOfClasses(classes)),
                            callee(cxxMethodDecl(hasName(from), parameterCountIs(0)))),
                        changeTo(cat(access(o, cat(to)), "()")),
                        cat("use '", to, "' instead of '", from, "'"));
    };

    renameMethod(<classes>, "count", "size");
    renameMethod(<classes>, "length", "size");

except that on() was replaced with a matcher that doesn't ignoreParens().

a.k.a qt-port-to-std-compatible-api V5 with config Scope: 'Container'.

Change-Id: I58e1b41b91c34d2e860dbb5847b3752edbfc6fc9
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2022-10-13 00:18:35 +02:00
Marc Mutz c2d490a238 Port from qAsConst() to std::as_const()
We've been requiring C++17 since Qt 6.0, and our qAsConst use finally
starts to bother us (QTBUG-99313), so time to port away from it
now.

Since qAsConst has exactly the same semantics as std::as_const (down
to rvalue treatment, constexpr'ness and noexcept'ness), there's really
nothing more to it than a global search-and-replace.

Task-number: QTBUG-99313
Change-Id: I601bf70f020f511019ed28731ba53b14b765dbf0
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2022-10-07 23:38:56 +02:00
Marc Mutz 958cd3ee10 Port from container::count() and length() to size()
This is a semantic patch using ClangTidyTransformator as in
qtbase/df9d882d41b741fef7c5beeddb0abe9d904443d8:

  auto QtContainerClass = anyOf(
      expr(hasType(cxxRecordDecl(isSameOrDerivedFrom(hasAnyName(classes))))).bind(o),
      expr(hasType(namedDecl(hasAnyName(<classes>)))).bind(o));
  makeRule(cxxMemberCallExpr(on(QtContainerClass),
                             callee(cxxMethodDecl(hasAnyName({"count", "length"),
                                                  parameterCountIs(0))))),
           changeTo(cat(access(o, cat("size"), "()"))),
           cat("use 'size()' instead of 'count()/length()'"))

a.k.a qt-port-to-std-compatible-api with config Scope: 'Container',
with the extended set of container classes recognized.

Change-Id: Idb1f75dfe2323bd1d9e8b4d58d54f1b4b80c7ed7
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-10-07 23:38:48 +02:00
Mitch Curtis 08398aed81 tst_qquicklistview: remove some bindings to parent
See ed73efa27a.

Pick-to: 6.2 6.3 6.4
Change-Id: I32434afcfd5faaf1c05b50cd96dfe6e6468f3ac4
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2022-08-25 09:56:09 +08:00
Mitch Curtis 811009ffea tst_qquicklistview: fail on warnings
Task-number: QTBUG-98718
Pick-to: 6.2 6.3 6.4
Change-Id: Ia1395236848582681d03f43792ca92ed07db0408
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2022-07-05 14:34:37 +08:00
Mitch Curtis 234afb5502 Add convenience API for making QQmlDataTest-based tests fail on warnings
After this patch, if a QQmlDataTest-derived class passes
FailOnWarningsPolicy::FailOnWarnings to the base constructor, any
non-empty warning encountered by that test will result in a test
failure.

This avoids the need to duplicate the catch-all regex in tests that
want to fail on warnings.

The goal is to gradually enable failure-on-warnings over time.

Leave comments and explicitly pass DoNotFailOnWarnings for tests that
should never fail on warnings.

Task-number: QTBUG-98718
Pick-to: 6.2 6.3 6.4
Change-Id: I4b647d93a0f28ac891c4bdb19ef74569f2918e8f
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2022-07-05 14:34:37 +08:00
Lucie Gérard 0dc4fd240a Use SPDX license identifiers
Replace the current license disclaimer in files by
a SPDX-License-Identifier.
Files that have to be modified by hand are modified.
License files are organized under LICENSES directory.

Pick-to: 6.4
Task-number: QTBUG-67283
Change-Id: I63563bbeb6f60f89d2c99660400dca7fab78a294
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2022-06-11 08:05:15 +02:00
Mitch Curtis e58626a02b tst_qquicklistview: fix some TypeErrors and ReferenceErrors
- Ensure that context properties outlive the view.
- Ensure that delegates don't unconditionally reference properties of
the parent (which may be null).
- Add missing TestObject and test model.

Task-number: QTBUG-98718
Pick-to: 6.2 6.3 6.4
Change-Id: Icaf3c6824674819c88fc7be51932e6d7e5fb205a
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2022-06-10 10:32:31 +08:00
Mitch Curtis 36c6c1ea57 QtQuickTest: add API for checking for polish at window level
This adds a qIsPolishScheduled(QQuickWindow *) overload of
qIsPolishScheduled(QQuickItem *) (added in
40d6072bc8) and deprecates
qWaitForItemPolished() (added in
7a3cad0619) in favor of qWaitForPolish(),
which has QQuickItem* and QQuickWindow* overloads.

The existing functions that take QQuickItem are useful, but testing
Qt Quick applications can be made even easier by allowing users to
check if a window has any items that need to be polished. This
information is already present (in QQuickWindowPrivate::itemsToPolish),
so it's very efficient to check for.

This is especially useful now that Qt Quick Layouts using polishing for
their layouting, for example, as it's no longer necessary to find
individual polishable items in complex hierarchies before proceeding
to interact with child items.

[ChangeLog][QtQuickTest][QQuickTest] Added
QQuickTest::qIsPolishScheduled(QQuickWindow *) and
QQuickTest::qWaitForPolish(QQuickWindow *) functions for verifying that
updatePolish() was called on one or more items managed by a window.

[ChangeLog][QtQuickTest][QQuickTest] Deprecated
QQuickTest::qWaitForItemPolished(QQuickItem *). Use the new
QQuickTest::qWaitForPolish(QQuickItem *) function instead.

Fixes: QTBUG-93757
Change-Id: I95b6e051b3c9fd2fa93604f4d9ccda486bb29f9d
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-06-02 12:46:11 +08:00
Fabian Kosmale 4f50697e6c Do not rely on transitive includes in tests
Change-Id: Icb68dbecab6f675352cd58333c82fa6648025367
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2022-02-14 12:38:10 +01:00
Mitch Curtis 5d656b31eb Revert "Fix ListView.isCurrentItem when used with DelegateModel"
This reverts commit d9f9d773e9.

It causes a heap-use-after-free in tst_swipeview.qml.

Task-number: QTBUG-97423
Pick-to: 5.15 6.1 6.2
Change-Id: I42e9831ae1399a010df28c39496a7778121f5e35
Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
2021-11-26 21:23:08 +01:00
Joni Poikelin d9f9d773e9 Fix ListView.isCurrentItem when used with DelegateModel
Fixes: QTBUG-86744
Pick-to: 5.15 6.1 6.2
Change-Id: I7287b39afc8f84e336aa46739b534e33e4212ea7
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2021-09-29 13:39:41 +02:00
Mitch Curtis e310dadef7 Consolidate test helpers into private libraries
Previously each test would include and build sources from the shared
folder. Now we make those sources a library, build it once, then have
each test link to it instead.

We also take the opportunity to move some helpers that qtquickcontrols2
had added into the quicktestutils library where it makes sense, and
for the helpers that don't make sense to be there, move them into
quickcontrolstestutils.

We add the libraries to src/ so that they are internal modules built as
part of Qt, rather than tests. That way we can use them in a standalone
test outside of qtdeclarative.

Task-number: QTBUG-95621
Pick-to: 6.2
Change-Id: I0a2ab3976fdbff2e4414df7bdc0808f16453b80a
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-09-13 21:17:04 +02:00
Ulf Hermann 7c60fc811e Avoid memory leak in tst_qquicklistview
Change-Id: I74733325cdd81aa304c2e55acb257b1dbdb1300d
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
2021-08-17 16:14:53 +02:00
Mitch Curtis 0e3902b83d ListView: support QList<QUrl> models
For now this patch just tacks on another list type, but there may be a
better way to account for all types in the future.

This change also adds tst_qquicklistview2 to speed up development.
tst_QQuickListView is 10000 lines long, and compiling it
is slow (36 seconds on a 2016 i7 MacBook Pro). In addition, a similar
approach (creating a second test to avoid the slowness of a massive one)
already exists for QQuickItem tests.

Task-number: QTBUG-72906
Pick-to: 6.1
Change-Id: I05455a2f20978b07eb38591ab63e7d0fb7dac1ab
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-04-29 13:20:09 +02:00
Jan Arve Sæther 79014a1b39 QQuickListView: Add autotest so that animated delegate does not crash
This is separate from the fix, since the test is supposed to also be
merged into dev. (Where the fix was not needed)

Task-number: QTBUG-86567
Pick-to: 5.15
Change-Id: I2cf1a4b11eed4fe356588aeff322d3a432f0fe83
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2021-02-03 12:01:40 +00:00
Shawn Rutledge ca4d628836 Attempt to stabilize tst_QQuickListView::sectionsSnap
It only failed due to being in a "bad" sequence with other tests somehow.
Fixing by reordering is lame, but I can't find the actual reason that it
fails, so far.

Task-number: QTBUG-86729
Change-Id: I8450c2e4b3119326c8518a526801cd10e933dca0
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2020-11-24 12:33:09 +01:00
David Skoland e47edfe7a7 Update tests to use new metaType system
Change from the QVariant enum to the QMetaType enum and prefer typeId
over userType where possible

Change-Id: Ic89c55978d46cc23d23b8e9c82c475c0c220fae3
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-11-02 14:56:00 +01:00
Volker Hilsheimer 1270a88cb3 Fix compile warnings from tests
Use streaming operators for debug/warnings to avoid qsizehint/int
conflicts.
Don't ignore return values from [[no_discard]] functions.
Don't copy elements from containers that return references.
Remove unused variables.

Change-Id: I7a0bef94a5e828bd8facee0c625ec48c3d1f1bdb
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2020-10-22 16:00:22 +02:00
Shawn Rutledge 6857ad3e68 QQuickListView: prevent mouse delivery in floating header or footer
Earlier we reimplemented the contains() method of ListView to prevent
dragging in an Overlay or Pullback header or footer. But in QQuickWindow
(QQuickWindowPrivate::pointerTargets()), an early check prevents
delivery of pointer events to an item that is clipped and for which
contains() returns false, and also to its children.  In that case, the
header or footer no longer responds to a mouse event even if you put a
MouseArea in it.

Reverts 6ad3445f1e159d9beea936b66d267dcaacdc5d6c; reimplemented using
similar logic in a new QQuickListViewPrivate::wantsPointerEvent()
method, overriding QQuickFlickablePrivate::wantsPointerEvent(), which
is now checked in event-handling code in addition to checking the
interactive flag.

Done-with: Wang Chuan <ouchuanm@outlook.com>
Pick-to: 5.15
Task-number: QTBUG-74046
Fixes: QTBUG-85302
Change-Id: I9474f035d26b74ee36c0ac19e45a77de2e694bf1
Reviewed-by: Wang Chuan <ouchuanm@outlook.com>
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2020-10-07 11:08:41 +02:00
Shawn Rutledge 21f9f02e94 Stabilize tst_QQuickListView::parentBinding
Some platforms aren't registering their mouse devices yet, and we don't
want false failures in CI because of that, so just register a mouse,
even if it ends up being an extra one a lot of times.

Task-number: QTBUG-86729
Change-Id: Ia3a91e3d1e4fb8df90352555c9a7ec6ea18bf6fe
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2020-09-24 23:09:23 +02:00
Shawn Rutledge d0ae3a312a Remove QQuickPointerDevice in favor of QPointingDevice
...and generally deal with changes immediately required after adding
QInputDevice and QPointingDevice.

Also fixed a few usages of deprecated accessors that weren't taken
care of in 212c2bffbb.

Task-number: QTBUG-46412
Task-number: QTBUG-69433
Task-number: QTBUG-72167
Change-Id: I93a2643162878afa216556f10808fd92e0b20071
Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
2020-06-23 17:44:03 +02:00
Fabian Kosmale ab03621516 Cull removed items from QQuickItemView
Amends a20132c326, which fixed a crash,
but also prevented the item from being culled. This is fixed by
narrowing the scope of the condition to affect only the caching related
part.

Fixes: QTBUG-84604
Pick-to: 5.15
Change-Id: I9b8a1a148d6538a18280475d89b87a4049ff3465
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2020-06-15 17:52:16 +02:00
Shawn Rutledge 880ce02104 Modernize tst_QQuickListView::QTBUG_39492
- Don't use context properties: a singleton is better
- Use required properties to declare dependendencies
- Rename to treeDelegateModelLayoutChange() to describe what it's testing
  rather than just a bug number, and because it's somewhat analogous to
  tst_QQuickPathView::treeModel()

Task-number: QTBUG-39492
Change-Id: I753bbdf625b8d8c82774b6a2b1754fe3c8895823
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2020-06-10 18:55:37 +02:00
Shawn Rutledge a24a49dfbb Autotests: use std::atomic in incubateWhile()
Followup to a9bf6e652a

Change-Id: Ic010f2610177f93f8fc4e2312d6736c96390e585
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2020-05-15 08:48:03 +02:00
Simon Hausmann 0293ea2991 Update dependencies.yaml and adapt to API changes in qtbase
The evaluation callback does not have to perform the comparison anymore
and the shared pointer of the private is not used in the API anymore.

Also, the versionFunctions() has been moved out of QOpenGLContext
and renamed QOpenGLVersionFunctionsFactory::get().

QHash doesn't keep iterators stable under erase(), so clean up
the code relying on it, and avoid an intermediate QList at the
same time.

Task-number: QTBUG-74409
Change-Id: I90176be1067d88c8f2b1ea07198a06d432f5be9c
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2020-04-22 10:21:44 +02:00
Ulf Hermann bc30b5f3b4 tst_qquicklistview: Fix a few memory leaks
Change-Id: I8bcd06ce79e1d6795a8249df6f72d4b583dbfa28
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
2020-03-23 09:58:47 +01:00
Ulf Hermann 34a5567ae6 tst_qquicklistview: Don't use QTest::toString()
This construction leaks the resulting character array. You need to
actually delete[] it. However, we can be pretty sure that there are no
questionable characters in those strings. Therefore we can just use
qPrintable instead.

Change-Id: Ib863f0ed7db800680a44df534e3b46a4ba807798
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2020-03-20 09:49:01 +01:00
Ulf Hermann 639196d093 Robustify QQuickListView test
We should check for the window's root item before accessing it.

Change-Id: I196d9cb4d0e525ffb62b3fd347fd986033cab3dd
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2020-02-27 12:16:30 +01:00
Ulf Hermann 6ba3dc8d48 Models: Make sure we can use QList<QObject *> as required model
We can use it as model passed via a context property as shown in the
objectlistmodel example. We should also be able to pass it directly
then.

Change-Id: I55db74df969d8024553d9470f1afe4710e61b1bf
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2020-02-06 08:53:39 +01:00
Qt Forward Merge Bot 7d86b35dc6 Merge remote-tracking branch 'origin/5.14' into 5.15
Conflicts:
	.qmake.conf
	src/qml/types/qqmlbind.cpp
	src/quick/items/qquicklistview.cpp
	tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp

Change-Id: Id6805c13256ad13d5651011e5dd09bba0ec02987
2020-02-06 08:41:57 +01:00
Jan Arve Sæther 01660fbb67 Fix some ListView bugs related to snapping when it had a header
Most bugs were related to the PullBackHeader header positining mode, for
instance the old code did not take into consideration that for the
PullBackHeader it was sometimes not sufficient to scroll the view. The
header also had to be scrolled independently from the view:

We achieve this by hooking on to the same timeline that is used for
scrolling the view. (This way, both animations are synchronized, and
they start and end at the same time).

Change-Id: I75708c0fd8d4741032c04ad9ee144d7a49cf3359
Fixes: QTBUG-76362
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2020-01-30 15:26:40 +01:00
Qt Forward Merge Bot 67ac9dead8 Merge remote-tracking branch 'origin/5.14' into 5.15
Conflicts:
	src/quick/items/qquickitemview.cpp

Change-Id: Ib9faebdbef5eebb80f4e6aeb5b15b5df7494b157
2020-01-20 09:37:57 +01:00
Wang Chuan a20132c326 QQuickItemView: fix crash when changing model
When visible items become invisible, ListView will try to cache
them and redisplay these items if necessary. However, we can't
cache items when changing to a new model, since the old one will
be deleted later

Fix by adding a flag to let ListView know we are clearing items
and prevent cache unnecessary items

Fixes: QTBUG-80203
Change-Id: I50dcd3f0586c93496b143bdad0e59751360501a8
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2020-01-15 10:25:21 +08:00
Qt Forward Merge Bot 8182a8044f Merge remote-tracking branch 'origin/5.14' into 5.15
Conflicts:
	src/qml/common/qv4compileddata_p.h

Change-Id: I1150c8cd0161f0e22137d383013751394ae64e18
2019-12-09 12:22:24 +00:00
Fabian Kosmale db321e7441 QQuickItemView: Emit correct change signal on model reset
As the variable was manually set to -1 beforehand, we would never emit
the change signal, leaving bindings stale. However, simply removing the
assignment would lead to not triggering the signal when currentIndex was
0. So now we set it to -2, which cannot happen in any other place.

Note that QTBUG-64998 was already mostly fixed due to earlier changes
fixing the currentItem part, only currentIndex was still broken

Fixes: QTBUG-68232
Fixes: QTBUG-64998
Fixes: QTBUG-63422
Change-Id: I885e06f1e258e67c3368d017bf79bff760440863
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2019-12-05 14:09:39 +01:00
Qt Forward Merge Bot 88490da44e Merge remote-tracking branch 'origin/5.14' into 5.15
Conflicts:
	tests/auto/quick/qquicklistview/tst_qquicklistview.cpp
	tests/auto/quick/qquicktableview/tst_qquicktableview.cpp

Change-Id: Ib46bc1c717cf524eea2fb3d876810c8d55747c91
2019-12-05 10:09:17 +01:00
Shawn Rutledge 6ad3445f1e Don't allow dragging a ListView through a floating header or footer
If the header or footer positioning is Overlay or PullBack, the list
delegates appear to scroll underneath it.  The header or footer can
contain interactive content.  If a mouse or touch press happens to
"fall through" that, it should not be possible to drag the ListView
contents from there.

[ChangeLog][QtQuick][ListView] ListView no longer allows the user to
press on an Overlay or PullBack header or footer and start scrolling,
but only on the content delegates.

Fixes: QTBUG-74046
Change-Id: I4d06c789286be2691d098aeebb10a57b2a335744
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
2019-12-04 15:14:04 +01:00
Mitch Curtis e2af7c3b37 Fix ObjectModel item not being rendered when moved between models
When moving an item from ObjectModel A to ObjectModel B, polishes are
scheduled for the respective ListViews in order: the ListView for A
first, and then the ListView for B. However, when it comes time to
do the actual polishing via updatePolish(), the list of items is
traversed backwards. This means that the following calls

    var item = objectModelA.get(0)
    objectModelA.remove(0, 1)
    objectModelB.insert(0, item)

will result in updatePolish() being called for ListView B first, and
then ListView A. As a result of this, setCulled(false) will be called
by ListView B (since the item is now visible within it), followed by
ListView A calling setCulled(true) (since the item is now no longer in
it).

As there is no way for these models to know about each other (and it's
not feasible to store refcounts in QQuickItemPrivate::extraData, since
ObjectModel is in QtQml.Models, which can't know about QtQuick), this
patch makes ListView check if the item is parented to its contentItem
before culling it. This prevents it from hiding items which are no
longer shown in its view.

Change-Id: If50614ebc269fae875195bbc63c0c04dab237775
Fixes: QTBUG-67986
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2019-12-04 15:00:25 +01:00
Richard Moe Gustavsen 1841a9e41d QQuickListView: implement support for reusing items
This patch will implement delegate item recycling in
ListView. The API will be the same as used in TableView, except
that it will be off by default since the behavior of a delegate
that is reused is not compatible with legacy applications
which were not written with this in mind.

Most importantly:

- Component.onCompleted will only be called on a delegate the
first time it's created, and never when it's reused.

- Any user-declared properties in the delegate (that is, not
model roles, index, etc) will not be cleared or updated when an
item is reused. The application must do this manually upon
receiving the pooled or reused signal in the item.

[ChangeLog][ListView] ListView now has support for reusing delegate
items. This can be switched on by setting the reuseItems property of
ListView to true.

Task-number: QTBUG-80507
Change-Id: I68cc8300b050e4a1f89feebb1d31a2fd9189c793
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2019-12-04 01:35:02 +01:00
Qt Forward Merge Bot af9a96ca10 Merge remote-tracking branch 'origin/5.14' into 5.15
Change-Id: I4e4464d785c8c4a0d06ffaaff3e1cdd94e1c179a
2019-12-04 01:00:41 +01:00
Fabian Kosmale 705e80b702 QQuickItemView: Set moveReason to other on model change
This implements Michael Brasser's suggestion in the bug report.
As there do not seem to be other bug reports related to the
fixupPosition change, this might already be enough.

Fixes: QTBUG-66163
Change-Id: Iee45621ff7081b280626f4a81dab9bd36a7ea6b7
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2019-12-03 15:42:22 +01:00
Qt Forward Merge Bot 66db74e53e Merge remote-tracking branch 'origin/5.14' into 5.15
Change-Id: I1359574c7d89aaf3328958e2f667ba1e599ff7f1
2019-10-11 01:00:19 +02:00
Liang Qi aa057451b3 Merge remote-tracking branch 'origin/5.13' into 5.14
Conflicts:
	src/plugins/scenegraph/openvg/qsgopenvgcontext.cpp
	tests/auto/quick/qquickpathview/tst_qquickpathview.cpp

Change-Id: I117c8d62b21800329d1035021d312d9924f83a1b
2019-10-10 13:59:00 +02:00