branchobj.cpp
changeset 775 6e4b586aa88a
parent 773 340bc29da9a0
child 776 25e634a7e1dc
     1.1 --- a/branchobj.cpp	Tue May 26 11:24:51 2009 +0000
     1.2 +++ b/branchobj.cpp	Wed Jun 03 20:37:17 2009 +0000
     1.3 @@ -130,13 +130,14 @@
     1.4  	// m is position of mouse pointer 
     1.5  	// offset 0: default 1: below lmo   -1 above lmo  (if possible)
     1.6  
     1.7 -
     1.8 +	BranchItem *pi=(BranchItem*)(lmo->getTreeItem()->parent());
     1.9 +	int pi_depth=pi->depth();
    1.10  	BranchObj* o=(BranchObj*)(lmo);
    1.11  	if (!parObjTmpBuf) 
    1.12  		parObjTmpBuf=parObj;
    1.13  
    1.14  	// ignore mapcenter and mainbranch
    1.15 -	if (treeItem->depth()<2) off=0;
    1.16 +	if (pi_depth<2) off=0;
    1.17  	if (off==0)
    1.18  		link2ParPos=false;
    1.19  	else
    1.20 @@ -385,24 +386,36 @@
    1.21  
    1.22  void BranchObj::setDockPos()
    1.23  {
    1.24 -	// Sets childpos and parpos depending on orientation
    1.25 -	if (getOrientation()==LinkableMapObj::LeftOfCenter )
    1.26 -    {
    1.27 -		childPos=QPointF (
    1.28 -			ornamentsBBox.bottomLeft().x(), 
    1.29 -			bottomlineY);
    1.30 -		parPos=QPointF (
    1.31 -			ornamentsBBox.bottomRight().x(),
    1.32 -			bottomlineY);
    1.33 -    } else
    1.34 -    {
    1.35 -		childPos=QPointF (
    1.36 -			ornamentsBBox.bottomRight().x(), 
    1.37 -			bottomlineY);
    1.38 -		parPos=QPointF (
    1.39 -			ornamentsBBox.bottomLeft().x(),
    1.40 -			bottomlineY);
    1.41 -    }
    1.42 +	if (treeItem->getType()==TreeItem::MapCenter)
    1.43 +	{
    1.44 +		// set childPos to middle of MapCenterObj
    1.45 +		childPos.setX( clickBox.topLeft().x() + clickBox.width()/2 );
    1.46 +		childPos.setY( clickBox.topLeft().y() + clickBox.height()/2 );
    1.47 +		parPos=childPos;		
    1.48 +		for (int i=0; i<treeItem->branchCount(); ++i)
    1.49 +			treeItem->getBranchObjNum(i)->updateLink();
    1.50 +
    1.51 +	} else
    1.52 +	{
    1.53 +		// Sets childpos and parpos depending on orientation
    1.54 +		if (getOrientation()==LinkableMapObj::LeftOfCenter )
    1.55 +		{
    1.56 +			childPos=QPointF (
    1.57 +				ornamentsBBox.bottomLeft().x(), 
    1.58 +				bottomlineY);
    1.59 +			parPos=QPointF (
    1.60 +				ornamentsBBox.bottomRight().x(),
    1.61 +				bottomlineY);
    1.62 +		} else
    1.63 +		{
    1.64 +			childPos=QPointF (
    1.65 +				ornamentsBBox.bottomRight().x(), 
    1.66 +				bottomlineY);
    1.67 +			parPos=QPointF (
    1.68 +				ornamentsBBox.bottomLeft().x(),
    1.69 +				bottomlineY);
    1.70 +		}
    1.71 +	}
    1.72  }
    1.73  
    1.74  void BranchObj::updateData()