Пример #1
0
CNode* CParentNode::RemoveChild( long no )
{
	CNode *pNode = GetChild( no );

	if( pNode )
	{
		if( pNode->GetPrev() )
			pNode->GetPrev()->SetNext( pNode->GetNext() );
		if( pNode->GetNext() )
			pNode->GetNext()->SetPrev( pNode->GetPrev() );
		pNode->SetNext( NULL );
		pNode->SetPrev( NULL );
		pNode->SetParent( NULL );

		m_children.remove( no );
	}

	return pNode;
}
Пример #2
0
int InsertFromFrame( CFrameNode *pFrameNode, SelectNode &sn, int fUpCalc, SelectInfo *psi )
{
	if( pFrameNode == NULL ) return -1;

	if( pFrameNode->GetChildCount() == 1 )
	{
		Q_ASSERT( pFrameNode->GetFirstChild()->GetType() == NODE_LINE );
		return ::InsertFromLine( (CLineNode*) pFrameNode->GetChild( 0 ), sn, fUpCalc, psi );
	}
	else
	{
		Q_ASSERT( pFrameNode->GetChildCount() > 0 );

		BreakLine( sn, 0 );

		CNode *pPrev = sn.GetNode()->GetPrev();
		CNode *pNext = sn.GetNode();
		Q_ASSERT( pPrev );
		Q_ASSERT( pNext );

		CParentNode *pParentNode = sn.GetNode()->GetParent();

		int fRecalculateFull = (pFrameNode->GetLevel() != pParentNode->GetLevel());
		
		QVector<CNode*> children;
		pFrameNode->RecalculateSizeFull();
		pFrameNode->RemoveOrCopyChildren( children );

		if( psi )
		{
			psi->GetBegin().SetNode( children[ 0 ] );
			psi->GetBegin().SetPosition( 0 );
			psi->GetEnd() = sn;
		}

		pParentNode->InsertChildren( children, 
			pParentNode->GetChildIndex( sn.GetNode() ) );

		if( pNext->GetPrev() == pPrev )
		{
			Q_ASSERT( 0 );
		}
		else
		{
			if( GlueLine( sn, pNext->GetPrev(), 0, NULL ) == 0 )
				if( psi ) 
					psi->GetEnd() = sn;
			if( GlueLine( sn, pPrev, 0, NULL ) == 0 )
				if( psi ) 
					psi->GetBegin() = sn;
		}

		if( fRecalculateFull )
			pParentNode->RecalculateSizeFull();
		else
			pParentNode->RecalculateSize( 0 );

		if( pParentNode->GetParent() )
			pParentNode->GetParent()->RecalculateSize( fUpCalc );
		return 0;
	}
}