Ignore:
Timestamp:
Aug 2, 2010, 9:27:30 PM (15 years ago)
Author:
Dmitry A. Kuminov
Message:

trunk: Merged in qt 4.6.3 sources from branches/vendor/nokia/qt.

Location:
trunk
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/src/gui/graphicsview/qgraphicsitem.cpp

    r651 r769  
    320320
    321321    \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
    323323    shape. It is disabled by default. This behavior is enforced by
    324324    QGraphicsView::drawItems() or QGraphicsScene::drawItems(). This flag was
     
    358358    this flag, the child will be stacked behind it. This flag is useful for
    359359    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.
    361362
    362363    \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
    370373    and always initialized to 1. Use
    371     QStyleOptionGraphicsItem::levelOfDetailFromTransform() if you need a higher
    372     value.
     374    QStyleOptionGraphicsItem::levelOfDetailFromTransform() if you need
     375    a higher value. This flag was introduced in Qt 4.6.
    373376
    374377    \value ItemHasNoContents The item does not paint anything (i.e., calling
     
    388391    This flag was introduced in Qt 4.6.
    389392
    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.
    393397
    394398    \value ItemIsPanel The item is a panel. A panel provides activation and
     
    410414/*!
    411415    \enum QGraphicsItem::GraphicsItemChange
    412 
    413         ItemVisibleHasChanged,
    414         ItemEnabledHasChanged,
    415         ItemSelectedHasChanged,
    416         ItemParentHasChanged,
    417         ItemSceneHasChanged
    418416
    419417    This enum describes the state changes that are notified by
     
    644642
    645643    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.
    649654
    650655    \sa QGraphicsItem::setPanelModality(), QGraphicsItem::panelModality(), QGraphicsItem::ItemIsPanel
     
    11261131    }
    11271132
     1133    // Resolve depth.
     1134    invalidateDepthRecursively();
     1135
    11281136    if ((parent = newParent)) {
    11291137        if (parent->d_func()->scene && parent->d_func()->scene != scene) {
     
    11761184    }
    11771185
    1178     // Resolve depth.
    1179     invalidateDepthRecursively();
    11801186    dirtySceneTransform = 1;
    11811187
     
    13931399    delete d_ptr->transformData;
    13941400
    1395     qt_dataStore()->data.remove(this);
     1401    if (QGraphicsItemCustomDataStore *dataStore = qt_dataStore())
     1402        dataStore->data.remove(this);
    13961403}
    13971404
     
    15711578
    15721579/*!
    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()
    15841592*/
    15851593void QGraphicsItem::setParentItem(QGraphicsItem *newParent)
     
    18761884    bool noVisualChange = (mode == NoCache && lastMode == NoCache)
    18771885                          || (mode == NoCache && lastMode == DeviceCoordinateCache)
    1878                           || (mode == DeviceCoordinateCache && lastMode == NoCache);
     1886                          || (mode == DeviceCoordinateCache && lastMode == NoCache)
     1887                          || (mode == DeviceCoordinateCache && lastMode == DeviceCoordinateCache);
    18791888    if (mode == NoCache) {
    18801889        d_ptr->removeExtraItemCache();
     
    21702179        if (c)
    21712180            c->purge();
    2172         if (scene)
     2181        if (scene) {
     2182#ifndef QT_NO_GRAPHICSEFFECT
     2183            invalidateParentGraphicsEffectsRecursively();
     2184#endif //QT_NO_GRAPHICSEFFECT
    21732185            scene->d_func()->markDirty(q_ptr, QRectF(), /*invalidateChildren=*/false, /*force=*/true);
     2186        }
    21742187    }
    21752188
    21762189    // Certain properties are dropped as an item becomes invisible.
     2190    bool hasFocus = q_ptr->hasFocus();
    21772191    if (!newVisible) {
    21782192        if (scene) {
     
    21842198                scene->d_func()->leaveModal(q_ptr);
    21852199        }
    2186         if (q_ptr->hasFocus() && scene) {
     2200        if (hasFocus && scene) {
    21872201            // Hiding the closest non-panel ancestor of the focus item
    21882202            QGraphicsItem *focusItem = scene->focusItem();
     
    21972211            }
    21982212            if (clear)
    2199                 q_ptr->clearFocus();
     2213                clearFocusHelper(/* giveFocusToParent = */ false);
    22002214        }
    22012215        if (q_ptr->isSelected())
     
    22352249
    22362250    // 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;
    22482267                }
    2249                 break;
     2268                p = p->d_ptr->parent;
    22502269            }
    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                }
    22572290            }
    22582291        }
     
    31053138void QGraphicsItem::setFocus(Qt::FocusReason focusReason)
    31063139{
    3107     d_ptr->setFocusHelper(focusReason, /* climb = */ true);
     3140    d_ptr->setFocusHelper(focusReason, /* climb = */ true, /* focusFromShow = */ false);
    31083141}
    31093142
     
    31113144    \internal
    31123145*/
    3113 void QGraphicsItemPrivate::setFocusHelper(Qt::FocusReason focusReason, bool climb)
     3146void QGraphicsItemPrivate::setFocusHelper(Qt::FocusReason focusReason, bool climb, bool focusFromShow)
    31143147{
    31153148    // Disabled / unfocusable items cannot accept focus.
     
    31313164        if (p->flags() & QGraphicsItem::ItemIsFocusScope) {
    31323165            p->d_ptr->focusScopeItem = q_ptr;
    3133             if (!p->focusItem()) {
     3166            if (!p->focusItem() && !focusFromShow) {
    31343167                // If you call setFocus on a child of a focus scope that
    31353168                // doesn't currently have a focus item, then stop.
     
    31723205void QGraphicsItem::clearFocus()
    31733206{
    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*/
     3213void 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;
    31813226            }
    3182             p = p->d_ptr->parent;
    31833227        }
    31843228    }
    31853229
    31863230    // 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()) {
    31903234        // If this item has the scene's input focus, clear it.
    3191         d_ptr->scene->setFocusItem(0);
     3235        scene->setFocusItem(0);
    31923236    }
    31933237}
     
    35353579    if (!(d_ptr->flags & ItemSendsGeometryChanges)) {
    35363580        d_ptr->setPosHelper(pos);
     3581        if (d_ptr->isWidget)
     3582            static_cast<QGraphicsWidget *>(this)->d_func()->setGeometryFromSetPos();
    35373583        return;
    35383584    }
     
    72577303        QGraphicsScenePrivate *scenePrivate = d_ptr->scene->d_func();
    72587304        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);
    72607308
    72617309        // For compatibility reasons, we have to update the item's old geometry
     
    1080210850}
    1080310851
     10852// sourceRect must be in the given coordinate system
    1080410853QRect QGraphicsItemEffectSourcePrivate::paddedEffectRect(Qt::CoordinateSystem system, QGraphicsEffect::PixmapPadMode mode, const QRectF &sourceRect, bool *unpadded) const
    1080510854{
     
    1081110860    if (mode == QGraphicsEffect::PadToEffectiveBoundingRect) {
    1081210861        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);
    1081410864            if (unpadded)
    1081510865                *unpadded = (effectRectF.size() == sourceRect.size());
     
    1086010910    }
    1086110911
    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     }
    1088610912    if (effectRect.isEmpty())
    1088710913        return QPixmap();
  • trunk/src/gui/graphicsview/qgraphicsitem_p.h

    r651 r769  
    415415    inline void markParentDirty(bool updateBoundingRect = false);
    416416
    417     void setFocusHelper(Qt::FocusReason focusReason, bool climb);
     417    void setFocusHelper(Qt::FocusReason focusReason, bool climb, bool focusFromShow);
     418    void clearFocusHelper(bool giveFocusToParent);
    418419    void setSubFocus(QGraphicsItem *rootItem = 0);
    419420    void clearSubFocus(QGraphicsItem *rootItem = 0);
     
    769770{
    770771    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
    771779    while (parentp->parent) {
    772780        parentp = parentp->parent->d_ptr.data();
  • trunk/src/gui/graphicsview/qgraphicsproxywidget.cpp

    r651 r769  
    190190
    191191extern bool qt_sendSpontaneousEvent(QObject *, QEvent *);
    192 extern bool qt_tab_all_widgets;
     192Q_GUI_EXPORT extern bool qt_tab_all_widgets;
    193193
    194194/*!
     
    898898        break;
    899899    }
     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
    900923    default:
    901924        break;
     
    953976            }
    954977            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;
    955986        default:
    956987            break;
     
    13161347    }
    13171348
     1349    d->proxyIsGivingFocus = true;
     1350
    13181351    switch (event->reason()) {
    13191352    case Qt::TabFocusReason: {
     
    13291362        if (d->widget && d->widget->focusWidget()) {
    13301363            d->widget->focusWidget()->setFocus(event->reason());
    1331             return;
    1332         }
    1333         break;
    1334     }
     1364        }
     1365        break;
     1366    }
     1367
     1368    d->proxyIsGivingFocus = false;
    13351369}
    13361370
     
    14331467
    14341468    // Filter out repaints on the window frame.
    1435     const QRect exposedWidgetRect = (option->exposedRect & rect()).toRect();
     1469    const QRect exposedWidgetRect = (option->exposedRect & rect()).toAlignedRect();
    14361470    if (exposedWidgetRect.isEmpty())
    14371471        return;
  • trunk/src/gui/graphicsview/qgraphicsproxywidget_p.h

    r651 r769  
    7373          styleChangeMode(NoMode),
    7474          paletteChangeMode(NoMode),
     75          tooltipChangeMode(NoMode),
    7576          focusFromWidgetToProxy(0)
    7677    { }
     
    118119    quint32 styleChangeMode : 2;
    119120    quint32 paletteChangeMode : 2;
     121    quint32 tooltipChangeMode : 2;
    120122    quint32 focusFromWidgetToProxy : 1;
     123    quint32 proxyIsGivingFocus : 1;
    121124};
    122125
  • trunk/src/gui/graphicsview/qgraphicsscene.cpp

    r651 r769  
    694694    if (!selectionChanging && selectedItems.size() != oldSelectedItemsSize)
    695695        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    }
    696704}
    697705
     
    802810            if (item) {
    803811                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();
    805814            }
    806815        }
     
    808817    }
    809818
     819    if (item)
     820        focusItem = item;
     821    updateInputMethodSensitivityInViews();
    810822    if (item) {
    811         focusItem = item;
    812823        QFocusEvent event(QEvent::FocusIn, focusReason);
    813824        sendEvent(item, &event);
    814825    }
    815 
    816     updateInputMethodSensitivityInViews();
    817826}
    818827
     
    37723781    for (int i = 0; i < itemsAtPos.size(); ++i) {
    37733782        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        }
    37743789        if (!tmp->toolTip().isEmpty()) {
    37753790            toolTipItem = tmp;
     
    42854300        // Blit the subpixmap into the main pixmap.
    42864301        pixmapPainter.begin(pix);
     4302        pixmapPainter.setCompositionMode(QPainter::CompositionMode_Source);
    42874303        pixmapPainter.setClipRegion(pixmapExposed);
    42884304        pixmapPainter.drawPixmap(br.topLeft(), subPix);
     
    44504466
    44514467        // 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.
    44524470        bool pixModified = false;
    44534471        QGraphicsItemCache::DeviceData *deviceData = &itemCache->deviceData[widget];
     
    44574475            diff *= painter->worldTransform();
    44584476        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) {
    44604480            pixModified = true;
    44614481            itemCache->allExposed = true;
     
    46794699            item->d_ptr->paintedViewBoundingRects.insert(widget, viewBoundingRect);
    46804700        viewBoundingRect.adjust(-1, -1, 1, 1);
    4681         drawItem = exposedRegion ? exposedRegion->intersects(viewBoundingRect) : !viewBoundingRect.isEmpty();
     4701        drawItem = exposedRegion ? exposedRegion->intersects(viewBoundingRect)
     4702                                 : !viewBoundingRect.normalized().isEmpty();
    46824703        if (!drawItem) {
    46834704            if (!itemHasChildren)
     
    47134734            && sourced->lastEffectTransform != painter->worldTransform())
    47144735        {
    4715             bool unclipped = false;
    47164736            if (sourced->lastEffectTransform.type() <= QTransform::TxTranslate
    47174737                && painter->worldTransform().type() <= QTransform::TxTranslate)
    47184738            {
    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);
    47344745            }
    47354746
    47364747            sourced->lastEffectTransform = painter->worldTransform();
    4737 
    4738             if (!unclipped)
    4739                 sourced->invalidateCache(QGraphicsEffectSourcePrivate::TransformChanged);
    47404748        }
    47414749
     
    48494857
    48504858void 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)
    48524861{
    48534862    Q_ASSERT(item);
     
    49204929        item->d_ptr->ignoreOpacity = 1;
    49214930
    4922     item->d_ptr->markParentDirty();
     4931    if (!updateBoundingRect)
     4932        item->d_ptr->markParentDirty();
    49234933}
    49244934
     
    51315141
    51325142/*!
     5143    \obsolete
     5144
    51335145    Paints the given \a items using the provided \a painter, after the
    51345146    background has been drawn, and before the foreground has been
     
    51535165    \snippet doc/src/snippets/graphicssceneadditemsnippet.cpp 0
    51545166
    5155     \obsolete Since Qt 4.6, this function is not called anymore unless
     5167    Since Qt 4.6, this function is not called anymore unless
    51565168    the QGraphicsView::IndirectPainting flag is given as an Optimization
    51575169    flag.
     
    57095721            bool res = sendTouchBeginEvent(item, &touchEvent)
    57105722                       && 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                }
    57125730                ignoreSceneTouchEvent = false;
     5731            }
    57135732            break;
    57145733        }
     
    59015920            QList<QGraphicsObject *> result;
    59025921            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                    }
    59095933                }
     5934                // Don't propagate through panels.
     5935                if (item->isPanel())
     5936                    break;
    59105937            }
    59115938            DEBUG() << "QGraphicsScenePrivate::getGestureTargets:"
  • trunk/src/gui/graphicsview/qgraphicsscene_p.h

    r651 r769  
    223223
    224224    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);
    226227    void processDirtyItemsRecursive(QGraphicsItem *item, bool dirtyAncestorContainsChildren = false,
    227228                                    qreal parentOpacity = qreal(1.0));
  • trunk/src/gui/graphicsview/qgraphicssceneevent.h

    r651 r769  
    7878    QScopedPointer<QGraphicsSceneEventPrivate> d_ptr;
    7979    Q_DECLARE_PRIVATE(QGraphicsSceneEvent)
     80private:
     81    Q_DISABLE_COPY(QGraphicsSceneEvent)
    8082};
    8183
     
    125127private:
    126128    Q_DECLARE_PRIVATE(QGraphicsSceneMouseEvent)
     129    Q_DISABLE_COPY(QGraphicsSceneMouseEvent)
    127130};
    128131
     
    157160private:
    158161    Q_DECLARE_PRIVATE(QGraphicsSceneWheelEvent)
     162    Q_DISABLE_COPY(QGraphicsSceneWheelEvent)
    159163};
    160164
     
    185189private:
    186190    Q_DECLARE_PRIVATE(QGraphicsSceneContextMenuEvent)
     191    Q_DISABLE_COPY(QGraphicsSceneContextMenuEvent)
    187192};
    188193
     
    217222private:
    218223    Q_DECLARE_PRIVATE(QGraphicsSceneHoverEvent)
     224    Q_DISABLE_COPY(QGraphicsSceneHoverEvent)
    219225};
    220226
     
    234240private:
    235241    Q_DECLARE_PRIVATE(QGraphicsSceneHelpEvent)
     242    Q_DISABLE_COPY(QGraphicsSceneHelpEvent)
    236243};
    237244
     
    276283private:
    277284    Q_DECLARE_PRIVATE(QGraphicsSceneDragDropEvent)
     285    Q_DISABLE_COPY(QGraphicsSceneDragDropEvent)
    278286};
    279287
     
    282290{
    283291    Q_DECLARE_PRIVATE(QGraphicsSceneResizeEvent)
     292    Q_DISABLE_COPY(QGraphicsSceneResizeEvent)
    284293public:
    285294    QGraphicsSceneResizeEvent();
     
    297306{
    298307    Q_DECLARE_PRIVATE(QGraphicsSceneMoveEvent)
     308    Q_DISABLE_COPY(QGraphicsSceneMoveEvent)
    299309public:
    300310    QGraphicsSceneMoveEvent();
  • trunk/src/gui/graphicsview/qgraphicsview.cpp

    r651 r769  
    33613361            if (viewTransformed)
    33623362                backgroundPainter.setTransform(viewTransform);
    3363 #ifdef Q_WS_X11
    3364 #undef X11
    3365             if (backgroundPainter.paintEngine()->type() != QPaintEngine::X11)
    3366 #define X11 qt_x11Data
    3367 #endif
    3368                 backgroundPainter.setCompositionMode(QPainter::CompositionMode_Source);
    33693363            QRectF backgroundExposedSceneRect = mapToScene(d->backgroundPixmapExposed.boundingRect()).boundingRect();
    33703364            drawBackground(&backgroundPainter, backgroundExposedSceneRect);
     
    34013395            painter.setWorldTransform(viewTransform);
    34023396    } 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
    34033404        // Find all exposed items
    34043405        bool allItems = false;
     
    34093410            QGraphicsItem **itemArray = &itemList[0]; // Relies on QList internals, but is perfectly valid.
    34103411            QStyleOptionGraphicsItem *styleOptionArray = d->allocStyleOptionsArray(numItems);
     3412            QTransform transform(Qt::Uninitialized);
    34113413            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());
    34143431            }
    34153432            // Draw the items.
     
    36103627
    36113628/*!
     3629    \obsolete
     3630
    36123631    Draws the items \a items in the scene using \a painter, after the
    36133632    background and before the foreground are drawn. \a numItems is the number
     
    36183637    The default implementation calls the scene's drawItems() function.
    36193638
    3620     \obsolete Since Qt 4.6, this function is not called anymore unless
     3639    Since Qt 4.6, this function is not called anymore unless
    36213640    the QGraphicsView::IndirectPainting flag is given as an Optimization
    36223641    flag.
  • trunk/src/gui/graphicsview/qgraphicsview_p.h

    r651 r769  
    184184            QCoreApplication::sendPostedEvents(viewport->window(), QEvent::UpdateRequest);
    185185#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());
    188192#endif
    189193    }
  • trunk/src/gui/graphicsview/qgraphicswidget.cpp

    r651 r769  
    335335    a move event and a resize event. Also, if the widget has a layout
    336336    assigned, the layout will activate.
    337    
     337
    338338    \sa geometry(), resize()
    339339*/
     
    563563{
    564564    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 &&
    566566         (d->windowFlags & Qt::WindowType_Mask) != Qt::ToolTip && !(d->windowFlags & Qt::FramelessWindowHint)) {
    567567        QStyleOptionTitleBar bar;
     
    10451045        break;
    10461046    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();
    10541048        break;
    10551049    case ItemParentChange: {
     
    10681062        break;
    10691063    }
    1070     case ItemCursorChange: {
     1064    case ItemCursorHasChanged: {
    10711065        // Deliver CursorChange.
    10721066        QEvent event(QEvent::CursorChange);
     
    10741068        break;
    10751069    }
    1076     case ItemToolTipChange: {
     1070    case ItemToolTipHasChanged: {
    10771071        // Deliver ToolTipChange.
    10781072        QEvent event(QEvent::ToolTipChange);
     
    11401134    Returns true if \a event has been recognized and processed; otherwise,
    11411135    returns false.
    1142    
     1136
    11431137    \sa event()
    11441138*/
     
    11971191    if (!r.contains(pos))
    11981192        return Qt::NoSection;
    1199    
     1193
    12001194    const qreal left = r.left();
    12011195    const qreal top = r.top();
     
    23232317
    23242318QT_END_NAMESPACE
    2325        
     2319
    23262320#endif //QT_NO_GRAPHICSVIEW
  • trunk/src/gui/graphicsview/qgraphicswidget_p.cpp

    r651 r769  
    826826}
    827827
     828void 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
    828840QT_END_NAMESPACE
    829841
  • trunk/src/gui/graphicsview/qgraphicswidget_p.h

    r651 r769  
    130130    void windowFrameHoverLeaveEvent(QGraphicsSceneHoverEvent *event);
    131131    bool hasDecoration() const;
     132
     133    void setGeometryFromSetPos();
    132134
    133135    // State
Note: See TracChangeset for help on using the changeset viewer.