diff -r 1c8ff1928b97 -r b0d72eb511c9 xlinkobj.cpp --- a/xlinkobj.cpp Thu Nov 23 13:53:08 2006 +0000 +++ b/xlinkobj.cpp Wed Apr 25 16:02:54 2007 +0000 @@ -1,8 +1,6 @@ #include "xlinkobj.h" #include "branchobj.h" #include "mapeditor.h" -//Added by qt3to4: -#include ///////////////////////////////////////////////////////////////// @@ -17,9 +15,9 @@ init(); } -XLinkObj::XLinkObj (Q3Canvas* c):MapObj(c) +XLinkObj::XLinkObj (QGraphicsScene* s):MapObj(s) { - // cout << "Const XLinkObj (c) called from MapCenterObj (c)\n"; + // cout << "Const XLinkObj (s) called from MapCenterObj (s)\n"; init(); } @@ -42,15 +40,14 @@ xLinkState=undefinedXLink; color=QColor (180,180,180); - line=new Q3CanvasLine (canvas); width=1; - line->setPen (QPen(color, width)); - line->setZ (Z_XLINK); - - poly=new Q3CanvasPolygon (canvas); - poly->setBrush( color ); - poly->setZ (Z_XLINK); - + pen.setColor (color); + pen.setWidth (width); + pen.setCapStyle ( Qt::RoundCap ); + line=scene->addLine(QLineF(1,1,1,1),pen); + line->setZValue (Z_XLINK); + poly=scene->addPolygon(QPolygonF(),pen,color); + poly->setZValue (Z_XLINK); setVisibility (false); } @@ -62,6 +59,7 @@ beginBranch=other->beginBranch; endBranch=other->endBranch; width=other->width; + } void XLinkObj::setBegin (BranchObj *bo) @@ -97,27 +95,29 @@ void XLinkObj::setWidth (int w) { width=w; + pen.setWidth (w); setColor (color); } int XLinkObj::getWidth() { - return width; + return pen.width(); } void XLinkObj::setColor(QColor c) { color=c; - line->setPen (QPen(color, width)); + pen.setColor (c); + line->setPen (pen); poly->setBrush( color ); } QColor XLinkObj::getColor() { - return color; + return pen.color(); } -void XLinkObj::setEnd (QPoint p) +void XLinkObj::setEnd (QPointF p) { endPos=p; } @@ -160,8 +160,8 @@ void XLinkObj::updateXLink() { - QPoint a,b; - Q3PointArray pa (3); + QPointF a,b; + QPolygonF pa; if (visBranch) { // Only one of the linked branches is visible @@ -169,20 +169,20 @@ if (visBranch->getOrientation()==OrientRightOfCenter) { b.setX (b.x()+25); - pa.putPoints (0,3, - b.x(),b.y(), - b.x()-arrowSize,b.y()-arrowSize, - b.x()-arrowSize,b.y()+arrowSize - ); - poly->setPoints (pa); + + pa.clear(); + pa<< QPointF(b.x(),b.y())<< + QPointF(b.x()-arrowSize,b.y()-arrowSize)<< + QPointF(b.x()-arrowSize,b.y()+arrowSize); + poly->setPolygon(pa); } else { b.setX (b.x()-25); - pa.putPoints (0,3, - b.x(),b.y(), - b.x()+arrowSize,b.y()-arrowSize, - b.x()+arrowSize,b.y()+arrowSize); - poly->setPoints (pa); + pa.clear(); + pa<< QPointF(b.x(),b.y())<< + QPointF(b.x()+arrowSize,b.y()-arrowSize)<< + QPointF(b.x()+arrowSize,b.y()+arrowSize); + poly->setPolygon (pa); } } else { @@ -201,7 +201,7 @@ } - if (line->startPoint()==a && line->endPoint()==b && !visBranch) + if (line->line().p1()==a && line->line().p2()==b && !visBranch) { // update is called from both branches, so only // update if something has changed @@ -211,8 +211,8 @@ { beginPos=a; endPos=b; - line->setPen (QPen(color, width)); - line->setPoints (a.x(), a.y(), b.x(), b.y()); + line->setPen (pen); + line->setLine(a.x(), a.y(), b.x(), b.y()); } }