Changeset 769 for trunk/src/gui/graphicsview
- Timestamp:
- Aug 2, 2010, 9:27:30 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:mergeinfo changed
/branches/vendor/nokia/qt/4.6.3 (added) merged: 768 /branches/vendor/nokia/qt/current merged: 767 /branches/vendor/nokia/qt/4.6.2 removed
- Property svn:mergeinfo changed
-
trunk/src/gui/graphicsview/qgraphicsitem.cpp
r651 r769 320 320 321 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 ts322 draw or receive mouse, tablet, drag and drop or hover events outside its 323 323 shape. It is disabled by default. This behavior is enforced by 324 324 QGraphicsView::drawItems() or QGraphicsScene::drawItems(). This flag was … … 358 358 this flag, the child will be stacked behind it. This flag is useful for 359 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 363 \value ItemUsesExtendedStyleOption The item makes use of either 363 \l{QStyleOptionGraphicsItem::}{exposedRect} or 364 \l{QStyleOptionGraphicsItem::}{matrix} in QStyleOptionGraphicsItem. By default, 365 the \l{QStyleOptionGraphicsItem::}{exposedRect} is initialized to the item's 366 boundingRect() and the \l{QStyleOptionGraphicsItem::}{matrix} is untransformed. 367 You can enable this flag for the style options to be set up with more 368 fine-grained values. 369 Note that QStyleOptionGraphicsItem::levelOfDetail is unaffected by this flag 364 \l{QStyleOptionGraphicsItem::} {exposedRect} or 365 \l{QStyleOptionGraphicsItem::} {matrix} in 366 QStyleOptionGraphicsItem. By default, the 367 \l{QStyleOptionGraphicsItem::} {exposedRect} is initialized to the 368 item's boundingRect() and the 369 \l{QStyleOptionGraphicsItem::}{matrix} is untransformed. You can 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 373 and always initialized to 1. Use 371 QStyleOptionGraphicsItem::levelOfDetailFromTransform() if you need a higher372 value.374 QStyleOptionGraphicsItem::levelOfDetailFromTransform() if you need 375 a higher value. This flag was introduced in Qt 4.6. 373 376 374 377 \value ItemHasNoContents The item does not paint anything (i.e., calling … … 388 391 This flag was introduced in Qt 4.6. 389 392 390 \value ItemNegativeZStacksBehindParent The item automatically stacks behind 391 it's parent if it's z-value is negative. This flag enables setZValue() to 392 toggle ItemStacksBehindParent. 393 \value ItemNegativeZStacksBehindParent The item automatically 394 stacks behind it's parent if it's z-value is negative. This flag 395 enables setZValue() to toggle ItemStacksBehindParent. This flag 396 was introduced in Qt 4.6. 393 397 394 398 \value ItemIsPanel The item is a panel. A panel provides activation and … … 410 414 /*! 411 415 \enum QGraphicsItem::GraphicsItemChange 412 413 ItemVisibleHasChanged,414 ItemEnabledHasChanged,415 ItemSelectedHasChanged,416 ItemParentHasChanged,417 ItemSceneHasChanged418 416 419 417 This enum describes the state changes that are notified by … … 644 642 645 643 The values are: 646 \value NonModal The panel is not modal and does not block input to other panels. 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. 648 \value SceneModal The window is modal to the entire scene and blocks input to all panels. 644 645 \value NonModal The panel is not modal and does not block input to 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 655 \sa QGraphicsItem::setPanelModality(), QGraphicsItem::panelModality(), QGraphicsItem::ItemIsPanel … … 1126 1131 } 1127 1132 1133 // Resolve depth. 1134 invalidateDepthRecursively(); 1135 1128 1136 if ((parent = newParent)) { 1129 1137 if (parent->d_func()->scene && parent->d_func()->scene != scene) { … … 1176 1184 } 1177 1185 1178 // Resolve depth.1179 invalidateDepthRecursively();1180 1186 dirtySceneTransform = 1; 1181 1187 … … 1393 1399 delete d_ptr->transformData; 1394 1400 1395 qt_dataStore()->data.remove(this); 1401 if (QGraphicsItemCustomDataStore *dataStore = qt_dataStore()) 1402 dataStore->data.remove(this); 1396 1403 } 1397 1404 … … 1571 1578 1572 1579 /*! 1573 Sets this item's parent item to \a parent. If this item already has a 1574 parent, it is first removed from the previous parent. If \a parent is 0, 1575 this item will become a top-level item. 1576 1577 Note that this implicitly adds this graphics item to the scene of 1578 the parent. You should not \l{QGraphicsScene::addItem()}{add} the 1579 item to the scene yourself. 1580 1581 Calling this function on an item that is an ancestor of \a parent have undefined behaviour. 1582 1583 \sa parentItem(), childItems() 1580 Sets this item's parent item to \a newParent. If this item already 1581 has a parent, it is first removed from the previous parent. If \a 1582 newParent is 0, this item will become a top-level item. 1583 1584 Note that this implicitly adds this graphics item to the scene of 1585 the parent. You should not \l{QGraphicsScene::addItem()}{add} the 1586 item to the scene yourself. 1587 1588 Calling this function on an item that is an ancestor of \a newParent 1589 have undefined behaviour. 1590 1591 \sa parentItem(), childItems() 1584 1592 */ 1585 1593 void QGraphicsItem::setParentItem(QGraphicsItem *newParent) … … 1876 1884 bool noVisualChange = (mode == NoCache && lastMode == NoCache) 1877 1885 || (mode == NoCache && lastMode == DeviceCoordinateCache) 1878 || (mode == DeviceCoordinateCache && lastMode == NoCache); 1886 || (mode == DeviceCoordinateCache && lastMode == NoCache) 1887 || (mode == DeviceCoordinateCache && lastMode == DeviceCoordinateCache); 1879 1888 if (mode == NoCache) { 1880 1889 d_ptr->removeExtraItemCache(); … … 2170 2179 if (c) 2171 2180 c->purge(); 2172 if (scene) 2181 if (scene) { 2182 #ifndef QT_NO_GRAPHICSEFFECT 2183 invalidateParentGraphicsEffectsRecursively(); 2184 #endif //QT_NO_GRAPHICSEFFECT 2173 2185 scene->d_func()->markDirty(q_ptr, QRectF(), /*invalidateChildren=*/false, /*force=*/true); 2186 } 2174 2187 } 2175 2188 2176 2189 // Certain properties are dropped as an item becomes invisible. 2190 bool hasFocus = q_ptr->hasFocus(); 2177 2191 if (!newVisible) { 2178 2192 if (scene) { … … 2184 2198 scene->d_func()->leaveModal(q_ptr); 2185 2199 } 2186 if ( q_ptr->hasFocus()&& scene) {2200 if (hasFocus && scene) { 2187 2201 // Hiding the closest non-panel ancestor of the focus item 2188 2202 QGraphicsItem *focusItem = scene->focusItem(); … … 2197 2211 } 2198 2212 if (clear) 2199 q_ptr->clearFocus();2213 clearFocusHelper(/* giveFocusToParent = */ false); 2200 2214 } 2201 2215 if (q_ptr->isSelected()) … … 2235 2249 2236 2250 // Enable subfocus 2237 if (scene && newVisible) { 2238 QGraphicsItem *p = parent; 2239 bool done = false; 2240 while (p) { 2241 if (p->flags() & QGraphicsItem::ItemIsFocusScope) { 2242 QGraphicsItem *fsi = p->d_ptr->focusScopeItem; 2243 if (q_ptr == fsi || q_ptr->isAncestorOf(fsi)) { 2244 done = true; 2245 while (fsi->d_ptr->focusScopeItem && fsi->d_ptr->focusScopeItem->isVisible()) 2246 fsi = fsi->d_ptr->focusScopeItem; 2247 scene->setFocusItem(fsi); 2251 if (scene) { 2252 if (newVisible) { 2253 // Item is shown 2254 QGraphicsItem *p = parent; 2255 bool done = false; 2256 while (p) { 2257 if (p->flags() & QGraphicsItem::ItemIsFocusScope) { 2258 QGraphicsItem *fsi = p->d_ptr->focusScopeItem; 2259 if (q_ptr == fsi || q_ptr->isAncestorOf(fsi)) { 2260 done = true; 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; 2248 2267 } 2249 break;2268 p = p->d_ptr->parent; 2250 2269 } 2251 p = p->d_ptr->parent; 2252 } 2253 if (!done) { 2254 QGraphicsItem *fi = subFocusItem; 2255 if (fi && fi != scene->focusItem()) { 2256 scene->setFocusItem(fi); 2270 if (!done) { 2271 QGraphicsItem *fi = subFocusItem; 2272 if (fi && fi != scene->focusItem()) { 2273 scene->setFocusItem(fi); 2274 } 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 } 2257 2290 } 2258 2291 } … … 3105 3138 void QGraphicsItem::setFocus(Qt::FocusReason focusReason) 3106 3139 { 3107 d_ptr->setFocusHelper(focusReason, /* climb = */ true );3140 d_ptr->setFocusHelper(focusReason, /* climb = */ true, /* focusFromShow = */ false); 3108 3141 } 3109 3142 … … 3111 3144 \internal 3112 3145 */ 3113 void QGraphicsItemPrivate::setFocusHelper(Qt::FocusReason focusReason, bool climb )3146 void QGraphicsItemPrivate::setFocusHelper(Qt::FocusReason focusReason, bool climb, bool focusFromShow) 3114 3147 { 3115 3148 // Disabled / unfocusable items cannot accept focus. … … 3131 3164 if (p->flags() & QGraphicsItem::ItemIsFocusScope) { 3132 3165 p->d_ptr->focusScopeItem = q_ptr; 3133 if (!p->focusItem() ) {3166 if (!p->focusItem() && !focusFromShow) { 3134 3167 // If you call setFocus on a child of a focus scope that 3135 3168 // doesn't currently have a focus item, then stop. … … 3172 3205 void QGraphicsItem::clearFocus() 3173 3206 { 3174 // Pass focus to the closest parent focus scope. 3175 if (!d_ptr->inDestructor) { 3176 QGraphicsItem *p = d_ptr->parent; 3177 while (p) { 3178 if (p->flags() & ItemIsFocusScope) { 3179 p->d_ptr->setFocusHelper(Qt::OtherFocusReason, /* climb = */ false); 3180 return; 3207 d_ptr->clearFocusHelper(/* giveFocusToParent = */ true); 3208 } 3209 3210 /*! 3211 \internal 3212 */ 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; 3181 3226 } 3182 p = p->d_ptr->parent;3183 3227 } 3184 3228 } 3185 3229 3186 3230 // Invisible items with focus must explicitly clear subfocus. 3187 d_ptr->clearSubFocus(this);3188 3189 if ( hasFocus()) {3231 clearSubFocus(q_ptr); 3232 3233 if (q_ptr->hasFocus()) { 3190 3234 // If this item has the scene's input focus, clear it. 3191 d_ptr->scene->setFocusItem(0);3235 scene->setFocusItem(0); 3192 3236 } 3193 3237 } … … 3535 3579 if (!(d_ptr->flags & ItemSendsGeometryChanges)) { 3536 3580 d_ptr->setPosHelper(pos); 3581 if (d_ptr->isWidget) 3582 static_cast<QGraphicsWidget *>(this)->d_func()->setGeometryFromSetPos(); 3537 3583 return; 3538 3584 } … … 7257 7303 QGraphicsScenePrivate *scenePrivate = d_ptr->scene->d_func(); 7258 7304 scenePrivate->index->prepareBoundingRectChange(this); 7259 scenePrivate->markDirty(this, QRectF(), /*invalidateChildren=*/true); 7305 scenePrivate->markDirty(this, QRectF(), /*invalidateChildren=*/true, /*force=*/false, 7306 /*ignoreOpacity=*/ false, /*removingItemFromScene=*/ false, 7307 /*updateBoundingRect=*/true); 7260 7308 7261 7309 // For compatibility reasons, we have to update the item's old geometry … … 10802 10850 } 10803 10851 10852 // sourceRect must be in the given coordinate system 10804 10853 QRect QGraphicsItemEffectSourcePrivate::paddedEffectRect(Qt::CoordinateSystem system, QGraphicsEffect::PixmapPadMode mode, const QRectF &sourceRect, bool *unpadded) const 10805 10854 { … … 10811 10860 if (mode == QGraphicsEffect::PadToEffectiveBoundingRect) { 10812 10861 if (info) { 10813 effectRectF = item->graphicsEffect()->boundingRectFor(boundingRect(Qt::DeviceCoordinates)); 10862 QRectF deviceRect = system == Qt::DeviceCoordinates ? sourceRect : info->painter->worldTransform().mapRect(sourceRect); 10863 effectRectF = item->graphicsEffect()->boundingRectFor(deviceRect); 10814 10864 if (unpadded) 10815 10865 *unpadded = (effectRectF.size() == sourceRect.size()); … … 10860 10910 } 10861 10911 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 10912 if (effectRect.isEmpty()) 10887 10913 return QPixmap(); -
trunk/src/gui/graphicsview/qgraphicsitem_p.h
r651 r769 415 415 inline void markParentDirty(bool updateBoundingRect = false); 416 416 417 void setFocusHelper(Qt::FocusReason focusReason, bool climb); 417 void setFocusHelper(Qt::FocusReason focusReason, bool climb, bool focusFromShow); 418 void clearFocusHelper(bool giveFocusToParent); 418 419 void setSubFocus(QGraphicsItem *rootItem = 0); 419 420 void clearSubFocus(QGraphicsItem *rootItem = 0); … … 769 770 { 770 771 QGraphicsItemPrivate *parentp = this; 772 #ifndef QT_NO_GRAPHICSEFFECT 773 if (updateBoundingRect && parentp->graphicsEffect && !parentp->inSetPosHelper) { 774 parentp->notifyInvalidated = 1; 775 static_cast<QGraphicsItemEffectSourcePrivate *>(parentp->graphicsEffect->d_func() 776 ->source->d_func())->invalidateCache(); 777 } 778 #endif 771 779 while (parentp->parent) { 772 780 parentp = parentp->parent->d_ptr.data(); -
trunk/src/gui/graphicsview/qgraphicsproxywidget.cpp
r651 r769 190 190 191 191 extern bool qt_sendSpontaneousEvent(QObject *, QEvent *); 192 extern bool qt_tab_all_widgets;192 Q_GUI_EXPORT extern bool qt_tab_all_widgets; 193 193 194 194 /*! … … 898 898 break; 899 899 } 900 #ifndef QT_NO_TOOLTIP 901 case QEvent::GraphicsSceneHelp: { 902 // Propagate the help event (for tooltip) to the widget under mouse 903 if (d->lastWidgetUnderMouse) { 904 QGraphicsSceneHelpEvent *he = static_cast<QGraphicsSceneHelpEvent *>(event); 905 QPoint pos = d->mapToReceiver(mapFromScene(he->scenePos()), d->lastWidgetUnderMouse).toPoint(); 906 QHelpEvent e(QEvent::ToolTip, pos, he->screenPos()); 907 QApplication::sendEvent(d->lastWidgetUnderMouse, &e); 908 event->setAccepted(e.isAccepted()); 909 return e.isAccepted(); 910 } 911 break; 912 } 913 case QEvent::ToolTipChange: { 914 // Propagate tooltip change to the widget 915 if (!d->tooltipChangeMode) { 916 d->tooltipChangeMode = QGraphicsProxyWidgetPrivate::ProxyToWidgetMode; 917 d->widget->setToolTip(toolTip()); 918 d->tooltipChangeMode = QGraphicsProxyWidgetPrivate::NoMode; 919 } 920 break; 921 } 922 #endif 900 923 default: 901 924 break; … … 953 976 } 954 977 break; 978 case QEvent::ToolTipChange: 979 // Propagate tooltip change to the proxy. 980 if (!d->tooltipChangeMode) { 981 d->tooltipChangeMode = QGraphicsProxyWidgetPrivate::WidgetToProxyMode; 982 setToolTip(d->widget->toolTip()); 983 d->tooltipChangeMode = QGraphicsProxyWidgetPrivate::NoMode; 984 } 985 break; 955 986 default: 956 987 break; … … 1316 1347 } 1317 1348 1349 d->proxyIsGivingFocus = true; 1350 1318 1351 switch (event->reason()) { 1319 1352 case Qt::TabFocusReason: { … … 1329 1362 if (d->widget && d->widget->focusWidget()) { 1330 1363 d->widget->focusWidget()->setFocus(event->reason()); 1331 return; 1332 } 1333 break; 1334 } 1364 } 1365 break; 1366 } 1367 1368 d->proxyIsGivingFocus = false; 1335 1369 } 1336 1370 … … 1433 1467 1434 1468 // Filter out repaints on the window frame. 1435 const QRect exposedWidgetRect = (option->exposedRect & rect()).to Rect();1469 const QRect exposedWidgetRect = (option->exposedRect & rect()).toAlignedRect(); 1436 1470 if (exposedWidgetRect.isEmpty()) 1437 1471 return; -
trunk/src/gui/graphicsview/qgraphicsproxywidget_p.h
r651 r769 73 73 styleChangeMode(NoMode), 74 74 paletteChangeMode(NoMode), 75 tooltipChangeMode(NoMode), 75 76 focusFromWidgetToProxy(0) 76 77 { } … … 118 119 quint32 styleChangeMode : 2; 119 120 quint32 paletteChangeMode : 2; 121 quint32 tooltipChangeMode : 2; 120 122 quint32 focusFromWidgetToProxy : 1; 123 quint32 proxyIsGivingFocus : 1; 121 124 }; 122 125 -
trunk/src/gui/graphicsview/qgraphicsscene.cpp
r651 r769 694 694 if (!selectionChanging && selectedItems.size() != oldSelectedItemsSize) 695 695 emit q->selectionChanged(); 696 697 QHash<QGesture *, QGraphicsObject *>::iterator it; 698 for (it = gestureTargets.begin(); it != gestureTargets.end();) { 699 if (it.value() == item) 700 it = gestureTargets.erase(it); 701 else 702 ++it; 703 } 696 704 } 697 705 … … 802 810 if (item) { 803 811 for (int i = 0; i < views.size(); ++i) 804 views.at(i)->inputContext()->reset(); 812 if (views.at(i)->inputContext()) 813 views.at(i)->inputContext()->reset(); 805 814 } 806 815 } … … 808 817 } 809 818 819 if (item) 820 focusItem = item; 821 updateInputMethodSensitivityInViews(); 810 822 if (item) { 811 focusItem = item;812 823 QFocusEvent event(QEvent::FocusIn, focusReason); 813 824 sendEvent(item, &event); 814 825 } 815 816 updateInputMethodSensitivityInViews();817 826 } 818 827 … … 3772 3781 for (int i = 0; i < itemsAtPos.size(); ++i) { 3773 3782 QGraphicsItem *tmp = itemsAtPos.at(i); 3783 if (tmp->d_func()->isProxyWidget()) { 3784 // if the item is a proxy widget, the event is forwarded to it 3785 sendEvent(tmp, helpEvent); 3786 if (helpEvent->isAccepted()) 3787 return; 3788 } 3774 3789 if (!tmp->toolTip().isEmpty()) { 3775 3790 toolTipItem = tmp; … … 4285 4300 // Blit the subpixmap into the main pixmap. 4286 4301 pixmapPainter.begin(pix); 4302 pixmapPainter.setCompositionMode(QPainter::CompositionMode_Source); 4287 4303 pixmapPainter.setClipRegion(pixmapExposed); 4288 4304 pixmapPainter.drawPixmap(br.topLeft(), subPix); … … 4450 4466 4451 4467 // Create or reuse offscreen pixmap, possibly scroll/blit from the old one. 4468 // If the world transform is rotated we always recreate the cache to avoid 4469 // wrong blending. 4452 4470 bool pixModified = false; 4453 4471 QGraphicsItemCache::DeviceData *deviceData = &itemCache->deviceData[widget]; … … 4457 4475 diff *= painter->worldTransform(); 4458 4476 deviceData->lastTransform = painter->worldTransform(); 4459 if (!invertable || diff.type() > QTransform::TxTranslate) { 4477 if (!invertable 4478 || diff.type() > QTransform::TxTranslate 4479 || painter->worldTransform().type() > QTransform::TxScale) { 4460 4480 pixModified = true; 4461 4481 itemCache->allExposed = true; … … 4679 4699 item->d_ptr->paintedViewBoundingRects.insert(widget, viewBoundingRect); 4680 4700 viewBoundingRect.adjust(-1, -1, 1, 1); 4681 drawItem = exposedRegion ? exposedRegion->intersects(viewBoundingRect) : !viewBoundingRect.isEmpty(); 4701 drawItem = exposedRegion ? exposedRegion->intersects(viewBoundingRect) 4702 : !viewBoundingRect.normalized().isEmpty(); 4682 4703 if (!drawItem) { 4683 4704 if (!itemHasChildren) … … 4713 4734 && sourced->lastEffectTransform != painter->worldTransform()) 4714 4735 { 4715 bool unclipped = false;4716 4736 if (sourced->lastEffectTransform.type() <= QTransform::TxTranslate 4717 4737 && painter->worldTransform().type() <= QTransform::TxTranslate) 4718 4738 { 4719 QRectF itemRect = item->boundingRect(); 4720 if (!item->d_ptr->children.isEmpty()) 4721 itemRect |= item->childrenBoundingRect(); 4722 4723 QRectF oldSourceRect = sourced->lastEffectTransform.mapRect(itemRect); 4724 QRectF newSourceRect = painter->worldTransform().mapRect(itemRect); 4725 4726 QRect oldEffectRect = sourced->paddedEffectRect(sourced->currentCachedSystem(), sourced->currentCachedMode(), oldSourceRect); 4727 QRect newEffectRect = sourced->paddedEffectRect(sourced->currentCachedSystem(), sourced->currentCachedMode(), newSourceRect); 4728 4729 QRect deviceRect(0, 0, painter->device()->width(), painter->device()->height()); 4730 if (deviceRect.contains(oldEffectRect) && deviceRect.contains(newEffectRect)) { 4731 sourced->setCachedOffset(newEffectRect.topLeft()); 4732 unclipped = true; 4733 } 4739 QRectF sourceRect = sourced->boundingRect(Qt::DeviceCoordinates); 4740 QRect effectRect = sourced->paddedEffectRect(Qt::DeviceCoordinates, sourced->currentCachedMode(), sourceRect); 4741 4742 sourced->setCachedOffset(effectRect.topLeft()); 4743 } else { 4744 sourced->invalidateCache(QGraphicsEffectSourcePrivate::TransformChanged); 4734 4745 } 4735 4746 4736 4747 sourced->lastEffectTransform = painter->worldTransform(); 4737 4738 if (!unclipped)4739 sourced->invalidateCache(QGraphicsEffectSourcePrivate::TransformChanged);4740 4748 } 4741 4749 … … 4849 4857 4850 4858 void QGraphicsScenePrivate::markDirty(QGraphicsItem *item, const QRectF &rect, bool invalidateChildren, 4851 bool force, bool ignoreOpacity, bool removingItemFromScene) 4859 bool force, bool ignoreOpacity, bool removingItemFromScene, 4860 bool updateBoundingRect) 4852 4861 { 4853 4862 Q_ASSERT(item); … … 4920 4929 item->d_ptr->ignoreOpacity = 1; 4921 4930 4922 item->d_ptr->markParentDirty(); 4931 if (!updateBoundingRect) 4932 item->d_ptr->markParentDirty(); 4923 4933 } 4924 4934 … … 5131 5141 5132 5142 /*! 5143 \obsolete 5144 5133 5145 Paints the given \a items using the provided \a painter, after the 5134 5146 background has been drawn, and before the foreground has been … … 5153 5165 \snippet doc/src/snippets/graphicssceneadditemsnippet.cpp 0 5154 5166 5155 \obsoleteSince Qt 4.6, this function is not called anymore unless5167 Since Qt 4.6, this function is not called anymore unless 5156 5168 the QGraphicsView::IndirectPainting flag is given as an Optimization 5157 5169 flag. … … 5709 5721 bool res = sendTouchBeginEvent(item, &touchEvent) 5710 5722 && touchEvent.isAccepted(); 5711 if (!res) 5723 if (!res) { 5724 // forget about these touch points, we didn't handle them 5725 for (int i = 0; i < touchEvent.touchPoints().count(); ++i) { 5726 const QTouchEvent::TouchPoint &touchPoint = touchEvent.touchPoints().at(i); 5727 itemForTouchPointId.remove(touchPoint.id()); 5728 sceneCurrentTouchPoints.remove(touchPoint.id()); 5729 } 5712 5730 ignoreSceneTouchEvent = false; 5731 } 5713 5732 break; 5714 5733 } … … 5901 5920 QList<QGraphicsObject *> result; 5902 5921 for (int j = 0; j < items.size(); ++j) { 5903 QGraphicsObject *item = items.at(j)->toGraphicsObject(); 5904 if (!item) 5905 continue; 5906 QGraphicsItemPrivate *d = item->QGraphicsItem::d_func(); 5907 if (d->gestureContext.contains(gestureType)) { 5908 result.append(item); 5922 QGraphicsItem *item = items.at(j); 5923 5924 // Check if the item is blocked by a modal panel and use it as 5925 // a target instead of this item. 5926 (void) item->isBlockedByModalPanel(&item); 5927 5928 if (QGraphicsObject *itemobj = item->toGraphicsObject()) { 5929 QGraphicsItemPrivate *d = item->d_func(); 5930 if (d->gestureContext.contains(gestureType)) { 5931 result.append(itemobj); 5932 } 5909 5933 } 5934 // Don't propagate through panels. 5935 if (item->isPanel()) 5936 break; 5910 5937 } 5911 5938 DEBUG() << "QGraphicsScenePrivate::getGestureTargets:" -
trunk/src/gui/graphicsview/qgraphicsscene_p.h
r651 r769 223 223 224 224 void markDirty(QGraphicsItem *item, const QRectF &rect = QRectF(), bool invalidateChildren = false, 225 bool force = false, bool ignoreOpacity = false, bool removingItemFromScene = false); 225 bool force = false, bool ignoreOpacity = false, bool removingItemFromScene = false, 226 bool updateBoundingRect = false); 226 227 void processDirtyItemsRecursive(QGraphicsItem *item, bool dirtyAncestorContainsChildren = false, 227 228 qreal parentOpacity = qreal(1.0)); -
trunk/src/gui/graphicsview/qgraphicssceneevent.h
r651 r769 78 78 QScopedPointer<QGraphicsSceneEventPrivate> d_ptr; 79 79 Q_DECLARE_PRIVATE(QGraphicsSceneEvent) 80 private: 81 Q_DISABLE_COPY(QGraphicsSceneEvent) 80 82 }; 81 83 … … 125 127 private: 126 128 Q_DECLARE_PRIVATE(QGraphicsSceneMouseEvent) 129 Q_DISABLE_COPY(QGraphicsSceneMouseEvent) 127 130 }; 128 131 … … 157 160 private: 158 161 Q_DECLARE_PRIVATE(QGraphicsSceneWheelEvent) 162 Q_DISABLE_COPY(QGraphicsSceneWheelEvent) 159 163 }; 160 164 … … 185 189 private: 186 190 Q_DECLARE_PRIVATE(QGraphicsSceneContextMenuEvent) 191 Q_DISABLE_COPY(QGraphicsSceneContextMenuEvent) 187 192 }; 188 193 … … 217 222 private: 218 223 Q_DECLARE_PRIVATE(QGraphicsSceneHoverEvent) 224 Q_DISABLE_COPY(QGraphicsSceneHoverEvent) 219 225 }; 220 226 … … 234 240 private: 235 241 Q_DECLARE_PRIVATE(QGraphicsSceneHelpEvent) 242 Q_DISABLE_COPY(QGraphicsSceneHelpEvent) 236 243 }; 237 244 … … 276 283 private: 277 284 Q_DECLARE_PRIVATE(QGraphicsSceneDragDropEvent) 285 Q_DISABLE_COPY(QGraphicsSceneDragDropEvent) 278 286 }; 279 287 … … 282 290 { 283 291 Q_DECLARE_PRIVATE(QGraphicsSceneResizeEvent) 292 Q_DISABLE_COPY(QGraphicsSceneResizeEvent) 284 293 public: 285 294 QGraphicsSceneResizeEvent(); … … 297 306 { 298 307 Q_DECLARE_PRIVATE(QGraphicsSceneMoveEvent) 308 Q_DISABLE_COPY(QGraphicsSceneMoveEvent) 299 309 public: 300 310 QGraphicsSceneMoveEvent(); -
trunk/src/gui/graphicsview/qgraphicsview.cpp
r651 r769 3361 3361 if (viewTransformed) 3362 3362 backgroundPainter.setTransform(viewTransform); 3363 #ifdef Q_WS_X113364 #undef X113365 if (backgroundPainter.paintEngine()->type() != QPaintEngine::X11)3366 #define X11 qt_x11Data3367 #endif3368 backgroundPainter.setCompositionMode(QPainter::CompositionMode_Source);3369 3363 QRectF backgroundExposedSceneRect = mapToScene(d->backgroundPixmapExposed.boundingRect()).boundingRect(); 3370 3364 drawBackground(&backgroundPainter, backgroundExposedSceneRect); … … 3401 3395 painter.setWorldTransform(viewTransform); 3402 3396 } else { 3397 // Make sure we don't have unpolished items before we draw 3398 if (!d->scene->d_func()->unpolishedItems.isEmpty()) 3399 d->scene->d_func()->_q_polishItems(); 3400 // We reset updateAll here (after we've issued polish events) 3401 // so that we can discard update requests coming from polishEvent(). 3402 d->scene->d_func()->updateAll = false; 3403 3403 3404 // Find all exposed items 3404 3405 bool allItems = false; … … 3409 3410 QGraphicsItem **itemArray = &itemList[0]; // Relies on QList internals, but is perfectly valid. 3410 3411 QStyleOptionGraphicsItem *styleOptionArray = d->allocStyleOptionsArray(numItems); 3412 QTransform transform(Qt::Uninitialized); 3411 3413 for (int i = 0; i < numItems; ++i) { 3412 itemArray[i]->d_ptr->initStyleOption(&styleOptionArray[i], viewTransform, 3413 d->exposedRegion, allItems); 3414 QGraphicsItem *item = itemArray[i]; 3415 QGraphicsItemPrivate *itemd = item->d_ptr.data(); 3416 itemd->initStyleOption(&styleOptionArray[i], viewTransform, d->exposedRegion, allItems); 3417 // Cache the item's area in view coordinates. 3418 // Note that we have to do this here in case the base class implementation 3419 // (QGraphicsScene::drawItems) is not called. If it is, we'll do this 3420 // operation twice, but that's the price one has to pay for using indirect 3421 // painting :-/. 3422 const QRectF brect = adjustedItemEffectiveBoundingRect(item); 3423 if (!itemd->itemIsUntransformable()) { 3424 transform = item->sceneTransform(); 3425 if (viewTransformed) 3426 transform *= viewTransform; 3427 } else { 3428 transform = item->deviceTransform(viewTransform); 3429 } 3430 itemd->paintedViewBoundingRects.insert(d->viewport, transform.mapRect(brect).toRect()); 3414 3431 } 3415 3432 // Draw the items. … … 3610 3627 3611 3628 /*! 3629 \obsolete 3630 3612 3631 Draws the items \a items in the scene using \a painter, after the 3613 3632 background and before the foreground are drawn. \a numItems is the number … … 3618 3637 The default implementation calls the scene's drawItems() function. 3619 3638 3620 \obsoleteSince Qt 4.6, this function is not called anymore unless3639 Since Qt 4.6, this function is not called anymore unless 3621 3640 the QGraphicsView::IndirectPainting flag is given as an Optimization 3622 3641 flag. -
trunk/src/gui/graphicsview/qgraphicsview_p.h
r651 r769 184 184 QCoreApplication::sendPostedEvents(viewport->window(), QEvent::UpdateRequest); 185 185 #else 186 QCoreApplication::processEvents(QEventLoop::AllEvents | QEventLoop::ExcludeSocketNotifiers 187 | QEventLoop::ExcludeUserInputEvents); 186 // At this point either HIViewSetNeedsDisplay (Carbon) or setNeedsDisplay: YES (Cocoa) 187 // is called, which means there's a pending update request. We want to dispatch it 188 // now because otherwise graphics view updates would require two 189 // round-trips in the event loop before the item is painted. 190 extern void qt_mac_dispatchPendingUpdateRequests(QWidget *); 191 qt_mac_dispatchPendingUpdateRequests(viewport->window()); 188 192 #endif 189 193 } -
trunk/src/gui/graphicsview/qgraphicswidget.cpp
r651 r769 335 335 a move event and a resize event. Also, if the widget has a layout 336 336 assigned, the layout will activate. 337 337 338 338 \sa geometry(), resize() 339 339 */ … … 563 563 { 564 564 Q_D(QGraphicsWidget); 565 if ((d->windowFlags & Qt::Window) && (d->windowFlags & Qt::WindowType_Mask) != Qt::Popup && 565 if ((d->windowFlags & Qt::Window) && (d->windowFlags & Qt::WindowType_Mask) != Qt::Popup && 566 566 (d->windowFlags & Qt::WindowType_Mask) != Qt::ToolTip && !(d->windowFlags & Qt::FramelessWindowHint)) { 567 567 QStyleOptionTitleBar bar; … … 1045 1045 break; 1046 1046 case ItemPositionHasChanged: 1047 if (!d->inSetGeometry) { 1048 d->inSetPos = 1; 1049 // Ensure setGeometry is called (avoid recursion when setPos is 1050 // called from within setGeometry). 1051 setGeometry(QRectF(pos(), size())); 1052 d->inSetPos = 0 ; 1053 } 1047 d->setGeometryFromSetPos(); 1054 1048 break; 1055 1049 case ItemParentChange: { … … 1068 1062 break; 1069 1063 } 1070 case ItemCursor Change: {1064 case ItemCursorHasChanged: { 1071 1065 // Deliver CursorChange. 1072 1066 QEvent event(QEvent::CursorChange); … … 1074 1068 break; 1075 1069 } 1076 case ItemToolTip Change: {1070 case ItemToolTipHasChanged: { 1077 1071 // Deliver ToolTipChange. 1078 1072 QEvent event(QEvent::ToolTipChange); … … 1140 1134 Returns true if \a event has been recognized and processed; otherwise, 1141 1135 returns false. 1142 1136 1143 1137 \sa event() 1144 1138 */ … … 1197 1191 if (!r.contains(pos)) 1198 1192 return Qt::NoSection; 1199 1193 1200 1194 const qreal left = r.left(); 1201 1195 const qreal top = r.top(); … … 2323 2317 2324 2318 QT_END_NAMESPACE 2325 2319 2326 2320 #endif //QT_NO_GRAPHICSVIEW -
trunk/src/gui/graphicsview/qgraphicswidget_p.cpp
r651 r769 826 826 } 827 827 828 void QGraphicsWidgetPrivate::setGeometryFromSetPos() 829 { 830 if (inSetGeometry) 831 return; 832 Q_Q(QGraphicsWidget); 833 inSetPos = 1; 834 // Ensure setGeometry is called (avoid recursion when setPos is 835 // called from within setGeometry). 836 q->setGeometry(QRectF(pos, q->size())); 837 inSetPos = 0 ; 838 } 839 828 840 QT_END_NAMESPACE 829 841 -
trunk/src/gui/graphicsview/qgraphicswidget_p.h
r651 r769 130 130 void windowFrameHoverLeaveEvent(QGraphicsSceneHoverEvent *event); 131 131 bool hasDecoration() const; 132 133 void setGeometryFromSetPos(); 132 134 133 135 // State
Note:
See TracChangeset
for help on using the changeset viewer.