Don't emit activeFocusChanged() unless the active focus actually changed
authorTor Arne Vestbø <tor.arne.vestbo@nokia.com>
Tue, 7 Dec 2010 13:27:14 +0000 (14:27 +0100)
committerTor Arne Vestbø <tor.arne.vestbo@nokia.com>
Tue, 7 Dec 2010 20:51:16 +0000 (21:51 +0100)
commit783a278f243c6411f5f32d11f2165b9eed9b6f8c
tree7c250ad639d7c669cb5622e2187ac91999479917
parent6af078b2a13f4855a35d48376e58154ee2d57ec1
Don't emit activeFocusChanged() unless the active focus actually changed

We would previously call subFocusItemChanged(0) on the item as part of
clearing the subfocus, even if the item in question would recieve a new
subfocus item as part of setting the new subfocus.

This resulted in the declarative item emitting activeFocusChanged(false)
and then activeFocusChanged(true), which was affecting any animation or
state bound to the activeFocus property of the item.

We now stop clearing the subfocus when encountering an item that we know
will get subfocus during the set-subfocus pass. We then set subfocus all
the way to the root item, since the subfocus item itself might change.

The effect of this is that the declarative item will only get one call
to subFocusItemChanged(), passing the new subfocus item, instead of two.
This means the declarative item can keep track of wherther ot not it had
a subfocus item previously, and only emit activeFocusChanged() when the
active focus goes from true to false or false to true.

Task-number: QTBUG-15615
Reviewed-by: Yoann Lopes <yoann.lopes@nokia.com>
src/declarative/graphicsitems/qdeclarativeitem_p.h
src/gui/graphicsview/qgraphicsitem.cpp
src/gui/graphicsview/qgraphicsitem_p.h
tests/auto/declarative/qdeclarativefocusscope/data/forceActiveFocus.qml [new file with mode: 0644]
tests/auto/declarative/qdeclarativefocusscope/tst_qdeclarativefocusscope.cpp