src/gui/graphicsview/qgraphicsitem_p.h
branchRCL_3
changeset 5 d3bac044e0f0
parent 4 3b1da2848fc7
child 8 3f74d0d4af4c
equal deleted inserted replaced
4:3b1da2848fc7 5:d3bac044e0f0
   151         isWidget(0),
   151         isWidget(0),
   152         dirty(0),
   152         dirty(0),
   153         dirtyChildren(0),
   153         dirtyChildren(0),
   154         localCollisionHack(0),
   154         localCollisionHack(0),
   155         inSetPosHelper(0),
   155         inSetPosHelper(0),
   156         needSortChildren(1), // ### can be 0 by default?
   156         needSortChildren(0),
   157         allChildrenDirty(0),
   157         allChildrenDirty(0),
   158         fullUpdatePending(0),
   158         fullUpdatePending(0),
   159         flags(0),
   159         flags(0),
   160         dirtyChildrenBoundingRect(1),
   160         dirtyChildrenBoundingRect(1),
   161         paintedViewBoundingRectsNeedRepaint(0),
   161         paintedViewBoundingRectsNeedRepaint(0),
   176         wantsActive(0),
   176         wantsActive(0),
   177         holesInSiblingIndex(0),
   177         holesInSiblingIndex(0),
   178         sequentialOrdering(1),
   178         sequentialOrdering(1),
   179         updateDueToGraphicsEffect(0),
   179         updateDueToGraphicsEffect(0),
   180         scenePosDescendants(0),
   180         scenePosDescendants(0),
       
   181         pendingPolish(0),
       
   182         mayHaveChildWithGraphicsEffect(0),
   181         globalStackingOrder(-1),
   183         globalStackingOrder(-1),
   182         q_ptr(0)
   184         q_ptr(0)
   183     {
   185     {
   184     }
   186     }
   185 
   187 
   193     static QGraphicsItemPrivate *get(QGraphicsItem *item)
   195     static QGraphicsItemPrivate *get(QGraphicsItem *item)
   194     {
   196     {
   195         return item->d_ptr.data();
   197         return item->d_ptr.data();
   196     }
   198     }
   197 
   199 
       
   200     void updateChildWithGraphicsEffectFlagRecursively();
   198     void updateAncestorFlag(QGraphicsItem::GraphicsItemFlag childFlag,
   201     void updateAncestorFlag(QGraphicsItem::GraphicsItemFlag childFlag,
   199                             AncestorFlag flag = NoFlag, bool enabled = false, bool root = true);
   202                             AncestorFlag flag = NoFlag, bool enabled = false, bool root = true);
       
   203     void updateAncestorFlags();
   200     void setIsMemberOfGroup(bool enabled);
   204     void setIsMemberOfGroup(bool enabled);
   201     void remapItemPos(QEvent *event, QGraphicsItem *item);
   205     void remapItemPos(QEvent *event, QGraphicsItem *item);
   202     QPointF genericMapFromScene(const QPointF &pos, const QWidget *viewport) const;
   206     QPointF genericMapFromScene(const QPointF &pos, const QWidget *viewport) const;
   203     inline bool itemIsUntransformable() const
   207     inline bool itemIsUntransformable() const
   204     {
   208     {
   221     void setEnabledHelper(bool newEnabled, bool explicitly, bool update = true);
   225     void setEnabledHelper(bool newEnabled, bool explicitly, bool update = true);
   222     bool discardUpdateRequest(bool ignoreVisibleBit = false,
   226     bool discardUpdateRequest(bool ignoreVisibleBit = false,
   223                               bool ignoreDirtyBit = false, bool ignoreOpacity = false) const;
   227                               bool ignoreDirtyBit = false, bool ignoreOpacity = false) const;
   224     int depth() const;
   228     int depth() const;
   225 #ifndef QT_NO_GRAPHICSEFFECT
   229 #ifndef QT_NO_GRAPHICSEFFECT
   226     void invalidateGraphicsEffectsRecursively();
   230     enum InvalidateReason {
       
   231         OpacityChanged
       
   232     };
       
   233     void invalidateParentGraphicsEffectsRecursively();
       
   234     void invalidateChildGraphicsEffectsRecursively(InvalidateReason reason);
   227 #endif //QT_NO_GRAPHICSEFFECT
   235 #endif //QT_NO_GRAPHICSEFFECT
   228     void invalidateDepthRecursively();
   236     void invalidateDepthRecursively();
   229     void resolveDepth();
   237     void resolveDepth();
   230     void addChild(QGraphicsItem *child);
   238     void addChild(QGraphicsItem *child);
   231     void removeChild(QGraphicsItem *child);
   239     void removeChild(QGraphicsItem *child);
   232     void setParentItemHelper(QGraphicsItem *parent);
   240     void setParentItemHelper(QGraphicsItem *parent, const QVariant *newParentVariant,
       
   241                              const QVariant *thisPointerVariant);
   233     void childrenBoundingRectHelper(QTransform *x, QRectF *rect);
   242     void childrenBoundingRectHelper(QTransform *x, QRectF *rect);
   234     void initStyleOption(QStyleOptionGraphicsItem *option, const QTransform &worldTransform,
   243     void initStyleOption(QStyleOptionGraphicsItem *option, const QTransform &worldTransform,
   235                          const QRegion &exposedRegion, bool allItems = false) const;
   244                          const QRegion &exposedRegion, bool allItems = false) const;
   236     QRectF effectiveBoundingRect() const;
   245     QRectF effectiveBoundingRect() const;
   237     QRectF sceneEffectiveBoundingRect() const;
   246     QRectF sceneEffectiveBoundingRect() const;
   394 
   403 
   395     inline bool isInvisible() const
   404     inline bool isInvisible() const
   396     {
   405     {
   397         return !visible || (childrenCombineOpacity() && isFullyTransparent());
   406         return !visible || (childrenCombineOpacity() && isFullyTransparent());
   398     }
   407     }
       
   408 
       
   409     inline void markParentDirty(bool updateBoundingRect = false);
   399 
   410 
   400     void setFocusHelper(Qt::FocusReason focusReason, bool climb);
   411     void setFocusHelper(Qt::FocusReason focusReason, bool climb);
   401     void setSubFocus(QGraphicsItem *rootItem = 0);
   412     void setSubFocus(QGraphicsItem *rootItem = 0);
   402     void clearSubFocus(QGraphicsItem *rootItem = 0);
   413     void clearSubFocus(QGraphicsItem *rootItem = 0);
   403     void resetFocusProxy();
   414     void resetFocusProxy();
   482     quint32 wantsActive : 1;
   493     quint32 wantsActive : 1;
   483     quint32 holesInSiblingIndex : 1;
   494     quint32 holesInSiblingIndex : 1;
   484     quint32 sequentialOrdering : 1;
   495     quint32 sequentialOrdering : 1;
   485     quint32 updateDueToGraphicsEffect : 1;
   496     quint32 updateDueToGraphicsEffect : 1;
   486     quint32 scenePosDescendants : 1;
   497     quint32 scenePosDescendants : 1;
       
   498     quint32 pendingPolish : 1;
       
   499     quint32 mayHaveChildWithGraphicsEffect : 1;
   487 
   500 
   488     // Optional stacking order
   501     // Optional stacking order
   489     int globalStackingOrder;
   502     int globalStackingOrder;
   490     QGraphicsItem *q_ptr;
   503     QGraphicsItem *q_ptr;
   491 };
   504 };
   719     \internal
   732     \internal
   720 */
   733 */
   721 inline void QGraphicsItemPrivate::ensureSortedChildren()
   734 inline void QGraphicsItemPrivate::ensureSortedChildren()
   722 {
   735 {
   723     if (needSortChildren) {
   736     if (needSortChildren) {
   724         qSort(children.begin(), children.end(), qt_notclosestLeaf);
       
   725         needSortChildren = 0;
   737         needSortChildren = 0;
   726         sequentialOrdering = 1;
   738         sequentialOrdering = 1;
       
   739         if (children.isEmpty())
       
   740             return;
       
   741         qSort(children.begin(), children.end(), qt_notclosestLeaf);
   727         for (int i = 0; i < children.size(); ++i) {
   742         for (int i = 0; i < children.size(); ++i) {
   728             if (children[i]->d_ptr->siblingIndex != i) {
   743             if (children.at(i)->d_ptr->siblingIndex != i) {
   729                 sequentialOrdering = 0;
   744                 sequentialOrdering = 0;
   730                 break;
   745                 break;
   731             }
   746             }
   732         }
   747         }
   733     }
   748     }
   739 inline bool QGraphicsItemPrivate::insertionOrder(QGraphicsItem *a, QGraphicsItem *b)
   754 inline bool QGraphicsItemPrivate::insertionOrder(QGraphicsItem *a, QGraphicsItem *b)
   740 {
   755 {
   741     return a->d_ptr->siblingIndex < b->d_ptr->siblingIndex;
   756     return a->d_ptr->siblingIndex < b->d_ptr->siblingIndex;
   742 }
   757 }
   743 
   758 
       
   759 /*!
       
   760     \internal
       
   761 */
       
   762 inline void QGraphicsItemPrivate::markParentDirty(bool updateBoundingRect)
       
   763 {
       
   764     QGraphicsItemPrivate *parentp = this;
       
   765     while (parentp->parent) {
       
   766         parentp = parentp->parent->d_ptr.data();
       
   767         parentp->dirtyChildren = 1;
       
   768 
       
   769         if (updateBoundingRect) {
       
   770             parentp->dirtyChildrenBoundingRect = 1;
       
   771             // ### Only do this if the parent's effect applies to the entire subtree.
       
   772             parentp->notifyBoundingRectChanged = 1;
       
   773         }
       
   774 #ifndef QT_NO_GRAPHICSEFFECT
       
   775         if (parentp->graphicsEffect) {
       
   776             if (updateBoundingRect) {
       
   777                 parentp->notifyInvalidated = 1;
       
   778                 static_cast<QGraphicsItemEffectSourcePrivate *>(parentp->graphicsEffect->d_func()
       
   779                                                                 ->source->d_func())->invalidateCache();
       
   780             }
       
   781             if (parentp->graphicsEffect->isEnabled()) {
       
   782                 parentp->dirty = 1;
       
   783                 parentp->fullUpdatePending = 1;
       
   784             }
       
   785         }
       
   786 #endif
       
   787     }
       
   788 }
       
   789 
   744 QT_END_NAMESPACE
   790 QT_END_NAMESPACE
   745 
   791 
   746 #endif // QT_NO_GRAPHICSVIEW
   792 #endif // QT_NO_GRAPHICSVIEW
   747 
   793 
   748 #endif
   794 #endif