summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMichael Brasser <michael.brasser@nokia.com>2010-08-05 04:36:57 (GMT)
committerMichael Brasser <michael.brasser@nokia.com>2010-08-05 04:38:13 (GMT)
commiteb8c7d19c98d547f89caa1b5866fd2b5e43b32bf (patch)
tree56656466ea742db7741fc9987d88b67375193e9f /src
parent5a98d58c1ed78262c20b05aa178a92b4a1a097df (diff)
downloadQt-eb8c7d19c98d547f89caa1b5866fd2b5e43b32bf.zip
Qt-eb8c7d19c98d547f89caa1b5866fd2b5e43b32bf.tar.gz
Qt-eb8c7d19c98d547f89caa1b5866fd2b5e43b32bf.tar.bz2
Make sure onFocusChanged is correctly emitted for items in a FocusScope.
Task-number: QTBUG-12649 Reviewed-by: Martin Jones
Diffstat (limited to 'src')
-rw-r--r--src/declarative/graphicsitems/qdeclarativeitem.cpp13
-rw-r--r--src/gui/graphicsview/qgraphicsitem.cpp5
2 files changed, 6 insertions, 12 deletions
diff --git a/src/declarative/graphicsitems/qdeclarativeitem.cpp b/src/declarative/graphicsitems/qdeclarativeitem.cpp
index 50998eb..5b74129 100644
--- a/src/declarative/graphicsitems/qdeclarativeitem.cpp
+++ b/src/declarative/graphicsitems/qdeclarativeitem.cpp
@@ -2406,18 +2406,7 @@ void QDeclarativeItemPrivate::focusChanged(bool flag)
Q_Q(QDeclarativeItem);
if (!(flags & QGraphicsItem::ItemIsFocusScope) && parent)
emit q->activeFocusChanged(flag); //see also QDeclarativeItemPrivate::subFocusItemChange()
-
- bool inScope = false;
- QGraphicsItem *p = parent;
- while (p) {
- if (p->flags() & QGraphicsItem::ItemIsFocusScope) {
- inScope = true;
- break;
- }
- p = p->parentItem();
- }
- if (!inScope)
- emit q->focusChanged(flag);
+ emit q->focusChanged(flag);
}
/*! \internal */
diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp
index 1626d83..ff3dc1f 100644
--- a/src/gui/graphicsview/qgraphicsitem.cpp
+++ b/src/gui/graphicsview/qgraphicsitem.cpp
@@ -3259,8 +3259,12 @@ void QGraphicsItemPrivate::setFocusHelper(Qt::FocusReason focusReason, bool clim
QGraphicsItem *p = parent;
while (p) {
if (p->flags() & QGraphicsItem::ItemIsFocusScope) {
+ QGraphicsItem *oldFocusScopeItem = p->d_ptr->focusScopeItem;
p->d_ptr->focusScopeItem = q_ptr;
if (!p->focusItem() && !focusFromShow) {
+ if (oldFocusScopeItem)
+ oldFocusScopeItem->d_ptr->focusScopeItemChange(false);
+ focusScopeItemChange(true);
// If you call setFocus on a child of a focus scope that
// doesn't currently have a focus item, then stop.
return;
@@ -5595,6 +5599,7 @@ void QGraphicsItemPrivate::subFocusItemChange()
*/
void QGraphicsItemPrivate::focusScopeItemChange(bool isSubFocusItem)
{
+ Q_UNUSED(isSubFocusItem);
}
/*!