From 92bca69c15898dd504f96e18227a22566038154a Mon Sep 17 00:00:00 2001 From: "Eduardo M. Fleury" Date: Mon, 22 Jun 2009 12:27:31 -0300 Subject: QGraphicsAnchorLayout: Fix QGraphicsItem reparent code Using QGraphicsLayoutPrivate methods for proper reparenting of items. This makes it work in cases where nested layouts are used. Signed-off-by: Eduardo M. Fleury --- src/gui/graphicsview/qgraphicsanchorlayout.cpp | 4 ++-- src/gui/graphicsview/qgraphicsanchorlayout.h | 3 +-- src/gui/graphicsview/qgraphicsanchorlayout_p.cpp | 30 ------------------------ src/gui/graphicsview/qgraphicsanchorlayout_p.h | 4 ---- 4 files changed, 3 insertions(+), 38 deletions(-) diff --git a/src/gui/graphicsview/qgraphicsanchorlayout.cpp b/src/gui/graphicsview/qgraphicsanchorlayout.cpp index 1a72ace..a86626b 100644 --- a/src/gui/graphicsview/qgraphicsanchorlayout.cpp +++ b/src/gui/graphicsview/qgraphicsanchorlayout.cpp @@ -105,11 +105,11 @@ void QGraphicsAnchorLayout::anchor(QGraphicsLayoutItem *firstItem, // Ensure that the internal anchors have been created for both items. if (firstItem != this && !d->items.contains(firstItem)) { d->createItemEdges(firstItem); - d->addChildItem(firstItem); + d->addChildLayoutItem(firstItem); } if (secondItem != this && !d->items.contains(secondItem)) { d->createItemEdges(secondItem); - d->addChildItem(secondItem); + d->addChildLayoutItem(secondItem); } // Use heuristics to find out what the user meant with this anchor. diff --git a/src/gui/graphicsview/qgraphicsanchorlayout.h b/src/gui/graphicsview/qgraphicsanchorlayout.h index fb6c396..cd1c080 100644 --- a/src/gui/graphicsview/qgraphicsanchorlayout.h +++ b/src/gui/graphicsview/qgraphicsanchorlayout.h @@ -94,8 +94,7 @@ public: protected: private: - -// Q_DISABLE_COPY(QGraphicsAnchorLayout) //### TO UNCOMMENT + Q_DISABLE_COPY(QGraphicsAnchorLayout) Q_DECLARE_PRIVATE(QGraphicsAnchorLayout) }; diff --git a/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp b/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp index 3745b3b..3569b3d 100644 --- a/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp +++ b/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp @@ -673,36 +673,6 @@ void QGraphicsAnchorLayoutPrivate::correctEdgeDirection(QGraphicsLayoutItem *&fi /*! \internal - XXX: REMOVE THIS ONCE WE INHERIT SOMEONE ELSE! -*/ -QGraphicsItem *QGraphicsAnchorLayoutPrivate::parentItem() const -{ - Q_Q(const QGraphicsLayoutItem); - - const QGraphicsLayoutItem *parent = q; - while (parent && parent->isLayout()) { - parent = parent->parentLayoutItem(); - } - return parent ? parent->graphicsItem() : 0; -} - -/*! - \internal -*/ -void QGraphicsAnchorLayoutPrivate::addChildItem(QGraphicsLayoutItem *child) -{ - // XXX: Re-implement this!! - if (child) { - Q_Q(QGraphicsAnchorLayout); - child->setParentLayoutItem(q); - - child->graphicsItem()->setParentItem(parentItem()); - } -} - -/*! - \internal - Called on activation. Uses Linear Programming to define minimum, preferred and maximum sizes for the layout. Also calculates the sizes that each item should assume when the layout is in one of such situations. diff --git a/src/gui/graphicsview/qgraphicsanchorlayout_p.h b/src/gui/graphicsview/qgraphicsanchorlayout_p.h index f945cf7..1e9af63 100644 --- a/src/gui/graphicsview/qgraphicsanchorlayout_p.h +++ b/src/gui/graphicsview/qgraphicsanchorlayout_p.h @@ -289,10 +289,6 @@ public: QGraphicsLayoutItem *&secondItem, QGraphicsAnchorLayout::Edge &secondEdge); - // Child manipulation methods - QGraphicsItem *parentItem() const; - void addChildItem(QGraphicsLayoutItem *child); - // Activation methods void simplifyGraph(Orientation orientation); void restoreSimplifiedGraph(Orientation orientation); -- cgit v0.12