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:
2 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();
Note: See TracChangeset for help on using the changeset viewer.