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 |
73 |
129 |
74 class QGraphicsItemCache |
130 class QGraphicsItemCache |
75 { |
131 { |
76 public: |
132 public: |
77 QGraphicsItemCache() : allExposed(false) { } |
133 QGraphicsItemCache() : allExposed(false) { } |
235 #endif //QT_NO_GRAPHICSEFFECT |
291 #endif //QT_NO_GRAPHICSEFFECT |
236 void invalidateDepthRecursively(); |
292 void invalidateDepthRecursively(); |
237 void resolveDepth(); |
293 void resolveDepth(); |
238 void addChild(QGraphicsItem *child); |
294 void addChild(QGraphicsItem *child); |
239 void removeChild(QGraphicsItem *child); |
295 void removeChild(QGraphicsItem *child); |
|
296 QDeclarativeListProperty<QGraphicsObject> childrenList(); |
240 void setParentItemHelper(QGraphicsItem *parent, const QVariant *newParentVariant, |
297 void setParentItemHelper(QGraphicsItem *parent, const QVariant *newParentVariant, |
241 const QVariant *thisPointerVariant); |
298 const QVariant *thisPointerVariant); |
242 void childrenBoundingRectHelper(QTransform *x, QRectF *rect); |
299 void childrenBoundingRectHelper(QTransform *x, QRectF *rect); |
243 void initStyleOption(QStyleOptionGraphicsItem *option, const QTransform &worldTransform, |
300 void initStyleOption(QStyleOptionGraphicsItem *option, const QTransform &worldTransform, |
244 const QRegion &exposedRegion, bool allItems = false) const; |
301 const QRegion &exposedRegion, bool allItems = false) const; |
356 myFlags = parentFlags; |
413 myFlags = parentFlags; |
357 } |
414 } |
358 return o; |
415 return o; |
359 } |
416 } |
360 |
417 |
|
418 inline bool isOpacityNull() const |
|
419 { return (opacity < qreal(0.001)); } |
|
420 |
|
421 static inline bool isOpacityNull(qreal opacity) |
|
422 { return (opacity < qreal(0.001)); } |
|
423 |
361 inline bool isFullyTransparent() const |
424 inline bool isFullyTransparent() const |
362 { |
425 { |
363 if (opacity < 0.001) |
426 if (isOpacityNull()) |
364 return true; |
427 return true; |
365 if (!parent) |
428 if (!parent) |
366 return false; |
429 return false; |
367 |
430 |
368 return calcEffectiveOpacity() < 0.001; |
431 return isOpacityNull(calcEffectiveOpacity()); |
369 } |
432 } |
370 |
433 |
371 inline qreal effectiveOpacity() const { |
434 inline qreal effectiveOpacity() const { |
372 if (!parent || !opacity) |
435 if (!parent || !opacity) |
373 return opacity; |
436 return opacity; |
406 return !visible || (childrenCombineOpacity() && isFullyTransparent()); |
469 return !visible || (childrenCombineOpacity() && isFullyTransparent()); |
407 } |
470 } |
408 |
471 |
409 inline void markParentDirty(bool updateBoundingRect = false); |
472 inline void markParentDirty(bool updateBoundingRect = false); |
410 |
473 |
411 void setFocusHelper(Qt::FocusReason focusReason, bool climb); |
474 void setFocusHelper(Qt::FocusReason focusReason, bool climb, bool focusFromShow); |
|
475 void clearFocusHelper(bool giveFocusToParent); |
412 void setSubFocus(QGraphicsItem *rootItem = 0); |
476 void setSubFocus(QGraphicsItem *rootItem = 0); |
413 void clearSubFocus(QGraphicsItem *rootItem = 0); |
477 void clearSubFocus(QGraphicsItem *rootItem = 0); |
414 void resetFocusProxy(); |
478 void resetFocusProxy(); |
415 virtual void subFocusItemChange(); |
479 virtual void subFocusItemChange(); |
416 |
480 |
417 inline QTransform transformToParent() const; |
481 inline QTransform transformToParent() const; |
418 inline void ensureSortedChildren(); |
482 inline void ensureSortedChildren(); |
|
483 static void append(QDeclarativeListProperty<QGraphicsObject> *list, QGraphicsObject *item); |
419 static inline bool insertionOrder(QGraphicsItem *a, QGraphicsItem *b); |
484 static inline bool insertionOrder(QGraphicsItem *a, QGraphicsItem *b); |
420 void ensureSequentialSiblingIndex(); |
485 void ensureSequentialSiblingIndex(); |
421 inline void sendScenePosChange(); |
486 inline void sendScenePosChange(); |
422 virtual void siblingOrderChange(); |
487 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(); |
423 |
497 |
424 QRectF childrenBoundingRect; |
498 QRectF childrenBoundingRect; |
425 QRectF needsRepaint; |
499 QRectF needsRepaint; |
426 QMap<QWidget *, QRect> paintedViewBoundingRects; |
500 QMap<QWidget *, QRect> paintedViewBoundingRects; |
427 QPointF pos; |
501 QPointF pos; |