317 an input item). Enabling this flag will allow the item to accept focus, |
317 an input item). Enabling this flag will allow the item to accept focus, |
318 which again allows the delivery of key events to |
318 which again allows the delivery of key events to |
319 QGraphicsItem::keyPressEvent() and QGraphicsItem::keyReleaseEvent(). |
319 QGraphicsItem::keyPressEvent() and QGraphicsItem::keyReleaseEvent(). |
320 |
320 |
321 \value ItemClipsToShape The item clips to its own shape. The item cannot |
321 \value ItemClipsToShape The item clips to its own shape. The item cannot |
322 draw or receive mouse, tablet, drag and drop or hover events outside ts |
322 draw or receive mouse, tablet, drag and drop or hover events outside its |
323 shape. It is disabled by default. This behavior is enforced by |
323 shape. It is disabled by default. This behavior is enforced by |
324 QGraphicsView::drawItems() or QGraphicsScene::drawItems(). This flag was |
324 QGraphicsView::drawItems() or QGraphicsScene::drawItems(). This flag was |
325 introduced in Qt 4.3. |
325 introduced in Qt 4.3. |
326 |
326 |
327 \value ItemClipsChildrenToShape The item clips the painting of all its |
327 \value ItemClipsChildrenToShape The item clips the painting of all its |
355 |
355 |
356 \value ItemStacksBehindParent The item is stacked behind its parent. By |
356 \value ItemStacksBehindParent The item is stacked behind its parent. By |
357 default, child items are stacked on top of the parent item. But setting |
357 default, child items are stacked on top of the parent item. But setting |
358 this flag, the child will be stacked behind it. This flag is useful for |
358 this flag, the child will be stacked behind it. This flag is useful for |
359 drop shadow effects and for decoration objects that follow the parent |
359 drop shadow effects and for decoration objects that follow the parent |
360 item's geometry without drawing on top of it. |
360 item's geometry without drawing on top of it. This flag was introduced |
|
361 in Qt 4.5. |
361 |
362 |
362 \value ItemUsesExtendedStyleOption The item makes use of either |
363 \value ItemUsesExtendedStyleOption The item makes use of either |
363 \l{QStyleOptionGraphicsItem::}{exposedRect} or |
364 \l{QStyleOptionGraphicsItem::} {exposedRect} or |
364 \l{QStyleOptionGraphicsItem::}{matrix} in QStyleOptionGraphicsItem. By default, |
365 \l{QStyleOptionGraphicsItem::} {matrix} in |
365 the \l{QStyleOptionGraphicsItem::}{exposedRect} is initialized to the item's |
366 QStyleOptionGraphicsItem. By default, the |
366 boundingRect() and the \l{QStyleOptionGraphicsItem::}{matrix} is untransformed. |
367 \l{QStyleOptionGraphicsItem::} {exposedRect} is initialized to the |
367 You can enable this flag for the style options to be set up with more |
368 item's boundingRect() and the |
368 fine-grained values. |
369 \l{QStyleOptionGraphicsItem::}{matrix} is untransformed. You can |
369 Note that QStyleOptionGraphicsItem::levelOfDetail is unaffected by this flag |
370 enable this flag for the style options to be set up with more |
|
371 fine-grained values. Note that |
|
372 QStyleOptionGraphicsItem::levelOfDetail is unaffected by this flag |
370 and always initialized to 1. Use |
373 and always initialized to 1. Use |
371 QStyleOptionGraphicsItem::levelOfDetailFromTransform() if you need a higher |
374 QStyleOptionGraphicsItem::levelOfDetailFromTransform() if you need |
372 value. |
375 a higher value. This flag was introduced in Qt 4.6. |
373 |
376 |
374 \value ItemHasNoContents The item does not paint anything (i.e., calling |
377 \value ItemHasNoContents The item does not paint anything (i.e., calling |
375 paint() on the item has no effect). You should set this flag on items that |
378 paint() on the item has no effect). You should set this flag on items that |
376 do not need to be painted to ensure that Graphics View avoids unnecessary |
379 do not need to be painted to ensure that Graphics View avoids unnecessary |
377 painting preparations. This flag was introduced in Qt 4.6. |
380 painting preparations. This flag was introduced in Qt 4.6. |
385 |
388 |
386 \value ItemAcceptsInputMethod The item supports input methods typically |
389 \value ItemAcceptsInputMethod The item supports input methods typically |
387 used for Asian languages. |
390 used for Asian languages. |
388 This flag was introduced in Qt 4.6. |
391 This flag was introduced in Qt 4.6. |
389 |
392 |
390 \value ItemNegativeZStacksBehindParent The item automatically stacks behind |
393 \value ItemNegativeZStacksBehindParent The item automatically |
391 it's parent if it's z-value is negative. This flag enables setZValue() to |
394 stacks behind it's parent if it's z-value is negative. This flag |
392 toggle ItemStacksBehindParent. |
395 enables setZValue() to toggle ItemStacksBehindParent. This flag |
|
396 was introduced in Qt 4.6. |
393 |
397 |
394 \value ItemIsPanel The item is a panel. A panel provides activation and |
398 \value ItemIsPanel The item is a panel. A panel provides activation and |
395 contained focus handling. Only one panel can be active at a time (see |
399 contained focus handling. Only one panel can be active at a time (see |
396 QGraphicsItem::isActive()). When no panel is active, QGraphicsScene |
400 QGraphicsItem::isActive()). When no panel is active, QGraphicsScene |
397 activates all non-panel items. Window items (i.e., |
401 activates all non-panel items. Window items (i.e., |
407 introduced in Qt 4.6. |
411 introduced in Qt 4.6. |
408 */ |
412 */ |
409 |
413 |
410 /*! |
414 /*! |
411 \enum QGraphicsItem::GraphicsItemChange |
415 \enum QGraphicsItem::GraphicsItemChange |
412 |
|
413 ItemVisibleHasChanged, |
|
414 ItemEnabledHasChanged, |
|
415 ItemSelectedHasChanged, |
|
416 ItemParentHasChanged, |
|
417 ItemSceneHasChanged |
|
418 |
416 |
419 This enum describes the state changes that are notified by |
417 This enum describes the state changes that are notified by |
420 QGraphicsItem::itemChange(). The notifications are sent as the state |
418 QGraphicsItem::itemChange(). The notifications are sent as the state |
421 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 |
422 for each change for details). |
420 for each change for details). |
641 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 |
642 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 |
643 are children of a modal panel are not blocked. |
641 are children of a modal panel are not blocked. |
644 |
642 |
645 The values are: |
643 The values are: |
646 \value NonModal The panel is not modal and does not block input to other panels. |
644 |
647 \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 |
648 \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. |
649 |
654 |
650 \sa QGraphicsItem::setPanelModality(), QGraphicsItem::panelModality(), QGraphicsItem::ItemIsPanel |
655 \sa QGraphicsItem::setPanelModality(), QGraphicsItem::panelModality(), QGraphicsItem::ItemIsPanel |
651 */ |
656 */ |
652 |
657 |
653 #include "qgraphicsitem.h" |
658 #include "qgraphicsitem.h" |
1123 } |
1128 } |
1124 p = p->d_ptr->parent; |
1129 p = p->d_ptr->parent; |
1125 } |
1130 } |
1126 } |
1131 } |
1127 |
1132 |
|
1133 // Resolve depth. |
|
1134 invalidateDepthRecursively(); |
|
1135 |
1128 if ((parent = newParent)) { |
1136 if ((parent = newParent)) { |
1129 if (parent->d_func()->scene && parent->d_func()->scene != scene) { |
1137 if (parent->d_func()->scene && parent->d_func()->scene != scene) { |
1130 // Move this item to its new parent's scene |
1138 // Move this item to its new parent's scene |
1131 parent->d_func()->scene->addItem(q); |
1139 parent->d_func()->scene->addItem(q); |
1132 } else if (!parent->d_func()->scene && scene) { |
1140 } else if (!parent->d_func()->scene && scene) { |
1173 if (!enabled && !explicitlyDisabled) |
1181 if (!enabled && !explicitlyDisabled) |
1174 setEnabledHelper(true, /* explicit = */ false); |
1182 setEnabledHelper(true, /* explicit = */ false); |
1175 } |
1183 } |
1176 } |
1184 } |
1177 |
1185 |
1178 // Resolve depth. |
|
1179 invalidateDepthRecursively(); |
|
1180 dirtySceneTransform = 1; |
1186 dirtySceneTransform = 1; |
1181 |
1187 |
1182 // Restore the sub focus chain. |
1188 // Restore the sub focus chain. |
1183 if (subFocusItem) { |
1189 if (subFocusItem) { |
1184 subFocusItem->d_ptr->setSubFocus(newParent); |
1190 subFocusItem->d_ptr->setSubFocus(newParent); |
1874 { |
1881 { |
1875 CacheMode lastMode = CacheMode(d_ptr->cacheMode); |
1882 CacheMode lastMode = CacheMode(d_ptr->cacheMode); |
1876 d_ptr->cacheMode = mode; |
1883 d_ptr->cacheMode = mode; |
1877 bool noVisualChange = (mode == NoCache && lastMode == NoCache) |
1884 bool noVisualChange = (mode == NoCache && lastMode == NoCache) |
1878 || (mode == NoCache && lastMode == DeviceCoordinateCache) |
1885 || (mode == NoCache && lastMode == DeviceCoordinateCache) |
1879 || (mode == DeviceCoordinateCache && lastMode == NoCache); |
1886 || (mode == DeviceCoordinateCache && lastMode == NoCache) |
|
1887 || (mode == DeviceCoordinateCache && lastMode == DeviceCoordinateCache); |
1880 if (mode == NoCache) { |
1888 if (mode == NoCache) { |
1881 d_ptr->removeExtraItemCache(); |
1889 d_ptr->removeExtraItemCache(); |
1882 } else { |
1890 } else { |
1883 QGraphicsItemCache *cache = d_ptr->extraItemCache(); |
1891 QGraphicsItemCache *cache = d_ptr->extraItemCache(); |
1884 |
1892 |
2168 // Schedule redrawing |
2176 // Schedule redrawing |
2169 if (update) { |
2177 if (update) { |
2170 QGraphicsItemCache *c = (QGraphicsItemCache *)qVariantValue<void *>(extra(ExtraCacheData)); |
2178 QGraphicsItemCache *c = (QGraphicsItemCache *)qVariantValue<void *>(extra(ExtraCacheData)); |
2171 if (c) |
2179 if (c) |
2172 c->purge(); |
2180 c->purge(); |
2173 if (scene) |
2181 if (scene) { |
|
2182 #ifndef QT_NO_GRAPHICSEFFECT |
|
2183 invalidateParentGraphicsEffectsRecursively(); |
|
2184 #endif //QT_NO_GRAPHICSEFFECT |
2174 scene->d_func()->markDirty(q_ptr, QRectF(), /*invalidateChildren=*/false, /*force=*/true); |
2185 scene->d_func()->markDirty(q_ptr, QRectF(), /*invalidateChildren=*/false, /*force=*/true); |
|
2186 } |
2175 } |
2187 } |
2176 |
2188 |
2177 // 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(); |
2178 if (!newVisible) { |
2191 if (!newVisible) { |
2179 if (scene) { |
2192 if (scene) { |
2180 if (scene->d_func()->mouseGrabberItems.contains(q)) |
2193 if (scene->d_func()->mouseGrabberItems.contains(q)) |
2181 q->ungrabMouse(); |
2194 q->ungrabMouse(); |
2182 if (scene->d_func()->keyboardGrabberItems.contains(q)) |
2195 if (scene->d_func()->keyboardGrabberItems.contains(q)) |
2183 q->ungrabKeyboard(); |
2196 q->ungrabKeyboard(); |
2184 if (q->isPanel() && panelModality != QGraphicsItem::NonModal) |
2197 if (q->isPanel() && panelModality != QGraphicsItem::NonModal) |
2185 scene->d_func()->leaveModal(q_ptr); |
2198 scene->d_func()->leaveModal(q_ptr); |
2186 } |
2199 } |
2187 if (q_ptr->hasFocus() && scene) { |
2200 if (hasFocus && scene) { |
2188 // Hiding the closest non-panel ancestor of the focus item |
2201 // Hiding the closest non-panel ancestor of the focus item |
2189 QGraphicsItem *focusItem = scene->focusItem(); |
2202 QGraphicsItem *focusItem = scene->focusItem(); |
2190 bool clear = true; |
2203 bool clear = true; |
2191 if (isWidget && !focusItem->isPanel()) { |
2204 if (isWidget && !focusItem->isPanel()) { |
2192 do { |
2205 do { |
2233 scene->setActivePanel(parent); |
2246 scene->setActivePanel(parent); |
2234 } |
2247 } |
2235 } |
2248 } |
2236 |
2249 |
2237 // Enable subfocus |
2250 // Enable subfocus |
2238 if (scene && newVisible) { |
2251 if (scene) { |
2239 QGraphicsItem *p = parent; |
2252 if (newVisible) { |
2240 bool done = false; |
2253 // Item is shown |
2241 while (p) { |
2254 QGraphicsItem *p = parent; |
2242 if (p->flags() & QGraphicsItem::ItemIsFocusScope) { |
2255 bool done = false; |
2243 QGraphicsItem *fsi = p->d_ptr->focusScopeItem; |
2256 while (p) { |
2244 if (q_ptr == fsi || q_ptr->isAncestorOf(fsi)) { |
2257 if (p->flags() & QGraphicsItem::ItemIsFocusScope) { |
2245 done = true; |
2258 QGraphicsItem *fsi = p->d_ptr->focusScopeItem; |
2246 while (fsi->d_ptr->focusScopeItem && fsi->d_ptr->focusScopeItem->isVisible()) |
2259 if (q_ptr == fsi || q_ptr->isAncestorOf(fsi)) { |
2247 fsi = fsi->d_ptr->focusScopeItem; |
2260 done = true; |
2248 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; |
2249 } |
2267 } |
2250 break; |
2268 p = p->d_ptr->parent; |
2251 } |
2269 } |
2252 p = p->d_ptr->parent; |
2270 if (!done) { |
2253 } |
2271 QGraphicsItem *fi = subFocusItem; |
2254 if (!done) { |
2272 if (fi && fi != scene->focusItem()) { |
2255 QGraphicsItem *fi = subFocusItem; |
2273 scene->setFocusItem(fi); |
2256 if (fi && fi != scene->focusItem()) { |
2274 } |
2257 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 } |
2258 } |
2290 } |
2259 } |
2291 } |
2260 } |
2292 } |
2261 |
2293 |
2262 // Deliver post-change notification. |
2294 // Deliver post-change notification. |
2582 d_ptr->invalidateChildGraphicsEffectsRecursively(QGraphicsItemPrivate::OpacityChanged); |
2615 d_ptr->invalidateChildGraphicsEffectsRecursively(QGraphicsItemPrivate::OpacityChanged); |
2583 #endif //QT_NO_GRAPHICSEFFECT |
2616 #endif //QT_NO_GRAPHICSEFFECT |
2584 d_ptr->scene->d_func()->markDirty(this, QRectF(), |
2617 d_ptr->scene->d_func()->markDirty(this, QRectF(), |
2585 /*invalidateChildren=*/true, |
2618 /*invalidateChildren=*/true, |
2586 /*force=*/false, |
2619 /*force=*/false, |
2587 /*ignoreOpacity=*/true); |
2620 /*ignoreOpacity=*/d_ptr->isOpacityNull()); |
|
2621 if (wasFullyTransparent) |
|
2622 d_ptr->paintedViewBoundingRectsNeedRepaint = 1; |
2588 } |
2623 } |
2589 |
2624 |
2590 if (d_ptr->isObject) |
2625 if (d_ptr->isObject) |
2591 emit static_cast<QGraphicsObject *>(this)->opacityChanged(); |
2626 emit static_cast<QGraphicsObject *>(this)->opacityChanged(); |
2592 } |
2627 } |
3100 |
3135 |
3101 \sa clearFocus(), hasFocus(), focusItem(), focusProxy() |
3136 \sa clearFocus(), hasFocus(), focusItem(), focusProxy() |
3102 */ |
3137 */ |
3103 void QGraphicsItem::setFocus(Qt::FocusReason focusReason) |
3138 void QGraphicsItem::setFocus(Qt::FocusReason focusReason) |
3104 { |
3139 { |
3105 d_ptr->setFocusHelper(focusReason, /* climb = */ true); |
3140 d_ptr->setFocusHelper(focusReason, /* climb = */ true, /* focusFromShow = */ false); |
3106 } |
3141 } |
3107 |
3142 |
3108 /*! |
3143 /*! |
3109 \internal |
3144 \internal |
3110 */ |
3145 */ |
3111 void QGraphicsItemPrivate::setFocusHelper(Qt::FocusReason focusReason, bool climb) |
3146 void QGraphicsItemPrivate::setFocusHelper(Qt::FocusReason focusReason, bool climb, bool focusFromShow) |
3112 { |
3147 { |
3113 // Disabled / unfocusable items cannot accept focus. |
3148 // Disabled / unfocusable items cannot accept focus. |
3114 if (!q_ptr->isEnabled() || !(flags & QGraphicsItem::ItemIsFocusable)) |
3149 if (!q_ptr->isEnabled() || !(flags & QGraphicsItem::ItemIsFocusable)) |
3115 return; |
3150 return; |
3116 |
3151 |
3126 // Update focus scope item ptr. |
3161 // Update focus scope item ptr. |
3127 QGraphicsItem *p = parent; |
3162 QGraphicsItem *p = parent; |
3128 while (p) { |
3163 while (p) { |
3129 if (p->flags() & QGraphicsItem::ItemIsFocusScope) { |
3164 if (p->flags() & QGraphicsItem::ItemIsFocusScope) { |
3130 p->d_ptr->focusScopeItem = q_ptr; |
3165 p->d_ptr->focusScopeItem = q_ptr; |
3131 if (!p->focusItem()) { |
3166 if (!p->focusItem() && !focusFromShow) { |
3132 // 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 |
3133 // doesn't currently have a focus item, then stop. |
3168 // doesn't currently have a focus item, then stop. |
3134 return; |
3169 return; |
3135 } |
3170 } |
3136 break; |
3171 break; |
3167 |
3202 |
3168 \sa setFocus(), hasFocus(), QGraphicsWidget::focusPolicy |
3203 \sa setFocus(), hasFocus(), QGraphicsWidget::focusPolicy |
3169 */ |
3204 */ |
3170 void QGraphicsItem::clearFocus() |
3205 void QGraphicsItem::clearFocus() |
3171 { |
3206 { |
3172 // Pass focus to the closest parent focus scope. |
3207 d_ptr->clearFocusHelper(/* giveFocusToParent = */ true); |
3173 if (!d_ptr->inDestructor) { |
3208 } |
3174 QGraphicsItem *p = d_ptr->parent; |
3209 |
3175 while (p) { |
3210 /*! |
3176 if (p->flags() & ItemIsFocusScope) { |
3211 \internal |
3177 p->d_ptr->setFocusHelper(Qt::OtherFocusReason, /* climb = */ false); |
3212 */ |
3178 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; |
3179 } |
3226 } |
3180 p = p->d_ptr->parent; |
|
3181 } |
3227 } |
3182 } |
3228 } |
3183 |
3229 |
3184 // Invisible items with focus must explicitly clear subfocus. |
3230 // Invisible items with focus must explicitly clear subfocus. |
3185 d_ptr->clearSubFocus(this); |
3231 clearSubFocus(q_ptr); |
3186 |
3232 |
3187 if (hasFocus()) { |
3233 if (q_ptr->hasFocus()) { |
3188 // If this item has the scene's input focus, clear it. |
3234 // If this item has the scene's input focus, clear it. |
3189 d_ptr->scene->setFocusItem(0); |
3235 scene->setFocusItem(0); |
3190 } |
3236 } |
3191 } |
3237 } |
3192 |
3238 |
3193 /*! |
3239 /*! |
3194 \since 4.6 |
3240 \since 4.6 |
5177 // number is equal to the size of the children list. |
5223 // number is equal to the size of the children list. |
5178 ensureSequentialSiblingIndex(); |
5224 ensureSequentialSiblingIndex(); |
5179 needSortChildren = 1; // ### maybe 0 |
5225 needSortChildren = 1; // ### maybe 0 |
5180 child->d_ptr->siblingIndex = children.size(); |
5226 child->d_ptr->siblingIndex = children.size(); |
5181 children.append(child); |
5227 children.append(child); |
|
5228 if (isObject) |
|
5229 emit static_cast<QGraphicsObject *>(q_ptr)->childrenChanged(); |
5182 } |
5230 } |
5183 |
5231 |
5184 /*! |
5232 /*! |
5185 \internal |
5233 \internal |
5186 |
5234 |
5199 children.removeOne(child); |
5247 children.removeOne(child); |
5200 // NB! Do not use children.removeAt(child->d_ptr->siblingIndex) because |
5248 // NB! Do not use children.removeAt(child->d_ptr->siblingIndex) because |
5201 // 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. |
5202 // (see ensureSortedChildren()). |
5250 // (see ensureSortedChildren()). |
5203 child->d_ptr->siblingIndex = -1; |
5251 child->d_ptr->siblingIndex = -1; |
|
5252 if (isObject) |
|
5253 emit static_cast<QGraphicsObject *>(q_ptr)->childrenChanged(); |
5204 } |
5254 } |
5205 |
5255 |
5206 /*! |
5256 /*! |
5207 \internal |
5257 \internal |
5208 */ |
5258 */ |
7406 QGestureManager *manager = QGestureManager::instance(); |
7456 QGestureManager *manager = QGestureManager::instance(); |
7407 manager->cleanupCachedGestures(this, gesture); |
7457 manager->cleanupCachedGestures(this, gesture); |
7408 } |
7458 } |
7409 } |
7459 } |
7410 |
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 |
7411 /*! |
7543 /*! |
7412 \property QGraphicsObject::parent |
7544 \property QGraphicsObject::parent |
7413 \brief the parent of the item |
7545 \brief the parent of the item |
7414 |
7546 |
7415 \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 |
7592 origin for scale and rotation. |
7724 origin for scale and rotation. |
7593 |
7725 |
7594 \sa scale, rotation, QGraphicsItem::transformOriginPoint() |
7726 \sa scale, rotation, QGraphicsItem::transformOriginPoint() |
7595 */ |
7727 */ |
7596 |
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 */ |
7597 |
7746 |
7598 /*! |
7747 /*! |
7599 \class QAbstractGraphicsShapeItem |
7748 \class QAbstractGraphicsShapeItem |
7600 \brief The QAbstractGraphicsShapeItem class provides a common base for |
7749 \brief The QAbstractGraphicsShapeItem class provides a common base for |
7601 all path items. |
7750 all path items. |
10799 info->widget, info->opacity, &effectTransform, info->wasDirtySceneTransform, |
10948 info->widget, info->opacity, &effectTransform, info->wasDirtySceneTransform, |
10800 info->drawItem); |
10949 info->drawItem); |
10801 } |
10950 } |
10802 } |
10951 } |
10803 |
10952 |
|
10953 // sourceRect must be in the given coordinate system |
10804 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 |
10805 { |
10955 { |
10806 QRectF effectRectF; |
10956 QRectF effectRectF; |
10807 |
10957 |
10808 if (unpadded) |
10958 if (unpadded) |
10809 *unpadded = false; |
10959 *unpadded = false; |
10810 |
10960 |
10811 if (mode == QGraphicsEffect::PadToEffectiveBoundingRect) { |
10961 if (mode == QGraphicsEffect::PadToEffectiveBoundingRect) { |
10812 if (info) { |
10962 if (info) { |
10813 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); |
10814 if (unpadded) |
10965 if (unpadded) |
10815 *unpadded = (effectRectF.size() == sourceRect.size()); |
10966 *unpadded = (effectRectF.size() == sourceRect.size()); |
10816 if (info && system == Qt::LogicalCoordinates) |
10967 if (info && system == Qt::LogicalCoordinates) |
10817 effectRectF = info->painter->worldTransform().inverted().mapRect(effectRectF); |
10968 effectRectF = info->painter->worldTransform().inverted().mapRect(effectRectF); |
10818 } else { |
10969 } else { |
10857 if (offset) |
11008 if (offset) |
10858 *offset = boundingRect(system).topLeft().toPoint(); |
11009 *offset = boundingRect(system).topLeft().toPoint(); |
10859 return static_cast<QGraphicsPixmapItem *>(item)->pixmap(); |
11010 return static_cast<QGraphicsPixmapItem *>(item)->pixmap(); |
10860 } |
11011 } |
10861 |
11012 |
10862 if (deviceCoordinates) { |
|
10863 // Clip to viewport rect. |
|
10864 int left, top, right, bottom; |
|
10865 effectRect.getCoords(&left, &top, &right, &bottom); |
|
10866 if (left < 0) { |
|
10867 if (offset) |
|
10868 offset->rx() += -left; |
|
10869 effectRect.setX(0); |
|
10870 } |
|
10871 if (top < 0) { |
|
10872 if (offset) |
|
10873 offset->ry() += -top; |
|
10874 effectRect.setY(0); |
|
10875 } |
|
10876 // NB! We use +-1 for historical reasons (see QRect documentation). |
|
10877 QPaintDevice *device = info->painter->device(); |
|
10878 const int deviceWidth = device->width(); |
|
10879 const int deviceHeight = device->height(); |
|
10880 if (right + 1 > deviceWidth) |
|
10881 effectRect.setRight(deviceWidth - 1); |
|
10882 if (bottom + 1 > deviceHeight) |
|
10883 effectRect.setBottom(deviceHeight -1); |
|
10884 |
|
10885 } |
|
10886 if (effectRect.isEmpty()) |
11013 if (effectRect.isEmpty()) |
10887 return QPixmap(); |
11014 return QPixmap(); |
10888 |
11015 |
10889 QPixmap pixmap(effectRect.size()); |
11016 QPixmap pixmap(effectRect.size()); |
10890 pixmap.fill(Qt::transparent); |
11017 pixmap.fill(Qt::transparent); |