1.1 --- a/branchobj.cpp Thu Sep 17 09:41:09 2009 +0000
1.2 +++ b/branchobj.cpp Wed Sep 23 11:59:54 2009 +0000
1.3 @@ -115,30 +115,32 @@
1.4 return false;
1.5 }
1.6
1.7 -void BranchObj::setParObjTmp(LinkableMapObj* lmo, QPointF m, int off)
1.8 +void BranchObj::setParObjTmp(LinkableMapObj* dst, QPointF m, int off)
1.9 {
1.10 - // Temporary link to lmo
1.11 + // Temporary link to dst
1.12 // m is position of mouse pointer
1.13 - // offset 0: default 1: below lmo -1 above lmo (if possible)
1.14 + // offset 0: default 1: below dst -1 above dst (if possible)
1.15
1.16 - BranchItem *pi=(BranchItem*)(lmo->getTreeItem()->parent());
1.17 + BranchItem *dsti=(BranchItem*)(dst->getTreeItem());
1.18 +
1.19 + BranchItem *pi=(BranchItem*)(dsti->parent());
1.20 int pi_depth=pi->depth();
1.21 - BranchObj* o=(BranchObj*)(lmo);
1.22 - if (!parObjTmpBuf)
1.23 - parObjTmpBuf=parObj;
1.24 + BranchObj* bo=(BranchObj*)(dst);
1.25
1.26 - // ignore mapcenter and mainbranch //FIXME-3 MCO meanwhile also could be relinked
1.27 + if (!parObjTmpBuf) parObjTmpBuf=parObj;
1.28 +
1.29 + // ignore mapcenter and mainbranch //FIXME-1 MCO meanwhile also could be relinked
1.30 if (pi_depth<2) off=0;
1.31 if (off==0)
1.32 link2ParPos=false;
1.33 else
1.34 link2ParPos=true;
1.35 - parObj=o;
1.36 + parObj=bo;
1.37
1.38 // setLinkStyle calls updateLinkGeometry, only set it once
1.39 - //LinkableMapObj::Style ls=getDefLinkStyle (lmo->getTreeItem() );
1.40 + //LinkableMapObj::Style ls=getDefLinkStyle (dst->getTreeItem() );
1.41 //if (style!=ls ) setLinkStyle (ls);
1.42 - setLinkStyle (lmo->getDefLinkStyle (lmo->getTreeItem()));
1.43 + setLinkStyle (dst->getDefLinkStyle (dsti));
1.44
1.45 // Move temporary to new position at destination
1.46 // Usually the positioning would be done by reposition(),
1.47 @@ -149,8 +151,7 @@
1.48
1.49 //FIXME-2 rewrite to us new normalize QPointF p= normalize ( QPointF (m.x() - o->getChildPos().x(),
1.50 // m.y() - o->getChildPos().y() ));
1.51 - QPointF p= ( QPointF (m.x() - o->getChildPos().x(),
1.52 - m.y() - o->getChildPos().y() ));
1.53 + QPointF p= ( m - bo->getChildPos());
1.54 if (p.x()<0) p.setX( p.x()-bbox.width() );
1.55 move2RelPos (p);
1.56 } else
1.57 @@ -159,8 +160,8 @@
1.58 if (off==0)
1.59 {
1.60 // new parent is just a branch, link to it
1.61 - QRectF t=o->getBBoxSizeWithChildren();
1.62 - if (o->getTreeItem()->getLastBranch())
1.63 + QRectF t=bo->getBBoxSizeWithChildren();
1.64 + if (dsti->getLastBranch())
1.65 y=t.y() + t.height() ;
1.66 else
1.67 y=t.y();
1.68 @@ -168,19 +169,19 @@
1.69 } else
1.70 {
1.71 if (off<0)
1.72 - // we want to link above lmo
1.73 - y=o->y() - height() + 5;
1.74 + // we want to link above dst
1.75 + y=bo->y() - height() + 5;
1.76 else
1.77 - // we want to link below lmo
1.78 + // we want to link below dst
1.79 // Bottom of sel should be 5 pixels above
1.80 // the bottom of the branch _below_ the target:
1.81 // Don't try to find that branch, guess 12 pixels
1.82 - y=o->getChildPos().y() -height() + 12;
1.83 + y=bo->getChildPos().y() -height() + 12;
1.84 }
1.85 - if (o->getOrientation()==LinkableMapObj::LeftOfCenter)
1.86 - move ( o->getChildPos().x() - linkwidth, y );
1.87 + if (bo->getOrientation()==LinkableMapObj::LeftOfCenter)
1.88 + move ( bo->getChildPos().x() - linkwidth, y );
1.89 else
1.90 - move (o->getChildPos().x() + linkwidth, y );
1.91 + move (bo->getChildPos().x() + linkwidth, y );
1.92 }
1.93
1.94 // updateLinkGeometry is called implicitly in move
1.95 @@ -264,12 +265,6 @@
1.96 void BranchObj::move (double x, double y)
1.97 {
1.98 OrnamentedObj::move (x,y);
1.99 - FloatImageObj *fio;
1.100 - for (int i=0; i<treeItem->imageCount(); ++i )
1.101 - {
1.102 - fio=treeItem->getImageObjNum(i);
1.103 - if (fio) fio->reposition();
1.104 - }
1.105 positionBBox();
1.106 }
1.107
1.108 @@ -550,6 +545,10 @@
1.109 angle=getAngle (QPointF ((int)(x() - parObj->getChildPos().x() ),
1.110 (int)(y() - parObj->getChildPos().y() ) ) );
1.111 }
1.112 + if (depth==1)
1.113 + {
1.114 + move2RelPos (getRelPos() );
1.115 + }
1.116 if (depth>1)
1.117 {
1.118 // Align myself depending on orientation and parent, but
1.119 @@ -647,28 +646,6 @@
1.120 }
1.121
1.122
1.123 -QPolygonF BranchObj::shape()
1.124 -{
1.125 - QPolygonF p;
1.126 -
1.127 - QRectF r=getTotalBBox();
1.128 - if (orientation==LinkableMapObj::LeftOfCenter)
1.129 - p <<r.bottomLeft()
1.130 - <<r.topLeft()
1.131 - <<QPointF (bbox.topLeft().x(), r.topLeft().y() )
1.132 - <<bbox.topRight()
1.133 - <<bbox.bottomRight()
1.134 - <<QPointF (bbox.bottomLeft().x(), r.bottomLeft().y() ) ;
1.135 - else
1.136 - p <<r.bottomRight()
1.137 - <<r.topRight()
1.138 - <<QPointF (bbox.topRight().x(), r.topRight().y() )
1.139 - <<bbox.topLeft()
1.140 - <<bbox.bottomLeft()
1.141 - <<QPointF (bbox.bottomRight().x(), r.bottomRight().y() ) ;
1.142 - return p;
1.143 -}
1.144 -
1.145 QRectF BranchObj::getTotalBBox()
1.146 {
1.147 QRectF r=bbox;