summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Aardal Hanssen <andreas.aardal.hanssen@nokia.com>2009-09-08 10:21:29 +0200
committerAndreas Aardal Hanssen <andreas.aardal.hanssen@nokia.com>2009-09-09 17:18:07 +0200
commitc44402453593cbdf2eafa66f6ee23d17aacf44fd (patch)
tree6eb627350e64902bbbc0ecf52188f657a14520f1
parent486ff054b8b65c191df39748dfe59f9440a60578 (diff)
Remove ItemAutoDetectsFocusProxy from QGraphicsItem.
This change partially reverts f68fed388dcdba6ab6dad3af4933bcd3aa123cf8, which was an attempt at getting FocusRealms working. Turns out this approach is wrong. The flag behaves badly when reparenting, and the feature conflicts with plain old setting focus. Discussed with Aaron; this change was already reverted in the kinetic-declarativeui branch. Reviewed-by: TrustMe
-rw-r--r--src/gui/graphicsview/qgraphicsitem.cpp33
-rw-r--r--src/gui/graphicsview/qgraphicsitem.h5
-rw-r--r--src/gui/graphicsview/qgraphicsscene.cpp13
-rw-r--r--tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp71
4 files changed, 4 insertions, 118 deletions
diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp
index d67011be15..86c60be96a 100644
--- a/src/gui/graphicsview/qgraphicsitem.cpp
+++ b/src/gui/graphicsview/qgraphicsitem.cpp
@@ -335,10 +335,6 @@
it's parent if it's z-value is negative. This flag enables setZValue() to
toggle ItemStacksBehindParent.
- \value ItemAutoDetectsFocusProxy The item will assign any child that
- gains input focus as its focus proxy. See also focusProxy().
- This flag was introduced in Qt 4.6.
-
\value ItemIsPanel. The item is a panel. A panel provides activation and
contained focus handling. Only one panel can be active at a time (see
QGraphicsItem::isActive()). When no panel is active, QGraphicsScene
@@ -954,17 +950,6 @@ void QGraphicsItemPrivate::setParentItemHelper(QGraphicsItem *newParent)
parent->itemChange(QGraphicsItem::ItemChildRemovedChange, thisPointerVariant);
}
- // Auto-update focus proxy. Any ancestor that has this as focus proxy
- //needs to be nulled.
- QGraphicsItem *p = parent;
- while (p) {
- if ((p->d_ptr->flags & QGraphicsItem::ItemAutoDetectsFocusProxy) &&
- (p->focusProxy() == q)) {
- p->setFocusProxy(0);
- }
- p = p->d_ptr->parent;
- }
-
// Update toplevelitem list. If this item is being deleted, its parent
// will be 0 but we don't want to register/unregister it in the TLI list.
if (scene && !inDestructor) {
@@ -1044,17 +1029,6 @@ void QGraphicsItemPrivate::setParentItemHelper(QGraphicsItem *newParent)
if (lastSubFocusItem)
lastSubFocusItem->d_ptr->setSubFocus();
- // Auto-update focus proxy. The closest parent that detects
- // focus proxies is updated as the proxy gains or loses focus.
- p = newParent;
- while (p) {
- if (p->d_ptr->flags & QGraphicsItem::ItemAutoDetectsFocusProxy) {
- p->setFocusProxy(q);
- break;
- }
- p = p->d_ptr->parent;
- }
-
// Deliver post-change notification
q->itemChange(QGraphicsItem::ItemParentHasChanged, newParentVariant);
@@ -2808,7 +2782,7 @@ void QGraphicsItem::clearFocus()
Returns this item's focus proxy, or 0 if this item has no
focus proxy.
- \sa setFocusProxy(), ItemAutoDetectsFocusProxy, setFocus(), hasFocus()
+ \sa setFocusProxy(), setFocus(), hasFocus()
*/
QGraphicsItem *QGraphicsItem::focusProxy() const
{
@@ -2832,7 +2806,7 @@ QGraphicsItem *QGraphicsItem::focusProxy() const
The focus proxy \a item must belong to the same scene as
this item.
- \sa focusProxy(), ItemAutoDetectsFocusProxy, setFocus(), hasFocus()
+ \sa focusProxy(), setFocus(), hasFocus()
*/
void QGraphicsItem::setFocusProxy(QGraphicsItem *item)
{
@@ -10568,9 +10542,6 @@ QDebug operator<<(QDebug debug, QGraphicsItem::GraphicsItemFlag flag)
case QGraphicsItem::ItemNegativeZStacksBehindParent:
str = "ItemNegativeZStacksBehindParent";
break;
- case QGraphicsItem::ItemAutoDetectsFocusProxy:
- str = "ItemAutoDetectsFocusProxy";
- break;
case QGraphicsItem::ItemIsPanel:
str = "ItemIsPanel";
break;
diff --git a/src/gui/graphicsview/qgraphicsitem.h b/src/gui/graphicsview/qgraphicsitem.h
index 1b657005e3..1c969ba247 100644
--- a/src/gui/graphicsview/qgraphicsitem.h
+++ b/src/gui/graphicsview/qgraphicsitem.h
@@ -103,9 +103,8 @@ public:
ItemHasNoContents = 0x400,
ItemSendsGeometryChanges = 0x800,
ItemAcceptsInputMethod = 0x1000,
- ItemAutoDetectsFocusProxy = 0x2000,
- ItemNegativeZStacksBehindParent = 0x4000,
- ItemIsPanel = 0x8000
+ ItemNegativeZStacksBehindParent = 0x2000,
+ ItemIsPanel = 0x4000
// NB! Don't forget to increase the d_ptr->flags bit field by 1 when adding a new flag.
};
Q_DECLARE_FLAGS(GraphicsItemFlags, GraphicsItemFlag)
diff --git a/src/gui/graphicsview/qgraphicsscene.cpp b/src/gui/graphicsview/qgraphicsscene.cpp
index ee4cfe0913..b09c5f43ca 100644
--- a/src/gui/graphicsview/qgraphicsscene.cpp
+++ b/src/gui/graphicsview/qgraphicsscene.cpp
@@ -653,19 +653,6 @@ void QGraphicsScenePrivate::setFocusItemHelper(QGraphicsItem *item,
return;
}
- // Auto-update focus proxy. The closest parent that detects
- // focus proxies is updated as the proxy gains or loses focus.
- if (item) {
- QGraphicsItem *p = item->d_ptr->parent;
- while (p) {
- if (p->d_ptr->flags & QGraphicsItem::ItemAutoDetectsFocusProxy) {
- p->setFocusProxy(item);
- break;
- }
- p = p->d_ptr->parent;
- }
- }
-
if (focusItem) {
QFocusEvent event(QEvent::FocusOut, focusReason);
lastFocusItem = focusItem;
diff --git a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
index b8061dae87..cefff80293 100644
--- a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
+++ b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
@@ -164,7 +164,6 @@ public slots:
void init();
private slots:
- void explicitDeleteAutoFocusProxy();
void construction();
void constructionWithParent();
void destruction();
@@ -284,9 +283,7 @@ private slots:
void hitTestUntransformableItem();
void hitTestGraphicsEffectItem();
void focusProxy();
- void autoDetectFocusProxy();
void subFocus();
- void reverseCreateAutoFocusProxy();
void focusProxyDeletion();
void negativeZStacksBehindParent();
void setGraphicsEffect();
@@ -7551,31 +7548,6 @@ void tst_QGraphicsItem::focusProxy()
QCOMPARE(item3->focusProxy(), (QGraphicsItem *)0);
}
-void tst_QGraphicsItem::autoDetectFocusProxy()
-{
- QGraphicsScene scene;
- QGraphicsItem *item = scene.addRect(0, 0, 10, 10);
- item->setFlag(QGraphicsItem::ItemIsFocusable);
-
- QGraphicsItem *item2 = scene.addRect(0, 0, 10, 10);
- item2->setParentItem(item);
- item2->setFlag(QGraphicsItem::ItemIsFocusable);
-
- QGraphicsItem *item3 = scene.addRect(0, 0, 10, 10);
- item3->setParentItem(item2);
- item3->setFlag(QGraphicsItem::ItemIsFocusable);
-
- item->setFlag(QGraphicsItem::ItemAutoDetectsFocusProxy);
- QCOMPARE(item->focusProxy(), (QGraphicsItem *)0);
-
- item2->setFocus();
- QCOMPARE(item->focusProxy(), item2);
- item3->setFocus();
- QCOMPARE(item->focusProxy(), item3);
- item3->clearFocus();
- QCOMPARE(item->focusProxy(), item3);
-}
-
void tst_QGraphicsItem::subFocus()
{
// Construct a text item that's not part of a scene (yet)
@@ -7635,49 +7607,6 @@ void tst_QGraphicsItem::subFocus()
QVERIFY(text2->hasFocus());
}
-void tst_QGraphicsItem::reverseCreateAutoFocusProxy()
-{
- QGraphicsTextItem *text = new QGraphicsTextItem;
- text->setTextInteractionFlags(Qt::TextEditorInteraction);
- text->setFlag(QGraphicsItem::ItemAutoDetectsFocusProxy);
-
- QGraphicsTextItem *text2 = new QGraphicsTextItem;
- text2->setTextInteractionFlags(Qt::TextEditorInteraction);
- text2->setFocus();
- QVERIFY(!text2->hasFocus());
- QCOMPARE(text->focusProxy(), (QGraphicsItem *)0);
- text2->setParentItem(text);
- QCOMPARE(text->focusProxy(), (QGraphicsItem *)text2);
- QCOMPARE(text->focusItem(), (QGraphicsItem *)text2);
-
- QGraphicsScene scene;
- scene.addItem(text);
- QVERIFY(text2->hasFocus());
-}
-
-void tst_QGraphicsItem::explicitDeleteAutoFocusProxy()
-{
- QGraphicsTextItem *text = new QGraphicsTextItem;
- text->setTextInteractionFlags(Qt::TextEditorInteraction);
- text->setFlag(QGraphicsItem::ItemAutoDetectsFocusProxy);
-
- QGraphicsTextItem *text2 = new QGraphicsTextItem;
- text2->setTextInteractionFlags(Qt::TextEditorInteraction);
- text2->setFocus();
- QVERIFY(!text2->hasFocus());
- QCOMPARE(text->focusProxy(), (QGraphicsItem *)0);
- text2->setParentItem(text);
- QCOMPARE(text->focusProxy(), (QGraphicsItem *)text2);
- QCOMPARE(text->focusItem(), (QGraphicsItem *)text2);
-
- QGraphicsScene scene;
- scene.addItem(text);
- QVERIFY(text2->hasFocus());
-
- delete text2;
- QCOMPARE(text->focusProxy(), (QGraphicsItem *)0);
-}
-
void tst_QGraphicsItem::focusProxyDeletion()
{
QGraphicsRectItem *rect = new QGraphicsRectItem;