insilmaril@0: #include "branchobj.h" insilmaril@616: insilmaril@749: #include "branchitem.h" insilmaril@643: #include "geometry.h" insilmaril@0: #include "mapeditor.h" insilmaril@0: #include "mainwindow.h" insilmaril@616: #include "misc.h" insilmaril@616: insilmaril@767: extern FlagRow *standardFlagsMaster; insilmaril@767: extern FlagRow *systemFlagsMaster; insilmaril@0: insilmaril@0: ///////////////////////////////////////////////////////////////// insilmaril@0: // BranchObj insilmaril@0: ///////////////////////////////////////////////////////////////// insilmaril@0: insilmaril@746: BranchObj::BranchObj () :OrnamentedObj() // FIXME-3 needed at all? insilmaril@0: { insilmaril@0: // cout << "Const BranchObj ()\n"; insilmaril@0: setParObj (this); insilmaril@0: init(); insilmaril@0: } insilmaril@0: insilmaril@755: BranchObj::BranchObj (QGraphicsScene* s):OrnamentedObj (s)// FIXME-3 needed at all? insilmaril@0: { insilmaril@755: // cout << "Const BranchObj (s) \n"; insilmaril@83: parObj=NULL; insilmaril@408: scene=s; insilmaril@755: init(); insilmaril@0: } insilmaril@0: insilmaril@755: BranchObj::BranchObj (QGraphicsScene* s, LinkableMapObj* p):OrnamentedObj (s)// FIXME-3 needed at all? insilmaril@0: { insilmaril@408: // cout << "Const BranchObj (s,p)\n"; insilmaril@408: scene=s; insilmaril@0: setParObj (p); insilmaril@755: if (treeItem->depth()==1) insilmaril@0: // Calc angle to mapCenter if I am a mainbranch insilmaril@0: // needed for reordering the mainbranches clockwise insilmaril@0: // around mapcenter insilmaril@408: angle=getAngle (QPointF (x() - parObj->getChildPos().x() , insilmaril@408: (y() - parObj->getChildPos().y() ) ) ); insilmaril@0: init(); insilmaril@0: } insilmaril@0: insilmaril@0: BranchObj::~BranchObj () insilmaril@0: { insilmaril@757: // cout << "Destr BranchObj of "<getHeading().toStdString()<<")"<stopAnimation (this); insilmaril@722: } insilmaril@722: insilmaril@0: // Check, if this branch was the last child to be deleted insilmaril@749: // If so, unset the scrolled flags in parent // FIXME-2 better do this in model? insilmaril@0: insilmaril@749: /* insilmaril@425: BranchObj *po=(BranchObj*)parObj; insilmaril@83: BranchObj *bo; insilmaril@0: if (po) insilmaril@0: { insilmaril@425: bo=((BranchObj*)parObj)->getLastBranch(); insilmaril@425: if (bo) po->unScroll(); insilmaril@0: } insilmaril@749: */ insilmaril@83: clear(); insilmaril@0: } insilmaril@0: insilmaril@0: bool BranchObj::operator< ( const BranchObj & other ) insilmaril@0: { insilmaril@0: return angle < other.angle; insilmaril@0: } insilmaril@0: insilmaril@0: bool BranchObj::operator== ( const BranchObj & other ) insilmaril@0: { insilmaril@0: return angle == other.angle; insilmaril@0: } insilmaril@0: insilmaril@0: void BranchObj::init () insilmaril@0: { insilmaril@83: if (parObj) insilmaril@83: { insilmaril@83: absPos=getRandPos(); insilmaril@83: absPos+=parObj->getChildPos(); insilmaril@83: } insilmaril@0: insilmaril@0: setChildObj(this); insilmaril@0: insilmaril@169: includeImagesVer=false; insilmaril@169: includeImagesHor=false; insilmaril@0: } insilmaril@0: insilmaril@0: void BranchObj::copy (BranchObj* other) insilmaril@0: { insilmaril@0: OrnamentedObj::copy(other); insilmaril@0: insilmaril@404: for (int i=0; ifloatimage.size(); ++i) insilmaril@404: addFloatImage (other->floatimage.at(i)); insilmaril@749: insilmaril@0: setVisibility (other->visible); insilmaril@0: insilmaril@0: angle=other->angle; insilmaril@0: insilmaril@0: positionBBox(); insilmaril@0: } insilmaril@0: insilmaril@0: void BranchObj::clear() insilmaril@0: { insilmaril@755: //setVisibility (true); //FIXME-4 needed? insilmaril@425: insilmaril@404: while (!floatimage.isEmpty()) insilmaril@404: delete floatimage.takeFirst(); insilmaril@404: insilmaril@95: while (!xlink.isEmpty()) insilmaril@406: delete xlink.takeFirst(); insilmaril@0: } insilmaril@0: insilmaril@411: bool isAbove (BranchObj* a, BranchObj *b) insilmaril@411: { insilmaril@411: if (a->angle < b->angle) insilmaril@411: return true; insilmaril@411: else insilmaril@411: return false; insilmaril@411: } insilmaril@411: insilmaril@408: void BranchObj::setParObjTmp(LinkableMapObj* lmo, QPointF m, int off) insilmaril@0: { insilmaril@0: // Temporary link to lmo insilmaril@0: // m is position of mouse pointer insilmaril@0: // offset 0: default 1: below lmo -1 above lmo (if possible) insilmaril@0: insilmaril@0: insilmaril@0: BranchObj* o=(BranchObj*)(lmo); insilmaril@0: if (!parObjTmpBuf) insilmaril@0: parObjTmpBuf=parObj; insilmaril@0: insilmaril@0: // ignore mapcenter and mainbranch insilmaril@755: if (treeItem->depth()<2) off=0; insilmaril@0: if (off==0) insilmaril@0: link2ParPos=false; insilmaril@0: else insilmaril@0: link2ParPos=true; insilmaril@93: parObj=o; insilmaril@0: insilmaril@755: // FIXME-2 depth=parObj->getDepth()+1; insilmaril@0: insilmaril@0: // setLinkStyle calls updateLink, only set it once insilmaril@0: if (style!=getDefLinkStyle() ) setLinkStyle (getDefLinkStyle()); insilmaril@0: insilmaril@0: // Move temporary to new position at destination insilmaril@0: // Usually the positioning would be done by reposition(), insilmaril@0: // but then also the destination branch would "Jump" around... insilmaril@0: // Better just do it approximately insilmaril@755: if (treeItem->depth()==1) insilmaril@0: { // new parent is the mapcenter itself insilmaril@0: insilmaril@408: QPointF p= normalise ( QPointF (m.x() - o->getChildPos().x(), insilmaril@0: m.y() - o->getChildPos().y() )); insilmaril@0: if (p.x()<0) p.setX( p.x()-bbox.width() ); insilmaril@0: move2RelPos (p); insilmaril@0: } else insilmaril@0: { insilmaril@408: qreal y; insilmaril@0: if (off==0) insilmaril@0: { insilmaril@0: // new parent is just a branch, link to it insilmaril@721: QRectF t=o->getBBoxSizeWithChildren(); insilmaril@750: if (o->getTreeItem()->getLastBranch()) insilmaril@0: y=t.y() + t.height() ; insilmaril@0: else insilmaril@0: y=t.y(); insilmaril@0: insilmaril@0: } else insilmaril@0: { insilmaril@0: if (off<0) insilmaril@0: // we want to link above lmo insilmaril@0: y=o->y() - height() + 5; insilmaril@0: else insilmaril@0: // we want to link below lmo insilmaril@0: // Bottom of sel should be 5 pixels above insilmaril@0: // the bottom of the branch _below_ the target: insilmaril@0: // Don't try to find that branch, guess 12 pixels insilmaril@0: y=o->getChildPos().y() -height() + 12; insilmaril@0: } insilmaril@462: if (o->getOrientation()==LinkableMapObj::LeftOfCenter) insilmaril@0: move ( o->getChildPos().x() - linkwidth, y ); insilmaril@0: else insilmaril@0: move (o->getChildPos().x() + linkwidth, y ); insilmaril@0: } insilmaril@0: insilmaril@0: // updateLink is called implicitly in move insilmaril@417: requestReposition(); insilmaril@0: } insilmaril@0: insilmaril@0: void BranchObj::unsetParObjTmp() insilmaril@0: { insilmaril@0: if (parObjTmpBuf) insilmaril@0: { insilmaril@0: link2ParPos=false; insilmaril@0: parObj=parObjTmpBuf; insilmaril@0: parObjTmpBuf=NULL; insilmaril@755: //FIXME-2 depth=parObj->getDepth()+1; insilmaril@0: setLinkStyle (getDefLinkStyle() ); insilmaril@93: updateLink(); insilmaril@0: } insilmaril@0: } insilmaril@0: insilmaril@0: void BranchObj::setVisibility(bool v, int toDepth) insilmaril@0: { insilmaril@749: BranchItem *bi=(BranchItem*)treeItem; insilmaril@755: if (bi->depth() <= toDepth) insilmaril@0: { insilmaril@0: frame->setVisibility(v); insilmaril@0: heading->setVisibility(v); insilmaril@0: systemFlags->setVisibility(v); insilmaril@0: standardFlags->setVisibility(v); insilmaril@0: LinkableMapObj::setVisibility (v); insilmaril@730: int i; insilmaril@730: for (i=0; isetVisibility (v); insilmaril@730: for (i=0; isetVisibility (); insilmaril@730: insilmaril@721: // Only change children, if I am not scrolled insilmaril@749: if (! bi->isScrolled() && (bi->depth() < toDepth)) insilmaril@0: { insilmaril@721: // Now go recursivly through all children insilmaril@750: for (i=0; ibranchCount(); ++i) insilmaril@753: treeItem->getBranchObjNum(i)->setVisibility (v,toDepth); insilmaril@0: } insilmaril@0: } // depth <= toDepth insilmaril@0: requestReposition(); insilmaril@0: } insilmaril@0: insilmaril@0: void BranchObj::setVisibility(bool v) insilmaril@0: { insilmaril@0: setVisibility (v,MAX_DEPTH); insilmaril@0: } insilmaril@0: insilmaril@0: insilmaril@0: void BranchObj::setLinkColor () insilmaril@0: { insilmaril@0: // Overloaded from LinkableMapObj insilmaril@0: // BranchObj can use color of heading insilmaril@0: insilmaril@721: if (model) insilmaril@611: { insilmaril@721: if (model->getMapLinkColorHint()==HeadingColor) insilmaril@164: LinkableMapObj::setLinkColor (heading->getColor() ); insilmaril@164: else insilmaril@164: LinkableMapObj::setLinkColor (); insilmaril@611: } insilmaril@0: } insilmaril@0: insilmaril@417: void BranchObj::setColorSubtree(QColor col) insilmaril@0: { insilmaril@638: setColor (col); insilmaril@750: for (int i=0; ibranchCount(); ++i) insilmaril@753: treeItem->getBranchObjNum(i)->setColorSubtree(col); insilmaril@753: } insilmaril@753: insilmaril@753: void BranchObj::updateContentSize() insilmaril@753: { insilmaril@753: calcBBoxSize(); insilmaril@753: positionBBox(); insilmaril@753: requestReposition(); insilmaril@100: } insilmaril@0: insilmaril@333: void BranchObj::positionContents() insilmaril@333: { insilmaril@404: for (int i=0; ireposition(); insilmaril@333: OrnamentedObj::positionContents(); insilmaril@333: } insilmaril@0: insilmaril@0: void BranchObj::move (double x, double y) insilmaril@0: { insilmaril@0: OrnamentedObj::move (x,y); insilmaril@404: for (int i=0; ireposition(); insilmaril@0: positionBBox(); insilmaril@0: } insilmaril@0: insilmaril@408: void BranchObj::move (QPointF p) insilmaril@0: { insilmaril@0: move (p.x(), p.y()); insilmaril@0: } insilmaril@0: insilmaril@0: void BranchObj::moveBy (double x, double y) insilmaril@0: { insilmaril@0: OrnamentedObj::moveBy (x,y); insilmaril@750: for (int i=0; ibranchCount(); ++i) insilmaril@753: treeItem->getBranchObjNum(i)->moveBy (x,y); insilmaril@333: positionBBox(); insilmaril@0: } insilmaril@83: insilmaril@408: void BranchObj::moveBy (QPointF p) insilmaril@0: { insilmaril@0: moveBy (p.x(), p.y()); insilmaril@0: } insilmaril@0: insilmaril@0: insilmaril@0: void BranchObj::positionBBox() insilmaril@0: { insilmaril@408: QPointF ap=getAbsPos(); insilmaril@223: bbox.moveTopLeft (ap); insilmaril@169: positionContents(); insilmaril@0: insilmaril@0: // set the frame insilmaril@408: frame->setRect(QRectF(bbox.x(),bbox.y(),bbox.width(),bbox.height() ) ); insilmaril@83: insilmaril@83: // Update links to other branches insilmaril@406: for (int i=0; iupdateXLink(); insilmaril@0: } insilmaril@0: insilmaril@0: void BranchObj::calcBBoxSize() insilmaril@0: { insilmaril@408: QSizeF heading_r=heading->getSize(); insilmaril@408: qreal heading_w=(qreal) heading_r.width() ; insilmaril@408: qreal heading_h=(qreal) heading_r.height() ; insilmaril@767: QSizeF sysflags_r=systemFlags->getSize(); insilmaril@767: qreal sysflags_h=sysflags_r.height(); insilmaril@767: qreal sysflags_w=sysflags_r.width(); insilmaril@767: QSizeF stanflags_r=standardFlags->getSize(); insilmaril@767: qreal stanflags_h=stanflags_r.height(); insilmaril@767: qreal stanflags_w=stanflags_r.width(); insilmaril@408: qreal w; insilmaril@408: qreal h; insilmaril@0: insilmaril@0: // set width to sum of all widths insilmaril@0: w=heading_w + sysflags_w + stanflags_w; insilmaril@0: // set height to maximum needed height insilmaril@0: h=max (sysflags_h,stanflags_h); insilmaril@0: h=max (h,heading_h); insilmaril@0: insilmaril@223: // Save the dimension of flags and heading insilmaril@408: ornamentsBBox.setSize ( QSizeF(w,h)); insilmaril@223: insilmaril@223: // clickBox includes Flags and Heading insilmaril@223: clickBox.setSize (ornamentsBBox.size() ); insilmaril@169: insilmaril@169: // Floatimages insilmaril@408: QPointF rp; insilmaril@169: insilmaril@169: topPad=botPad=leftPad=rightPad=0; insilmaril@169: if (includeImagesVer || includeImagesHor) insilmaril@169: { insilmaril@749: if (treeItem->imageCount()>0) insilmaril@169: { insilmaril@404: for (int i=0; igetRelPos(); insilmaril@169: if (includeImagesVer) insilmaril@169: { insilmaril@169: if (rp.y() < 0) insilmaril@223: topPad=max (topPad,-rp.y()-h); insilmaril@404: if (rp.y()+floatimage.at(i)->height() > 0) insilmaril@404: botPad=max (botPad,rp.y()+floatimage.at(i)->height()); insilmaril@169: } insilmaril@213: if (includeImagesHor) insilmaril@213: { insilmaril@462: if (orientation==LinkableMapObj::RightOfCenter) insilmaril@223: { insilmaril@223: if (-rp.x()-w > 0) insilmaril@223: leftPad=max (leftPad,-rp.x()-w); insilmaril@404: if (rp.x()+floatimage.at(i)->width() > 0) insilmaril@404: rightPad=max (rightPad,rp.x()+floatimage.at(i)->width()); insilmaril@223: } else insilmaril@223: { insilmaril@223: if (rp.x()< 0) insilmaril@223: leftPad=max (leftPad,-rp.x()); insilmaril@404: if (rp.x()+floatimage.at(i)->width() > w) insilmaril@404: rightPad=max (rightPad,rp.x()+floatimage.at(i)->width()-w); insilmaril@223: } insilmaril@213: } insilmaril@169: } insilmaril@169: } insilmaril@169: h+=topPad+botPad; insilmaril@213: w+=leftPad+rightPad; insilmaril@169: } insilmaril@169: insilmaril@169: // Frame thickness insilmaril@462: w+=frame->getPadding(); insilmaril@462: h+=frame->getPadding(); insilmaril@169: insilmaril@169: // Finally set size insilmaril@408: bbox.setSize (QSizeF (w,h)); insilmaril@0: } insilmaril@0: insilmaril@223: void BranchObj::setDockPos() insilmaril@223: { insilmaril@382: // Sets childpos and parpos depending on orientation insilmaril@462: if (getOrientation()==LinkableMapObj::LeftOfCenter ) insilmaril@223: { insilmaril@440: childPos=QPointF ( insilmaril@440: ornamentsBBox.bottomLeft().x(), insilmaril@440: bottomlineY); insilmaril@440: parPos=QPointF ( insilmaril@440: ornamentsBBox.bottomRight().x(), insilmaril@440: bottomlineY); insilmaril@223: } else insilmaril@223: { insilmaril@440: childPos=QPointF ( insilmaril@440: ornamentsBBox.bottomRight().x(), insilmaril@440: bottomlineY); insilmaril@440: parPos=QPointF ( insilmaril@440: ornamentsBBox.bottomLeft().x(), insilmaril@440: bottomlineY); insilmaril@223: } insilmaril@223: } insilmaril@382: insilmaril@767: void BranchObj::updateData() insilmaril@0: { insilmaril@767: bool changed=false; insilmaril@753: if (!treeItem) insilmaril@254: { insilmaril@753: qWarning ("BranchObj::udpateHeading treeItem==NULL"); insilmaril@753: return; insilmaril@753: } insilmaril@767: QString s=treeItem->getHeading(); insilmaril@767: if (s!=heading->text()) insilmaril@767: { insilmaril@767: heading->setText (s); insilmaril@767: changed=true; insilmaril@767: } insilmaril@767: QStringList TIactiveFlags=treeItem->activeStandardFlagNames(); insilmaril@767: insilmaril@767: // Add missing standard flags active in TreeItem insilmaril@767: for (int i=0;i<=TIactiveFlags.size()-1;i++) insilmaril@767: { insilmaril@767: if (!standardFlags->isActive (TIactiveFlags.at(i) )) insilmaril@767: { insilmaril@767: Flag *f=standardFlagsMaster->getFlag(TIactiveFlags.at(i)); insilmaril@767: if (f) standardFlags->activate (f); insilmaril@767: changed=true; insilmaril@767: } insilmaril@767: } insilmaril@767: // Remove standard flags no longer active in TreeItem insilmaril@767: QStringList BOactiveFlags=standardFlags->activeFlagNames(); insilmaril@767: for (int i=0;ideactivate (BOactiveFlags.at(i)); insilmaril@767: changed=true; insilmaril@767: } insilmaril@767: insilmaril@767: // Add missing system flags active in TreeItem insilmaril@767: TIactiveFlags=treeItem->activeSystemFlagNames(); insilmaril@767: for (int i=0;iisActive (TIactiveFlags.at(i) )) insilmaril@767: { insilmaril@767: Flag *f=systemFlagsMaster->getFlag(TIactiveFlags.at(i)); insilmaril@767: if (f) systemFlags->activate (f); insilmaril@767: changed=true; insilmaril@767: } insilmaril@767: } insilmaril@767: // Remove system flags no longer active in TreeItem insilmaril@767: BOactiveFlags=systemFlags->activeFlagNames(); insilmaril@767: for (int i=0;ideactivate (BOactiveFlags.at(i)); insilmaril@767: changed=true; insilmaril@767: } insilmaril@767: } insilmaril@767: insilmaril@767: if (changed) insilmaril@767: updateContentSize(); insilmaril@254: } insilmaril@254: insilmaril@0: insilmaril@95: void BranchObj::addXLink (XLinkObj *xlo) insilmaril@83: { insilmaril@95: xlink.append (xlo); insilmaril@83: insilmaril@83: } insilmaril@83: insilmaril@95: void BranchObj::removeXLinkRef (XLinkObj *xlo) insilmaril@83: { insilmaril@406: xlink.removeAt (xlink.indexOf(xlo)); insilmaril@83: } insilmaril@83: insilmaril@95: void BranchObj::deleteXLink(XLinkObj *xlo) insilmaril@83: { insilmaril@95: xlo->deactivate(); insilmaril@95: if (!xlo->isUsed()) delete (xlo); insilmaril@83: } insilmaril@83: insilmaril@95: void BranchObj::deleteXLinkAt (int i) insilmaril@94: { insilmaril@95: XLinkObj *xlo=xlink.at(i); insilmaril@95: xlo->deactivate(); insilmaril@95: if (!xlo->isUsed()) delete(xlo); insilmaril@94: } insilmaril@94: insilmaril@97: XLinkObj* BranchObj::XLinkAt (int i) insilmaril@97: { insilmaril@97: return xlink.at(i); insilmaril@97: } insilmaril@97: insilmaril@95: BranchObj* BranchObj::XLinkTargetAt (int i) insilmaril@89: { insilmaril@406: if (i>=0 && iotherBranch (this); insilmaril@406: } insilmaril@406: return NULL; insilmaril@89: } insilmaril@89: insilmaril@169: void BranchObj::setIncludeImagesVer(bool b) insilmaril@169: { insilmaril@169: includeImagesVer=b; insilmaril@169: calcBBoxSize(); insilmaril@169: positionBBox(); insilmaril@169: requestReposition(); insilmaril@169: } insilmaril@169: insilmaril@169: bool BranchObj::getIncludeImagesVer() insilmaril@169: { insilmaril@169: return includeImagesVer; insilmaril@169: } insilmaril@169: insilmaril@169: void BranchObj::setIncludeImagesHor(bool b) insilmaril@169: { insilmaril@169: includeImagesHor=b; insilmaril@169: calcBBoxSize(); insilmaril@169: positionBBox(); insilmaril@169: requestReposition(); insilmaril@169: } insilmaril@169: insilmaril@169: bool BranchObj::getIncludeImagesHor() insilmaril@169: { insilmaril@169: return includeImagesHor; insilmaril@169: } insilmaril@169: insilmaril@169: QString BranchObj::getIncludeImageAttr() insilmaril@169: { insilmaril@169: QString a; insilmaril@169: if (includeImagesVer) insilmaril@169: a=attribut ("incImgV","true"); insilmaril@169: else insilmaril@169: a=attribut ("incImgV","false"); insilmaril@169: if (includeImagesHor) insilmaril@213: a+=attribut ("incImgH","true"); insilmaril@169: else insilmaril@213: a+=attribut ("incImgH","false"); insilmaril@169: return a; insilmaril@169: } insilmaril@169: insilmaril@395: FloatImageObj* BranchObj::addFloatImage () insilmaril@0: { insilmaril@408: FloatImageObj *newfi=new FloatImageObj (scene,this); insilmaril@0: floatimage.append (newfi); insilmaril@749: if ( ((BranchItem*)treeItem)->hasScrolledParent((BranchItem*)treeItem) ) insilmaril@0: newfi->setVisibility (false); insilmaril@0: else insilmaril@0: newfi->setVisibility(visible); insilmaril@395: /* insilmaril@169: calcBBoxSize(); insilmaril@169: positionBBox(); insilmaril@395: */ insilmaril@0: requestReposition(); insilmaril@0: return newfi; insilmaril@0: } insilmaril@0: insilmaril@395: FloatImageObj* BranchObj::addFloatImage (FloatImageObj *fio) insilmaril@0: { insilmaril@408: FloatImageObj *newfi=new FloatImageObj (scene,this); insilmaril@0: floatimage.append (newfi); insilmaril@0: newfi->copy (fio); insilmaril@749: if (((BranchItem*)treeItem)->hasScrolledParent((BranchItem*)treeItem) ) insilmaril@0: newfi->setVisibility (false); insilmaril@0: else insilmaril@0: newfi->setVisibility(visible); insilmaril@395: /* insilmaril@169: calcBBoxSize(); insilmaril@169: positionBBox(); insilmaril@395: */ insilmaril@0: requestReposition(); insilmaril@0: return newfi; insilmaril@0: } insilmaril@0: insilmaril@0: FloatImageObj* BranchObj::getFirstFloatImage () insilmaril@0: { insilmaril@0: return floatimage.first(); insilmaril@0: } insilmaril@0: insilmaril@0: FloatImageObj* BranchObj::getLastFloatImage () insilmaril@0: { insilmaril@0: return floatimage.last(); insilmaril@0: } insilmaril@0: insilmaril@0: FloatImageObj* BranchObj::getFloatImageNum (const uint &i) insilmaril@0: { insilmaril@0: return floatimage.at(i); insilmaril@0: } insilmaril@0: insilmaril@0: void BranchObj::removeFloatImage (FloatImageObj *fio) insilmaril@0: { insilmaril@404: int i=floatimage.indexOf (fio); insilmaril@411: if (i>-1) delete (floatimage.takeAt (i)); insilmaril@169: calcBBoxSize(); insilmaril@169: positionBBox(); insilmaril@0: requestReposition(); insilmaril@0: } insilmaril@0: insilmaril@0: void BranchObj::savePosInAngle () insilmaril@0: { insilmaril@0: // Save position in angle insilmaril@750: for (int i=0; ibranchCount(); ++i) insilmaril@753: treeItem->getBranchObjNum(i)->angle=i; insilmaril@0: } insilmaril@0: insilmaril@146: void BranchObj::setDefAttr (BranchModification mod) insilmaril@146: { insilmaril@146: int fontsize; insilmaril@755: switch (treeItem->depth()) insilmaril@146: { insilmaril@146: case 0: fontsize=16; break; insilmaril@146: case 1: fontsize=12; break; insilmaril@146: default: fontsize=10; break; insilmaril@146: } insilmaril@146: insilmaril@146: setLinkColor (); insilmaril@146: setLinkStyle(getDefLinkStyle()); insilmaril@146: QFont font("Sans Serif,8,-1,5,50,0,0,0,0,0"); insilmaril@146: font.setPointSize(fontsize); insilmaril@146: heading->setFont(font ); insilmaril@146: insilmaril@146: if (mod==NewBranch) insilmaril@760: setColor (treeItem->getHeadingColor() ); insilmaril@146: calcBBoxSize(); insilmaril@146: } insilmaril@146: insilmaril@760: void BranchObj::removeBranchHere(BranchObj* borem) // FIXME-2 getNum no longer available insilmaril@98: { insilmaril@749: /* insilmaril@98: // This removes the branch bo from list, but insilmaril@721: // inserts its children at the place of bo insilmaril@98: BranchObj *bo; insilmaril@98: bo=borem->getLastBranch(); insilmaril@139: int pos=borem->getNum(); insilmaril@98: while (bo) insilmaril@98: { insilmaril@421: bo->linkTo (this,pos+1); insilmaril@98: bo=borem->getLastBranch(); insilmaril@98: } insilmaril@98: removeBranch (borem); insilmaril@749: */ insilmaril@98: } insilmaril@98: insilmaril@755: void BranchObj::removeChildren() // FIXME-3 not needed here insilmaril@98: { insilmaril@98: clear(); insilmaril@98: } insilmaril@98: insilmaril@760: void BranchObj::removeBranch(BranchObj* bo) // FIXME-2 not needed here insilmaril@0: { insilmaril@753: /* insilmaril@0: // if bo is not in branch remove returns false, we insilmaril@0: // don't care... insilmaril@83: insilmaril@406: int i=branch.indexOf(bo); insilmaril@406: if (i>=0) insilmaril@406: { insilmaril@83: delete (bo); insilmaril@406: branch.removeAt (i); insilmaril@406: } else insilmaril@83: qWarning ("BranchObj::removeBranch tried to remove non existing branch?!\n"); insilmaril@83: requestReposition(); insilmaril@753: */ insilmaril@83: } insilmaril@83: insilmaril@760: void BranchObj::removeBranchPtr(BranchObj* bo) // FIXME-3 not needed here insilmaril@83: { insilmaril@753: /* insilmaril@406: int i=branch.indexOf(bo); insilmaril@406: insilmaril@406: if (i>=0) insilmaril@406: branch.removeAt (i); insilmaril@406: else insilmaril@406: qWarning ("BranchObj::removeBranchPtr tried to remove non existing branch?!\n"); insilmaril@0: requestReposition(); insilmaril@753: */ insilmaril@0: } insilmaril@0: insilmaril@760: void BranchObj::sortChildren() //FIXME-2 insilmaril@604: { insilmaril@749: /* insilmaril@749: int childCount=branch.count(); insilmaril@604: int curChildIndex; insilmaril@604: bool madeChanges=false; insilmaril@604: do insilmaril@604: { insilmaril@604: madeChanges=false; insilmaril@604: for(curChildIndex=1;curChildIndexgetBranchObjNum(curChildIndex); insilmaril@753: BranchObj* prevChild=(BranchObj*)treeItem->getBranchObjNum(curChildIndex-1); insilmaril@604: if(prevChild->heading->text().compare(curChild->heading->text())>0) insilmaril@604: { insilmaril@604: this->moveBranchUp(curChild); insilmaril@604: madeChanges=true; insilmaril@604: } insilmaril@604: } insilmaril@604: }while(madeChanges); insilmaril@749: */ insilmaril@604: } insilmaril@604: insilmaril@721: void BranchObj::alignRelativeTo (QPointF ref,bool alignSelf) insilmaril@0: { insilmaril@408: qreal th = bboxTotal.height(); insilmaril@755: int depth=treeItem->depth(); insilmaril@223: // TODO testing insilmaril@223: /* insilmaril@755: insilmaril@755: QString h=QString (depth,' '); insilmaril@753: h+=treeItem->getHeading(); insilmaril@753: h+=QString (15,' '); insilmaril@753: h.truncate (15); insilmaril@688: QPointF pp; if (parObj) pp=parObj->getChildPos(); insilmaril@753: cout << "BO::alignRelTo "; insilmaril@753: cout<