68 #if !defined(QT_NO_GRAPHICSVIEW) || (QT_EDITION & QT_MODULE_GRAPHICSVIEW) != QT_MODULE_GRAPHICSVIEW |
68 #if !defined(QT_NO_GRAPHICSVIEW) || (QT_EDITION & QT_MODULE_GRAPHICSVIEW) != QT_MODULE_GRAPHICSVIEW |
69 |
69 |
70 QT_BEGIN_NAMESPACE |
70 QT_BEGIN_NAMESPACE |
71 |
71 |
72 class QGraphicsItemPrivate; |
72 class QGraphicsItemPrivate; |
73 |
|
74 #ifndef QDECLARATIVELISTPROPERTY |
|
75 #define QDECLARATIVELISTPROPERTY |
|
76 template<typename T> |
|
77 struct QDeclarativeListProperty { |
|
78 typedef void (*AppendFunction)(QDeclarativeListProperty<T> *, T*); |
|
79 typedef int (*CountFunction)(QDeclarativeListProperty<T> *); |
|
80 typedef T *(*AtFunction)(QDeclarativeListProperty<T> *, int); |
|
81 typedef void (*ClearFunction)(QDeclarativeListProperty<T> *); |
|
82 |
|
83 QDeclarativeListProperty() |
|
84 : object(0), data(0), append(0), count(0), at(0), clear(0), dummy1(0), dummy2(0) {} |
|
85 QDeclarativeListProperty(QObject *o, QList<T *> &list) |
|
86 : object(o), data(&list), append(qlist_append), count(qlist_count), at(qlist_at), |
|
87 clear(qlist_clear), dummy1(0), dummy2(0) {} |
|
88 QDeclarativeListProperty(QObject *o, void *d, AppendFunction a, CountFunction c = 0, AtFunction t = 0, |
|
89 ClearFunction r = 0) |
|
90 : object(o), data(d), append(a), count(c), at(t), clear(r), dummy1(0), dummy2(0) {} |
|
91 |
|
92 bool operator==(const QDeclarativeListProperty &o) const { |
|
93 return object == o.object && |
|
94 data == o.data && |
|
95 append == o.append && |
|
96 count == o.count && |
|
97 at == o.at && |
|
98 clear == o.clear; |
|
99 } |
|
100 |
|
101 QObject *object; |
|
102 void *data; |
|
103 |
|
104 AppendFunction append; |
|
105 |
|
106 CountFunction count; |
|
107 AtFunction at; |
|
108 |
|
109 ClearFunction clear; |
|
110 |
|
111 void *dummy1; |
|
112 void *dummy2; |
|
113 |
|
114 private: |
|
115 static void qlist_append(QDeclarativeListProperty *p, T *v) { |
|
116 ((QList<T *> *)p->data)->append(v); |
|
117 } |
|
118 static int qlist_count(QDeclarativeListProperty *p) { |
|
119 return ((QList<T *> *)p->data)->count(); |
|
120 } |
|
121 static T *qlist_at(QDeclarativeListProperty *p, int idx) { |
|
122 return ((QList<T *> *)p->data)->at(idx); |
|
123 } |
|
124 static void qlist_clear(QDeclarativeListProperty *p) { |
|
125 return ((QList<T *> *)p->data)->clear(); |
|
126 } |
|
127 }; |
|
128 #endif |
|
129 |
73 |
130 class QGraphicsItemCache |
74 class QGraphicsItemCache |
131 { |
75 { |
132 public: |
76 public: |
133 QGraphicsItemCache() : allExposed(false) { } |
77 QGraphicsItemCache() : allExposed(false) { } |
291 #endif //QT_NO_GRAPHICSEFFECT |
235 #endif //QT_NO_GRAPHICSEFFECT |
292 void invalidateDepthRecursively(); |
236 void invalidateDepthRecursively(); |
293 void resolveDepth(); |
237 void resolveDepth(); |
294 void addChild(QGraphicsItem *child); |
238 void addChild(QGraphicsItem *child); |
295 void removeChild(QGraphicsItem *child); |
239 void removeChild(QGraphicsItem *child); |
296 QDeclarativeListProperty<QGraphicsObject> childrenList(); |
|
297 void setParentItemHelper(QGraphicsItem *parent, const QVariant *newParentVariant, |
240 void setParentItemHelper(QGraphicsItem *parent, const QVariant *newParentVariant, |
298 const QVariant *thisPointerVariant); |
241 const QVariant *thisPointerVariant); |
299 void childrenBoundingRectHelper(QTransform *x, QRectF *rect); |
242 void childrenBoundingRectHelper(QTransform *x, QRectF *rect); |
300 void initStyleOption(QStyleOptionGraphicsItem *option, const QTransform &worldTransform, |
243 void initStyleOption(QStyleOptionGraphicsItem *option, const QTransform &worldTransform, |
301 const QRegion &exposedRegion, bool allItems = false) const; |
244 const QRegion &exposedRegion, bool allItems = false) const; |
478 void resetFocusProxy(); |
421 void resetFocusProxy(); |
479 virtual void subFocusItemChange(); |
422 virtual void subFocusItemChange(); |
480 |
423 |
481 inline QTransform transformToParent() const; |
424 inline QTransform transformToParent() const; |
482 inline void ensureSortedChildren(); |
425 inline void ensureSortedChildren(); |
483 static void append(QDeclarativeListProperty<QGraphicsObject> *list, QGraphicsObject *item); |
|
484 static inline bool insertionOrder(QGraphicsItem *a, QGraphicsItem *b); |
426 static inline bool insertionOrder(QGraphicsItem *a, QGraphicsItem *b); |
485 void ensureSequentialSiblingIndex(); |
427 void ensureSequentialSiblingIndex(); |
486 inline void sendScenePosChange(); |
428 inline void sendScenePosChange(); |
487 virtual void siblingOrderChange(); |
429 virtual void siblingOrderChange(); |
488 |
|
489 // Private Properties |
|
490 virtual qreal width() const; |
|
491 virtual void setWidth(qreal); |
|
492 virtual void resetWidth(); |
|
493 |
|
494 virtual qreal height() const; |
|
495 virtual void setHeight(qreal); |
|
496 virtual void resetHeight(); |
|
497 |
430 |
498 QRectF childrenBoundingRect; |
431 QRectF childrenBoundingRect; |
499 QRectF needsRepaint; |
432 QRectF needsRepaint; |
500 QMap<QWidget *, QRect> paintedViewBoundingRects; |
433 QMap<QWidget *, QRect> paintedViewBoundingRects; |
501 QPointF pos; |
434 QPointF pos; |
834 \internal |
767 \internal |
835 */ |
768 */ |
836 inline void QGraphicsItemPrivate::markParentDirty(bool updateBoundingRect) |
769 inline void QGraphicsItemPrivate::markParentDirty(bool updateBoundingRect) |
837 { |
770 { |
838 QGraphicsItemPrivate *parentp = this; |
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 |
839 while (parentp->parent) { |
779 while (parentp->parent) { |
840 parentp = parentp->parent->d_ptr.data(); |
780 parentp = parentp->parent->d_ptr.data(); |
841 parentp->dirtyChildren = 1; |
781 parentp->dirtyChildren = 1; |
842 |
782 |
843 if (updateBoundingRect) { |
783 if (updateBoundingRect) { |