aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/items/qquicklistview.cpp
Commit message (Collapse)AuthorAgeFilesLines
* doc: delegateModelAccess was added in Qt 6.10Kai Uwe Broulik2025-11-061-0/+1
| | | | | | Pick-to: 6.10 Change-Id: I795c2a35e2fec71d8dbe481ff334b9bcfdf6692a Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Set explicit default security level of all files with default securityJan Arve Sæther2025-09-171-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | The files (folders) already processed are listed in each issue in epic QTBUG-134547 These files were processed half a year ago. In order to make it clear that all of these files are already processed, mark them with an explicit default security header. For the record, this was generated with this script: find -E . -regex ".*\.(cpp|h|hpp|mm|qml|js)$" | xargs python3 ~/bin/add-cra-header.py in the folders listed in each subtask of QTBUG-134547 (add-cra-header.py only exist at my desktop, but it simply adds the default security header if it doesn't already have any existing security header) QUIP: 23 Fixes: QTBUG-134547 Pick-to: 6.10 6.9 6.8 Change-Id: Ieb8c78ea6561fdbdd27c7b13185ece853eedf80f Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
* Release section item when the corresponding view item removedSanthosh Kumar2025-09-121-0/+4
| | | | | | | | | | | | | | | | | | | | | | | The section item has not been removed or added to the section cache in all cases when the corresponding delegate item has been moved out of the visible area, either during flick or scroll. This happens in a case where the delegate item has been requested to be removed (as it goes out of the visible area) from the list view, but it's not released from the delegate model due to its caching mechanism. When an item is outside the visible area, releaseItem() is triggered, intended to free the item and its sections. The problem arises when releaseItem() calls QQmlInstanceModel::release(), which caches the item in the delegate model, but does not free the section. This prevents the section item from being released properly. This patch releases the section item whenever removeItem is triggered from the list view, which happens when the delegate item is moved out of the visible area. Fixes: QTBUG-137172 Pick-to: 6.10 6.9 6.8 6.5 Change-Id: Ib7e78309e076e76750b03f3238a7501563a3962a Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
* Expose delegateModelAccess from QQuickItemViewUlf Hermann2025-03-181-0/+7
| | | | | | | | | | | | | | It mirrors the same property from any internal delegate model. If the internal model is not a delegate model, the value is "Qt5ReadWrite". [ChangeLog][QtQuick] ListView and GridView now have a new property delegateModelAccess. Setting it to DelegateModel.ReadWrite allows you to write values into the model via required properties just as you could with context properties. Task-number: QTBUG-132420 Change-Id: I72e27fd737ef2ef25da067e4192b58aad9084143 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Document better how listview snaps its items under its various modesJan Arve Sæther2025-03-061-0/+16
| | | | | | | Also add a manual test Change-Id: I28955a454eeaa8ab52431c85cd99649ccbb667d0 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* QQuickListViewPrivate::fixup: fix potential use-after-freeVladimir Belyavsky2024-12-141-8/+13
| | | | | | | | | | | When using the StrictlyEnforceRange highlight range mode, call updateHighlight() _before_ calling snapItemAt(), because if we do that later, the item returned by snapItemAt() might be destroyed as soon as updateHighlight() calls applyPendingChanges() internally. Fixes: QTBUG-129231 Pick-to: 6.9 6.8 6.5 Change-Id: I5d1dbac4730238302187d16476dd0c4aea614e13 Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
* Doc: add "Hiding Delegates" section to ListView's docsMitch Curtis2024-11-281-0/+22
| | | | | | | | This comes up often online, so let's document the official advice. Pick-to: 6.5 6.8 Change-Id: I926326bc3b033d38746a508e5c448b5b055effeb Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
* Doc: add "Avoid Storing State in Delegates" section to ListView's docsMitch Curtis2024-11-281-3/+21
| | | | | | | | | | | This is mentioned in a couple of places, so add a dedicated section and link to it. Also add a section to the Qt Quick best practices page. Pick-to: 6.5 6.8 Change-Id: I0ba528e6c37b0c9c82ca1847817251f176b7f978 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Doc:Update ListView Documentation of the property countDheerendra Purohit2024-10-291-1/+2
| | | | | | | | | | | The count property in ListView reflects the total number of items in the model.Add addtional clarification to ListView::count. Pick-to: 6.8 Fixes: QTBUG-120082 Change-Id: I20c4de57cc4f114b56db5adb36f34f5dc133bde9 Reviewed-by: Axel Spoerl <axel.spoerl@qt.io> Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* Doc: Replace \instantiates with \nativetypePaul Wicking2024-08-201-1/+1
| | | | | | | | | | | Since the implementation of the `\nativetype`-command in QDoc, the `\instantiates`-command is deprecated. Replace the use of the deprecated command in favor of its replacement. Pick-to: 6.8 Task-number: QTBUG-128216 Change-Id: I23d9f66d3f6db2e5f827d7868497a432bb9b0626 Reviewed-by: Venugopal Shivashankar <Venugopal.Shivashankar@qt.io>
* Views: use isNull for zero-size checks rather than isEmptyMitch Curtis2024-08-191-1/+1
| | | | | | | | | | | | QSizeF::isEmpty returns true if either dimension is negative, but according to tst_QQuickListView::resizeView, we support negative-sized views. Amends 37c25c6e74f4f74d7cca8f5b0f12a40ec0354f7e. Pick-to: 6.5 6.7 6.8 Change-Id: If860cd5a459adf75470e5fc2deba3967b2e66366 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* (List|Grid)ViewAttached: Narrow down the view typeFabian Kosmale2024-07-181-1/+1
| | | | | | | | | | | | | | | | | | The classes tried to reuse as much functionality as possible by putting it into the common base class, QQuickItemViewAttached. That however meant that the view property could only have the type QQuickItemView, confusing tooling. This change moves the property to the derived classes, and changes the type to the derived type (matching what is already documented). This is safe (API stability wise) because QQuickItemViewAttached does not exist as its own type in QML, and the C++ type exists only in a private header. Fixes: QTBUG-124412 Pick-to: 6.8 Change-Id: Ic613d2afce311d974072913a110a601ce2ee0251 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* ListView: take section size into account while snapping an item into placeIvan Solovev2024-06-271-0/+13
| | | | | | | | | | | | | | | | In case the sections are displayed using ViewSection.CurrentLabelAtStart, the section size should be taken into account while snapping the items. This patch extends the fixup() method to perform such checks. The drawback of this approach is that the position adjustment takes some time (because of the animation) and happens after the scrolling is finished. A better solution would be to fix the scrolling process in such a way, that no adjustment is needed during fixup. Fixes: QTBUG-30768 Pick-to: 6.8 6.7 6.5 6.2 Change-Id: I31a1a3af55afe8be4e8d7980cbb163622e3283bc Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Make more logging categories staticUlf Hermann2024-06-241-1/+1
| | | | | | | Non-static, non-forward-declared logging categories are deprecated. Change-Id: Iaeb0183ef7ca05bbd0f4587166096c29825cc175 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* ListView: fix potential out-of-bounds write to list of visible itemsVolker Hilsheimer2024-06-111-1/+4
| | | | | | | Fixes: QTBUG-122658 Pick-to: 6.8 6.7 6.5 Change-Id: I5bec0d9d880d362d2633d29ff644876736949bb5 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* Fix documentation of List/GridView countAlbert Astals Cid2024-04-221-1/+1
| | | | | | | | | It doesn't return the number of items in the view, it returns the number of elements in the model Pick-to: 6.7 6.5 6.2 5.15 Change-Id: Iea479ef0fef1823718d7681ae30bb49f60025237 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* ListView: allow binding on x and y in footer and header delegatesOliver Eftevaag2024-03-131-17/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is generally a bad idea, but it's technically a regression that was introduced in f03a9839b689a3a1810846bb8ec08e02a9bf23b5. The reason why it's not recommended to bind directly on x and y in delegates, is because the delegate item positions are determined by the item views layout, which are in conflict with the positional bindings. However, it should be possible to partially support positional bindings in the header and footer delegates, in ListView. The reason for using the word "partially", is because a ListView with horizontal orientation, should always place the header first (with x typically being 0). But the y axis, can in theory be set directly, since it won't cause overlap with the remaining delegate items. Same idea for vertical ListViews. Except that the y axis become the "primary" axis, when the orientation changes to vertical, meaning that the x axis will then be safe to modify. The model-view-delegate doc page is also updated, to discourage people from binding directly on x and y, in delegates that are meant to be used for item views. Fixes: QTBUG-122665 Pick-to: 6.7 Change-Id: I78363e159f14827a28dba7c72d1ecef45b0c6d2a Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* ListView: position delegate items at zero on the inactive axisOliver Eftevaag2023-11-181-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | FxListItemSG::setPosition() only cares about a single axis, which is based on the current orientation. If the orientation is Vertical, then the y axis will be used with positioning the delegate item, and if the orientation is Horizontal, then the x axis will be used instead. This would cause problems when the ListView is changing its orientation. Because if the ListView's orientation suddently changes from Vertical to Horizontal, then all the delegate items will keep their old y value, which FxListItemSG::setPosition() won't do anything about since the new "active" axis is now the x axis. This patch fixes the issue by resetting the value for the "inactive" axis back to zero, in pointForPosition() which is used by FxListItemSG::setPosition(). The problem wasn't noticeable when using a normal QQmlDelegateModel, since the delegate items would be created lazily when they needed to appear inside the viewport, at which point they'd be given the correct x and y values. (The position is first (0, 0), and then layoutVisibleItems will updated one of those values based on the orientation). But if the user decides to use a QQmlObjectModel based model instead, then the delegate items would all be created immediately with a persistent lifetime, which would never have their position reset as a natural result of the item view delegate lifecycle mechanism. Fixes: QTBUG-115696 Pick-to: 6.6 6.5 Change-Id: I5377aeb556be2f536794f489b8232c5b9675ab78 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Fix build without features.quick-transitionsTasuku Suzuki2023-10-141-0/+2
| | | | | Change-Id: I8e0c2c8962ae3c243d5b72a8bb678a77f1e2ab59 Reviewed-by: Santhosh Kumar <santhosh.kumar.selvaraj@qt.io>
* Doc: Fix documentation warnings in Qt Qml and Quick docsTopi Reinio2023-09-151-1/+1
| | | | | | | | | | | | | | | | | | | | | | | * src/qml/doc/src/qmlfunctions.qdoc:451: (qdoc) warning: Can't link to 'Extension Objects' * src/qml/doc/src/cppintegration/topic.qdoc:4: (qdoc) warning: Can't link to 'qtqml-cpp-integration-exposecppstate.html * src/quicktemplates/qquickpane.cpp:14: (qdoc) warning: Can't link to 'wheelEnabled' * src/quick/scenegraph/util/qsgtextnode.cpp:96: (qdoc) warning: clang couldn't find function when parsing \fn QSGTextNode::TextStyle QSGTextNode::textStyle() const * src/quick/items/qquicklistview.cpp:2020: (qdoc) warning: Can't link to 'ListView::cacheBuffer.' Pick-to: 6.6 6.5 Change-Id: I0d6f88239bb02ea2d012c998542dddc60f6d4ce3 Reviewed-by: Paul Wicking <paul.wicking@qt.io> Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* ListView: add extra note about reusing itemsRichard Moe Gustavsen2023-08-091-0/+4
| | | | | | | | | | | | The current documentation leads the reader to think that all items are always pooled as soon as they are flicked out the viewport. Add a small note that explains that this is not always the case. Pick-to: 6.6 6.5 6.2 Task-number: QTBUG-115317 Change-Id: I31bc7920ae7fa2477764f1f2ce33a29ef6825a3f Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* Update ListView doc to specify behavior of zero size viewSanthosh Kumar2023-07-131-0/+5
| | | | | | | | | | | Follow up patch for 37c25c6e74f4f74d7cca8f5b0f12a40ec0354f7e. ListView doesn't load any delegates when no size specified. This is made to improve performance of the view. Fixes: QTBUG-114166 Pick-to: 6.5 6.6 Change-Id: I5253301c244d191f3245e36dd983c179e9d99ed2 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* QQuickListView: Do not re-parent existing contextsUlf Hermann2023-07-111-1/+2
| | | | | | | | | | | | | If we're not creating a new context, we should not re-parent it. Otherwise it gets deleted in unexpected moments. Amends commit 471c909a688df0bc56b6bc7773767a1ad5ecd85f. Pick-to: 6.5 6.6 Fixes: QTBUG-115106 Change-Id: Ib51d80dda07096587c64ac2262d115ea08855cd2 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Fix grammar and links in ListView documentationMatthias Rauter2023-06-161-6/+6
| | | | | | Pick-to: 6.5 6.6 Change-Id: I0a72dab7d4bebddc7371c214d3c8a908bc233a1a Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Doc: Don't mix \value and \tableAndreas Eliasson2023-06-151-10/+4
| | | | | | | | | | | | | Fix broken \table that immediately followed a \value command. The table generated by the \value command and the content of the \table command got merged together with unexpected results. Remove the \table entirely, and use \inlineimage inside the \value command. Fixes: QTBUG-114421 Pick-to: 6.6 6.5 Change-Id: Ie4a18a82e375098a3a2e13820c1c957d191605c8 Reviewed-by: Venugopal Shivashankar <Venugopal.Shivashankar@qt.io>
* Flickable: Proportional wheel scrolling if deceleration is largeShawn Rutledge2023-06-121-9/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Many users have complained about scrolling via mouse wheel being more or less uncontrollable: it's very hard to scroll shorter distances, and multiple "clicks" of the wheel usually overshoot far beyond what was intended. It was possible to mitigate that by setting flickDeceleration, but then touch-flicking also became much more "sticky". So now we have the flickDeceleration property dedicated to touchscreen flicks only, with the default coming from QPlatformIntegration::FlickDeceleration. There's no QPlatformIntegration::StyleHint for mouse-wheel deceleration. We disable the old wheel-acceleration feature by default, because many users nowadays have fancier mice or touchpads that achieve the acceleration in their own way. That's achieved by having the wheel deceleration value set to 15000 by default, which would be quite "stiff" if it was applied to the timeline, but in fact is defined to mean that there will be no acceleration. If the default is changed to 14999 or less, we continue reusing the same animation timeline for both flicking and wheeling, and applying the same acceleration/deceleration as before. There's some risk that some users will miss the old behavior; so we add a new QT_QUICK_FLICKABLE_WHEEL_DECELERATION environment variable to allow the user to override the default (to something less than 15000). When acceleration is disabled (which it is by default), QQuickFlickable::wheelEvent() no longer calls flick(), but instead uses the timeline to move the contentItem directly. Includes a drive-by fix, that enables scrolling to continue, even after the contentItem has moved into an edge. This behavioral change makes sense now that the scroll movement is more predictable. fixup() will still be called, to trigger the rebound animation. This patch reduces the strength of wheelEvent scrolling, so it made small tweeks to tst_QQuickListView2::wheelSnap necessary. [ChangeLog][QtQuick][Flickable] When using a plain "clicky" mouse wheel, Flickable has historically applied acceleration: the faster you rotate the wheel, the faster it flicked. The default value of flickDeceleration was 5000, which felt hard to control, but changing it in QML affected touch-flicking and wheel behavior simultaneously. So now we decouple those: flickDeceleration only affects touchscreen flicking, and Flickable rather uses a new default value of 15000, which is defined to mean that scroll distance becomes directly proportional to QWheelEvent::angleDelta() * QStyleHints::wheelScrollLines() (where a "line" is 24 logical pixels, because Flickable does not have direct understanding of its contents). You can set the new environment var QT_QUICK_FLICKABLE_WHEEL_DECELERATION to a value from 1 to 14999 to restore wheel acceleration behavior from older versions; 5000 was the old value. Done-with: Oliver Eftevaag <oliver.eftevaag@qt.io> Done-with: Paul Olav Tvete <paul.tvete@qt.io> Task-number: QTBUG-35609 Task-number: QTBUG-80720 Task-number: QTBUG-82565 Fixes: QTBUG-97055 Fixes: QTBUG-106338 Pick-to: 6.6 Change-Id: I0645c08c9681f57bc749b4cc7f4d26507f5cb211 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
* Doc: Fix documentation issuesTopi Reinio2023-06-091-1/+1
| | | | | | | | | | | | * src/qmltest/TestCase.qml:267: (qdoc) warning: Cannot find file to quote from * src/quick/items/qquicklistview.cpp:2223: (qdoc) warning: Unknown command '\section' Pick-to: 6.6 6.5 Change-Id: I480d3bd622856a1f3c8e63075913c96c49179426 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Doc: Mask some QML attached properties as read-onlyIvan Tkachenko2023-06-061-0/+10
| | | | | | | This affects ListView, GridView, PathView and StackLayout. Change-Id: Iacff4cf9118323916ca66bd755736a397c26fc43 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* Add documentation of workaround for jumpy scroll barsMatthias Rauter2023-05-311-1/+13
| | | | | | | | Fixes: QTBUG-76830 Fixes: QTBUG-108171 Pick-to: 6.5 Change-Id: Ic0fe388fe01438ba4599675bee2509a451a8ca7b Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* QQuickItemView: Skip instantiating delegates if size is 0Fabian Kosmale2023-04-201-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | If the area of a (List|Grid)View is 0, then instantiating delegates is pointless, as they couldn't be shown anyway. However, our current logic could not handle this case well, and would end up instantiating a delegate for every delegate entry if their size also ended up being 0 - you can after all fit infinitely many 0 sized items into a zero sized container. Detect this situation in QQuickItemViewPrivate::refill and the applyInsertionChange implementations. Note that we only exit early if there are no visible items and the view is zero-sized; if there are visible items, we still want to ensure that they are removed after all. We also need to adjust a few tests which had zero sized views to no longer be zero sized; otherwise they wouldn't have created their delegates in time. [ChangeLog][QtQuick][ListView][Important Behavior Change] If a ListView has size zero, it won't instantiate any delegates until its size becomes non-zero. Pick-to: 6.5 Fixes: QTBUG-110625 Fixes: QTBUG-89568 Fixes: QTBUG-51773 Change-Id: Ibe0e6fa5f01784016882522c120d2fee38df285b Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* QQuickListView: relayout when section geometry changesWang Chuan2023-04-191-0/+8
| | | | | | | | | | | | | | | | | | | Section delegate items will now notify the ListView when their geometry changes. Enabling the ListView to call layoutVisibleItems to rearrange the delegate items based on the geometric changes made to the section delegate. The listener is added when the item is created or fetched from the cache. The listener is removed when the item is hidden or removed from the scene. Fixes: QTBUG-101985 Fixes: QTBUG-100002 Pick-to: 6.2 6.3 6.4 6.5 Change-Id: Ia7617424a8447ba82f62629d93b6a000a72bfc02 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* doc: Use \value rather than \li for enumeration values and constantsShawn Rutledge2023-03-281-65/+48
| | | | | | Pick-to: 6.2 6.5 Change-Id: Ica8354a53d0a5fb5dd1d8cd5f774dcdc56b6f99a Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* Fix build with -no-feature-quick-viewtransitionsTasuku Suzuki2023-03-071-1/+31
| | | | | | Pick-to: 6.5 Change-Id: I609a843bddbd0776452d289b144dab803503a483 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Fix content position of list viewSanthosh Kumar2023-03-031-0/+6
| | | | | | | | | | | | | | | 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>
* ListView: Mention section's support for required propertiesFabian Kosmale2023-03-021-1/+2
| | | | | | | | | | It was used in the code snippet, but we didn't explain so far why it was there. Pick-to: 6.5 6.4 6.2 Change-Id: I53005d897f4a3732b7707c7cc0e88f2842ca7433 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io> Reviewed-by: Santhosh Kumar <santhosh.kumar.selvaraj@qt.io>
* ListView: Do not create context for section if component is boundFabian Kosmale2023-03-011-7/+11
| | | | | | | | | | | | | | | | | | | ListView's section needs to inject a "section" property for compatibility, unless a required property is used for this case. So far, this made it impossible to use ComponentBehavior: Bound with sections. Remedy this by not creating a separate context if we detect that required properties are used. Adjust the check in QQuickListViewPrivate::setSectionHelper: If we don't create a custom context, it might pick up the context property from somewhere else; but we can then detect that the used context is internal, and use that check to decide whether we should call setContextProperyt or setProperty. Fixes: QTBUG-111433 Pick-to: 6.5 Change-Id: Icd3c138d48f790db92d02c53613539f8f17f5c77 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QtQuick: Fix conflicting definition of MinimumFlickVelocity in CMake Unity ↵Friedemann Kleint2023-02-071-1/+2
| | | | | | | | | | | | (Jumbo) builds Move constant MinimumFlickVelocity to a common header and prefix it to avoid clashes in static builds. Pick-to: 6.5 Task-number: QTBUG-109394 Change-Id: Ic4178a3e7c1ea930a711c4e04f26edda19ad3efb Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Fix crash in ListView with PullBackHeader/FooterRobert Griebl2023-01-251-2/+6
| | | | | | | | | | | | | | | | | | The header/footer positioning code would otherwise call qBound() with max < min when a PullBackHeader/Footer is used and the delegates do not fill the whole content area (i.e. the list does not need scrolling). After qtbase ad5c5bb541ae20a205ac07122153b302dee1d3e1 that was causing an assertion failure. Even though relying on the old qBound() behavior seems strange, it does produce the correct header/footer positioning, while swapping the min/max values (in case max < min) does not. So we need to call qMin and qMax explicitly rather than using qBound, to avoid the assert. Task-number: QTBUG-104679 Pick-to: 6.4 6.5 Change-Id: Iefc50e347e77ed51c6d90ddbc6e1cf21d76fc62c Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* QQuickListView: suppress GCC13 warning about maybe-uninitialized posThiago Macieira2023-01-111-1/+1
| | | | | | | | | | | | | | | | | It is initialized in all possible branches, except in case the switch (headerPositioning) didn't match anything. We could fix that by making that switch an IILE, but it doesn't cost us much to simply initialize pos. In function ‘constexpr const T& qMin(const T&, const T&) [with T = double]’, inlined from ‘constexpr const T& qBound(const T&, const T&, const T&) [with T = double]’ inlined from ‘virtual void QQuickListViewPrivate::fixup(QQuickFlickablePrivate::AxisData&, qreal, qreal)’ qminmax.h:40:73: error: ‘pos’ may be used uninitialized [-Werror=maybe-uninitialized] qquicklistview.cpp:1690:15: note: ‘pos’ was declared here Pick-to: 6.5 Change-Id: Ide4dbd0777a44ed0870efffd1739193e2c1df40c Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
* ListView: Snap one item mode fix next item calculationEvgen Pervenenko2022-11-081-8/+8
| | | | | | | | | | | | | Details: Move value for velocity less than 0 should consider size of item, for getting correct position for next item, bias should not be considered with press position when QWheelEvent::phase() gives us NoScrollPhase because it is possible to use value saved last time (last wheelevent with press position) Fixes: QTBUG-98979 Pick-to: 6.2 6.4 Change-Id: I825033c958602032f699f2c207b0a4312dd96c8c Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
* Port from qAsConst() to std::as_const()Marc Mutz2022-10-071-7/+7
| | | | | | | | | | | | | | 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>
* Port from container::count() and length() to size()Marc Mutz2022-10-071-36/+36
| | | | | | | | | | | | | | | | | | | | 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>
* Use SPDX license identifiersLucie Gérard2022-06-111-38/+2
| | | | | | | | | | | | 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>
* Item views: fix error when accessing attached view from non-delegatesMitch Curtis2022-06-101-0/+10
| | | | | | | | | | | | Ensure that the view is set on the relevant attached objects before QQmlComponent::completeCreate() is called, which would otherwise result in a TypeError because the view would be set too late. Fixes: QTBUG-104026 Task-number: QTBUG-98718 Pick-to: 6.2 6.3 6.4 Change-Id: Ic65370bd4534e7452f2377ab4d60a74badf02079 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* QQmlDelegateModel: Consider only top level required propertiesUlf Hermann2022-05-171-1/+1
| | | | | | | | | Required properties deeper inside the delegate must not suppress the passing of model data via the context. Fixes: QTBUG-103479 Change-Id: I2d350d93633a87b90e7a7d08b1e26a06a966b24a Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Avoid memory leaks in QQuickListView and tst_qqmlinstantiatorUlf Hermann2022-05-111-1/+3
| | | | | | Pick-to: 6.2 6.3 Change-Id: Ieceffedb082e893b54bcda99076df3ccdeff6010 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* QQuickListView: Stop overlap for section and firstItem delegatesOliver Eftevaag2022-01-201-1/+6
| | | | | | | | | | | | | | | | | | | | | | | | | Problem: The first delegate after a section delegate would have the same position as the section delegate, if the section delegate is invisible during initialization. In case the section delegates become visible later on during program execution, the delegates would be re-positioned again in the QQuickListViewPrivate::layoutVisibleItems function. But this would not call setPosition for the first item (delegate). It would only call setPosition for all delegates after the first one. This would mean that the position for the first delegate would never be updated, after the delegate was first created. Solution: Call FxListItemSG::setPosition() for the first item in QQuickListViewPrivate::layoutVisibleItems, just like we're already doing for all the items after the first one in the for-loop. Fixes: QTBUG-94848 Pick-to: 6.3 Change-Id: I34a5ada336ab507b31e3675a1c11eba066fa139a Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Move Q_DECLARE_PUBLIC to the public sectionThiago Macieira2021-11-271-1/+1
| | | | | | | This is now required to use QObjectPrivate::connect. Change-Id: Iccb47e5527544b6fbd75fffd16b8bd87f0818ad5 Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* If ListView visibleItems count is zero update footerTony Leinonen2021-11-191-0/+4
| | | | | | | | | | | After removing the last visible item from ListView the footer jumped back to its original position. Call updateFooter if the are no items in the visibleItems list to set the footer to its correct position. Task-number: QTBUG-86044 Pick-to: 6.2 Change-Id: Id226304030ecc8db26d413670a908f50feef5ba0 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QQuickItemView: avoid leaking of highlights and animatorsUlf Hermann2021-10-291-22/+19
| | | | | | | | | It's unclear where exactly they leak, but the tst_snippets test in quickcontrols exposes it. Turning them into unique_ptrs is the clean solution anyway. They are clearly owned. Change-Id: I076ea86639b1e0ab3f688eb982b4cee6cb908f6b Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>