aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/items/qquickitemview.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Add itemAtIndex to quick viewsPaolo Angelelli2019-01-171-0/+7
| | | | | | | | | | | | This patch adds itemAtIndex method to ItemView-derived views and to PathView. [ChangeLog][QtQuick][QQuickItemView] Added itemAtIndex() to GridView, ListView and PathView to fetch a visible delegate by index. Change-Id: Id8475d06c1481036984fe5109bb52cf2729b1c21 Fixes: QTBUG-72961 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Item Views: cancel flicking before a model resetTobias Koenig2018-10-191-0/+1
| | | | | | | | | | | While the view is flicking, if the content is updated by a model reset, it gets very confused and creates many delegates that won't be shown inside the visible area. Now we cancel any active flicking before the model reset is handled. Fixes: QTBUG-70742 Change-Id: I6f7aa368b760a00d08c540f3963c32e1e174a908 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Item Views: cancel flicking before programmatic absolute positioningShawn Rutledge2018-10-111-0/+2
| | | | | | | | | | | | When the velocity timeline is driving movement and simultaneously someone calls positionViewAtIndex(), it gets very confused and goes on creating and destroying delegates for a very long time. So now we cancel the flicking animation immediately when calling any of the positionViewAt* invokables. Fixes: QTBUG-70941 Change-Id: I85e09344e79356b877a57ab634f72be1d7f93fca Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* QQuickItemView: Don't change the viewport while in layoutUlf Hermann2018-09-271-0/+6
| | | | | | | | | Moving the viewport in the middle of a layout operation is a bad idea as it causes the visible items to change. Task-number: QTBUG-49224 Change-Id: I45a214560e00b65ed53b9385e7a539bb4304b7d9 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* QQuickItemViewFxItem: factor out FxViewItem from QQuickItemViewRichard Moe Gustavsen2018-03-231-104/+2
| | | | | | | | | | | FxItemViews wraps the QQuickItems used in QQuickItemView with additional item view information, like transition status. This patch will factor out FxItemView so that it can be reused in the coming QQuickTable as well. Change-Id: I5544b177d0ff28b2cbb76f33343808d953ec47bd Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
* use nullptr consistently (clang-tidy)Shawn Rutledge2018-02-261-41/+41
| | | | | | | | | | | | | From now on we prefer nullptr instead of 0 to clarify cases where we are assigning or testing a pointer rather than a numeric zero. Also, replaced cases where 0 was passed as Qt::KeyboardModifiers with Qt::NoModifier (clang-tidy replaced them with nullptr, which waas wrong, so it was just as well to make the tests more readable rather than to revert those lines). Change-Id: I4735d35e4d9f42db5216862ce091429eadc6e65d Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* QQuickItemView::currentItemChanged called upon currentItem destructionAleix Pol2018-02-131-0/+7
| | | | | | | | | There were some cases where the signal wasn't emitted and we ended up with events being delivered to objects that didn't exist anymore. Task-number: QTBUG-65881 Change-Id: I847669a978e82a0332907b029a8295bb993d2850 Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
* Fix transition when removing the last item from ListView/GridViewKari Hautamäki2018-02-021-1/+3
| | | | | | | | | Use the previous item view boundaries (before a remove was applied) when defining transition properties. Task-number: QTBUG-64311 Change-Id: I66870a7267ac26ea430c364383f32fd5c47d4a5d Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* QQuickItemView: Clear pending changes when refillingUlf Hermann2017-12-181-35/+41
| | | | | | | | | | | | | | | | | | | | | | | | | Generally the bufferedChanges are an "extension" of the currentChanges, which can just not be applied at the moment because we are in a layout phase. If we regenerate or clear the whole view in the mean time, the bufferedChanges become just as invalid as the currentChanges. On top of that, refilling can trigger further changes, part of which will be applied during the refilling. As that leaves us in an inconsistent state, we need to loop the refilling until no further changes are generated. As the changes might affect items that are already visible, and therefore not subject to refilling, we need to clear all the items before refilling in this case. In QTBUG-46488 things are added in the onCompleted callback of the delegates (by expanding the tree view, which translates into adding rows to the list view). Depending on where you add the new items, the list view might pick them up when iterating the model on refill() or it might create delegates for the same model entry twice. So, if that happens we need to discard the result and refill again. Task-number: QTBUG-46488 Change-Id: Ie4e0a731f7feda6aa962b6cb9a6cd5c3bf90486e Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* QQmlDelegateModel: add incubationStatus(), and use it to determine ↵Richard Moe Gustavsen2017-11-301-3/+9
| | | | | | | | | | | | | | 'requestedIndex' We used to assign the currently incubating item to 'requestedIndex' based on requested incubation mode alone. This is not sufficient, as the item can also be loaded async when the mode is AsyncIfNested. To check if the item is really loading async (and that we're not getting nullptr because of some other failure), we need to ask the incubator. Task-number: QTBUG-61537 Change-Id: Id1f458db4a7584a6b58d5bad0e7832ce4fc341dc Reviewed-by: J-P Nurmi <jpnurmi@qt.io>
* QQmlIntanceModel: use QQmlIncubator::IncubationMode instead of bool to ↵Richard Moe Gustavsen2017-11-301-5/+5
| | | | | | | | | | | | | | | | | | | | | | specify incubation mode The current implementation would pass a boolean to signal if asynchronous or synchronous incubation should be used to create an item. The problem with this approach is that passing 'synchronous" would translate to QQmlIncubation::AsynchronousIfNested later down the chain. This meant that even if the caller requested synchronous incubation, it could end up with asynchronous incubation anyway, e.g if an async parent incubator was active at the time of the call. And this can easily come as an unhandled supprise for the caller, and as such, cause unforseen bugs. This patch is a first of a set of patches that is done to fix the bug reported in the task below. It will not change any behavior, it is written to preserve the logic exactly as it were, just as a preparation for subsequent patches. It makes it explicit at the call location what incubation mode will be used, and especially make it clear whenever the AsynchronousIfNested flag is in play. Task-number: QTBUG-61537 Change-Id: I8b3ba5438ebb2cd59983a098bd8ceeeb844da87b Reviewed-by: J-P Nurmi <jpnurmi@qt.io>
* Fix ListView::positionViewAtIndex with ListView.Contain modeJoni Poikelin2017-11-071-11/+16
| | | | | | | | | Sticky headers and footers weren't accounted for when calculating new view position causing the requested item to be left behind them. Task-number: QTBUG-63974 Change-Id: Id69579643a942e8558960b2c8b0fee980fa86947 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Fix providing correct velocity when using index based scrollingPasi Petäjäjärvi2017-11-031-3/+0
| | | | | | | | | Index based scrolling does not enable moving and flicking properties. Task-number: QTBUG-34576 Change-Id: Ief06d37115ca389027670c97ce6c0457a74d4872 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* QQuickItemView: always honor the removeDisplaced animationAlberto Mardegan2017-11-031-1/+11
| | | | | | | | | | | | | | | The animation was not being performed if the delayRemove attached property was changed by the handler of the remove() attached signal. We need to run the delayed transitions not only if we have an animation for the target item, but also if we have an animation for the items being displaced. (The flag variables can safely be obtained outside of the for loop, given that their value should not change during the loop iteration) Task-number: QTBUG-57225 Change-Id: I8c138677d7dcdf63e0932ec5cf7738c0caeb2ab8 Reviewed-by: J-P Nurmi <jpnurmi@qt.io> Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* ListView: don't stop moving the highlight because of model updatesShawn Rutledge2017-11-031-1/+0
| | | | | | | | | | | | | | | | | In QQuickItemViewPrivate::applyModelChanges(), if moveReason = QQuickItemViewPrivate::Other, then QQuickItemView::trackedPositionChanged() will fail to call d->setPosition(pos), which is normally what keeps the Flickable moving for a while. Leave the reason as-is (it will be SetIndex in this case), so as not to forget that we were actually trying to move down. Updating the model was just a side-effect of that: either because some QML code was trying to append to the model or because fetchMore() was called. Task-number: QTBUG-61269 Task-number: QTBUG-62864 Change-Id: I3fd402469950d6c12e6a8d6e42be83ea4f54776a Reviewed-by: J-P Nurmi <jpnurmi@qt.io>
* QQuickItemView: avoid wrong repositioning of removed itemsAlberto Mardegan2017-11-031-2/+3
| | | | | | | | | | | | | If all the items currently in the view are being removed, lastVisibleIndex will be -1. This caused an unwanted repositioning of all the deleted items, which got moved to a wrong location. Therefore, when all visible items are removed, we should avoid recomputing any item's position. Task-number: QTBUG-57225 Change-Id: I9909748a9cccb5e6a3726306e250921ce69fcba9 Reviewed-by: J-P Nurmi <jpnurmi@qt.io> Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Fix ListView::StrictlyEnforceRange with resizing delegateMichael Brasser2017-08-091-1/+1
| | | | | | | | | | | When fixupPosition is called for a ListView with StrictlyEnforceRange, the original reason for the move is lost, and the fixup is applied immediately. There are already checks for whether the view is moving, so expand these checks to include movement caused by highlight. Change-Id: I25f771b9a529d31dc28acb9f91fcd2b582428200 Task-number: QTBUG-33568 Reviewed-by: Robin Burchell <robin.burchell@crimson.no>
* QQuickItemView: fix releaseItem() loopsJ-P Nurmi2017-06-121-6/+2
| | | | | | | | | | | | | | Calling releaseItem() destroys the item, which emits childrenChanged for the contentItem, and if at that point anything calls setFooMargin(), setContentHeight(), returnToBounds(), or many other methods that indirectly access the visibleItems list, it leads to a crash due to read after free. Add a releaseVisibleItems() helper method that makes a copy, clears the original list first, and then releases the items. Task-number: QTBUG-48394 Task-number: QTBUG-61294 Change-Id: I29e4d3870d33549e8bf789de84c67ab1826fca7d Reviewed-by: Robin Burchell <robin.burchell@crimson.no>
* Run includemocs in qtdeclarativeThiago Macieira2017-04-261-0/+2
| | | | | Change-Id: I84e363d735b443cb9beefffd14b8c023a37aa489 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* QQuickItemView: use some more C++11 range for loopsJ-P Nurmi2017-01-181-35/+34
| | | | | Change-Id: Ief706dfce0c81351ac06b8791267107ad8165974 Reviewed-by: Robin Burchell <robin.burchell@crimson.no>
* Port existing qmlInfo callers to qmlWarningRobin Burchell2017-01-111-2/+2
| | | | | | | | | | | | | Now that qmlInfo actually reports info messages, we want to change existing callers to use warning-level messages to preserve the original message level. This was done through: perl -p -i -e "s/qmlInfo\(/qmlWarning\(/" **/*.{cpp,h,qdoc} .. with a little care taken to only add the hunks that should be changed. Change-Id: I511cee11ce0a26ec1048cd2b84c7536b812a0d89 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Merge remote-tracking branch 'origin/5.8' into devLiang Qi2016-11-231-2/+2
|\ | | | | | | | | | | | | Conflicts: src/qml/jsruntime/qv4object_p.h Change-Id: Iff4d3aba7710a999b8befdc493cbe959e1ce02f9
| * Quick: Do not calculate the difference in a geometryChangeErik Verbruggen2016-11-101-2/+2
| | | | | | | | | | | | | | | | | | | | | | This difference is only used by the ListView, so calculating it and storing it (on the stack) introduces a penalty for all items. As the new geometry is already applied, the old geometry is passed along. This has the added advantage that the ListView does not have to re-calculate that either. This fixes a performance regression. Change-Id: Id5e67bb663a5b11a55ec15ff24ca5b213d1fcef5 Reviewed-by: Gunnar Sletta <gunnar@sletta.org>
* | Quick: mark some methods as constAnton Kudryavtsev2016-10-121-3/+3
| | | | | | | | | | | | | | These methods do not modify objects. Change-Id: Ibb2622cad6fbcec31c785f5d032304c648372350 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | QQuickItemView: Extract Method fxViewItemAtPosition()Anton Kudryavtsev2016-10-041-13/+12
| | | | | | | | | | | | | | | | ... and reuse it in itemAt() and indexAt() Change-Id: I3e4682685227aa7c60d004152dffbc0ccaab6195 Reviewed-by: Robin Burchell <robin.burchell@viroteck.net> Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* | QQuickItemView: de-duplicate calls and cache resultsAnton Kudryavtsev2016-08-221-11/+14
|/ | | | | Change-Id: If4b95446fcd0d84a6bb5e285e770450b966d5bc0 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* QQuickItemView: use reverse iterators moreAnton Kudryavtsev2016-08-191-9/+8
| | | | | | | Since qt5.6 we can use reverse iterators. Change-Id: Ibf78b937e793c868ecc40710ef74c25308cc39bf Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Quick: replace 'foreach' with 'range for'Anton Kudryavtsev2016-08-181-2/+2
| | | | | Change-Id: I3493b16a184fc811289db9e98eff37bb987113a3 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Quick: use const (and const APIs) moreAnton Kudryavtsev2016-08-121-16/+17
| | | | | | | | For CoW types, prefer const methods to avoid needless detach()ing. Change-Id: I270cdc6eb8c5946f5c20b379bbb7c60f0ba518eb Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io> Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* QML: Pass the kind of geometry change aroundErik Verbruggen2016-07-111-2/+3
| | | | | | | | | | | | | This prevents re-calculation of what actually changed, and removes the now unused parameter newGeometry. Other than this change calculation, the only place where oldGeometry was used is QQuickListViewPrivate::itemGeometryChanged. To get rid of oldGeometry too, QQuickListViewPrivate now stores the current (i.e. last known) geometry, and updates it in itemGeometryChanged. Change-Id: I8a5286d08a04132c9a4c81de7ce221f5676946e6 Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io> Reviewed-by: Robin Burchell <robin.burchell@viroteck.net>
* QQuickItemView::forceLayout: Also call layout when d->forceLayoutAlbert Astals Cid2016-03-111-1/+2
| | | | | | | | | | | | | This way callers of forceLayout get a relayout if the dimension of a delegate that affects the itemview content size has just changed but the itemview content size has not been updated yet. This is useful because sometimes in the QML side you want to do things when the item view delegate size has changed but need the item view content size to be already updated. Change-Id: I846984a841e8e14c84d7a700a7ff736196b60afb Reviewed-by: Michael Brasser <michael.brasser@live.com> Reviewed-by: Shawn Rutledge <shawn.rutledge@theqtcompany.com>
* Merge remote-tracking branch 'origin/5.6' into devLiang Qi2016-02-121-2/+4
|\ | | | | | | | | | | | | Conflicts: .qmake.conf Change-Id: I356ec83cf687bd2833f9a7c5e820d56b1efa8979
| * Fix QQuickItemViewPrivate::updateUnrequestedPositions()J-P Nurmi2016-02-021-2/+4
| | | | | | | | | | | | | | | | | | | | | | Don't attempt to reposition unrequested items at negative indexes, meaning that they are not in the model. The chances are that they have been already deleted. Change-Id: Iadd08518b11e0ea5d7965215a517aafaf35c95ba Task-number: QTBUG-48277 Reviewed-by: Nikita Krupenko <krnekit@gmail.com> Reviewed-by: Robin Burchell <robin.burchell@viroteck.net>
* | Merge remote-tracking branch 'origin/5.6' into devSimon Hausmann2016-01-221-2/+2
|\| | | | | | | Change-Id: I4af0bf8ec1569097d97f8ce0bb8bf1a0e4a989ec
| * QQuickItemView: Take sticky header/footer into account for ↵Robin Burchell2016-01-151-2/+2
| | | | | | | | | | | | | | | | | | | | | | positionViewAtIndex(). When using an overlaid header or footer, we must adjust the position we come up with by the appropriate size in order to end up at the correct place. Change-Id: I218b9aef7fdf37f56ffb63dc395f97045b55a186 Task-number: QTBUG-50097 Reviewed-by: J-P Nurmi <jpnurmi@theqtcompany.com>
* | Updated license headersJani Heikkinen2016-01-191-14/+20
| | | | | | | | | | | | | | | | | | | | | | From Qt 5.7 -> LGPL v2.1 isn't an option anymore, see http://blog.qt.io/blog/2016/01/13/new-agreement-with-the-kde-free-qt-foundation/ Updated license headers to use new LGPL header instead of LGPL21 one (in those files which will be under LGPL v3) Change-Id: Ic36f1a0a1436fe6ac6eeca8c2375a79857e9cb12 Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
* | ListView: add keyNavigationEnabled propertyMitch Curtis2015-12-081-0/+26
|/ | | | | | | | | | | | | It is useful for applications that need to selectively enable or disable mouse and keyboard interaction. [ChangeLog][QtQuick][ListView] added keyNavigationEnabled property to allow mouse and keyboard interaction to be selectively enabled/disabled. Change-Id: I1cdb73e7be105bcc5c131e3cf2ae242dc66e8a65 Task-number: QTBUG-17051 Reviewed-by: J-P Nurmi <jpnurmi@theqtcompany.com>
* Item views: Don't emit 'currentItemChanged' if the current item didn't ↵Gabriel de Dietrich2015-09-051-1/+2
| | | | | | | really change Change-Id: I8892bb9b6ab6737d4a6f6f8aab836f863668682e Reviewed-by: J-P Nurmi <jpnurmi@theqtcompany.com>
* Fix potential use of incorrect bounds in delegate tracking.Michael Brasser2015-07-121-14/+31
| | | | | | | | | | Using GridView.SnapToRow and GridView.ApplyRange with a top margin could lead to the view jumping (rather than smoothly transitioning) when changing the currentIndex. Change-Id: I6936b378220f59e8d416f7531cf8b6906c723cb2 Task-number: QTBUG-45640 Reviewed-by: Martin Jones <martin.jones@qinetic.com.au>
* Fixed a QQuickListView crashLiang Qi2015-06-291-18/+26
| | | | | | | | | When an ObjectModel item is removed and destroyed. Task-number: QTBUG-46798 Change-Id: Ia41dd359d9f3ec5b7af85498dc798f7ab55dca3c Reviewed-by: J-P Nurmi <jpnurmi@theqtcompany.com> Reviewed-by: Alan Alpert <aalpert@blackberry.com>
* ListView/GridView contentHeight should include delayRemove-d itemsMatt Vogt2015-06-231-2/+3
| | | | | | | | | | When one or more items are in delayRemove state, the ListView's contentHeight property should include their height. This previously failed if the delayRemove items were at the end of the visibleItems list. Also applies to GridView. Change-Id: Id839e850367a3503123e8ac81dac6ebdccef1a1f Reviewed-by: Martin Jones <martin.jones@qinetic.com.au>
* Item views: don't assume that attached objects existJ-P Nurmi2015-06-091-10/+14
| | | | | | | | | | Attached properties are only on objects created by QML. In case a QQmlInstanceModel contains items that were created in C++, the attached properties object doesn't exist. Adding the missing null checks avoids a crash in such scenario. Change-Id: I93148ac6cefa4cb83a8a7eb24a84b125aaa443d2 Reviewed-by: Alan Alpert <aalpert@blackberry.com>
* Fix build with QT_STRICT_ITERATORSSérgio Martins2015-05-151-1/+1
| | | | | Change-Id: I3df6ac107cb46b3a1b15b80f39d7c6015adcd9ac Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* QtQuick: Micro-optimize iterator loops.Friedemann Kleint2015-02-261-3/+5
| | | | | | | Avoid repeated instantiation of end() in loops, use variable instead. Change-Id: I6ab1fe2b82406d5ee91710a0333587ffb82c04d4 Reviewed-by: Erik Verbruggen <erik.verbruggen@theqtcompany.com>
* Update copyright headersJani Heikkinen2015-02-121-7/+7
| | | | | | | | | Qt copyrights are now in The Qt Company, so we could update the source code headers accordingly. In the same go we should also fix the links to point to qt.io. Change-Id: I61120571787870c0ed17066afb31779b1e6e30e9 Reviewed-by: Iikka Eklund <iikka.eklund@theqtcompany.com>
* Repeater & itemviews: fix setModel() JS array handlingJ-P Nurmi2014-10-291-1/+5
| | | | | | | | | | | | QVariant comparison in setModel() started failing because JS arrays are now passed as a QJSValue. Re-assigning the same array content should not trigger a model change. This change restores the old behavior it had before, when JS arrays were passed as QVariantLists. Change-Id: I1882b3531f2893b116dbd817edeecab1ae812ce8 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Update license headers and add new licensesJani Heikkinen2014-08-251-19/+11
| | | | | | | | | - Renamed LICENSE.LGPL to LICENSE.LGPLv21 - Added LICENSE.LGPLv3 & LICENSE.GPLv2 - Removed LICENSE.GPL Change-Id: I84a565e2e0caa3b76bf291a7d188a57a4b00e1b0 Reviewed-by: Jani Heikkinen <jani.heikkinen@digia.com>
* ItemView: use categorized logging for delegate lifecycleShawn Rutledge2014-08-131-0/+2
| | | | | | | | | It becomes configurable at runtime instead of having to uncomment and recompile. Change-Id: I2c6f24c89f7e6fe1a9a77b948cdac6f2994680bf Reviewed-by: Frederik Gladhorn <frederik.gladhorn@digia.com> Reviewed-by: Robin Burchell <robin.burchell@viroteck.net>
* Merge remote-tracking branch 'origin/5.3' into devSimon Hausmann2014-07-261-6/+8
|\ | | | | | | | | | | | | | | | | Conflicts: src/qml/compiler/qv4ssa.cpp src/qml/jsruntime/qv4arrayobject.cpp src/qml/jsruntime/qv4engine.cpp Change-Id: Ie3ef6202b6a3a8521971e1be10c40c6a2db6989c
| * Don't recreate header and footer unnecessarilyMartin Jones2014-07-251-6/+8
| | | | | | | | | | | | | | | | | | | | The only time that they need to be recreated is if the orientation changes (even then, a good implementation could handle it, but no point requiring that now). Task-number: QTBUG-40375 Change-Id: Id0215fb812724827bb139cda8f8dc6208c703852 Reviewed-by: Andrew den Exter <andrew.den.exter@qinetic.com.au>