diff -r 5db8dfd30ea2 -r c2a05fa925a1 branchobj.cpp --- a/branchobj.cpp Thu Nov 23 16:18:26 2006 +0000 +++ b/branchobj.cpp Fri Dec 08 20:18:56 2006 +0000 @@ -37,25 +37,25 @@ depth=-1; } -BranchObj::BranchObj (Q3Canvas* c):OrnamentedObj (c) +BranchObj::BranchObj (QGraphicsScene* s):OrnamentedObj (s) { -// cout << "Const BranchObj (c) called from MapCenterObj (c)\n"; +// cout << "Const BranchObj (s) called from MapCenterObj (s)\n"; parObj=NULL; - canvas=c; + scene=s; } -BranchObj::BranchObj (Q3Canvas* c, LinkableMapObj* p):OrnamentedObj (c) +BranchObj::BranchObj (QGraphicsScene* s, LinkableMapObj* p):OrnamentedObj (s) { -// cout << "Const BranchObj (c,p)\n"; - canvas=c; +// cout << "Const BranchObj (s,p)\n"; + scene=s; setParObj (p); depth=p->getDepth()+1; if (depth==1) // Calc angle to mapCenter if I am a mainbranch // needed for reordering the mainbranches clockwise // around mapcenter - angle=getAngle (QPoint ((int)(x() - parObj->getChildPos().x() ), - (int)(y() - parObj->getChildPos().y() ) ) ); + angle=getAngle (QPointF (x() - parObj->getChildPos().x() , + (y() - parObj->getChildPos().y() ) ) ); init(); } @@ -93,7 +93,7 @@ absPos+=parObj->getChildPos(); } - lastSelectedBranch=-1; + lastSelectedBranch=0; setChildObj(this); @@ -171,7 +171,7 @@ return xlink.count(); } -void BranchObj::setParObjTmp(LinkableMapObj* lmo, QPoint m, int off) +void BranchObj::setParObjTmp(LinkableMapObj* lmo, QPointF m, int off) { // Temporary link to lmo // m is position of mouse pointer @@ -202,17 +202,17 @@ if (depth==1) { // new parent is the mapcenter itself - QPoint p= normalise ( QPoint (m.x() - o->getChildPos().x(), + QPointF p= normalise ( QPointF (m.x() - o->getChildPos().x(), m.y() - o->getChildPos().y() )); if (p.x()<0) p.setX( p.x()-bbox.width() ); move2RelPos (p); } else { - int y; + qreal y; if (off==0) { // new parent is just a branch, link to it - QRect t=o->getBBoxSizeWithChilds(); + QRectF t=o->getBBoxSizeWithChilds(); if (o->getLastBranch()) y=t.y() + t.height() ; else @@ -547,7 +547,7 @@ positionBBox(); } -void BranchObj::move (QPoint p) +void BranchObj::move (QPointF p) { move (p.x(), p.y()); } @@ -560,7 +560,7 @@ positionBBox(); } -void BranchObj::moveBy (QPoint p) +void BranchObj::moveBy (QPointF p) { moveBy (p.x(), p.y()); } @@ -568,13 +568,13 @@ void BranchObj::positionBBox() { - QPoint ap=getAbsPos(); + QPointF ap=getAbsPos(); bbox.moveTopLeft (ap); positionContents(); setSelBox(); // set the frame - frame->setRect(QRect(bbox.x(),bbox.y(),bbox.width(),bbox.height() ) ); + frame->setRect(QRectF(bbox.x(),bbox.y(),bbox.width(),bbox.height() ) ); // Update links to other branches for (int i=0; igetSize(); - int heading_w=(int) heading_r.width() ; - int heading_h=(int) heading_r.height() ; - QSize sysflags_r=systemFlags->getSize(); - int sysflags_h=sysflags_r.height(); - int sysflags_w=sysflags_r.width(); - QSize stanflags_r=standardFlags->getSize(); - int stanflags_h=stanflags_r.height(); - int stanflags_w=stanflags_r.width(); - int w; - int h; + QSizeF heading_r=heading->getSize(); + qreal heading_w=(qreal) heading_r.width() ; + qreal heading_h=(qreal) heading_r.height() ; + QSizeF sysflags_r=systemFlags->getSize(); + qreal sysflags_h=sysflags_r.height(); + qreal sysflags_w=sysflags_r.width(); + QSizeF stanflags_r=standardFlags->getSize(); + qreal stanflags_h=stanflags_r.height(); + qreal stanflags_w=stanflags_r.width(); + qreal w; + qreal h; // set width to sum of all widths w=heading_w + sysflags_w + stanflags_w; @@ -602,13 +602,13 @@ h=max (h,heading_h); // Save the dimension of flags and heading - ornamentsBBox.setSize ( QSize(w,h)); + ornamentsBBox.setSize ( QSizeF(w,h)); // clickBox includes Flags and Heading clickBox.setSize (ornamentsBBox.size() ); // Floatimages - QPoint rp; + QPointF rp; topPad=botPad=leftPad=rightPad=0; if (includeImagesVer || includeImagesHor) @@ -652,7 +652,7 @@ h+=frame->getBorder(); // Finally set size - bbox.setSize (QSize (w,h)); + bbox.setSize (QSizeF (w,h)); } void BranchObj::setDockPos() @@ -660,16 +660,16 @@ // Sets childpos and parpos depending on orientation if (getOrientation()==OrientLeftOfCenter ) { - childPos=QPoint (ornamentsBBox.bottomLeft().x(), ornamentsBBox.bottomLeft().y() ); - parPos=QPoint (ornamentsBBox.bottomRight().x(),ornamentsBBox.bottomRight().y() ); + childPos=QPointF (ornamentsBBox.bottomLeft().x(), ornamentsBBox.bottomLeft().y() ); + parPos=QPointF (ornamentsBBox.bottomRight().x(),ornamentsBBox.bottomRight().y() ); } else { - childPos=QPoint (ornamentsBBox.bottomRight().x(), ornamentsBBox.bottomRight().y() ); - parPos=QPoint (ornamentsBBox.bottomLeft().x(),ornamentsBBox.bottomLeft().y() ); + childPos=QPointF (ornamentsBBox.bottomRight().x(), ornamentsBBox.bottomRight().y() ); + parPos=QPointF (ornamentsBBox.bottomLeft().x(),ornamentsBBox.bottomLeft().y() ); } } -LinkableMapObj* BranchObj::findMapObj(QPoint p, LinkableMapObj* excludeLMO) +LinkableMapObj* BranchObj::findMapObj(QPointF p, LinkableMapObj* excludeLMO) { // Search branches LinkableMapObj *lmo; @@ -735,7 +735,7 @@ return false; } -QString BranchObj::saveToDir (const QString &tmpdir,const QString &prefix, const QPoint& offset) +QString BranchObj::saveToDir (const QString &tmpdir,const QString &prefix, const QPointF& offset) { if (hidden) return ""; @@ -757,10 +757,10 @@ if (!((BranchObj*)(parObj))->isScrolled() ) { areaAttr= - attribut("x1",QString().setNum(absPos.x()-offset.x(),10)) + - attribut("y1",QString().setNum(absPos.y()-offset.y(),10)) + - attribut("x2",QString().setNum(absPos.x()+width()-offset.x(),10)) + - attribut("y2",QString().setNum(absPos.y()+height()-offset.y(),10)); + attribut("x1",QString().setNum(absPos.x()-offset.x())) + + attribut("y1",QString().setNum(absPos.y()-offset.y())) + + attribut("x2",QString().setNum(absPos.x()+width()-offset.x())) + + attribut("y2",QString().setNum(absPos.y()+height()-offset.y())); } else areaAttr=""; @@ -913,7 +913,7 @@ FloatImageObj* BranchObj::addFloatImage () { - FloatImageObj *newfi=new FloatImageObj (canvas,this); + FloatImageObj *newfi=new FloatImageObj (scene,this); floatimage.append (newfi); if (hasScrolledParent(this) ) newfi->setVisibility (false); @@ -929,7 +929,7 @@ FloatImageObj* BranchObj::addFloatImage (FloatImageObj *fio) { - FloatImageObj *newfi=new FloatImageObj (canvas,this); + FloatImageObj *newfi=new FloatImageObj (scene,this); floatimage.append (newfi); newfi->copy (fio); if (hasScrolledParent(this) ) @@ -1000,7 +1000,7 @@ BranchObj* BranchObj::addBranch() { - BranchObj* newbo=new BranchObj(canvas,this); + BranchObj* newbo=new BranchObj(scene,this); branch.append (newbo); newbo->setParObj(this); newbo->setDefAttr(NewBranch); @@ -1016,7 +1016,7 @@ BranchObj* BranchObj::addBranch(BranchObj* bo) { - BranchObj* newbo=new BranchObj(canvas,this); + BranchObj* newbo=new BranchObj(scene,this); branch.append (newbo); newbo->copy(bo); newbo->setParObj(this); @@ -1129,22 +1129,25 @@ BranchObj* BranchObj::getLastSelectedBranch () { - if (lastSelectedBranch>=0) - { - BranchObj* bo=branch.at(lastSelectedBranch); - if (bo) return bo; - } - return branch.first(); + if (lastSelectedBranch>=0 && branch.size()>0) + return branch.at(lastSelectedBranch); + return NULL; } BranchObj* BranchObj::getFirstBranch () { - return branch.first(); + if (branch.size()>0) + return branch.first(); + else + return NULL; } BranchObj* BranchObj::getLastBranch () { - return branch.last(); + if (branch.size()>0) + return branch.last(); + else + return NULL; } BranchObj* BranchObj::getBranchNum (int i) @@ -1238,9 +1241,9 @@ } } -void BranchObj::alignRelativeTo (QPoint ref) +void BranchObj::alignRelativeTo (QPointF ref) { - int th = bboxTotal.height(); + qreal th = bboxTotal.height(); // TODO testing /* cout << "BO::alignRelTo "<getChildPos().x() ), + angle=getAngle (QPointF ((int)(x() - parObj->getChildPos().x() ), (int)(y() - parObj->getChildPos().y() ) ) ); } } @@ -1296,7 +1299,7 @@ if (scrolled) return; // Set reference point for alignment of childs - QPoint ref2; + QPointF ref2; if (orientation==OrientLeftOfCenter) ref2.setX(bbox.topLeft().x() - linkwidth); else @@ -1336,11 +1339,11 @@ // changes its height, // all upper LMOs have to change, too. calcBBoxSizeWithChilds(); - updateLink(); // This update is needed if the canvas is resized + updateLink(); // This update is needed if the scene is resized // due to excessive moving of a FIO // FIXME really needed? reposition is also called from updateLink... - alignRelativeTo ( QPoint (absPos.x(), + alignRelativeTo ( QPointF (absPos.x(), absPos.y()-(bboxTotal.height()-bbox.height())/2) ); //FIXME branch.sort(); positionBBox(); // Reposition bbox and contents @@ -1348,7 +1351,7 @@ { // This is only important for moving branches: // For editing a branch it isn't called... - alignRelativeTo ( QPoint (absPos.x(), + alignRelativeTo ( QPointF (absPos.x(), absPos.y()-(bboxTotal.height()-bbox.height())/2) ); } } @@ -1361,9 +1364,9 @@ } -QRect BranchObj::getTotalBBox() +QRectF BranchObj::getTotalBBox() { - QRect r=bbox; + QRectF r=bbox; if (scrolled) return r; @@ -1378,7 +1381,7 @@ return r; } -QRect BranchObj::getBBoxSizeWithChilds() +QRectF BranchObj::getBBoxSizeWithChilds() { return bboxTotal; } @@ -1419,8 +1422,8 @@ return; } - QRect r(0,0,0,0); - QRect br; + QRectF r(0,0,0,0); + QRectF br; // Now calculate recursivly // sum of heights // maximum of widths