src/gui/graphicsview/qgraphicsitem.cpp
changeset 19 fcece45ef507
parent 18 2f34d5167611
child 22 79de32ba3296
equal deleted inserted replaced
18:2f34d5167611 19:fcece45ef507
   412 */
   412 */
   413 
   413 
   414 /*!
   414 /*!
   415     \enum QGraphicsItem::GraphicsItemChange
   415     \enum QGraphicsItem::GraphicsItemChange
   416 
   416 
   417         ItemVisibleHasChanged,
       
   418         ItemEnabledHasChanged,
       
   419         ItemSelectedHasChanged,
       
   420         ItemParentHasChanged,
       
   421         ItemSceneHasChanged
       
   422 
       
   423     This enum describes the state changes that are notified by
   417     This enum describes the state changes that are notified by
   424     QGraphicsItem::itemChange(). The notifications are sent as the state
   418     QGraphicsItem::itemChange(). The notifications are sent as the state
   425     changes, and in some cases, adjustments can be made (see the documentation
   419     changes, and in some cases, adjustments can be made (see the documentation
   426     for each change for details).
   420     for each change for details).
   427 
   421 
   645     This enum specifies the behavior of a modal panel. A modal panel
   639     This enum specifies the behavior of a modal panel. A modal panel
   646     is one that blocks input to other panels. Note that items that
   640     is one that blocks input to other panels. Note that items that
   647     are children of a modal panel are not blocked.
   641     are children of a modal panel are not blocked.
   648 
   642 
   649     The values are:
   643     The values are:
   650     \value NonModal   The panel is not modal and does not block input to other panels.
   644 
   651     \value PanelModal The panel is modal to a single item hierarchy and blocks input to its parent pane, all grandparent panels, and all siblings of its parent and grandparent panels.
   645     \value NonModal The panel is not modal and does not block input to
   652     \value SceneModal The window is modal to the entire scene and blocks input to all panels.
   646     other panels. This is the default value for panels.
       
   647 
       
   648     \value PanelModal The panel is modal to a single item hierarchy
       
   649     and blocks input to its parent pane, all grandparent panels, and
       
   650     all siblings of its parent and grandparent panels.
       
   651 
       
   652     \value SceneModal The window is modal to the entire scene and
       
   653     blocks input to all panels.
   653 
   654 
   654     \sa QGraphicsItem::setPanelModality(), QGraphicsItem::panelModality(), QGraphicsItem::ItemIsPanel
   655     \sa QGraphicsItem::setPanelModality(), QGraphicsItem::panelModality(), QGraphicsItem::ItemIsPanel
   655 */
   656 */
   656 
   657 
   657 #include "qgraphicsitem.h"
   658 #include "qgraphicsitem.h"
  1127             }
  1128             }
  1128             p = p->d_ptr->parent;
  1129             p = p->d_ptr->parent;
  1129         }
  1130         }
  1130     }
  1131     }
  1131 
  1132 
       
  1133     // Resolve depth.
       
  1134     invalidateDepthRecursively();
       
  1135 
  1132     if ((parent = newParent)) {
  1136     if ((parent = newParent)) {
  1133         if (parent->d_func()->scene && parent->d_func()->scene != scene) {
  1137         if (parent->d_func()->scene && parent->d_func()->scene != scene) {
  1134             // Move this item to its new parent's scene
  1138             // Move this item to its new parent's scene
  1135             parent->d_func()->scene->addItem(q);
  1139             parent->d_func()->scene->addItem(q);
  1136         } else if (!parent->d_func()->scene && scene) {
  1140         } else if (!parent->d_func()->scene && scene) {
  1177             if (!enabled && !explicitlyDisabled)
  1181             if (!enabled && !explicitlyDisabled)
  1178                 setEnabledHelper(true, /* explicit = */ false);
  1182                 setEnabledHelper(true, /* explicit = */ false);
  1179         }
  1183         }
  1180     }
  1184     }
  1181 
  1185 
  1182     // Resolve depth.
       
  1183     invalidateDepthRecursively();
       
  1184     dirtySceneTransform = 1;
  1186     dirtySceneTransform = 1;
  1185 
  1187 
  1186     // Restore the sub focus chain.
  1188     // Restore the sub focus chain.
  1187     if (subFocusItem) {
  1189     if (subFocusItem) {
  1188         subFocusItem->d_ptr->setSubFocus(newParent);
  1190         subFocusItem->d_ptr->setSubFocus(newParent);
  1879 {
  1881 {
  1880     CacheMode lastMode = CacheMode(d_ptr->cacheMode);
  1882     CacheMode lastMode = CacheMode(d_ptr->cacheMode);
  1881     d_ptr->cacheMode = mode;
  1883     d_ptr->cacheMode = mode;
  1882     bool noVisualChange = (mode == NoCache && lastMode == NoCache)
  1884     bool noVisualChange = (mode == NoCache && lastMode == NoCache)
  1883                           || (mode == NoCache && lastMode == DeviceCoordinateCache)
  1885                           || (mode == NoCache && lastMode == DeviceCoordinateCache)
  1884                           || (mode == DeviceCoordinateCache && lastMode == NoCache);
  1886                           || (mode == DeviceCoordinateCache && lastMode == NoCache)
       
  1887                           || (mode == DeviceCoordinateCache && lastMode == DeviceCoordinateCache);
  1885     if (mode == NoCache) {
  1888     if (mode == NoCache) {
  1886         d_ptr->removeExtraItemCache();
  1889         d_ptr->removeExtraItemCache();
  1887     } else {
  1890     } else {
  1888         QGraphicsItemCache *cache = d_ptr->extraItemCache();
  1891         QGraphicsItemCache *cache = d_ptr->extraItemCache();
  1889 
  1892 
  2173     // Schedule redrawing
  2176     // Schedule redrawing
  2174     if (update) {
  2177     if (update) {
  2175         QGraphicsItemCache *c = (QGraphicsItemCache *)qVariantValue<void *>(extra(ExtraCacheData));
  2178         QGraphicsItemCache *c = (QGraphicsItemCache *)qVariantValue<void *>(extra(ExtraCacheData));
  2176         if (c)
  2179         if (c)
  2177             c->purge();
  2180             c->purge();
  2178         if (scene)
  2181         if (scene) {
       
  2182 #ifndef QT_NO_GRAPHICSEFFECT
       
  2183             invalidateParentGraphicsEffectsRecursively();
       
  2184 #endif //QT_NO_GRAPHICSEFFECT
  2179             scene->d_func()->markDirty(q_ptr, QRectF(), /*invalidateChildren=*/false, /*force=*/true);
  2185             scene->d_func()->markDirty(q_ptr, QRectF(), /*invalidateChildren=*/false, /*force=*/true);
       
  2186         }
  2180     }
  2187     }
  2181 
  2188 
  2182     // Certain properties are dropped as an item becomes invisible.
  2189     // Certain properties are dropped as an item becomes invisible.
       
  2190     bool hasFocus = q_ptr->hasFocus();
  2183     if (!newVisible) {
  2191     if (!newVisible) {
  2184         if (scene) {
  2192         if (scene) {
  2185             if (scene->d_func()->mouseGrabberItems.contains(q))
  2193             if (scene->d_func()->mouseGrabberItems.contains(q))
  2186                 q->ungrabMouse();
  2194                 q->ungrabMouse();
  2187             if (scene->d_func()->keyboardGrabberItems.contains(q))
  2195             if (scene->d_func()->keyboardGrabberItems.contains(q))
  2188                 q->ungrabKeyboard();
  2196                 q->ungrabKeyboard();
  2189             if (q->isPanel() && panelModality != QGraphicsItem::NonModal)
  2197             if (q->isPanel() && panelModality != QGraphicsItem::NonModal)
  2190                 scene->d_func()->leaveModal(q_ptr);
  2198                 scene->d_func()->leaveModal(q_ptr);
  2191         }
  2199         }
  2192         if (q_ptr->hasFocus() && scene) {
  2200         if (hasFocus && scene) {
  2193             // Hiding the closest non-panel ancestor of the focus item
  2201             // Hiding the closest non-panel ancestor of the focus item
  2194             QGraphicsItem *focusItem = scene->focusItem();
  2202             QGraphicsItem *focusItem = scene->focusItem();
  2195             bool clear = true;
  2203             bool clear = true;
  2196             if (isWidget && !focusItem->isPanel()) {
  2204             if (isWidget && !focusItem->isPanel()) {
  2197                 do {
  2205                 do {
  2200                         break;
  2208                         break;
  2201                     }
  2209                     }
  2202                 } while ((focusItem = focusItem->parentWidget()) && !focusItem->isPanel());
  2210                 } while ((focusItem = focusItem->parentWidget()) && !focusItem->isPanel());
  2203             }
  2211             }
  2204             if (clear)
  2212             if (clear)
  2205                 q_ptr->clearFocus();
  2213                 clearFocusHelper(/* giveFocusToParent = */ false);
  2206         }
  2214         }
  2207         if (q_ptr->isSelected())
  2215         if (q_ptr->isSelected())
  2208             q_ptr->setSelected(false);
  2216             q_ptr->setSelected(false);
  2209     } else {
  2217     } else {
  2210         geometryChanged = 1;
  2218         geometryChanged = 1;
  2238                 scene->setActivePanel(parent);
  2246                 scene->setActivePanel(parent);
  2239         }
  2247         }
  2240     }
  2248     }
  2241 
  2249 
  2242     // Enable subfocus
  2250     // Enable subfocus
  2243     if (scene && newVisible) {
  2251     if (scene) {
  2244         QGraphicsItem *p = parent;
  2252         if (newVisible) {
  2245         bool done = false;
  2253             // Item is shown
  2246         while (p) {
  2254             QGraphicsItem *p = parent;
  2247             if (p->flags() & QGraphicsItem::ItemIsFocusScope) {
  2255             bool done = false;
  2248                 QGraphicsItem *fsi = p->d_ptr->focusScopeItem;
  2256             while (p) {
  2249                 if (q_ptr == fsi || q_ptr->isAncestorOf(fsi)) {
  2257                 if (p->flags() & QGraphicsItem::ItemIsFocusScope) {
  2250                     done = true;
  2258                     QGraphicsItem *fsi = p->d_ptr->focusScopeItem;
  2251                     while (fsi->d_ptr->focusScopeItem && fsi->d_ptr->focusScopeItem->isVisible())
  2259                     if (q_ptr == fsi || q_ptr->isAncestorOf(fsi)) {
  2252                         fsi = fsi->d_ptr->focusScopeItem;
  2260                         done = true;
  2253                     scene->setFocusItem(fsi);
  2261                         while (fsi->d_ptr->focusScopeItem && fsi->d_ptr->focusScopeItem->isVisible())
       
  2262                             fsi = fsi->d_ptr->focusScopeItem;
       
  2263                         fsi->d_ptr->setFocusHelper(Qt::OtherFocusReason, /* climb = */ true,
       
  2264                                                    /* focusFromShow = */ true);
       
  2265                     }
       
  2266                     break;
  2254                 }
  2267                 }
  2255                 break;
  2268                 p = p->d_ptr->parent;
  2256             }
  2269             }
  2257             p = p->d_ptr->parent;
  2270             if (!done) {
  2258         }
  2271                 QGraphicsItem *fi = subFocusItem;
  2259         if (!done) {
  2272                 if (fi && fi != scene->focusItem()) {
  2260             QGraphicsItem *fi = subFocusItem;
  2273                     scene->setFocusItem(fi);
  2261             if (fi && fi != scene->focusItem()) {
  2274                 }
  2262                 scene->setFocusItem(fi);
  2275             }
       
  2276         } else {
       
  2277             // Item is hidden
       
  2278             if (hasFocus) {
       
  2279                 QGraphicsItem *p = parent;
       
  2280                 while (p) {
       
  2281                     if (p->flags() & QGraphicsItem::ItemIsFocusScope) {
       
  2282                         if (p->d_ptr->visible) {
       
  2283                             p->d_ptr->setFocusHelper(Qt::OtherFocusReason, /* climb = */ true,
       
  2284                                                      /* focusFromShow = */ true);
       
  2285                         }
       
  2286                         break;
       
  2287                     }
       
  2288                     p = p->d_ptr->parent;
       
  2289                 }
  2263             }
  2290             }
  2264         }
  2291         }
  2265     }
  2292     }
  2266 
  2293 
  2267     // Deliver post-change notification.
  2294     // Deliver post-change notification.
  3108 
  3135 
  3109     \sa clearFocus(), hasFocus(), focusItem(), focusProxy()
  3136     \sa clearFocus(), hasFocus(), focusItem(), focusProxy()
  3110 */
  3137 */
  3111 void QGraphicsItem::setFocus(Qt::FocusReason focusReason)
  3138 void QGraphicsItem::setFocus(Qt::FocusReason focusReason)
  3112 {
  3139 {
  3113     d_ptr->setFocusHelper(focusReason, /* climb = */ true);
  3140     d_ptr->setFocusHelper(focusReason, /* climb = */ true, /* focusFromShow = */ false);
  3114 }
  3141 }
  3115 
  3142 
  3116 /*!
  3143 /*!
  3117     \internal
  3144     \internal
  3118 */
  3145 */
  3119 void QGraphicsItemPrivate::setFocusHelper(Qt::FocusReason focusReason, bool climb)
  3146 void QGraphicsItemPrivate::setFocusHelper(Qt::FocusReason focusReason, bool climb, bool focusFromShow)
  3120 {
  3147 {
  3121     // Disabled / unfocusable items cannot accept focus.
  3148     // Disabled / unfocusable items cannot accept focus.
  3122     if (!q_ptr->isEnabled() || !(flags & QGraphicsItem::ItemIsFocusable))
  3149     if (!q_ptr->isEnabled() || !(flags & QGraphicsItem::ItemIsFocusable))
  3123         return;
  3150         return;
  3124 
  3151 
  3134     // Update focus scope item ptr.
  3161     // Update focus scope item ptr.
  3135     QGraphicsItem *p = parent;
  3162     QGraphicsItem *p = parent;
  3136     while (p) {
  3163     while (p) {
  3137         if (p->flags() & QGraphicsItem::ItemIsFocusScope) {
  3164         if (p->flags() & QGraphicsItem::ItemIsFocusScope) {
  3138             p->d_ptr->focusScopeItem = q_ptr;
  3165             p->d_ptr->focusScopeItem = q_ptr;
  3139             if (!p->focusItem()) {
  3166             if (!p->focusItem() && !focusFromShow) {
  3140                 // If you call setFocus on a child of a focus scope that
  3167                 // If you call setFocus on a child of a focus scope that
  3141                 // doesn't currently have a focus item, then stop.
  3168                 // doesn't currently have a focus item, then stop.
  3142                 return;
  3169                 return;
  3143             }
  3170             }
  3144             break;
  3171             break;
  3175 
  3202 
  3176     \sa setFocus(), hasFocus(), QGraphicsWidget::focusPolicy
  3203     \sa setFocus(), hasFocus(), QGraphicsWidget::focusPolicy
  3177 */
  3204 */
  3178 void QGraphicsItem::clearFocus()
  3205 void QGraphicsItem::clearFocus()
  3179 {
  3206 {
  3180     // Pass focus to the closest parent focus scope.
  3207     d_ptr->clearFocusHelper(/* giveFocusToParent = */ true);
  3181     if (!d_ptr->inDestructor) {
  3208 }
  3182         QGraphicsItem *p = d_ptr->parent;
  3209 
  3183         while (p) {
  3210 /*!
  3184             if (p->flags() & ItemIsFocusScope) {
  3211     \internal
  3185                 p->d_ptr->setFocusHelper(Qt::OtherFocusReason, /* climb = */ false);
  3212 */
  3186                 return;
  3213 void QGraphicsItemPrivate::clearFocusHelper(bool giveFocusToParent)
       
  3214 {
       
  3215     if (giveFocusToParent) {
       
  3216         // Pass focus to the closest parent focus scope
       
  3217         if (!inDestructor) {
       
  3218             QGraphicsItem *p = parent;
       
  3219             while (p) {
       
  3220                 if (p->flags() & QGraphicsItem::ItemIsFocusScope) {
       
  3221                     p->d_ptr->setFocusHelper(Qt::OtherFocusReason, /* climb = */ false,
       
  3222                                              /* focusFromShow = */ false);
       
  3223                     return;
       
  3224                 }
       
  3225                 p = p->d_ptr->parent;
  3187             }
  3226             }
  3188             p = p->d_ptr->parent;
       
  3189         }
  3227         }
  3190     }
  3228     }
  3191 
  3229 
  3192     // Invisible items with focus must explicitly clear subfocus.
  3230     // Invisible items with focus must explicitly clear subfocus.
  3193     d_ptr->clearSubFocus(this);
  3231     clearSubFocus(q_ptr);
  3194 
  3232 
  3195     if (hasFocus()) {
  3233     if (q_ptr->hasFocus()) {
  3196         // If this item has the scene's input focus, clear it.
  3234         // If this item has the scene's input focus, clear it.
  3197         d_ptr->scene->setFocusItem(0);
  3235         scene->setFocusItem(0);
  3198     }
  3236     }
  3199 }
  3237 }
  3200 
  3238 
  3201 /*!
  3239 /*!
  3202     \since 4.6
  3240     \since 4.6
  5185     // number is equal to the size of the children list.
  5223     // number is equal to the size of the children list.
  5186     ensureSequentialSiblingIndex();
  5224     ensureSequentialSiblingIndex();
  5187     needSortChildren = 1; // ### maybe 0
  5225     needSortChildren = 1; // ### maybe 0
  5188     child->d_ptr->siblingIndex = children.size();
  5226     child->d_ptr->siblingIndex = children.size();
  5189     children.append(child);
  5227     children.append(child);
       
  5228     if (isObject)
       
  5229         emit static_cast<QGraphicsObject *>(q_ptr)->childrenChanged();
  5190 }
  5230 }
  5191 
  5231 
  5192 /*!
  5232 /*!
  5193     \internal
  5233     \internal
  5194 
  5234 
  5207         children.removeOne(child);
  5247         children.removeOne(child);
  5208     // NB! Do not use children.removeAt(child->d_ptr->siblingIndex) because
  5248     // NB! Do not use children.removeAt(child->d_ptr->siblingIndex) because
  5209     // the child is not guaranteed to be at the index after the list is sorted.
  5249     // the child is not guaranteed to be at the index after the list is sorted.
  5210     // (see ensureSortedChildren()).
  5250     // (see ensureSortedChildren()).
  5211     child->d_ptr->siblingIndex = -1;
  5251     child->d_ptr->siblingIndex = -1;
       
  5252     if (isObject)
       
  5253         emit static_cast<QGraphicsObject *>(q_ptr)->childrenChanged();
  5212 }
  5254 }
  5213 
  5255 
  5214 /*!
  5256 /*!
  5215     \internal
  5257     \internal
  5216 */
  5258 */
  7414         QGestureManager *manager = QGestureManager::instance();
  7456         QGestureManager *manager = QGestureManager::instance();
  7415         manager->cleanupCachedGestures(this, gesture);
  7457         manager->cleanupCachedGestures(this, gesture);
  7416     }
  7458     }
  7417 }
  7459 }
  7418 
  7460 
       
  7461 void QGraphicsItemPrivate::append(QDeclarativeListProperty<QGraphicsObject> *list, QGraphicsObject *item)
       
  7462 {
       
  7463     QGraphicsItemPrivate::get(item)->setParentItemHelper(static_cast<QGraphicsObject *>(list->object), /*newParentVariant=*/0, /*thisPointerVariant=*/0);
       
  7464 }
       
  7465 
       
  7466 /*!
       
  7467     Returns a list of this item's children.
       
  7468 
       
  7469     The items are sorted by stacking order. This takes into account both the
       
  7470     items' insertion order and their Z-values.
       
  7471 
       
  7472 */
       
  7473 QDeclarativeListProperty<QGraphicsObject> QGraphicsItemPrivate::childrenList()
       
  7474 {
       
  7475     Q_Q(QGraphicsItem);
       
  7476     if (isObject) {
       
  7477         QGraphicsObject *that = static_cast<QGraphicsObject *>(q);
       
  7478         return QDeclarativeListProperty<QGraphicsObject>(that, &children, QGraphicsItemPrivate::append);
       
  7479     } else {
       
  7480         //QGraphicsItem is not supported for this property
       
  7481         return QDeclarativeListProperty<QGraphicsObject>();
       
  7482     }
       
  7483 }
       
  7484 
       
  7485 /*!
       
  7486   \internal
       
  7487   Returns the width of the item
       
  7488   Reimplemented by QGraphicsWidget
       
  7489 */
       
  7490 qreal QGraphicsItemPrivate::width() const
       
  7491 {
       
  7492     return 0;
       
  7493 }
       
  7494 
       
  7495 /*!
       
  7496   \internal
       
  7497   Set the width of the item
       
  7498   Reimplemented by QGraphicsWidget
       
  7499 */
       
  7500 void QGraphicsItemPrivate::setWidth(qreal w)
       
  7501 {
       
  7502     Q_UNUSED(w);
       
  7503 }
       
  7504 
       
  7505 /*!
       
  7506   \internal
       
  7507   Reset the width of the item
       
  7508   Reimplemented by QGraphicsWidget
       
  7509 */
       
  7510 void QGraphicsItemPrivate::resetWidth()
       
  7511 {
       
  7512 }
       
  7513 
       
  7514 /*!
       
  7515   \internal
       
  7516   Returns the height of the item
       
  7517   Reimplemented by QGraphicsWidget
       
  7518 */
       
  7519 qreal QGraphicsItemPrivate::height() const
       
  7520 {
       
  7521     return 0;
       
  7522 }
       
  7523 
       
  7524 /*!
       
  7525   \internal
       
  7526   Set the height of the item
       
  7527   Reimplemented by QGraphicsWidget
       
  7528 */
       
  7529 void QGraphicsItemPrivate::setHeight(qreal h)
       
  7530 {
       
  7531     Q_UNUSED(h);
       
  7532 }
       
  7533 
       
  7534 /*!
       
  7535   \internal
       
  7536   Reset the height of the item
       
  7537   Reimplemented by QGraphicsWidget
       
  7538 */
       
  7539 void QGraphicsItemPrivate::resetHeight()
       
  7540 {
       
  7541 }
       
  7542 
  7419 /*!
  7543 /*!
  7420   \property QGraphicsObject::parent
  7544   \property QGraphicsObject::parent
  7421   \brief the parent of the item
  7545   \brief the parent of the item
  7422 
  7546 
  7423   \note The item's parent is set independently of the parent object returned
  7547   \note The item's parent is set independently of the parent object returned
  7600   origin for scale and rotation.
  7724   origin for scale and rotation.
  7601 
  7725 
  7602   \sa scale, rotation, QGraphicsItem::transformOriginPoint()
  7726   \sa scale, rotation, QGraphicsItem::transformOriginPoint()
  7603 */
  7727 */
  7604 
  7728 
       
  7729 /*!
       
  7730     \fn void QGraphicsObject::widthChanged()
       
  7731     \internal
       
  7732 */
       
  7733 
       
  7734 /*!
       
  7735     \fn void QGraphicsObject::heightChanged()
       
  7736     \internal
       
  7737 */
       
  7738 
       
  7739 /*!
       
  7740 
       
  7741   \fn QGraphicsObject::childrenChanged()
       
  7742 
       
  7743   This signal gets emitted whenever the children list changes
       
  7744   \internal
       
  7745 */
  7605 
  7746 
  7606 /*!
  7747 /*!
  7607     \class QAbstractGraphicsShapeItem
  7748     \class QAbstractGraphicsShapeItem
  7608     \brief The QAbstractGraphicsShapeItem class provides a common base for
  7749     \brief The QAbstractGraphicsShapeItem class provides a common base for
  7609     all path items.
  7750     all path items.
 10807                      info->widget, info->opacity, &effectTransform, info->wasDirtySceneTransform,
 10948                      info->widget, info->opacity, &effectTransform, info->wasDirtySceneTransform,
 10808                      info->drawItem);
 10949                      info->drawItem);
 10809     }
 10950     }
 10810 }
 10951 }
 10811 
 10952 
       
 10953 // sourceRect must be in the given coordinate system
 10812 QRect QGraphicsItemEffectSourcePrivate::paddedEffectRect(Qt::CoordinateSystem system, QGraphicsEffect::PixmapPadMode mode, const QRectF &sourceRect, bool *unpadded) const
 10954 QRect QGraphicsItemEffectSourcePrivate::paddedEffectRect(Qt::CoordinateSystem system, QGraphicsEffect::PixmapPadMode mode, const QRectF &sourceRect, bool *unpadded) const
 10813 {
 10955 {
 10814     QRectF effectRectF;
 10956     QRectF effectRectF;
 10815 
 10957 
 10816     if (unpadded)
 10958     if (unpadded)
 10817         *unpadded = false;
 10959         *unpadded = false;
 10818 
 10960 
 10819     if (mode == QGraphicsEffect::PadToEffectiveBoundingRect) {
 10961     if (mode == QGraphicsEffect::PadToEffectiveBoundingRect) {
 10820         if (info) {
 10962         if (info) {
 10821             effectRectF = item->graphicsEffect()->boundingRectFor(boundingRect(Qt::DeviceCoordinates));
 10963             QRectF deviceRect = system == Qt::DeviceCoordinates ? sourceRect : info->painter->worldTransform().mapRect(sourceRect);
       
 10964             effectRectF = item->graphicsEffect()->boundingRectFor(deviceRect);
 10822             if (unpadded)
 10965             if (unpadded)
 10823                 *unpadded = (effectRectF.size() == sourceRect.size());
 10966                 *unpadded = (effectRectF.size() == sourceRect.size());
 10824             if (info && system == Qt::LogicalCoordinates)
 10967             if (info && system == Qt::LogicalCoordinates)
 10825                 effectRectF = info->painter->worldTransform().inverted().mapRect(effectRectF);
 10968                 effectRectF = info->painter->worldTransform().inverted().mapRect(effectRectF);
 10826         } else {
 10969         } else {
 10865         if (offset)
 11008         if (offset)
 10866             *offset = boundingRect(system).topLeft().toPoint();
 11009             *offset = boundingRect(system).topLeft().toPoint();
 10867         return static_cast<QGraphicsPixmapItem *>(item)->pixmap();
 11010         return static_cast<QGraphicsPixmapItem *>(item)->pixmap();
 10868     }
 11011     }
 10869 
 11012 
 10870     if (deviceCoordinates) {
       
 10871         // Clip to viewport rect.
       
 10872         int left, top, right, bottom;
       
 10873         effectRect.getCoords(&left, &top, &right, &bottom);
       
 10874         if (left < 0) {
       
 10875             if (offset)
       
 10876                 offset->rx() += -left;
       
 10877             effectRect.setX(0);
       
 10878         }
       
 10879         if (top < 0) {
       
 10880             if (offset)
       
 10881                 offset->ry() += -top;
       
 10882             effectRect.setY(0);
       
 10883         }
       
 10884         // NB! We use +-1 for historical reasons (see QRect documentation).
       
 10885         QPaintDevice *device = info->painter->device();
       
 10886         const int deviceWidth = device->width();
       
 10887         const int deviceHeight = device->height();
       
 10888         if (right + 1 > deviceWidth)
       
 10889             effectRect.setRight(deviceWidth - 1);
       
 10890         if (bottom + 1 > deviceHeight)
       
 10891             effectRect.setBottom(deviceHeight -1);
       
 10892 
       
 10893     }
       
 10894     if (effectRect.isEmpty())
 11013     if (effectRect.isEmpty())
 10895         return QPixmap();
 11014         return QPixmap();
 10896 
 11015 
 10897     QPixmap pixmap(effectRect.size());
 11016     QPixmap pixmap(effectRect.size());
 10898     pixmap.fill(Qt::transparent);
 11017     pixmap.fill(Qt::transparent);