diff -r 7516d6d86cf5 -r ed14f46c0e55 src/hbcore/layouts/hbanchorlayout.cpp --- a/src/hbcore/layouts/hbanchorlayout.cpp Mon Oct 04 17:49:30 2010 +0300 +++ b/src/hbcore/layouts/hbanchorlayout.cpp Mon Oct 18 18:23:13 2010 +0300 @@ -269,27 +269,6 @@ } -/*! - Returns list of effective anchors - those which has mappings to QGraphicsItem - \return list of effective anchors. -*/ -QList HbAnchorLayout::effectiveAnchors() -{ - Q_D( HbAnchorLayout ); - d->resolveAnchors(); - return d->mResolvedAnchors; -} - -/*! - Returns list of all anchors set to this layout - \return list of all anchors. -*/ -QList HbAnchorLayout::anchors() const -{ - Q_D( const HbAnchorLayout ); - return d->mAllAnchors; -} - /* \class HbAnchorLayoutPrivate \internal @@ -1009,6 +988,13 @@ vs->clear(); el->clear(); + if( type == Vertical ) { + mLayoutVarV = 0; + } else { + mLayoutVarH = 0; + } + + GraphVertex *layoutStart = new GraphVertex(); GraphVertex *layoutMiddle = new GraphVertex(); @@ -1780,6 +1766,11 @@ if ( !nodeId.isNull() && ( item != 0 ) ) { + QString oldMapping = this->nodeId( item ); + if (!oldMapping.isEmpty()) { + removeMapping(oldMapping); + } + for( int i = 0; i < d->mAllAnchors.size(); i++ ) { HbAnchor *anchor = d->mAllAnchors.at(i); if( anchor->startItem() == item ) { @@ -2007,10 +1998,7 @@ QString HbAnchorLayout::nodeId( QGraphicsLayoutItem *item ) const { Q_D( const HbAnchorLayout ); - if( d->mItemToNodeIdMap.contains( item ) ) { - return d->mItemToNodeIdMap.value( item ); - } - return QString(); + return d->mItemToNodeIdMap.value( item ); } /*! @@ -2046,6 +2034,50 @@ return d->mItemToNodeIdMap.key( nodeId ); } +/*! + Returns list of effective anchors - those which has mappings to QGraphicsItem + \return list of effective anchors. +*/ +QList HbAnchorLayout::effectiveAnchors() +{ + Q_D( HbAnchorLayout ); + d->resolveAnchors(); + return d->mResolvedAnchors; +} + +/*! + Returns list of all anchors set to this layout + \return list of all anchors. +*/ +QList HbAnchorLayout::anchors() const +{ + Q_D( const HbAnchorLayout ); + return d->mAllAnchors; +} + + +/*! + Returns actual length of given anchor in current layout configuration + \param anchor whose length need to be determined. + \return actual length of anchor or -1 if this anchor is not layouted (or doesn't exist at all) +*/ +qreal HbAnchorLayout::anchorLength( HbAnchor *anchor ) const +{ + Q_D( const HbAnchorLayout ); + + Variable *anchorVar = d->mVariablesHorizontal.findVariable( anchor ); + if( anchorVar && d->mSolutionHorizontal.contains( anchorVar ) ) { + return qAbs( d->mSolutionHorizontal.value( anchorVar ) ); + } + + anchorVar = d->mVariablesVertical.findVariable( anchor ); + if( anchorVar && d->mSolutionVertical.contains( anchorVar ) ) { + return qAbs( d->mSolutionVertical.value( anchorVar ) ); + } + return -1; +} + + /*! \reimp