diff options
author | Michael Brasser <michael.brasser@nokia.com> | 2010-10-19 23:35:26 (GMT) |
---|---|---|
committer | Michael Brasser <michael.brasser@nokia.com> | 2010-10-19 23:37:13 (GMT) |
commit | ddc7f627d85436d76f5ca881bd6f16efb8962af5 (patch) | |
tree | 3b7944c49d296ab48ad543843932fe5cbb905c61 /src/gui/graphicsview/qgraphicsitem.cpp | |
parent | 197354a4d7668fda7c4dce4704f0143528959938 (diff) | |
download | Qt-ddc7f627d85436d76f5ca881bd6f16efb8962af5.zip Qt-ddc7f627d85436d76f5ca881bd6f16efb8962af5.tar.gz Qt-ddc7f627d85436d76f5ca881bd6f16efb8962af5.tar.bz2 |
Further focus scope fixes.
Follow-up to e11ee40cefc981fbdcfb10816039d4efb080fb17.
Reviewed-by: Yoann Lopes
Diffstat (limited to 'src/gui/graphicsview/qgraphicsitem.cpp')
-rw-r--r-- | src/gui/graphicsview/qgraphicsitem.cpp | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index 2b6aaf5..7ab49cb 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -3322,8 +3322,7 @@ void QGraphicsItemPrivate::setFocusHelper(Qt::FocusReason focusReason, bool clim */ void QGraphicsItem::clearFocus() { - if (hasFocus()) - d_ptr->clearFocusHelper(/* giveFocusToParent = */ true); + d_ptr->clearFocusHelper(/* giveFocusToParent = */ true); } /*! @@ -3337,8 +3336,14 @@ void QGraphicsItemPrivate::clearFocusHelper(bool giveFocusToParent) QGraphicsItem *p = parent; while (p) { if (p->flags() & QGraphicsItem::ItemIsFocusScope) { - p->d_ptr->setFocusHelper(Qt::OtherFocusReason, /* climb = */ false, - /* focusFromHide = */ false); + if (p->d_ptr->focusScopeItem == q_ptr) { + p->d_ptr->focusScopeItem = 0; + if (!q_ptr->hasFocus()) //if it has focus, focusScopeItemChange is called elsewhere + focusScopeItemChange(false); + } + if (q_ptr->hasFocus()) + p->d_ptr->setFocusHelper(Qt::OtherFocusReason, /* climb = */ false, + /* focusFromHide = */ false); return; } p = p->d_ptr->parent; @@ -3346,10 +3351,10 @@ void QGraphicsItemPrivate::clearFocusHelper(bool giveFocusToParent) } } - // Invisible items with focus must explicitly clear subfocus. - clearSubFocus(q_ptr); - if (q_ptr->hasFocus()) { + // Invisible items with focus must explicitly clear subfocus. + clearSubFocus(q_ptr); + // If this item has the scene's input focus, clear it. scene->setFocusItem(0); } |