src/gui/graphicsview/qgraphicsitem_p.h
changeset 19 fcece45ef507
parent 18 2f34d5167611
child 22 79de32ba3296
equal deleted inserted replaced
18:2f34d5167611 19:fcece45ef507
    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;
   412         return !visible || (childrenCombineOpacity() && isFullyTransparent());
   469         return !visible || (childrenCombineOpacity() && isFullyTransparent());
   413     }
   470     }
   414 
   471 
   415     inline void markParentDirty(bool updateBoundingRect = false);
   472     inline void markParentDirty(bool updateBoundingRect = false);
   416 
   473 
   417     void setFocusHelper(Qt::FocusReason focusReason, bool climb);
   474     void setFocusHelper(Qt::FocusReason focusReason, bool climb, bool focusFromShow);
       
   475     void clearFocusHelper(bool giveFocusToParent);
   418     void setSubFocus(QGraphicsItem *rootItem = 0);
   476     void setSubFocus(QGraphicsItem *rootItem = 0);
   419     void clearSubFocus(QGraphicsItem *rootItem = 0);
   477     void clearSubFocus(QGraphicsItem *rootItem = 0);
   420     void resetFocusProxy();
   478     void resetFocusProxy();
   421     virtual void subFocusItemChange();
   479     virtual void subFocusItemChange();
   422 
   480 
   423     inline QTransform transformToParent() const;
   481     inline QTransform transformToParent() const;
   424     inline void ensureSortedChildren();
   482     inline void ensureSortedChildren();
       
   483     static void append(QDeclarativeListProperty<QGraphicsObject> *list, QGraphicsObject *item);
   425     static inline bool insertionOrder(QGraphicsItem *a, QGraphicsItem *b);
   484     static inline bool insertionOrder(QGraphicsItem *a, QGraphicsItem *b);
   426     void ensureSequentialSiblingIndex();
   485     void ensureSequentialSiblingIndex();
   427     inline void sendScenePosChange();
   486     inline void sendScenePosChange();
   428     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();
   429 
   497 
   430     QRectF childrenBoundingRect;
   498     QRectF childrenBoundingRect;
   431     QRectF needsRepaint;
   499     QRectF needsRepaint;
   432     QMap<QWidget *, QRect> paintedViewBoundingRects;
   500     QMap<QWidget *, QRect> paintedViewBoundingRects;
   433     QPointF pos;
   501     QPointF pos;