diff -r 7b4e73ac247e -r 1fb50e79661c linkablemapobj.cpp --- a/linkablemapobj.cpp Mon Jun 29 10:28:28 2009 +0000 +++ b/linkablemapobj.cpp Tue Jul 07 09:34:24 2009 +0000 @@ -79,11 +79,6 @@ bottomline->setZValue(Z_LINK); bottomline->show(); - // Prepare showing the selection of a MapObj - selected=false; - - hideLinkUnselected=false; - topPad=botPad=leftPad=rightPad=0; repositionRequest=false; @@ -287,16 +282,10 @@ return style; } -void LinkableMapObj::setHideLinkUnselected(bool b) +void LinkableMapObj::setHideLinkUnselected() { - hideLinkUnselected=b; setVisibility (visible); - updateLink(); -} - -bool LinkableMapObj::getHideLinkUnselected() -{ - return hideLinkUnselected; + updateLinkGeometry(); } void LinkableMapObj::setLinkPos(Position lp) @@ -353,10 +342,40 @@ void LinkableMapObj::setVisibility (bool v) { MapObj::setVisibility (v); + updateVisibility(); +} + +void LinkableMapObj::setOrientation() +{ + Orientation orientOld=orientation; + + if (!parObj) + { + orientation=UndefinedOrientation; + return; + } + + // Set orientation, first look for orientation of parent + if (parObj->getOrientation() != UndefinedOrientation ) + // use the orientation of the parent: + orientation=parObj->getOrientation(); + else + { + // calc orientation depending on position rel to parent + if (absPos.x() < QPointF(parObj->getChildPos() ).x() ) + orientation=LeftOfCenter; + else + orientation=RightOfCenter; + } + if (orientOld!=orientation) requestReposition(); +} + +void LinkableMapObj::updateVisibility() +{ bool visnow=visible; - // We can hide the link, while object is not selected - if (hideLinkUnselected && !selected) + if (((MapItem*)treeItem)->getHideLinkUnselected() + && treeItem->getModel()->getSelectedLMO() !=this) visnow=false; if (visnow) @@ -372,11 +391,11 @@ segment.at(i)->show(); break; case PolyLine: - if (!p) cout << "LMO::setVis p==0 (PolyLine)\n"; //FIXME-3 + if (!p) cout << "LMO::updateVis p==0 (PolyLine)\n"; //FIXME-3 if (p) p->show(); break; case PolyParabel: - if (!p) cout << "LMO::setVis p==0 (PolyParabel) "<getHeading().toStdString()<getHeading().toStdString()<show(); break; default: @@ -406,32 +425,7 @@ } } -void LinkableMapObj::setOrientation() -{ - Orientation orientOld=orientation; - - if (!parObj) - { - orientation=UndefinedOrientation; - return; - } - - // Set orientation, first look for orientation of parent - if (parObj->getOrientation() != UndefinedOrientation ) - // use the orientation of the parent: - orientation=parObj->getOrientation(); - else - { - // calc orientation depending on position rel to parent - if (absPos.x() < QPointF(parObj->getChildPos() ).x() ) - orientation=LeftOfCenter; - else - orientation=RightOfCenter; - } - if (orientOld!=orientation) requestReposition(); -} - -void LinkableMapObj::updateLink() +void LinkableMapObj::updateLinkGeometry() { // needs: // childPos of parent @@ -445,7 +439,7 @@ // bottomlineY // drawing of the link itself - // updateLink is called from move, but called from constructor we don't + // updateLinkGeometry is called from move, but called from constructor we don't // have parents yet... if (!parObj) @@ -456,7 +450,7 @@ parPos=childPos; // Redraw links to children for (int i=0; ibranchCount(); ++i) - treeItem->getBranchObjNum(i)->updateLink(); + treeItem->getBranchObjNum(i)->updateLinkGeometry(); return; } @@ -511,7 +505,6 @@ switch (style) { case Line: - //l->prepareGeometryChange(); l->setLine( QLine(qRound (parPos.x()), qRound(parPos.y()), qRound(p2x), @@ -520,17 +513,13 @@ case Parabel: parabel (pa0, p1x,p1y,p2x,p2y); for (int i=0; iprepareGeometryChange(); segment.at(i)->setLine(QLineF( pa0.at(i).x(), pa0.at(i).y(),pa0.at(i+1).x(),pa0.at(i+1).y())); - } break; case PolyLine: pa0.clear(); pa0<prepareGeometryChange(); p->setPolygon(QPolygonF (pa0)); break; case PolyParabel: @@ -541,12 +530,11 @@ pa0 << QPointF (pa1.at(i)); for (int i=0;i<=arcsegs;i++) pa0 << QPointF (pa2.at(arcsegs-i)); - //p->prepareGeometryChange(); p->setPolygon(QPolygonF (pa0)); break; default: break; - } // switch (style) + } } LinkableMapObj* LinkableMapObj::getParObj() @@ -626,23 +614,6 @@ return repositionRequest; } - -void LinkableMapObj::select() -{ - // select and unselect are still needed to - // handle hiding of links - selected=true; - setVisibility (visible); -} - - -void LinkableMapObj::unselect() -{ - selected=false; - // Maybe we have to hide the link: - setVisibility (visible); -} - void LinkableMapObj::parabel (QPolygonF &ya, double p1x, double p1y, double p2x, double p2y) { @@ -672,12 +643,3 @@ } } -QString LinkableMapObj::getLinkAttr () -{ - if (hideLinkUnselected) - return attribut ("hideLink","true"); - else - return attribut ("hideLink","false"); - -} -