aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/quick/qquicklayouts
Commit message (Collapse)AuthorAgeFilesLines
* Fix wrong item-sizeHint-cache when StackLayout children were reorderedJan Arve Sæther2022-11-211-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | This fixes the Tests_StackLayout::test_addAndRemoveItems() autotest The code uses an index to look up the cached size hints. This index corresponds to the layout's item child index (which doesn't have to correspond to the children index). The vector of sizeHints then had to be in sync with the index of the child layout items for this to work. The problem here was that if the first item in the stack was removed (or siblings was reordered), the vector was not adjusted for this (basically we could get the size hint of an previously removed item). In order to avoid to keep the QVector<SizeHints> index in sync with the layout children index, we change it to use a QHash instead, where we look up by QQuickItem*. QHash<QQuickItem*, SizeHints> Task-number: QTBUG-106520 Task-number: QTBUG-106521 Change-Id: I7c1f9fb018fcab093b074c45dfaba264f76749f4 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io> (cherry picked from commit c41075d9e2808f636d793c93e237f80a8ecadb2e)
* Move StackLayout tests from qtquickcontrols.git (5.15)Jan Arve Sæther2022-09-301-0/+414
| | | | | | | | | | | | | | In 5.15 branch, there were still some autotests for StackLayout lurking around in the qtquickcontrols repo that wasn't moved to declarative for some reason. Move them to qtdeclarative repo. One of these tests also demonstrated a genuine failure, so we want to keep these tests. (It is currently skip()ped) (Moved from tests/auto/controls/data/tst_stacklayout.qml) Change-Id: I826228625c9f15b6028ad881adfc5370bdd17ca1 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io> (cherry picked from commit aaf7f7c6b77ed75caea236322f799742466f0b64)
* StackLayout: Do not set size of children to (-1, -1)Jan Arve Sæther2022-09-061-0/+50
| | | | | | | | | | | The item-size-hint-cache in StackLayout was not always valid when QQuickStackLayout::rearrange() was entered, so it would end up setting the size of the item to (-1, -1) Fixes: QTBUG-105899 Change-Id: I632aa18bb10b84d59af35cd3c7cb0c675d8d1692 Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io> (cherry picked from commit 9a4874ab7f18a54b2497f689dfd7f7a2ee0516b8)
* QuickLayouts: fix crash when layout width depends on parent widthIvan Solovev2021-01-221-0/+37
| | | | | | | | | | | | | | | | | | Some tricky cases of setting layout width based on parent layout width were leading to infinite recursive loop of layout size calculation (see the attached example in the related Jira task). Initially the QQuickGridLayoutBase::rearrange() method already had a recurse check, but it seemed to happen too late, so that the recursive calls kept happening from the ensureLayoutItemsUpdated() calls. This commit moves the recursion check up, so that it's actually executed before we have a chance to get to the next level of recursion. Fixes: QTBUG-87253 Change-Id: I473ee219e7b5b13547e33ebbd3a6d884de2c7d45 Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io> (cherry picked from commit 4f8041b01445fd4eec0beb133719645d00d0b2ac) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Follow layoutMirroring in Layout marginsDavid Edmundson2020-08-261-0/+41
| | | | | | | | | | | | | | | | If a layout is laid out left to right using the layoutDirection property, we want left Margins on the left, and rightMargin still on the right However, if a layout is mirrored, not only should the layout direction change but also the left margin should now be on the right and vice versa. Task-number: QTBUG-62989 Change-Id: Iaae4bc436fd1eb7f1947869563ac325f3d6b79bb Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io> (cherry picked from commit 16613f3741af013f7e380c98df6889d73512d0ad) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Improve performance when dynamically adding items to a layoutJan Arve Sæther2020-05-263-25/+126
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This was especially noticeable when a Repeater was populating the children of a layout, and its model was dynamically changed: When the model was changed, the repeater removed one item at a time until all items were removed, then applied the new model and then added all the new items for the new model. The layout reacted to that by doing a full sync of the QML layout into the internal gridlayout engine each time an item got removed or added. For very large layouts (or layouts that have complex size hints to calculate), this caused a major slowdown. This patch fixes that by postponing the sync until we get a updatePolish(), basically replacing most calls to updateLayoutItems() (which does the sync) with a call to invalidate() (which schedules a polish). It will also get rid of some binding loop warnings due to this change. This means that there is a small change in behavior: impicitWidth, implicitHeight and Layout.{min,max}imum{Width,Height} might in some cases be incorrect until the updatePolish() have been done. (This is however consistent with how Row/Column/Grid behaves) The creation test in qmlbench was quite simple, so it did not suffer from the most severe performance issues, but we did not regress: > compareresults: auto/creation/layouts/delegates_rowlayout.qml: improvement by 3.91% auto/creation/layouts/delegates_columnlayout.qml: improvement by 6.59% auto/creation/layouts/delegates_gridlayout.qml: improvement by 1.83% Overall average of differences: 4.11% And for the gridlayout_large.qml (Repeater with 1000 dynamically changing items): > compareresults: auto/layouts/gridlayout_large.qml: improvement by 66477.78% Overall average of differences: 66477.78% [ChangeLog][Qt Quick Layouts] Performance improvements to Qt Quick Layouts. This has the small side-effect that size hints (implicitWidth/implicithHeight etc) changes are not immediately emitted after a layout has been modified (e.g item added) Fixes: QTBUG-71839 Fixes: QTBUG-65121 Fixes: QTBUG-66017 Change-Id: I6922efe449134246df66b177992e4442747bc8fb Reviewed-by: Mitch Curtis <mitch.curtis@qt.io> (cherry picked from commit cc77a0bc549ce8f0b218661e7ae0e82e5b89e0da) Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
* Test if a layout with "fixed" size still do a rearrange if neededJan Arve Sæther2020-05-181-0/+57
| | | | | | | | | If a layout doesn't change size, it should in many cases still rearrange its children. Change-Id: I72ae893da5c561d282800f80c9ab0bec86c557a3 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io> (cherry picked from commit 7e5a691006c1051be1a163fa6a7d40effb6ef0bb)
* Do not match for line numbers in the source code in ignoreWarning()Jan Arve Sæther2020-04-021-3/+3
| | | | | | | | It makes it very volatile to source code changes.. Use the RegExp variant of ignoreWarning() instead. Change-Id: I9a9a26e844d5e7e30289d3843c89a9e6724f9f71 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* Fix a bug where a layout could crash or become non-responsiveJan Arve Sæther2020-02-121-0/+31
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | This happened because of that QQuickText is ill-behaving: When the width on a QQuickText with word wrap enabled is changed to something less than its implicitWidth, its implicitHeight is changed to reflect the height it needs in order to fit all lines. This will cause the layout to be invalidated, and rearranged again. However, at the same time it will also change its implicitWidth actually become wider than its initial implicitWidth (this seems to be a bug). So the next time it is rearranged it will actually be wide enough so that it doesn't need to wrap. This again will cause its implicitWidth and implicitHeight to change to reflect that only one line is needed, which again will cause it to rearrange, but since the item has a too small width for that it will again change the implicitHeight to reflect that it needs more lines..... This went on forever until there was a stack overflow. In addition it also caused an endless (that is, if it didn't stack overflow) updatePolish()/polish() loop (basically polish() was called from within updatePolish() continuously). To make the layout more robust for such "ill-behaving" items we have to add one recursion guard, and one polish-loop guard. Change-Id: I9f752ed320a100c8d0f0fd340347a556e63318e5 Task-number: QTBUG-73683 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* Qt Quick Layouts: Do not assert when specifying an invalid row/columnJan Arve Sæther2019-11-131-0/+33
| | | | | | | | We now print a warning and try to gracefully handle it Change-Id: I66e79fe918808f5fede78a23df50e9e95b7b832d Fixes: QTBUG-67204 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* Add missing emits from various property setters in {Grid,Row}LayoutJan Arve Sæther2019-10-251-0/+54
| | | | | | Change-Id: I3ac473b3d46ff1f898c1607deb6ad3d586753244 Fixes: QTBUG-79359 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* tst_gridlayout.qml: use createTemporaryObject()Mitch Curtis2019-09-121-41/+15
| | | | | | | | Ensures that items created in a function are destroyed upon failures in that function, and results in less code. Change-Id: I62b3b7c3a19dbb2128c5c45bdc7adf4fe80df70d Reviewed-by: Liang Qi <liang.qi@qt.io>
* tst_gridlayout.qml: convert to a proper data-driven testMitch Curtis2019-09-121-13/+26
| | | | | Change-Id: I9f2ccd3d4e6933d68b03d82c2c319aa2e8951e78 Reviewed-by: Liang Qi <liang.qi@qt.io>
* Fix items in layouts not being rendered when layers are usedMitch Curtis2018-07-092-0/+96
| | | | | | | | | | | | | | | | A layer effect is apparently considered a child item of the layout that manages the item, and this causes issues when layouting. As was done for positioners in 865b4ec8, exclude any items for which QQuickItemPrivate::isTransparentForPositioner() returns true from layouting. As that commit made QQuickItemLayer set it to true when the layer is enabled, QQuickShaderEffectSource will be excluded from layouting. Task-number: QTBUG-63269 Change-Id: I463ff8d0cea0dfd6c4273f376de347971040d3d0 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io> Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
* Add testcase for how align-to-pixel affects size hint normalizationJan Arve Sæther2018-03-021-0/+17
| | | | | Change-Id: I404b06daa5202f6cca887dc63dc4c86d432dd1e5 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* Fix flaky test - wait for the LayoutRequest to arriveJan Arve Sæther2018-03-011-0/+1
| | | | | Change-Id: I5fb8419bc86f0355ca19957456d2a3ebba3c9ef3 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* Move test for ignoreMessage to the topJan Arve Sæther2018-02-281-62/+60
| | | | | | | This should make it more robust to changes in line numbers Change-Id: I8394fce060e05226d02af0dad5f7d8d9552bc63b Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* test_defaultPropertyAliasCrash(): fix anchor warningsMitch Curtis2018-02-201-1/+0
| | | | | | | | The item was trying to center itself within a layout for some reason. Change-Id: I7a4bdf0fdce91cd1dad6ec9c5ae27a5fbe07408f Reviewed-by: J-P Nurmi <jpnurmi@qt.io>
* Layout: improve warning message when anchors are detectedMitch Curtis2018-02-201-1/+2
| | | | | | | | | | - Use the more explicit term "manage" to make it clear that the warning only applies to items that are direct children of a layout type. - Instruct users towards the proper way to position items within a layout: Layout.alignment. Change-Id: Id13af95457a689e41aeaead1f9a0f958f095fca9 Reviewed-by: J-P Nurmi <jpnurmi@qt.io>
* Only warn about actual *anchors* in layout childrenJan Arve Sæther2018-02-191-0/+61
| | | | | | | | | | | Do not warn if they don't actually pose a problem, such as having just anchors.margins: 42 in a layout child item (as demonstrated by the test) Change-Id: I01e4515e91d7d0df3ae6bf9061cebe5c51802998 Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
* Fix positioning and placement of initially invisible items in layoutsSascha Siebert2017-11-221-0/+35
| | | | | | | | | | | Instead of misusing implicitWidth/Height as a storage mechanism in scenarios where width/height is used for preferred size evaluation, new members are created to hold this information to prevent incorrect sizing in mentioned scenario and get rid of blocking signals. Task-number: QTBUG-57455 Change-Id: I102c45805c4106e5829b17b65c2e247b2381573f Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
* Fix outdated BSD license headerKai Koehne2017-10-174-10/+50
| | | | | Change-Id: Icc08925454445fc9497fb3bfd2c26efe90605983 Reviewed-by: Jani Heikkinen <jani.heikkinen@qt.io>
* QQuickLayout: ensure that all change listeners are removedMitch Curtis2017-02-223-0/+111
| | | | | | | | | | | | | | | | | | The first fix for QTBUG-51927 (59c6c0e0) went to 5.6.2, where only the SiblingOrder ChangeType was listened to by QQuickLayout. It was then cherry-picked to 5.7 (5149aa68), where SiblingOrder was still the only ChangeType in use. 3b4f00ec then optimized QQuickLayout by swapping connections for item change listeners, but didn't check for usages of change types elsewhere in the file. This patch moves the change types into a variable that ensures there is one place for future changes. 5.6 is not affected. Task-number: QTBUG-51927 Change-Id: Ifd6e0545ce543ab79d6415e007b35c457cacc83a Reviewed-by: Robin Burchell <robin.burchell@crimson.no>
* StackLayout: propagate rearrange() call to child layoutsOleg Yadrov2017-01-192-1/+109
| | | | | | Task-number: QTBUG-57867 Change-Id: I0190b892e2bc2966b82a0dbd99e53fd9d6848957 Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
* Avoid needless notifications when destroying layoutsJan Arve Saether2017-01-121-0/+21
| | | | | | | | | | | | | | | | | When deleting a layout with children, it ends up in ~QQuickItem(), which in turn will call setParentItem(0). setParentItem(0) will in turn call setEffectiveVisibleRecur(), which will recurse down all its descendants. Therefore, deleting a top level layout might trigger item change listeners for *all* its descendants, not only its direct children. This behavior might even cause crashes: The visibility changes will then trigger an invalidation of the layout, which will propagate up the parent hierarchy, and potentially call invalidate() on a partially-destroyed layout, which then might crash. Change-Id: I48e11d57f69e9011ced6c3a0b51e3d89b24ad5c1 Task-number: QTBUG-55103 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Fix crash on exit when using default property aliases with layoutsMitch Curtis2016-09-153-0/+120
| | | | | | | | | | | | | | The layout was being destroyed before the text, which meant that the removeItemChangeListener() call never got hit. To ensure that the listener is always removed, loop through each child in QQuickLayout's destructor. This is a manual cherry-pick of 59c6c0e0b1b5b46747595a58e11311b7393d7e70. Task-number: QTBUG-51927 Change-Id: I669f42beb8c3dd6b4b741cae0b16e017bb3409df Reviewed-by: J-P Nurmi <jpnurmi@qt.io>
* Add more tests for pixel snapping of sizesJan Arve Sæther2016-03-021-0/+31
| | | | | | Task-number: QTBUG-41216 Change-Id: I4456709ec5c4e61183fb4056a5f6d6bd9bd863d5 Reviewed-by: Paul Olav Tvete <paul.tvete@theqtcompany.com>
* Change test because of slight behavior change in the layout engineJan Arve Sæther2016-03-011-1/+1
| | | | | | | | | The test was assuming that pixel snapping did not change the minimum size hint of the layout. An upcoming patch to qtbase will change that. Change-Id: I53bed57d086aa9ba9972188b014140c95d7669b9 Task-number: QTBUG-41216 Reviewed-by: Jan Arve Sæther <jan-arve.saether@theqtcompany.com>
* Make test more data drivenJan Arve Sæther2016-03-011-43/+21
| | | | | Change-Id: Ia1c2d53c77da29337b4453046ddb3d526c7015e4 Reviewed-by: Jan Arve Sæther <jan-arve.saether@theqtcompany.com>
* Move QtQuick.Layouts to qtdeclarative from qtquickcontrolsJan Arve Saether2016-02-264-0/+1999
This is in order for it to be available without having to install Qt Quick Controls Change-Id: I3f0d0dc108829947cd189b7861944e556e00cef3 Reviewed-by: J-P Nurmi <jpnurmi@theqtcompany.com>