From c0c89664feec6fa6d70b4ffb44a8cfdac9de532f Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Wed, 29 Jul 2009 13:10:42 +1000 Subject: Fixup merge errors --- src/declarative/fx/qfxitem.cpp | 57 +++++++++++++++++++---------- src/declarative/fx/qfxitem_p.h | 12 ------ src/gui/graphicsview/qgraphicsitem.cpp | 10 ----- src/gui/graphicsview/qgraphicsitem_p.h | 12 +----- src/gui/graphicsview/qgraphicstransform.cpp | 2 +- 5 files changed, 40 insertions(+), 53 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(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(d->options & IsFocusRealm); + + setFlag(QGraphicsItem::ItemAutoDetectsFocusProxy, d->options & IsFocusRealm); if ((old & MouseFilter) != (d->options & MouseFilter)) { if (d->options & MouseFilter) diff --git a/src/declarative/fx/qfxitem_p.h b/src/declarative/fx/qfxitem_p.h index bb3a97a..5ab31b8 100644 --- a/src/declarative/fx/qfxitem_p.h +++ b/src/declarative/fx/qfxitem_p.h @@ -197,18 +197,6 @@ public: void gvRemoveMouseFilter(); void gvAddMouseFilter(); - virtual void setActiveFocus(bool b) { - Q_Q(QFxItem); - QGraphicsItemPrivate::setActiveFocus(b); - q->activeFocusChanged(b); - } - - virtual void setFocusItemForArea(bool b) { - Q_Q(QFxItem); - QGraphicsItemPrivate::setFocusItemForArea(b); - q->focusChanged(b); - } - virtual void setPosHelper(const QPointF &pos) { Q_Q(QFxItem); diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index 667b3dc..b5fb15c 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -1188,16 +1188,6 @@ QGraphicsItem::~QGraphicsItem() d_ptr->inDestructor = 1; d_ptr->removeExtraItemCache(); - if (d_ptr->isFocusRealm && d_ptr->scene) - d_ptr->scene->d_func()->focusItemForFocusArea.remove(this); - if (d_ptr->isFocusItemForArea && d_ptr->scene) { - QGraphicsItem *prnt = parentItem(); - while (prnt && !prnt->d_func()->isFocusRealm) - prnt = prnt->parentItem(); - if (prnt && d_ptr->scene->d_func()->focusItemForFocusArea.value(prnt) == this) - d_ptr->scene->d_func()->focusItemForFocusArea.remove(prnt); - } - clearFocus(); if (!d_ptr->children.isEmpty()) { QList oldChildren = d_ptr->children; diff --git a/src/gui/graphicsview/qgraphicsitem_p.h b/src/gui/graphicsview/qgraphicsitem_p.h index 5724f16..b07213b 100644 --- a/src/gui/graphicsview/qgraphicsitem_p.h +++ b/src/gui/graphicsview/qgraphicsitem_p.h @@ -164,9 +164,6 @@ public: acceptedTouchBeginEvent(0), filtersDescendantEvents(0), sceneTransformTranslateOnly(0), - isFocusRealm(0), - isFocusItemForArea(0), - hasActiveFocus(0), mouseSetsFocus(1), globalStackingOrder(-1), q_ptr(0) @@ -405,14 +402,6 @@ public: inline QTransform transformToParent() const; inline void ensureSortedChildren(); - virtual void setActiveFocus(bool b) { - hasActiveFocus = b; - } - - virtual void setFocusItemForArea(bool b) { - isFocusItemForArea = b; - } - QPainterPath cachedClipPath; QRectF childrenBoundingRect; QRectF needsRepaint; @@ -473,6 +462,7 @@ public: quint32 acceptedTouchBeginEvent : 1; quint32 filtersDescendantEvents : 1; quint32 sceneTransformTranslateOnly : 1; + quint32 mouseSetsFocus : 1; quint32 unused : 4; // feel free to use // Optional stacking order diff --git a/src/gui/graphicsview/qgraphicstransform.cpp b/src/gui/graphicsview/qgraphicstransform.cpp index f18752a..b55d78e 100644 --- a/src/gui/graphicsview/qgraphicstransform.cpp +++ b/src/gui/graphicsview/qgraphicstransform.cpp @@ -63,7 +63,7 @@ void QGraphicsTransformPrivate::setItem(QGraphicsItem *i) item->prepareGeometryChange(); Q_ASSERT(d_ptr->transformData); - d_ptr->transformData->graphicsTransforms.remove(q); + d_ptr->transformData->graphicsTransforms.removeAll(q); d_ptr->dirtySceneTransform = 1; item = 0; } -- cgit v0.12