diff options
author | Andreas Aardal Hanssen <andreas.aardal.hanssen@nokia.com> | 2009-09-11 12:10:12 (GMT) |
---|---|---|
committer | Andreas Aardal Hanssen <andreas.aardal.hanssen@nokia.com> | 2009-09-15 09:32:07 (GMT) |
commit | c8bf9bd17a4520eefe4306b7b1bb4f93fb296d80 (patch) | |
tree | 0126827048c3740a213d5be39b89074bd4d9ae01 /src/gui/graphicsview/qgraphicsitem_p.h | |
parent | a06c7db92ff13a1f8a353851a586ae12755e7c6c (diff) | |
download | Qt-c8bf9bd17a4520eefe4306b7b1bb4f93fb296d80.zip Qt-c8bf9bd17a4520eefe4306b7b1bb4f93fb296d80.tar.gz Qt-c8bf9bd17a4520eefe4306b7b1bb4f93fb296d80.tar.bz2 |
Support for focus scopes: QGraphicsItem::ItemIsFocusScope.
This feature is essential for Declarative UI, but does not add much
value for C++ developers. A FocusScope provides a stack of focused
widgets, and it ensures that the topmost item on the stack has
focus if any of the items in the stack gains focus. When the topmost
loses focus, focus is passed to the "parent" focus scope, and so on.
You can get almost the same behavior using panels (ItemIsPanel),
except panels impose other behavior, like stopping clickfocus
propagation, and stopping event propagation in general. In a QML
world you would typically use FocusScope for controlling focus
locally, and panels when you need to maintain separate focus stacks.
Reviewed-by: akennedy
Diffstat (limited to 'src/gui/graphicsview/qgraphicsitem_p.h')
-rw-r--r-- | src/gui/graphicsview/qgraphicsitem_p.h | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/gui/graphicsview/qgraphicsitem_p.h b/src/gui/graphicsview/qgraphicsitem_p.h index 0b58ad3..fd2ff34 100644 --- a/src/gui/graphicsview/qgraphicsitem_p.h +++ b/src/gui/graphicsview/qgraphicsitem_p.h @@ -129,6 +129,7 @@ public: itemDepth(-1), focusProxy(0), subFocusItem(0), + focusScopeItem(0), imHints(Qt::ImhNone), acceptedMouseButtons(0x1f), visible(1), @@ -412,9 +413,11 @@ public: || (childrenCombineOpacity() && isFullyTransparent()); } - void setSubFocus(); - void clearSubFocus(); + void setFocusHelper(Qt::FocusReason focusReason, bool climb); + void setSubFocus(QGraphicsItem *rootItem = 0); + void clearSubFocus(QGraphicsItem *rootItem = 0); void resetFocusProxy(); + virtual void subFocusItemChange(); inline QTransform transformToParent() const; inline void ensureSortedChildren(); @@ -439,6 +442,7 @@ public: QGraphicsItem *focusProxy; QList<QGraphicsItem **> focusProxyRefs; QGraphicsItem *subFocusItem; + QGraphicsItem *focusScopeItem; Qt::InputMethodHints imHints; // Packed 32 bits |