Batch view changes instead of applying them immediately
authorBea Lam <bea.lam@nokia.com>
Mon, 29 Aug 2011 05:33:36 +0000 (15:33 +1000)
committerQt by Nokia <qt-info@nokia.com>
Wed, 31 Aug 2011 23:44:29 +0000 (01:44 +0200)
commit6fbc4b7e7e5aed8739ca1143e0fc1e38b8c8e17a
treec1aa4ec039d731bb40a7669f7d1a4fed4015873d
parent8801dd4f173a4e7676400dd18d76d89dfe3b3791
Batch view changes instead of applying them immediately

If there are multiple changes to be applied to a view before the next
repaint, collate them using QDeclarativeChangeSet and apply the changes
as a group on the next layout(). (Note that changes to the current index
are applied in sequence as changes are received, since changing it out
of order produces different results.)

Previously, any itemsInserted(), itemsRemoved() and itemsMoved() changes
were immediately applied and items were repositioned immediately. In
this situation if the same indexes changed multiple times between
repaints, this could lead to redundant changes and bugs arising from
multiple changes to the same items.

Functions that will execute differently depending on whether pending
view changes have been applied (e.g. count(), currentIndex(),
highlight()) now call applyPendingChanges() before proceeding to ensure
they are executed on a view that is up to date.

Also, itemsMoved() operations that moved item/s backwards will now
properly move backwards instead of being adjusted to a forward movement
(which was implemented recently with
e2b5681b1adab83555c7307b05f508d796a1152b) since backwards movements can
be implemented more easily with the batched changes which translates
moves into insert/remove actions.

Change-Id: If9b39755898e8d2ed7e4bc61288206d5f1d653fd
Reviewed-on: http://codereview.qt.nokia.com/3697
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Martin Jones <martin.jones@nokia.com>
src/declarative/items/qsggridview.cpp
src/declarative/items/qsggridview_p.h
src/declarative/items/qsgitemview.cpp
src/declarative/items/qsgitemview_p.h
src/declarative/items/qsgitemview_p_p.h
src/declarative/items/qsglistview.cpp
src/declarative/items/qsglistview_p.h
tests/auto/declarative/qsggridview/tst_qsggridview.cpp
tests/auto/declarative/qsglistview/tst_qsglistview.cpp