1.1 --- a/branchobj.cpp Wed Sep 23 12:14:08 2009 +0000
1.2 +++ b/branchobj.cpp Thu Oct 01 11:28:50 2009 +0000
1.3 @@ -115,7 +115,7 @@
1.4 return false;
1.5 }
1.6
1.7 -void BranchObj::setParObjTmp(LinkableMapObj* dst, QPointF m, int off)
1.8 +void BranchObj::setParObjTmp(LinkableMapObj* dst, QPointF m, int off) //FIXME-1 after moving a mainbranch to a branch and away again mainbranch is no longer connected to mapcenter...
1.9 {
1.10 // Temporary link to dst
1.11 // m is position of mouse pointer
1.12 @@ -127,9 +127,12 @@
1.13 int pi_depth=pi->depth();
1.14 BranchObj* bo=(BranchObj*)(dst);
1.15
1.16 - if (!parObjTmpBuf) parObjTmpBuf=parObj;
1.17 + if (!tmpParent)
1.18 + {
1.19 + tmpParent=true;
1.20 + parObjTmpBuf=parObj;
1.21 + }
1.22
1.23 - // ignore mapcenter and mainbranch //FIXME-1 MCO meanwhile also could be relinked
1.24 if (pi_depth<2) off=0;
1.25 if (off==0)
1.26 link2ParPos=false;
1.27 @@ -137,9 +140,6 @@
1.28 link2ParPos=true;
1.29 parObj=bo;
1.30
1.31 - // setLinkStyle calls updateLinkGeometry, only set it once
1.32 - //LinkableMapObj::Style ls=getDefLinkStyle (dst->getTreeItem() );
1.33 - //if (style!=ls ) setLinkStyle (ls);
1.34 setLinkStyle (dst->getDefLinkStyle (dsti));
1.35
1.36 // Move temporary to new position at destination
1.37 @@ -148,12 +148,11 @@
1.38 // Better just do it approximately
1.39 if (parObj->getTreeItem()->depth()==0)
1.40 { // new parent is a mapcenter
1.41 -
1.42 - //FIXME-2 rewrite to us new normalize QPointF p= normalize ( QPointF (m.x() - o->getChildPos().x(),
1.43 - // m.y() - o->getChildPos().y() ));
1.44 - QPointF p= ( m - bo->getChildPos());
1.45 - if (p.x()<0) p.setX( p.x()-bbox.width() );
1.46 - move2RelPos (p);
1.47 + Vector v= ( m - bo->getChildPos());
1.48 + if (v.x()<0) v.setX( v.x()-bbox.width() );
1.49 + v.normalize();
1.50 + v.scale (100);
1.51 + move2RelPos (v.toQPointF());
1.52 } else
1.53 {
1.54 qreal y;
1.55 @@ -190,8 +189,9 @@
1.56
1.57 void BranchObj::unsetParObjTmp()
1.58 {
1.59 - if (parObjTmpBuf)
1.60 + if (tmpParent)
1.61 {
1.62 + tmpParent=false;
1.63 link2ParPos=false;
1.64 parObj=parObjTmpBuf;
1.65 parObjTmpBuf=NULL;
1.66 @@ -485,9 +485,18 @@
1.67 int fontsize;
1.68 switch (treeItem->depth())
1.69 {
1.70 - case 0: fontsize=16; break;
1.71 - case 1: fontsize=12; break;
1.72 - default: fontsize=10; break;
1.73 + case 0:
1.74 + fontsize=16;
1.75 + setFrameType (FrameObj::Rectangle);
1.76 + break;
1.77 + case 1:
1.78 + fontsize=12;
1.79 + setFrameType (FrameObj::NoFrame);
1.80 + break;
1.81 + default:
1.82 + fontsize=10;
1.83 + setFrameType (FrameObj::NoFrame);
1.84 + break;
1.85 }
1.86 setLinkStyle(getDefLinkStyle(treeItem->parent() ));
1.87 setLinkColor ();
1.88 @@ -497,6 +506,10 @@
1.89
1.90 if (mod==NewBranch)
1.91 setColor (treeItem->getHeadingColor() );
1.92 + else
1.93 + // Also set styles for children
1.94 + for (int i=0; i<treeItem->branchCount(); ++i)
1.95 + treeItem->getBranchObjNum(i)->setDefAttr(MovedBranch);
1.96 calcBBoxSize();
1.97 }
1.98
1.99 @@ -672,7 +685,7 @@
1.100 return bboxTotal;
1.101 }
1.102
1.103 -ConvexPolygon BranchObj::getBoundingPolygon()
1.104 +ConvexPolygon BranchObj::getBoundingPolygon()
1.105 {
1.106 /*
1.107 if (!pi) //FIXME-3 Testing only
1.108 @@ -683,6 +696,7 @@
1.109 pi->setZValue(Z_BBOX);
1.110 }
1.111 */
1.112 +
1.113 if (treeItem->branchCount()==0 || treeItem->depth()==0)
1.114 {
1.115 if (pi) pi->setPolygon (MapObj::getBoundingPolygon() );
1.116 @@ -695,7 +709,9 @@
1.117 p<<bboxTotal.topRight();
1.118 p<<bboxTotal.bottomRight();
1.119 p<<bboxTotal.bottomLeft();
1.120 - if (pi) pi->setPolygon (p );
1.121 + //cout << "BO::getBP (total) "<<treeItem->getHeadingStd()<<" tL="<<bboxTotal.topLeft()<<" bR="<<bboxTotal.bottomRight()<<endl;
1.122 + //cout << " "<<" tL="<<bbox.topLeft()<<" bR="<<bbox.bottomRight()<<endl;
1.123 + if (pi) pi->setPolygon (p );
1.124 return p;
1.125 }
1.126
1.127 @@ -751,6 +767,7 @@
1.128 r.setWidth( max (br.width(), r.width() ));
1.129 r.setHeight(br.height() + r.height() );
1.130 if (br.y()<bboxTotal.y()) bboxTotal.setY(br.y());
1.131 + if (br.x()<bboxTotal.x()) bboxTotal.setX(br.x());
1.132 }
1.133 }
1.134 // Add myself and also