summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBjørn Erik Nilsen <bjorn.nilsen@nokia.com>2010-06-24 13:11:05 (GMT)
committerBjørn Erik Nilsen <bjorn.nilsen@nokia.com>2010-06-24 13:29:04 (GMT)
commit7bc00632dde1b718cbe1412e988ad006dc3d125f (patch)
tree8531eff6273230e8fd967df979217008b3cbed65 /src
parentbf65425213b451d83e13c7423b289f391fd9f81c (diff)
downloadQt-7bc00632dde1b718cbe1412e988ad006dc3d125f.zip
Qt-7bc00632dde1b718cbe1412e988ad006dc3d125f.tar.gz
Qt-7bc00632dde1b718cbe1412e988ad006dc3d125f.tar.bz2
Add a new (internal) flag QGraphicsItem::ItemStopsClickFocusPropagation.
This flag allows you to create a non-focusable item that can be clicked on without changing the focus. This is also possible to achieve by using focus scopes / panels, however the implementation is then way more complex. Thew new flag is tailored for simple uses cases where you simply want to stop the propagation and nothing more. Auto test included. Task-number: QT-3499 Reviewed-by: yoann
Diffstat (limited to 'src')
-rw-r--r--src/gui/graphicsview/qgraphicsitem.cpp8
-rw-r--r--src/gui/graphicsview/qgraphicsitem.h3
-rw-r--r--src/gui/graphicsview/qgraphicsitem_p.h6
-rw-r--r--src/gui/graphicsview/qgraphicsscene.cpp2
4 files changed, 15 insertions, 4 deletions
diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp
index 2de3638..61285d2 100644
--- a/src/gui/graphicsview/qgraphicsitem.cpp
+++ b/src/gui/graphicsview/qgraphicsitem.cpp
@@ -411,6 +411,11 @@
these notifications are disabled by default. You must enable this flag
to receive notifications for scene position changes. This flag was
introduced in Qt 4.6.
+
+ \omitvalue ItemStopsClickFocusPropagation \omit The item stops propagating
+ click focus to items underneath when being clicked on. This flag
+ allows you create a non-focusable item that can be clicked on without
+ changing the focus. \endomit
*/
/*!
@@ -11432,6 +11437,9 @@ QDebug operator<<(QDebug debug, QGraphicsItem::GraphicsItemFlag flag)
case QGraphicsItem::ItemSendsScenePositionChanges:
str = "ItemSendsScenePositionChanges";
break;
+ case QGraphicsItem::ItemStopsClickFocusPropagation:
+ str = "ItemStopsClickFocusPropagation";
+ break;
}
debug << str;
return debug;
diff --git a/src/gui/graphicsview/qgraphicsitem.h b/src/gui/graphicsview/qgraphicsitem.h
index d7d5332..3c193cd 100644
--- a/src/gui/graphicsview/qgraphicsitem.h
+++ b/src/gui/graphicsview/qgraphicsitem.h
@@ -106,7 +106,8 @@ public:
ItemNegativeZStacksBehindParent = 0x2000,
ItemIsPanel = 0x4000,
ItemIsFocusScope = 0x8000, // internal
- ItemSendsScenePositionChanges = 0x10000
+ ItemSendsScenePositionChanges = 0x10000,
+ ItemStopsClickFocusPropagation = 0x20000
// 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/qgraphicsitem_p.h b/src/gui/graphicsview/qgraphicsitem_p.h
index bde6e7d..f9f5d3d 100644
--- a/src/gui/graphicsview/qgraphicsitem_p.h
+++ b/src/gui/graphicsview/qgraphicsitem_p.h
@@ -556,7 +556,7 @@ public:
quint32 dirtyChildrenBoundingRect : 1;
// Packed 32 bits
- quint32 flags : 17;
+ quint32 flags : 18;
quint32 paintedViewBoundingRectsNeedRepaint : 1;
quint32 dirtySceneTransform : 1;
quint32 geometryChanged : 1;
@@ -571,9 +571,9 @@ public:
quint32 notifyBoundingRectChanged : 1;
quint32 notifyInvalidated : 1;
quint32 mouseSetsFocus : 1;
- quint32 explicitActivate : 1;
// New 32 bits
+ quint32 explicitActivate : 1;
quint32 wantsActive : 1;
quint32 holesInSiblingIndex : 1;
quint32 sequentialOrdering : 1;
@@ -582,7 +582,7 @@ public:
quint32 pendingPolish : 1;
quint32 mayHaveChildWithGraphicsEffect : 1;
quint32 isDeclarativeItem : 1;
- quint32 padding : 24;
+ quint32 padding : 23;
// Optional stacking order
int globalStackingOrder;
diff --git a/src/gui/graphicsview/qgraphicsscene.cpp b/src/gui/graphicsview/qgraphicsscene.cpp
index ca3b56f..d04074a 100644
--- a/src/gui/graphicsview/qgraphicsscene.cpp
+++ b/src/gui/graphicsview/qgraphicsscene.cpp
@@ -1336,6 +1336,8 @@ void QGraphicsScenePrivate::mousePressEventHandler(QGraphicsSceneMouseEvent *mou
break;
}
}
+ if (item->d_ptr->flags & QGraphicsItem::ItemStopsClickFocusPropagation)
+ break;
if (item->isPanel())
break;
}