summaryrefslogtreecommitdiffstats
path: root/src/gui/graphicsview
diff options
context:
space:
mode:
authorOlivier Goffart <ogoffart@trolltech.com>2009-11-05 12:11:03 (GMT)
committerOlivier Goffart <ogoffart@trolltech.com>2009-11-06 11:19:26 (GMT)
commitf8a0b7b9ea2e077be7167c58d4eac27360d4cee6 (patch)
tree8da241b063829cdd910277ebe0ed22032c2819c4 /src/gui/graphicsview
parent3433bc44168398734cdd53df9b64adf016c8ab3b (diff)
downloadQt-f8a0b7b9ea2e077be7167c58d4eac27360d4cee6.zip
Qt-f8a0b7b9ea2e077be7167c58d4eac27360d4cee6.tar.gz
Qt-f8a0b7b9ea2e077be7167c58d4eac27360d4cee6.tar.bz2
QGraphicsView: Fixes QGraphicsView::focusItem when scene is not active
When scene is not active, returns the item that would get the focus if the scene became active. This is more consistant with Qt 4.5 behaviour Reviewed-by: Andreas
Diffstat (limited to 'src/gui/graphicsview')
-rw-r--r--src/gui/graphicsview/qgraphicsitem.cpp2
-rw-r--r--src/gui/graphicsview/qgraphicsscene.cpp10
2 files changed, 7 insertions, 5 deletions
diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp
index 949f555..073c31b 100644
--- a/src/gui/graphicsview/qgraphicsitem.cpp
+++ b/src/gui/graphicsview/qgraphicsitem.cpp
@@ -2980,7 +2980,7 @@ bool QGraphicsItem::hasFocus() const
{
if (d_ptr->focusProxy)
return d_ptr->focusProxy->hasFocus();
- return (d_ptr->scene && d_ptr->scene->focusItem() == this);
+ return isActive() && (d_ptr->scene && d_ptr->scene->focusItem() == this);
}
/*!
diff --git a/src/gui/graphicsview/qgraphicsscene.cpp b/src/gui/graphicsview/qgraphicsscene.cpp
index 80cd2bc..a59e961 100644
--- a/src/gui/graphicsview/qgraphicsscene.cpp
+++ b/src/gui/graphicsview/qgraphicsscene.cpp
@@ -2883,18 +2883,20 @@ void QGraphicsScene::removeItem(QGraphicsItem *item)
}
/*!
- Returns the scene's current focus item, or 0 if no item currently has
- focus.
+ When the scene is active, this functions returns the scene's current focus
+ item, or 0 if no item currently has focus. When the scene is inactive, this
+ functions returns the item that will gain input focus when the scene becomes
+ active.
The focus item receives keyboard input when the scene receives a
key event.
- \sa setFocusItem(), QGraphicsItem::hasFocus()
+ \sa setFocusItem(), QGraphicsItem::hasFocus(), isActive()
*/
QGraphicsItem *QGraphicsScene::focusItem() const
{
Q_D(const QGraphicsScene);
- return d->focusItem;
+ return isActive() ? d->focusItem : d->lastFocusItem;
}
/*!