Changeset 846 for trunk/src/gui/graphicsview/qgraphicsitem.cpp
- Timestamp:
- May 5, 2011, 5:36:53 AM (14 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:mergeinfo changed
/branches/vendor/nokia/qt/4.7.2 (added) merged: 845 /branches/vendor/nokia/qt/current merged: 844 /branches/vendor/nokia/qt/4.6.3 removed
- Property svn:mergeinfo changed
-
trunk/src/gui/graphicsview/qgraphicsitem.cpp
r769 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 51 51 This includes defining the item's geometry, collision detection, its 52 52 painting implementation and item interaction through its event handlers. 53 QGraphicsItem is part of \l{TheGraphics View Framework}53 QGraphicsItem is part of the \l{Graphics View Framework} 54 54 55 55 \image graphicsview-items.png … … 134 134 \img graphicsview-parentchild.png 135 135 136 \section1 Transformation 136 \target Transformations 137 \section1 Transformations 137 138 138 139 QGraphicsItem supports projective transformations in addition to its base … … 265 266 user's convenience. 266 267 267 \sa QGraphicsScene, QGraphicsView, { TheGraphics View Framework}268 \sa QGraphicsScene, QGraphicsView, {Graphics View Framework} 268 269 */ 269 270 … … 382 383 \value ItemSendsGeometryChanges The item enables itemChange() 383 384 notifications for ItemPositionChange, ItemPositionHasChanged, 384 ItemMatrixChange, ItemTransformChange, and ItemTransformHasChanged. For 385 ItemMatrixChange, ItemTransformChange, ItemTransformHasChanged, 386 ItemRotationChange, ItemRotationHasChanged, ItemScaleChange, ItemScaleHasChanged, 387 ItemTransformOriginPointChange, and ItemTransformOriginPointHasChanged. For 385 388 performance reasons, these notifications are disabled by default. You must 386 389 enable this flag to receive notifications for position and transform … … 410 413 to receive notifications for scene position changes. This flag was 411 414 introduced in Qt 4.6. 415 416 \omitvalue ItemStopsClickFocusPropagation \omit The item stops propagating 417 click focus to items underneath when being clicked on. This flag 418 allows you create a non-focusable item that can be clicked on without 419 changing the focus. \endomit 412 420 */ 413 421 … … 475 483 (same as transform()), and QGraphicsItem ignores the return value for this 476 484 notification (i.e., a read-only notification). 485 486 \value ItemRotationChange The item's rotation property changes. This 487 notification is sent if the ItemSendsGeometryChanges flag is enabled, and 488 when the item's rotation property changes (i.e., as a result of calling 489 setRotation()). The value argument is the new rotation (i.e., a double); 490 to get the old rotation, call rotation(). Do not call setRotation() in 491 itemChange() as this notification is delivered; instead, you can return 492 the new rotation from itemChange(). 493 494 \value ItemRotationHasChanged The item's rotation property has changed. 495 This notification is sent if the ItemSendsGeometryChanges flag is enabled, 496 and after the item's rotation property has changed. The value argument is 497 the new rotation (i.e., a double), and QGraphicsItem ignores the return 498 value for this notification (i.e., a read-only notification). Do not call 499 setRotation() in itemChange() as this notification is delivered. 500 501 \value ItemScaleChange The item's scale property changes. This notification 502 is sent if the ItemSendsGeometryChanges flag is enabled, and when the item's 503 scale property changes (i.e., as a result of calling setScale()). The value 504 argument is the new scale (i.e., a double); to get the old scale, call 505 scale(). Do not call setScale() in itemChange() as this notification is 506 delivered; instead, you can return the new scale from itemChange(). 507 508 \value ItemScaleHasChanged The item's scale property has changed. This 509 notification is sent if the ItemSendsGeometryChanges flag is enabled, and 510 after the item's scale property has changed. The value argument is the new 511 scale (i.e., a double), and QGraphicsItem ignores the return value for this 512 notification (i.e., a read-only notification). Do not call setScale() in 513 itemChange() as this notification is delivered. 514 515 \value ItemTransformOriginPointChange The item's transform origin point 516 property changes. This notification is sent if the ItemSendsGeometryChanges 517 flag is enabled, and when the item's transform origin point property changes 518 (i.e., as a result of calling setTransformOriginPoint()). The value argument 519 is the new origin point (i.e., a QPointF); to get the old origin point, call 520 transformOriginPoint(). Do not call setTransformOriginPoint() in itemChange() 521 as this notification is delivered; instead, you can return the new transform 522 origin point from itemChange(). 523 524 \value ItemTransformOriginPointHasChanged The item's transform origin point 525 property has changed. This notification is sent if the ItemSendsGeometryChanges 526 flag is enabled, and after the item's transform origin point property has 527 changed. The value argument is the new origin point (i.e., a QPointF), and 528 QGraphicsItem ignores the return value for this notification (i.e., a read-only 529 notification). Do not call setTransformOriginPoint() in itemChange() as this 530 notification is delivered. 477 531 478 532 \value ItemSelectedChange The item's selected state changes. If the item is … … 674 728 #include <QtCore/qvariant.h> 675 729 #include <QtCore/qvarlengtharray.h> 730 #include <QtCore/qnumeric.h> 676 731 #include <QtGui/qapplication.h> 677 732 #include <QtGui/qbitmap.h> … … 683 738 #include <QtGui/qinputcontext.h> 684 739 #include <QtGui/qgraphicseffect.h> 740 #ifndef QT_NO_ACCESSIBILITY 741 # include "qaccessible.h" 742 #endif 685 743 686 744 #include <private/qgraphicsitem_p.h> … … 690 748 #include <private/qtextengine_p.h> 691 749 #include <private/qwidget_p.h> 750 #include <private/qapplication_p.h> 692 751 693 752 #ifdef Q_WS_X11 … … 1038 1097 return; 1039 1098 1099 if (isWidget) 1100 static_cast<QGraphicsWidgetPrivate *>(this)->fixFocusChainBeforeReparenting((newParent && 1101 newParent->isWidget()) ? static_cast<QGraphicsWidget *>(newParent) : 0, 1102 scene); 1040 1103 if (scene) { 1041 1104 // Deliver the change to the index … … 1088 1151 parentFocusScopeItem = fsi; 1089 1152 p->d_ptr->focusScopeItem = 0; 1153 fsi->d_ptr->focusScopeItemChange(false); 1090 1154 } 1091 1155 break; … … 1120 1184 if (p->d_ptr->flags & QGraphicsItem::ItemIsFocusScope) { 1121 1185 p->d_ptr->focusScopeItem = newFocusScopeItem; 1186 newFocusScopeItem->d_ptr->focusScopeItemChange(true); 1122 1187 // Ensure the new item is no longer the subFocusItem. The 1123 1188 // only way to set focus on a child of a focus scope is … … 1185 1250 1186 1251 dirtySceneTransform = 1; 1252 if (!inDestructor && (transformData || (newParent && newParent->d_ptr->transformData))) 1253 transformChanged(); 1187 1254 1188 1255 // Restore the sub focus chain. … … 1206 1273 Returns the bounding rect of this item's children (excluding itself). 1207 1274 */ 1208 void QGraphicsItemPrivate::childrenBoundingRectHelper(QTransform *x, QRectF *rect) 1209 { 1275 void QGraphicsItemPrivate::childrenBoundingRectHelper(QTransform *x, QRectF *rect, QGraphicsItem *topMostEffectItem) 1276 { 1277 Q_Q(QGraphicsItem); 1278 1279 QRectF childrenRect; 1280 QRectF *result = rect; 1281 rect = &childrenRect; 1282 const bool setTopMostEffectItem = !topMostEffectItem; 1283 1210 1284 for (int i = 0; i < children.size(); ++i) { 1211 1285 QGraphicsItem *child = children.at(i); 1212 1286 QGraphicsItemPrivate *childd = child->d_ptr.data(); 1287 if (setTopMostEffectItem) 1288 topMostEffectItem = child; 1213 1289 bool hasPos = !childd->pos.isNull(); 1214 1290 if (hasPos || childd->transformData) { … … 1217 1293 if (x) 1218 1294 matrix *= *x; 1219 *rect |= matrix.mapRect(child-> boundingRect());1295 *rect |= matrix.mapRect(child->d_ptr->effectiveBoundingRect(topMostEffectItem)); 1220 1296 if (!childd->children.isEmpty()) 1221 childd->childrenBoundingRectHelper(&matrix, rect );1297 childd->childrenBoundingRectHelper(&matrix, rect, topMostEffectItem); 1222 1298 } else { 1223 1299 if (x) 1224 *rect |= x->mapRect(child-> boundingRect());1300 *rect |= x->mapRect(child->d_ptr->effectiveBoundingRect(topMostEffectItem)); 1225 1301 else 1226 *rect |= child-> boundingRect();1302 *rect |= child->d_ptr->effectiveBoundingRect(topMostEffectItem); 1227 1303 if (!childd->children.isEmpty()) 1228 childd->childrenBoundingRectHelper(x, rect );1304 childd->childrenBoundingRectHelper(x, rect, topMostEffectItem); 1229 1305 } 1230 1306 } 1307 1308 if (flags & QGraphicsItem::ItemClipsChildrenToShape){ 1309 if (x) 1310 *rect &= x->mapRect(q->boundingRect()); 1311 else 1312 *rect &= q->boundingRect(); 1313 } 1314 1315 *result |= *rect; 1231 1316 } 1232 1317 … … 1356 1441 QGraphicsItem::~QGraphicsItem() 1357 1442 { 1358 if (d_ptr->isObject) 1359 QObjectPrivate::get(static_cast<QGraphicsObject *>(this))->wasDeleted = true; 1443 if (d_ptr->isObject) { 1444 QGraphicsObject *o = static_cast<QGraphicsObject *>(this); 1445 QObjectPrivate *p = QObjectPrivate::get(o); 1446 p->wasDeleted = true; 1447 if (p->declarativeData) { 1448 QAbstractDeclarativeData::destroyed(p->declarativeData, o); 1449 p->declarativeData = 0; 1450 } 1451 } 1452 1360 1453 d_ptr->inDestructor = 1; 1361 1454 d_ptr->removeExtraItemCache(); 1455 1456 #ifndef QT_NO_GESTURES 1457 if (d_ptr->isObject && !d_ptr->gestureContext.isEmpty()) { 1458 QGraphicsObject *o = static_cast<QGraphicsObject *>(this); 1459 if (QGestureManager *manager = QGestureManager::instance()) { 1460 foreach (Qt::GestureType type, d_ptr->gestureContext.keys()) 1461 manager->cleanupCachedGestures(o, type); 1462 } 1463 } 1464 #endif 1362 1465 1363 1466 clearFocus(); … … 1734 1837 void QGraphicsItem::setFlags(GraphicsItemFlags flags) 1735 1838 { 1736 if (isWindow())1737 flags |= ItemIsPanel;1738 1739 1839 // Notify change and check for adjustment. 1740 1840 if (quint32(d_ptr->flags) == quint32(flags)) … … 1750 1850 bool fullUpdate = (quint32(flags) & geomChangeFlagsMask) != (d_ptr->flags & geomChangeFlagsMask); 1751 1851 if (fullUpdate) 1752 d_ptr-> paintedViewBoundingRectsNeedRepaint = 1;1852 d_ptr->updatePaintedViewBoundingRects(/*children=*/true); 1753 1853 1754 1854 // Keep the old flags to compare the diff. … … 1774 1874 // all children. 1775 1875 d_ptr->updateAncestorFlag(ItemClipsChildrenToShape); 1876 // The childrenBoundingRect is clipped to the boundingRect in case of ItemClipsChildrenToShape, 1877 // which means we have to invalidate the cached childrenBoundingRect whenever this flag changes. 1878 d_ptr->dirtyChildrenBoundingRect = 1; 1879 d_ptr->markParentDirty(true); 1776 1880 } 1777 1881 … … 2022 2126 \snippet doc/src/snippets/code/src_gui_graphicsview_qgraphicsitem.cpp 2 2023 2127 2024 If no cursor has been set, the parent's cursoris used.2128 If no cursor has been set, the cursor of the item beneath is used. 2025 2129 2026 2130 \sa setCursor(), hasCursor(), unsetCursor(), QWidget::cursor, … … 2262 2366 fsi = fsi->d_ptr->focusScopeItem; 2263 2367 fsi->d_ptr->setFocusHelper(Qt::OtherFocusReason, /* climb = */ true, 2264 /* focusFrom Show = */ true);2368 /* focusFromHide = */ false); 2265 2369 } 2266 2370 break; … … 2272 2376 if (fi && fi != scene->focusItem()) { 2273 2377 scene->setFocusItem(fi); 2378 } else if (flags & QGraphicsItem::ItemIsFocusScope && 2379 !scene->focusItem() && 2380 q->isAncestorOf(scene->d_func()->lastFocusItem)) { 2381 q_ptr->setFocus(); 2274 2382 } 2275 2383 } … … 2282 2390 if (p->d_ptr->visible) { 2283 2391 p->d_ptr->setFocusHelper(Qt::OtherFocusReason, /* climb = */ true, 2284 /* focusFrom Show= */ true);2392 /* focusFromHide = */ true); 2285 2393 } 2286 2394 break; … … 2704 2812 QGraphicsEffect *effect = graphicsEffect; 2705 2813 if (scene && effect && effect->isEnabled()) { 2814 if (scene->d_func()->views.isEmpty()) 2815 return effect->boundingRectFor(rect); 2706 2816 QRectF sceneRect = q->mapRectToScene(rect); 2707 2817 QRectF sceneEffectRect; … … 2727 2837 \sa boundingRect() 2728 2838 */ 2729 QRectF QGraphicsItemPrivate::effectiveBoundingRect( ) const2839 QRectF QGraphicsItemPrivate::effectiveBoundingRect(QGraphicsItem *topMostEffectItem) const 2730 2840 { 2731 2841 #ifndef QT_NO_GRAPHICSEFFECT 2732 2842 Q_Q(const QGraphicsItem); 2733 2843 QRectF brect = effectiveBoundingRect(q_ptr->boundingRect()); 2734 if (ancestorFlags & QGraphicsItemPrivate::AncestorClipsChildren )2844 if (ancestorFlags & QGraphicsItemPrivate::AncestorClipsChildren || topMostEffectItem == q) 2735 2845 return brect; 2736 2846 … … 2743 2853 brect = effectParent->mapRectToItem(q, effectRectInParentSpace); 2744 2854 } 2745 if (effectParent->d_ptr->ancestorFlags & QGraphicsItemPrivate::AncestorClipsChildren) 2855 if (effectParent->d_ptr->ancestorFlags & QGraphicsItemPrivate::AncestorClipsChildren 2856 || topMostEffectItem == effectParent) { 2746 2857 return brect; 2858 } 2747 2859 effectParent = effectParent->d_ptr->parent; 2748 2860 } … … 3138 3250 void QGraphicsItem::setFocus(Qt::FocusReason focusReason) 3139 3251 { 3140 d_ptr->setFocusHelper(focusReason, /* climb = */ true, /* focusFrom Show= */ false);3252 d_ptr->setFocusHelper(focusReason, /* climb = */ true, /* focusFromHide = */ false); 3141 3253 } 3142 3254 … … 3144 3256 \internal 3145 3257 */ 3146 void QGraphicsItemPrivate::setFocusHelper(Qt::FocusReason focusReason, bool climb, bool focusFrom Show)3258 void QGraphicsItemPrivate::setFocusHelper(Qt::FocusReason focusReason, bool climb, bool focusFromHide) 3147 3259 { 3148 3260 // Disabled / unfocusable items cannot accept focus. … … 3163 3275 while (p) { 3164 3276 if (p->flags() & QGraphicsItem::ItemIsFocusScope) { 3277 QGraphicsItem *oldFocusScopeItem = p->d_ptr->focusScopeItem; 3165 3278 p->d_ptr->focusScopeItem = q_ptr; 3166 if (!p->focusItem() && !focusFromShow) { 3279 if (!p->focusItem() && !focusFromHide) { 3280 if (oldFocusScopeItem) 3281 oldFocusScopeItem->d_ptr->focusScopeItemChange(false); 3282 focusScopeItemChange(true); 3167 3283 // If you call setFocus on a child of a focus scope that 3168 3284 // doesn't currently have a focus item, then stop. … … 3180 3296 3181 3297 // Update the child focus chain. 3182 f->d_ptr->setSubFocus(); 3298 QGraphicsItem *commonAncestor = 0; 3299 if (scene && scene->focusItem()) { 3300 commonAncestor = scene->focusItem()->commonAncestorItem(f); 3301 scene->focusItem()->d_ptr->clearSubFocus(scene->focusItem(), commonAncestor); 3302 } 3303 3304 f->d_ptr->setSubFocus(f, commonAncestor); 3183 3305 3184 3306 // Update the scene's focus item. … … 3219 3341 while (p) { 3220 3342 if (p->flags() & QGraphicsItem::ItemIsFocusScope) { 3221 p->d_ptr->setFocusHelper(Qt::OtherFocusReason, /* climb = */ false, 3222 /* focusFromShow = */ false); 3343 if (p->d_ptr->focusScopeItem == q_ptr) { 3344 p->d_ptr->focusScopeItem = 0; 3345 if (!q_ptr->hasFocus()) //if it has focus, focusScopeItemChange is called elsewhere 3346 focusScopeItemChange(false); 3347 } 3348 if (q_ptr->hasFocus()) 3349 p->d_ptr->setFocusHelper(Qt::OtherFocusReason, /* climb = */ false, 3350 /* focusFromHide = */ false); 3223 3351 return; 3224 3352 } … … 3228 3356 } 3229 3357 3230 // Invisible items with focus must explicitly clear subfocus.3231 clearSubFocus(q_ptr);3232 3233 3358 if (q_ptr->hasFocus()) { 3359 // Invisible items with focus must explicitly clear subfocus. 3360 clearSubFocus(q_ptr); 3361 3234 3362 // If this item has the scene's input focus, clear it. 3235 3363 scene->setFocusItem(0); … … 3485 3613 return; 3486 3614 3487 d_ptr->setPosHelper(QPointF(x, d_ptr->pos.y())); 3615 if (qIsNaN(x)) 3616 return; 3617 3618 setPos(QPointF(x, d_ptr->pos.y())); 3488 3619 } 3489 3620 … … 3509 3640 return; 3510 3641 3511 d_ptr->setPosHelper(QPointF(d_ptr->pos.x(), y)); 3642 if (qIsNaN(y)) 3643 return; 3644 3645 setPos(QPointF(d_ptr->pos.x(), y)); 3512 3646 } 3513 3647 … … 3556 3690 transformData->transform = transform; 3557 3691 dirtySceneTransform = 1; 3692 transformChanged(); 3558 3693 } 3559 3694 … … 3577 3712 3578 3713 // Update and repositition. 3579 if (!(d_ptr->flags & ItemSendsGeometryChanges)) {3714 if (!(d_ptr->flags & (ItemSendsGeometryChanges | ItemSendsScenePositionChanges))) { 3580 3715 d_ptr->setPosHelper(pos); 3581 3716 if (d_ptr->isWidget) 3582 3717 static_cast<QGraphicsWidget *>(this)->d_func()->setGeometryFromSetPos(); 3718 if (d_ptr->scenePosDescendants) 3719 d_ptr->sendScenePosChange(); 3583 3720 return; 3584 3721 } … … 3724 3861 { 3725 3862 prepareGeometryChange(); 3863 qreal newRotation = angle; 3864 3865 if (d_ptr->flags & ItemSendsGeometryChanges) { 3866 // Notify the item that the rotation is changing. 3867 const QVariant newRotationVariant(itemChange(ItemRotationChange, angle)); 3868 newRotation = newRotationVariant.toReal(); 3869 } 3870 3726 3871 if (!d_ptr->transformData) 3727 3872 d_ptr->transformData = new QGraphicsItemPrivate::TransformData; 3728 d_ptr->transformData->rotation = angle; 3873 3874 if (d_ptr->transformData->rotation == newRotation) 3875 return; 3876 3877 d_ptr->transformData->rotation = newRotation; 3729 3878 d_ptr->transformData->onlyTransform = false; 3730 3879 d_ptr->dirtySceneTransform = 1; 3731 3880 3881 // Send post-notification. 3882 if (d_ptr->flags & ItemSendsGeometryChanges) 3883 itemChange(ItemRotationHasChanged, newRotation); 3884 3732 3885 if (d_ptr->isObject) 3733 3886 emit static_cast<QGraphicsObject *>(this)->rotationChanged(); 3887 3888 d_ptr->transformChanged(); 3734 3889 } 3735 3890 … … 3767 3922 transformations() to map the item's coordinate system to the parent item. 3768 3923 3769 \sa scale(), setTransformOriginPoint(), {Transformations }3924 \sa scale(), setTransformOriginPoint(), {Transformations Example} 3770 3925 */ 3771 3926 void QGraphicsItem::setScale(qreal factor) 3772 3927 { 3773 3928 prepareGeometryChange(); 3929 qreal newScale = factor; 3930 3931 if (d_ptr->flags & ItemSendsGeometryChanges) { 3932 // Notify the item that the scale is changing. 3933 const QVariant newScaleVariant(itemChange(ItemScaleChange, factor)); 3934 newScale = newScaleVariant.toReal(); 3935 } 3936 3774 3937 if (!d_ptr->transformData) 3775 3938 d_ptr->transformData = new QGraphicsItemPrivate::TransformData; 3776 d_ptr->transformData->scale = factor; 3939 3940 if (d_ptr->transformData->scale == newScale) 3941 return; 3942 3943 d_ptr->transformData->scale = newScale; 3777 3944 d_ptr->transformData->onlyTransform = false; 3778 3945 d_ptr->dirtySceneTransform = 1; 3779 3946 3947 // Send post-notification. 3948 if (d_ptr->flags & ItemSendsGeometryChanges) 3949 itemChange(ItemScaleHasChanged, newScale); 3950 3780 3951 if (d_ptr->isObject) 3781 3952 emit static_cast<QGraphicsObject *>(this)->scaleChanged(); 3953 3954 d_ptr->transformChanged(); 3782 3955 } 3783 3956 … … 3789 3962 3790 3963 QGraphicsTransform is for applying and controlling a chain of individual 3791 transformation operations on an item. It's particular ily useful in3964 transformation operations on an item. It's particularly useful in 3792 3965 animations, where each transform operation needs to be interpolated 3793 3966 independently, or differently. … … 3816 3989 3817 3990 QGraphicsTransform is for applying and controlling a chain of individual 3818 transformation operations on an item. It's particular ily useful in3991 transformation operations on an item. It's particularly useful in 3819 3992 animations, where each transform operation needs to be interpolated 3820 3993 independently, or differently. … … 3835 4008 d_ptr->transformData->onlyTransform = false; 3836 4009 d_ptr->dirtySceneTransform = 1; 4010 d_ptr->transformChanged(); 4011 } 4012 4013 /*! 4014 \internal 4015 */ 4016 void QGraphicsItemPrivate::prependGraphicsTransform(QGraphicsTransform *t) 4017 { 4018 if (!transformData) 4019 transformData = new QGraphicsItemPrivate::TransformData; 4020 if (!transformData->graphicsTransforms.contains(t)) 4021 transformData->graphicsTransforms.prepend(t); 4022 4023 Q_Q(QGraphicsItem); 4024 t->d_func()->setItem(q); 4025 transformData->onlyTransform = false; 4026 dirtySceneTransform = 1; 4027 transformChanged(); 3837 4028 } 3838 4029 … … 3851 4042 transformData->onlyTransform = false; 3852 4043 dirtySceneTransform = 1; 4044 transformChanged(); 3853 4045 } 3854 4046 … … 3879 4071 { 3880 4072 prepareGeometryChange(); 4073 QPointF newOrigin = origin; 4074 4075 if (d_ptr->flags & ItemSendsGeometryChanges) { 4076 // Notify the item that the origin point is changing. 4077 const QVariant newOriginVariant(itemChange(ItemTransformOriginPointChange, 4078 qVariantFromValue<QPointF>(origin))); 4079 newOrigin = newOriginVariant.toPointF(); 4080 } 4081 3881 4082 if (!d_ptr->transformData) 3882 4083 d_ptr->transformData = new QGraphicsItemPrivate::TransformData; 3883 d_ptr->transformData->xOrigin = origin.x(); 3884 d_ptr->transformData->yOrigin = origin.y(); 4084 4085 if (d_ptr->transformData->xOrigin == newOrigin.x() 4086 && d_ptr->transformData->yOrigin == newOrigin.y()) { 4087 return; 4088 } 4089 4090 d_ptr->transformData->xOrigin = newOrigin.x(); 4091 d_ptr->transformData->yOrigin = newOrigin.y(); 3885 4092 d_ptr->transformData->onlyTransform = false; 3886 4093 d_ptr->dirtySceneTransform = 1; 4094 4095 // Send post-notification. 4096 if (d_ptr->flags & ItemSendsGeometryChanges) 4097 itemChange(ItemTransformOriginPointHasChanged, qVariantFromValue<QPointF>(newOrigin)); 3887 4098 } 3888 4099 … … 4189 4400 4190 4401 // Update and set the new transformation. 4191 if (!(d_ptr->flags & ItemSendsGeometryChanges)) {4402 if (!(d_ptr->flags & (ItemSendsGeometryChanges | ItemSendsScenePositionChanges))) { 4192 4403 d_ptr->setTransformHelper(newTransform); 4404 if (d_ptr->scenePosDescendants) 4405 d_ptr->sendScenePosChange(); 4193 4406 return; 4194 4407 } … … 4531 4744 4532 4745 d_ptr->childrenBoundingRect = QRectF(); 4533 d_ptr->childrenBoundingRectHelper(0, &d_ptr->childrenBoundingRect );4746 d_ptr->childrenBoundingRectHelper(0, &d_ptr->childrenBoundingRect, 0); 4534 4747 d_ptr->dirtyChildrenBoundingRect = 0; 4535 4748 return d_ptr->childrenBoundingRect; … … 4972 5185 contents. Although it's expensive to calculate, it's also more precise 4973 5186 than boundingRect(), and it can help to avoid unnecessary repainting when 4974 an item is updated. This is particular ily efficient for thin items (e.g.,5187 an item is updated. This is particularly efficient for thin items (e.g., 4975 5188 lines or simple polygons). You can tune the granularity for the bounding 4976 5189 region by calling setBoundingRegionGranularity(). The default granularity … … 5228 5441 child->d_ptr->siblingIndex = children.size(); 5229 5442 children.append(child); 5443 if (isObject) 5444 emit static_cast<QGraphicsObject *>(q_ptr)->childrenChanged(); 5230 5445 } 5231 5446 … … 5250 5465 // (see ensureSortedChildren()). 5251 5466 child->d_ptr->siblingIndex = -1; 5467 if (isObject) 5468 emit static_cast<QGraphicsObject *>(q_ptr)->childrenChanged(); 5252 5469 } 5253 5470 … … 5285 5502 } 5286 5503 unsetExtra(ExtraCacheData); 5504 } 5505 5506 void QGraphicsItemPrivate::updatePaintedViewBoundingRects(bool updateChildren) 5507 { 5508 if (!scene) 5509 return; 5510 5511 for (int i = 0; i < scene->d_func()->views.size(); ++i) { 5512 QGraphicsViewPrivate *viewPrivate = scene->d_func()->views.at(i)->d_func(); 5513 QRect rect = paintedViewBoundingRects.value(viewPrivate->viewport); 5514 rect.translate(viewPrivate->dirtyScrollOffset); 5515 viewPrivate->updateRect(rect); 5516 } 5517 5518 if (updateChildren) { 5519 for (int i = 0; i < children.size(); ++i) 5520 children.at(i)->d_ptr->updatePaintedViewBoundingRects(true); 5521 } 5287 5522 } 5288 5523 … … 5324 5559 \internal 5325 5560 */ 5326 void QGraphicsItemPrivate::setSubFocus(QGraphicsItem *rootItem )5561 void QGraphicsItemPrivate::setSubFocus(QGraphicsItem *rootItem, QGraphicsItem *stopItem) 5327 5562 { 5328 5563 // Update focus child chain. Stop at panels, or if this item 5329 5564 // is hidden, stop at the first item with a visible parent. 5330 5565 QGraphicsItem *parent = rootItem ? rootItem : q_ptr; 5566 if (parent->panel() != q_ptr->panel()) 5567 return; 5568 5331 5569 do { 5332 5570 // Clear any existing ancestor's subFocusItem. … … 5334 5572 if (parent->d_ptr->subFocusItem == q_ptr) 5335 5573 break; 5336 parent->d_ptr->subFocusItem->d_ptr->clearSubFocus( );5574 parent->d_ptr->subFocusItem->d_ptr->clearSubFocus(0, stopItem); 5337 5575 } 5338 5576 parent->d_ptr->subFocusItem = q_ptr; … … 5347 5585 \internal 5348 5586 */ 5349 void QGraphicsItemPrivate::clearSubFocus(QGraphicsItem *rootItem )5587 void QGraphicsItemPrivate::clearSubFocus(QGraphicsItem *rootItem, QGraphicsItem *stopItem) 5350 5588 { 5351 5589 // Reset sub focus chain. … … 5355 5593 break; 5356 5594 parent->d_ptr->subFocusItem = 0; 5357 parent->d_ptr->subFocusItemChange(); 5595 if (parent != stopItem && !parent->isAncestorOf(stopItem)) 5596 parent->d_ptr->subFocusItemChange(); 5358 5597 } while (!parent->isPanel() && (parent = parent->d_ptr->parent)); 5359 5598 } … … 5380 5619 void QGraphicsItemPrivate::subFocusItemChange() 5381 5620 { 5621 } 5622 5623 /*! 5624 \internal 5625 5626 Subclasses can reimplement this function to be notified when an item 5627 becomes a focusScopeItem (or is no longer a focusScopeItem). 5628 */ 5629 void QGraphicsItemPrivate::focusScopeItemChange(bool isSubFocusItem) 5630 { 5631 Q_UNUSED(isSubFocusItem); 5382 5632 } 5383 5633 … … 5446 5696 } 5447 5697 5448 if (d_ptr->discardUpdateRequest())5449 return;5450 5451 5698 if (d_ptr->scene) 5452 5699 d_ptr->scene->d_func()->markDirty(this, rect); … … 5470 5717 is equivalent to calling update(\a rect). 5471 5718 5719 \bold{Note:} Scrolling is only supported when QGraphicsItem::ItemCoordinateCache 5720 is enabled; in all other cases calling this function is equivalent to calling 5721 update(\a rect). If you for sure know that the item is opaque and not overlapped 5722 by other items, you can map the \a rect to viewport coordinates and scroll the 5723 viewport. 5724 5725 \snippet doc/src/snippets/code/src_gui_graphicsview_qgraphicsitem.cpp 19 5726 5472 5727 \sa boundingRect() 5473 5728 */ … … 5479 5734 if (!d->scene) 5480 5735 return; 5481 if (d->cacheMode != NoCache) { 5482 QGraphicsItemCache *c; 5483 bool scrollCache = qFuzzyIsNull(dx - int(dx)) && qFuzzyIsNull(dy - int(dy)) 5484 && (c = (QGraphicsItemCache *)qVariantValue<void *>(d_ptr->extra(QGraphicsItemPrivate::ExtraCacheData))) 5485 && (d->cacheMode == ItemCoordinateCache && !c->fixedSize.isValid()); 5486 if (scrollCache) { 5487 QPixmap pix; 5488 if (QPixmapCache::find(c->key, &pix)) { 5489 // Adjust with 2 pixel margin. Notice the loss of precision 5490 // when converting to QRect. 5491 int adjust = 2; 5492 QRectF br = boundingRect().adjusted(-adjust, -adjust, adjust, adjust); 5493 QRect irect = rect.toRect().translated(-br.x(), -br.y()); 5494 5495 pix.scroll(dx, dy, irect); 5496 5497 QPixmapCache::replace(c->key, pix); 5498 5499 // Translate the existing expose. 5500 foreach (QRectF exposedRect, c->exposed) 5501 c->exposed += exposedRect.translated(dx, dy) & rect; 5502 5503 // Calculate exposure. 5504 QRegion exposed; 5505 QRect r = rect.toRect(); 5506 exposed += r; 5507 exposed -= r.translated(dx, dy); 5508 foreach (QRect rect, exposed.rects()) 5509 update(rect); 5510 d->scene->d_func()->markDirty(this); 5511 } else { 5512 update(rect); 5513 } 5514 } else { 5515 // ### This is very slow, and can be done much better. If the cache is 5516 // local and matches the below criteria for rotation and scaling, we 5517 // can easily scroll. And if the cache is in device coordinates, we 5518 // can scroll both the viewport and the cache. 5519 update(rect); 5520 } 5736 5737 // Accelerated scrolling means moving pixels from one location to another 5738 // and only redraw the newly exposed area. The following requirements must 5739 // be fulfilled in order to do that: 5740 // 5741 // 1) Item is opaque. 5742 // 2) Item is not overlapped by other items. 5743 // 5744 // There's (yet) no way to detect whether an item is opaque or not, which means 5745 // we cannot do accelerated scrolling unless the cache is enabled. In case of using 5746 // DeviceCoordinate cache we also have to take the device transform into account in 5747 // order to determine whether we can do accelerated scrolling or not. That's left out 5748 // for simplicity here, but it is definitely something we can consider in the future 5749 // as a performance improvement. 5750 if (d->cacheMode != QGraphicsItem::ItemCoordinateCache 5751 || !qFuzzyIsNull(dx - int(dx)) || !qFuzzyIsNull(dy - int(dy))) { 5752 update(rect); 5521 5753 return; 5522 5754 } 5523 5755 5524 QRectF scrollRect = !rect.isNull() ? rect : boundingRect(); 5525 int couldntScroll = d->scene->views().size(); 5526 foreach (QGraphicsView *view, d->scene->views()) { 5527 if (view->viewport()->inherits("QGLWidget")) { 5528 // ### Please replace with a widget attribute; any widget that 5529 // doesn't support partial updates / doesn't support scrolling 5530 // should be skipped in this code. Qt::WA_NoPartialUpdates or so. 5756 QGraphicsItemCache *cache = d->extraItemCache(); 5757 if (cache->allExposed || cache->fixedSize.isValid()) { 5758 // Cache is either invalidated or item is scaled (see QGraphicsItem::setCacheMode). 5759 update(rect); 5760 return; 5761 } 5762 5763 // Find pixmap in cache. 5764 QPixmap cachedPixmap; 5765 if (!QPixmapCache::find(cache->key, &cachedPixmap)) { 5766 update(rect); 5767 return; 5768 } 5769 5770 QRect scrollRect = (rect.isNull() ? boundingRect() : rect).toAlignedRect(); 5771 if (!scrollRect.intersects(cache->boundingRect)) 5772 return; // Nothing to scroll. 5773 5774 // Remove from cache to avoid deep copy when modifying. 5775 QPixmapCache::remove(cache->key); 5776 5777 QRegion exposed; 5778 cachedPixmap.scroll(dx, dy, scrollRect.translated(-cache->boundingRect.topLeft()), &exposed); 5779 5780 // Reinsert into cache. 5781 cache->key = QPixmapCache::insert(cachedPixmap); 5782 5783 // Translate the existing expose. 5784 for (int i = 0; i < cache->exposed.size(); ++i) { 5785 QRectF &e = cache->exposed[i]; 5786 if (!rect.isNull() && !e.intersects(rect)) 5531 5787 continue; 5532 } 5533 5534 static const QLineF up(0, 0, 0, -1); 5535 static const QLineF down(0, 0, 0, 1); 5536 static const QLineF left(0, 0, -1, 0); 5537 static const QLineF right(0, 0, 1, 0); 5538 5539 QTransform deviceTr = deviceTransform(view->viewportTransform()); 5540 QRect deviceScrollRect = deviceTr.mapRect(scrollRect).toRect(); 5541 QLineF v1 = deviceTr.map(right); 5542 QLineF v2 = deviceTr.map(down); 5543 QLineF u1 = v1.unitVector(); u1.translate(-v1.p1()); 5544 QLineF u2 = v2.unitVector(); u2.translate(-v2.p1()); 5545 bool noScroll = false; 5546 5547 // Check if the delta resolves to ints in device space. 5548 QPointF deviceDelta = deviceTr.map(QPointF(dx, dy)); 5549 if ((deviceDelta.x() - int(deviceDelta.x())) 5550 || (deviceDelta.y() - int(deviceDelta.y()))) { 5551 noScroll = true; 5552 } else { 5553 // Check if the unit vectors have no fraction in device space. 5554 qreal v1l = v1.length(); 5555 if (v1l - int(v1l)) { 5556 noScroll = true; 5557 } else { 5558 dx *= v1.length(); 5559 } 5560 qreal v2l = v2.length(); 5561 if (v2l - int(v2l)) { 5562 noScroll = true; 5563 } else { 5564 dy *= v2.length(); 5565 } 5566 } 5567 5568 if (!noScroll) { 5569 if (u1 == right) { 5570 if (u2 == up) { 5571 // flipped 5572 dy = -dy; 5573 } else if (u2 == down) { 5574 // normal 5575 } else { 5576 noScroll = true; 5577 } 5578 } else if (u1 == left) { 5579 if (u2 == up) { 5580 // mirrored & flipped / rotated 180 degrees 5581 dx = -dx; 5582 dy = -dy; 5583 } else if (u2 == down) { 5584 // mirrored 5585 dx = -dx; 5586 } else { 5587 noScroll = true; 5588 } 5589 } else if (u1 == up) { 5590 if (u2 == left) { 5591 // rotated -90 & mirrored 5592 qreal tmp = dy; 5593 dy = -dx; 5594 dx = -tmp; 5595 } else if (u2 == right) { 5596 // rotated -90 5597 qreal tmp = dy; 5598 dy = -dx; 5599 dx = tmp; 5600 } else { 5601 noScroll = true; 5602 } 5603 } else if (u1 == down) { 5604 if (u2 == left) { 5605 // rotated 90 5606 qreal tmp = dy; 5607 dy = dx; 5608 dx = -tmp; 5609 } else if (u2 == right) { 5610 // rotated 90 & mirrored 5611 qreal tmp = dy; 5612 dy = dx; 5613 dx = tmp; 5614 } else { 5615 noScroll = true; 5616 } 5617 } 5618 } 5619 5620 if (!noScroll) { 5621 view->viewport()->scroll(int(dx), int(dy), deviceScrollRect); 5622 --couldntScroll; 5623 } 5624 } 5625 if (couldntScroll) 5626 update(rect); 5788 e.translate(dx, dy); 5789 } 5790 5791 // Append newly exposed areas. Note that the exposed region is currently 5792 // in pixmap coordinates, so we have to translate it to item coordinates. 5793 exposed.translate(cache->boundingRect.topLeft()); 5794 const QVector<QRect> exposedRects = exposed.rects(); 5795 for (int i = 0; i < exposedRects.size(); ++i) 5796 cache->exposed += exposedRects.at(i); 5797 5798 // Trigger update. This will redraw the newly exposed area and make sure 5799 // the pixmap is re-blitted in case there are overlapping items. 5800 d->scene->d_func()->markDirty(this, rect); 5627 5801 } 5628 5802 … … 6500 6674 } 6501 6675 6676 if (event->type() == QEvent::FocusOut) { 6677 focusOutEvent(static_cast<QFocusEvent *>(event)); 6678 return true; 6679 } 6680 6502 6681 if (!d_ptr->visible) { 6503 6682 // Eaten … … 6508 6687 case QEvent::FocusIn: 6509 6688 focusInEvent(static_cast<QFocusEvent *>(event)); 6510 break;6511 case QEvent::FocusOut:6512 focusOutEvent(static_cast<QFocusEvent *>(event));6513 6689 break; 6514 6690 case QEvent::GraphicsSceneContextMenu: … … 6985 7161 // calculate their diff by mapping viewport coordinates 6986 7162 // directly to parent coordinates. 6987 QTransform viewToParentTransform = (item->transform().translate(item->d_ptr->pos.x(), item->d_ptr->pos.y())) 7163 // COMBINE 7164 QTransform itemTransform; 7165 if (item->d_ptr->transformData) 7166 itemTransform = item->d_ptr->transformData->computedFullTransform(); 7167 itemTransform.translate(item->d_ptr->pos.x(), item->d_ptr->pos.y()); 7168 QTransform viewToParentTransform = itemTransform 6988 7169 * (item->sceneTransform() * view->viewportTransform()).inverted(); 6989 7170 currentParentPos = viewToParentTransform.map(QPointF(view->mapFromGlobal(event->screenPos()))); … … 7179 7360 Q_D(QGraphicsItem); 7180 7361 d->imHints = hints; 7362 if (!hasFocus()) 7363 return; 7364 d->scene->d_func()->updateInputMethodSensitivityInViews(); 7365 #if !defined(QT_NO_IM) && (defined(Q_WS_X11) || defined(Q_WS_QWS) || defined(Q_OS_SYMBIAN)) 7366 QWidget *fw = QApplication::focusWidget(); 7367 if (!fw) 7368 return; 7369 for (int i = 0 ; i < scene()->views().count() ; ++i) 7370 if (scene()->views().at(i) == fw) 7371 if (QInputContext *inputContext = fw->inputContext()) 7372 inputContext->update(); 7373 #endif 7374 } 7375 7376 /*! 7377 Updates the item's micro focus. 7378 7379 \since 4.7 7380 7381 \sa QInputContext 7382 */ 7383 void QGraphicsItem::updateMicroFocus() 7384 { 7385 #if !defined(QT_NO_IM) && (defined(Q_WS_X11) || defined(Q_WS_QWS) || defined(Q_OS_SYMBIAN)) 7386 if (QWidget *fw = QApplication::focusWidget()) { 7387 if (scene()) { 7388 for (int i = 0 ; i < scene()->views().count() ; ++i) { 7389 if (scene()->views().at(i) == fw) 7390 if (QInputContext *inputContext = fw->inputContext()) 7391 inputContext->update(); 7392 } 7393 } 7394 #ifndef QT_NO_ACCESSIBILITY 7395 // ##### is this correct 7396 QAccessible::updateAccessibility(fw, 0, QAccessible::StateChanged); 7397 #endif 7398 } 7399 #endif 7181 7400 } 7182 7401 … … 7431 7650 } 7432 7651 7652 #ifndef QT_NO_GESTURES 7433 7653 /*! 7434 7654 Subscribes the graphics object to the given \a gesture with specific \a flags. … … 7438 7658 void QGraphicsObject::grabGesture(Qt::GestureType gesture, Qt::GestureFlags flags) 7439 7659 { 7440 QGraphicsItemPrivate * const d = QGraphicsItem::d_func(); 7441 d->gestureContext.insert(gesture, flags); 7442 (void)QGestureManager::instance(); // create a gesture manager 7660 bool contains = QGraphicsItem::d_ptr->gestureContext.contains(gesture); 7661 QGraphicsItem::d_ptr->gestureContext.insert(gesture, flags); 7662 if (!contains && QGraphicsItem::d_ptr->scene) 7663 QGraphicsItem::d_ptr->scene->d_func()->grabGesture(this, gesture); 7443 7664 } 7444 7665 … … 7450 7671 void QGraphicsObject::ungrabGesture(Qt::GestureType gesture) 7451 7672 { 7452 QGraphicsItemPrivate * const d = QGraphicsItem::d_func(); 7453 if (d->gestureContext.remove(gesture)) { 7454 QGestureManager *manager = QGestureManager::instance(); 7455 manager->cleanupCachedGestures(this, gesture); 7456 } 7457 } 7673 if (QGraphicsItem::d_ptr->gestureContext.remove(gesture) && QGraphicsItem::d_ptr->scene) 7674 QGraphicsItem::d_ptr->scene->d_func()->ungrabGesture(this, gesture); 7675 } 7676 #endif // QT_NO_GESTURES 7677 7678 /*! 7679 Updates the item's micro focus. This is slot for convenience. 7680 7681 \since 4.7 7682 7683 \sa QInputContext 7684 */ 7685 void QGraphicsObject::updateMicroFocus() 7686 { 7687 QGraphicsItem::updateMicroFocus(); 7688 } 7689 7690 void QGraphicsItemPrivate::children_append(QDeclarativeListProperty<QGraphicsObject> *list, QGraphicsObject *item) 7691 { 7692 QGraphicsObject *graphicsObject = static_cast<QGraphicsObject *>(list->object); 7693 if (QGraphicsItemPrivate::get(graphicsObject)->sendParentChangeNotification) { 7694 item->setParentItem(graphicsObject); 7695 } else { 7696 QGraphicsItemPrivate::get(item)->setParentItemHelper(graphicsObject, 0, 0); 7697 } 7698 } 7699 7700 int QGraphicsItemPrivate::children_count(QDeclarativeListProperty<QGraphicsObject> *list) 7701 { 7702 QGraphicsItemPrivate *d = QGraphicsItemPrivate::get(static_cast<QGraphicsObject *>(list->object)); 7703 return d->children.count(); 7704 } 7705 7706 QGraphicsObject *QGraphicsItemPrivate::children_at(QDeclarativeListProperty<QGraphicsObject> *list, int index) 7707 { 7708 QGraphicsItemPrivate *d = QGraphicsItemPrivate::get(static_cast<QGraphicsObject *>(list->object)); 7709 if (index >= 0 && index < d->children.count()) 7710 return d->children.at(index)->toGraphicsObject(); 7711 else 7712 return 0; 7713 } 7714 7715 void QGraphicsItemPrivate::children_clear(QDeclarativeListProperty<QGraphicsObject> *list) 7716 { 7717 QGraphicsItemPrivate *d = QGraphicsItemPrivate::get(static_cast<QGraphicsObject *>(list->object)); 7718 int childCount = d->children.count(); 7719 if (d->sendParentChangeNotification) { 7720 for (int index = 0; index < childCount; index++) 7721 d->children.at(0)->setParentItem(0); 7722 } else { 7723 for (int index = 0; index < childCount; index++) 7724 QGraphicsItemPrivate::get(d->children.at(0))->setParentItemHelper(0, 0, 0); 7725 } 7726 } 7727 7728 /*! 7729 Returns a list of this item's children. 7730 7731 The items are sorted by stacking order. This takes into account both the 7732 items' insertion order and their Z-values. 7733 7734 */ 7735 QDeclarativeListProperty<QGraphicsObject> QGraphicsItemPrivate::childrenList() 7736 { 7737 Q_Q(QGraphicsItem); 7738 if (isObject) { 7739 QGraphicsObject *that = static_cast<QGraphicsObject *>(q); 7740 return QDeclarativeListProperty<QGraphicsObject>(that, &children, children_append, 7741 children_count, children_at, children_clear); 7742 } else { 7743 //QGraphicsItem is not supported for this property 7744 return QDeclarativeListProperty<QGraphicsObject>(); 7745 } 7746 } 7747 7748 /*! 7749 \internal 7750 Returns the width of the item 7751 Reimplemented by QGraphicsWidget 7752 */ 7753 qreal QGraphicsItemPrivate::width() const 7754 { 7755 return 0; 7756 } 7757 7758 /*! 7759 \internal 7760 Set the width of the item 7761 Reimplemented by QGraphicsWidget 7762 */ 7763 void QGraphicsItemPrivate::setWidth(qreal w) 7764 { 7765 Q_UNUSED(w); 7766 } 7767 7768 /*! 7769 \internal 7770 Reset the width of the item 7771 Reimplemented by QGraphicsWidget 7772 */ 7773 void QGraphicsItemPrivate::resetWidth() 7774 { 7775 } 7776 7777 /*! 7778 \internal 7779 Returns the height of the item 7780 Reimplemented by QGraphicsWidget 7781 */ 7782 qreal QGraphicsItemPrivate::height() const 7783 { 7784 return 0; 7785 } 7786 7787 /*! 7788 \internal 7789 Set the height of the item 7790 Reimplemented by QGraphicsWidget 7791 */ 7792 void QGraphicsItemPrivate::setHeight(qreal h) 7793 { 7794 Q_UNUSED(h); 7795 } 7796 7797 /*! 7798 \internal 7799 Reset the height of the item 7800 Reimplemented by QGraphicsWidget 7801 */ 7802 void QGraphicsItemPrivate::resetHeight() 7803 { 7804 } 7805 7806 /*! 7807 \property QGraphicsObject::children 7808 \since 4.7 7809 \internal 7810 */ 7811 7812 /*! 7813 \property QGraphicsObject::width 7814 \since 4.7 7815 \internal 7816 */ 7817 7818 /*! 7819 \property QGraphicsObject::height 7820 \since 4.7 7821 \internal 7822 */ 7458 7823 7459 7824 /*! … … 7643 8008 */ 7644 8009 8010 /*! 8011 \fn void QGraphicsObject::widthChanged() 8012 \internal 8013 */ 8014 8015 /*! 8016 \fn void QGraphicsObject::heightChanged() 8017 \internal 8018 */ 8019 8020 /*! 8021 8022 \fn QGraphicsObject::childrenChanged() 8023 8024 This signal gets emitted whenever the children list changes 8025 \internal 8026 */ 8027 8028 /*! 8029 \property QGraphicsObject::effect 8030 \since 4.7 8031 \brief the effect attached to this item 8032 8033 \sa QGraphicsItem::setGraphicsEffect(), QGraphicsItem::graphicsEffect() 8034 */ 7645 8035 7646 8036 /*! … … 7660 8050 \sa QGraphicsRectItem, QGraphicsEllipseItem, QGraphicsPathItem, 7661 8051 QGraphicsPolygonItem, QGraphicsTextItem, QGraphicsLineItem, 7662 QGraphicsPixmapItem, { TheGraphics View Framework}8052 QGraphicsPixmapItem, {Graphics View Framework} 7663 8053 */ 7664 8054 … … 7799 8189 7800 8190 \sa QGraphicsRectItem, QGraphicsEllipseItem, QGraphicsPolygonItem, 7801 QGraphicsTextItem, QGraphicsLineItem, QGraphicsPixmapItem, { TheGraphics8191 QGraphicsTextItem, QGraphicsLineItem, QGraphicsPixmapItem, {Graphics 7802 8192 View Framework} 7803 8193 */ … … 8008 8398 8009 8399 \sa QGraphicsPathItem, QGraphicsEllipseItem, QGraphicsPolygonItem, 8010 QGraphicsTextItem, QGraphicsLineItem, QGraphicsPixmapItem, { TheGraphics8400 QGraphicsTextItem, QGraphicsLineItem, QGraphicsPixmapItem, {Graphics 8011 8401 View Framework} 8012 8402 */ … … 8252 8642 8253 8643 \sa QGraphicsPathItem, QGraphicsRectItem, QGraphicsPolygonItem, 8254 QGraphicsTextItem, QGraphicsLineItem, QGraphicsPixmapItem, { TheGraphics8644 QGraphicsTextItem, QGraphicsLineItem, QGraphicsPixmapItem, {Graphics 8255 8645 View Framework} 8256 8646 */ … … 8561 8951 8562 8952 \sa QGraphicsPathItem, QGraphicsRectItem, QGraphicsEllipseItem, 8563 QGraphicsTextItem, QGraphicsLineItem, QGraphicsPixmapItem, { TheGraphics8953 QGraphicsTextItem, QGraphicsLineItem, QGraphicsPixmapItem, {Graphics 8564 8954 View Framework} 8565 8955 */ … … 8793 9183 8794 9184 \sa QGraphicsPathItem, QGraphicsRectItem, QGraphicsEllipseItem, 8795 QGraphicsTextItem, QGraphicsPolygonItem, QGraphicsPixmapItem, {The8796 Graphics View Framework}9185 QGraphicsTextItem, QGraphicsPolygonItem, QGraphicsPixmapItem, 9186 {Graphics View Framework} 8797 9187 */ 8798 9188 … … 9063 9453 9064 9454 \sa QGraphicsPathItem, QGraphicsRectItem, QGraphicsEllipseItem, 9065 QGraphicsTextItem, QGraphicsPolygonItem, QGraphicsLineItem, {The9066 Graphics View Framework}9455 QGraphicsTextItem, QGraphicsPolygonItem, QGraphicsLineItem, 9456 {Graphics View Framework} 9067 9457 */ 9068 9458 … … 9434 9824 \sa QGraphicsSimpleTextItem, QGraphicsPathItem, QGraphicsRectItem, 9435 9825 QGraphicsEllipseItem, QGraphicsPixmapItem, QGraphicsPolygonItem, 9436 QGraphicsLineItem, { TheGraphics View Framework}9826 QGraphicsLineItem, {Graphics View Framework} 9437 9827 */ 9438 9828 … … 9805 10195 } 9806 10196 break; 10197 case QEvent::ShortcutOverride: 10198 dd->sendControlEvent(event); 10199 return true; 9807 10200 default: 9808 10201 break; … … 10347 10740 \img graphicsview-simpletextitem.png 10348 10741 10349 \sa QGraphicsTextItem, QGraphicsPathItem, QGraphicsRectItem, QGraphicsEllipseItem,10350 QGraphics PixmapItem, QGraphicsPolygonItem, QGraphicsLineItem, {The10351 Graphics View Framework}10742 \sa QGraphicsTextItem, QGraphicsPathItem, QGraphicsRectItem, 10743 QGraphicsEllipseItem, QGraphicsPixmapItem, QGraphicsPolygonItem, 10744 QGraphicsLineItem, {Graphics View Framework} 10352 10745 */ 10353 10746 … … 10557 10950 /*! 10558 10951 \class QGraphicsItemGroup 10559 \brief The QGraphicsItemGroup class provides treating a group of items as10560 one.10952 \brief The QGraphicsItemGroup class provides a container that treats 10953 a group of items as a single item. 10561 10954 \since 4.2 10562 10955 \ingroup graphicsview-api … … 10610 11003 position and transformation remain intact. 10611 11004 10612 \sa QGraphicsItem, { TheGraphics View Framework}11005 \sa QGraphicsItem, {Graphics View Framework} 10613 11006 */ 10614 11007 … … 10931 11324 } else if (deviceCoordinates) { 10932 11325 // Device coordinates with info. 10933 scened->draw(item, &pixmapPainter, info->viewTransform, info->transformPtr, info->exposedRegion,11326 scened->draw(item, &pixmapPainter, info->viewTransform, info->transformPtr, 0, 10934 11327 info->widget, info->opacity, &effectTransform, info->wasDirtySceneTransform, 10935 11328 info->drawItem); … … 10938 11331 QTransform newEffectTransform = info->transformPtr->inverted(); 10939 11332 newEffectTransform *= effectTransform; 10940 scened->draw(item, &pixmapPainter, info->viewTransform, info->transformPtr, info->exposedRegion,11333 scened->draw(item, &pixmapPainter, info->viewTransform, info->transformPtr, 0, 10941 11334 info->widget, info->opacity, &newEffectTransform, info->wasDirtySceneTransform, 10942 11335 info->drawItem); … … 11074 11467 str = "ItemScenePositionHasChanged"; 11075 11468 break; 11469 case QGraphicsItem::ItemRotationChange: 11470 str = "ItemRotationChange"; 11471 break; 11472 case QGraphicsItem::ItemRotationHasChanged: 11473 str = "ItemRotationHasChanged"; 11474 break; 11475 case QGraphicsItem::ItemScaleChange: 11476 str = "ItemScaleChange"; 11477 break; 11478 case QGraphicsItem::ItemScaleHasChanged: 11479 str = "ItemScaleHasChanged"; 11480 break; 11481 case QGraphicsItem::ItemTransformOriginPointChange: 11482 str = "ItemTransformOriginPointChange"; 11483 break; 11484 case QGraphicsItem::ItemTransformOriginPointHasChanged: 11485 str = "ItemTransformOriginPointHasChanged"; 11486 break; 11076 11487 } 11077 11488 debug << str; … … 11134 11545 str = "ItemSendsScenePositionChanges"; 11135 11546 break; 11547 case QGraphicsItem::ItemStopsClickFocusPropagation: 11548 str = "ItemStopsClickFocusPropagation"; 11549 break; 11136 11550 } 11137 11551 debug << str; … … 11143 11557 debug << '('; 11144 11558 bool f = false; 11145 for (int i = 0; i < 1 6; ++i) {11559 for (int i = 0; i < 17; ++i) { 11146 11560 if (flags & (1 << i)) { 11147 11561 if (f)
Note:
See TracChangeset
for help on using the changeset viewer.