diff options
author | Aaron Kennedy <aaron.kennedy@nokia.com> | 2009-07-29 03:10:42 (GMT) |
---|---|---|
committer | Aaron Kennedy <aaron.kennedy@nokia.com> | 2009-07-29 03:10:42 (GMT) |
commit | c0c89664feec6fa6d70b4ffb44a8cfdac9de532f (patch) | |
tree | 5d007e71b717d4276e2474bc4bd751cd35967486 /src/declarative/fx/qfxitem.cpp | |
parent | 4e74fffb4499fae1550b2b708a1f88a47982a645 (diff) | |
download | Qt-c0c89664feec6fa6d70b4ffb44a8cfdac9de532f.zip Qt-c0c89664feec6fa6d70b4ffb44a8cfdac9de532f.tar.gz Qt-c0c89664feec6fa6d70b4ffb44a8cfdac9de532f.tar.bz2 |
Fixup merge errors
Diffstat (limited to 'src/declarative/fx/qfxitem.cpp')
-rw-r--r-- | src/declarative/fx/qfxitem.cpp | 57 |
1 files changed, 38 insertions, 19 deletions
diff --git a/src/declarative/fx/qfxitem.cpp b/src/declarative/fx/qfxitem.cpp index f8ed7b4..b8f4696 100644 --- a/src/declarative/fx/qfxitem.cpp +++ b/src/declarative/fx/qfxitem.cpp @@ -1897,8 +1897,6 @@ QVariant QFxItem::itemChange(GraphicsItemChange change, if (options() & QFxItem::MouseFilter) d->gvAddMouseFilter(); - if (d->canvas && d->isFocusItemForArea) - d->canvas->setFocusItem(this); } else if (change == ItemChildAddedChange || change == ItemChildRemovedChange) { childrenChanged(); @@ -2154,28 +2152,49 @@ QFxItem *QFxItem::mouseGrabberItem() const bool QFxItem::hasFocus() const { - Q_D(const QFxItem); - return d->isFocusItemForArea; + const QGraphicsItem *current = this->parentItem(); + while (current && !(current->flags() & ItemAutoDetectsFocusProxy)) + current = current->parentItem(); + + if (current) + return current->focusProxy() == this; + else + return QGraphicsItem::hasFocus(); } void QFxItem::setFocus(bool focus) { - Q_D(QFxItem); QGraphicsScene *s = scene(); - if (s) { - if (d->hasActiveFocus) - s->setFocusItem(focus ? this : 0); - else if (focus) - s->setFocusItem(this); - else { - d->isFocusItemForArea = false; - focusChanged(false); - } + if (!s) { + if (focus) QGraphicsItem::setFocus(Qt::OtherFocusReason); + else QGraphicsItem::clearFocus(); + focusChanged(focus); + return; + } - } else { - d->isFocusItemForArea = focus; + QGraphicsItem *current = this->parentItem(); + while (current && !(current->flags() & ItemAutoDetectsFocusProxy)) + current = current->parentItem(); + + if (!current) { + if (focus) QGraphicsItem::setFocus(Qt::OtherFocusReason); + else QGraphicsItem::clearFocus(); focusChanged(focus); + return; + } + + if (current->focusProxy() && current->focusProxy() != this) { + QFxItem *currentItem = qobject_cast<QFxItem *>(current->focusProxy()); + if (currentItem) + currentItem->setFocus(false); } + + if (current->focusProxy() == this && !focus) + current->setFocusProxy(0); + else if (focus) + current->setFocusProxy(this); + + focusChanged(focus); } /*! @@ -2185,8 +2204,7 @@ void QFxItem::setFocus(bool focus) bool QFxItem::hasActiveFocus() const { - Q_D(const QFxItem); - return d->hasActiveFocus; + return QGraphicsItem::hasFocus(); } bool QFxItem::activeFocusPanel() const @@ -2242,7 +2260,8 @@ void QFxItem::setOptions(Options options, bool set) setFiltersChildEvents(d->options & ChildMouseFilter); setFlag(QGraphicsItem::ItemAcceptsInputMethod, (d->options & AcceptsInputMethods)); setAcceptHoverEvents(d->options & HoverEvents); - d->isFocusRealm = static_cast<bool>(d->options & IsFocusRealm); + + setFlag(QGraphicsItem::ItemAutoDetectsFocusProxy, d->options & IsFocusRealm); if ((old & MouseFilter) != (d->options & MouseFilter)) { if (d->options & MouseFilter) |