3 #include "branchitem.h"
6 #include "mainwindow.h"
9 //class TextEditor; //FIXME-3
11 //extern TextEditor *textEditor;
12 //extern Main *mainWindow;
13 //extern FlagRowObj *standardFlagsDefault;
16 /////////////////////////////////////////////////////////////////
18 /////////////////////////////////////////////////////////////////
20 BranchObj::BranchObj () :OrnamentedObj() // FIXME-3 needed at all?
22 // cout << "Const BranchObj ()\n";
27 BranchObj::BranchObj (QGraphicsScene* s):OrnamentedObj (s)// FIXME-3 needed at all?
29 // cout << "Const BranchObj (s) \n";
35 BranchObj::BranchObj (QGraphicsScene* s, LinkableMapObj* p):OrnamentedObj (s)// FIXME-3 needed at all?
37 // cout << "Const BranchObj (s,p)\n";
40 if (treeItem->depth()==1)
41 // Calc angle to mapCenter if I am a mainbranch
42 // needed for reordering the mainbranches clockwise
44 angle=getAngle (QPointF (x() - parObj->getChildPos().x() ,
45 (y() - parObj->getChildPos().y() ) ) );
49 BranchObj::~BranchObj ()
51 // cout << "Destr BranchObj of "<<this<<" ("<<treeItem->getHeading().toStdString()<<")"<<endl;
53 // If I'm animated, I need to un-animate myself first
54 if (anim.isAnimated() )
56 anim.setAnimated (false);
57 model->stopAnimation (this);
60 // Check, if this branch was the last child to be deleted
61 // If so, unset the scrolled flags in parent // FIXME-2 better do this in model?
64 BranchObj *po=(BranchObj*)parObj;
68 bo=((BranchObj*)parObj)->getLastBranch();
69 if (bo) po->unScroll();
75 bool BranchObj::operator< ( const BranchObj & other )
77 return angle < other.angle;
80 bool BranchObj::operator== ( const BranchObj & other )
82 return angle == other.angle;
85 void BranchObj::init ()
90 absPos+=parObj->getChildPos();
95 includeImagesVer=false;
96 includeImagesHor=false;
99 void BranchObj::copy (BranchObj* other)
101 OrnamentedObj::copy(other);
103 for (int i=0; i<other->floatimage.size(); ++i)
104 addFloatImage (other->floatimage.at(i));
106 setVisibility (other->visible);
113 void BranchObj::clear()
115 //setVisibility (true); //FIXME-4 needed?
117 while (!floatimage.isEmpty())
118 delete floatimage.takeFirst();
120 while (!xlink.isEmpty())
121 delete xlink.takeFirst();
124 bool isAbove (BranchObj* a, BranchObj *b)
126 if (a->angle < b->angle)
132 void BranchObj::setParObjTmp(LinkableMapObj* lmo, QPointF m, int off)
134 // Temporary link to lmo
135 // m is position of mouse pointer
136 // offset 0: default 1: below lmo -1 above lmo (if possible)
139 BranchObj* o=(BranchObj*)(lmo);
143 // ignore mapcenter and mainbranch
144 if (treeItem->depth()<2) off=0;
151 // FIXME-2 depth=parObj->getDepth()+1;
153 // setLinkStyle calls updateLink, only set it once
154 if (style!=getDefLinkStyle() ) setLinkStyle (getDefLinkStyle());
156 // Move temporary to new position at destination
157 // Usually the positioning would be done by reposition(),
158 // but then also the destination branch would "Jump" around...
159 // Better just do it approximately
160 if (treeItem->depth()==1)
161 { // new parent is the mapcenter itself
163 QPointF p= normalise ( QPointF (m.x() - o->getChildPos().x(),
164 m.y() - o->getChildPos().y() ));
165 if (p.x()<0) p.setX( p.x()-bbox.width() );
172 // new parent is just a branch, link to it
173 QRectF t=o->getBBoxSizeWithChildren();
174 if (o->getTreeItem()->getLastBranch())
175 y=t.y() + t.height() ;
182 // we want to link above lmo
183 y=o->y() - height() + 5;
185 // we want to link below lmo
186 // Bottom of sel should be 5 pixels above
187 // the bottom of the branch _below_ the target:
188 // Don't try to find that branch, guess 12 pixels
189 y=o->getChildPos().y() -height() + 12;
191 if (o->getOrientation()==LinkableMapObj::LeftOfCenter)
192 move ( o->getChildPos().x() - linkwidth, y );
194 move (o->getChildPos().x() + linkwidth, y );
197 // updateLink is called implicitly in move
201 void BranchObj::unsetParObjTmp()
208 //FIXME-2 depth=parObj->getDepth()+1;
209 setLinkStyle (getDefLinkStyle() );
214 void BranchObj::setVisibility(bool v, int toDepth)
216 BranchItem *bi=(BranchItem*)treeItem;
217 if (bi->depth() <= toDepth)
219 frame->setVisibility(v);
220 heading->setVisibility(v);
221 systemFlags->setVisibility(v);
222 standardFlags->setVisibility(v);
223 LinkableMapObj::setVisibility (v);
225 for (i=0; i<floatimage.size(); ++i)
226 floatimage.at(i)->setVisibility (v);
227 for (i=0; i<xlink.size(); ++i)
228 xlink.at(i)->setVisibility ();
230 // Only change children, if I am not scrolled
231 if (! bi->isScrolled() && (bi->depth() < toDepth))
233 // Now go recursivly through all children
234 for (i=0; i<treeItem->branchCount(); ++i)
235 treeItem->getBranchObjNum(i)->setVisibility (v,toDepth);
237 } // depth <= toDepth
241 void BranchObj::setVisibility(bool v)
243 setVisibility (v,MAX_DEPTH);
247 void BranchObj::setLinkColor ()
249 // Overloaded from LinkableMapObj
250 // BranchObj can use color of heading
254 if (model->getMapLinkColorHint()==HeadingColor)
255 LinkableMapObj::setLinkColor (heading->getColor() );
257 LinkableMapObj::setLinkColor ();
261 void BranchObj::setColorSubtree(QColor col)
264 for (int i=0; i<treeItem->branchCount(); ++i)
265 treeItem->getBranchObjNum(i)->setColorSubtree(col);
268 void BranchObj::updateContentSize()
275 void BranchObj::positionContents()
277 for (int i=0; i<floatimage.size(); ++i )
278 floatimage.at(i)->reposition();
279 OrnamentedObj::positionContents();
282 void BranchObj::move (double x, double y)
284 OrnamentedObj::move (x,y);
285 for (int i=0; i<floatimage.size(); ++i )
286 floatimage.at(i)->reposition();
290 void BranchObj::move (QPointF p)
295 void BranchObj::moveBy (double x, double y)
297 OrnamentedObj::moveBy (x,y);
298 for (int i=0; i<treeItem->branchCount(); ++i)
299 treeItem->getBranchObjNum(i)->moveBy (x,y);
303 void BranchObj::moveBy (QPointF p)
305 moveBy (p.x(), p.y());
309 void BranchObj::positionBBox()
311 QPointF ap=getAbsPos();
312 bbox.moveTopLeft (ap);
316 frame->setRect(QRectF(bbox.x(),bbox.y(),bbox.width(),bbox.height() ) );
318 // Update links to other branches
319 for (int i=0; i<xlink.size(); ++i)
320 xlink.at(i)->updateXLink();
323 void BranchObj::calcBBoxSize()
325 QSizeF heading_r=heading->getSize();
326 qreal heading_w=(qreal) heading_r.width() ;
327 qreal heading_h=(qreal) heading_r.height() ;
328 QSizeF sysflags_r; //FIXME-1 =systemFlags->getSize();
329 qreal sysflags_h=0;//sysflags_r.height();
330 qreal sysflags_w=0;//sysflags_r.width();
331 QSizeF stanflags_r; //FIXME-1 =standardFlags->getSize();
332 qreal stanflags_h=0; //stanflags_r.height();
333 qreal stanflags_w=0; //stanflags_r.width();
337 // set width to sum of all widths
338 w=heading_w + sysflags_w + stanflags_w;
339 // set height to maximum needed height
340 h=max (sysflags_h,stanflags_h);
343 // Save the dimension of flags and heading
344 ornamentsBBox.setSize ( QSizeF(w,h));
346 // clickBox includes Flags and Heading
347 clickBox.setSize (ornamentsBBox.size() );
352 topPad=botPad=leftPad=rightPad=0;
353 if (includeImagesVer || includeImagesHor)
355 if (treeItem->imageCount()>0)
357 for (int i=0; i<floatimage.size(); ++i )
359 rp=floatimage.at(i)->getRelPos();
360 if (includeImagesVer)
363 topPad=max (topPad,-rp.y()-h);
364 if (rp.y()+floatimage.at(i)->height() > 0)
365 botPad=max (botPad,rp.y()+floatimage.at(i)->height());
367 if (includeImagesHor)
369 if (orientation==LinkableMapObj::RightOfCenter)
372 leftPad=max (leftPad,-rp.x()-w);
373 if (rp.x()+floatimage.at(i)->width() > 0)
374 rightPad=max (rightPad,rp.x()+floatimage.at(i)->width());
378 leftPad=max (leftPad,-rp.x());
379 if (rp.x()+floatimage.at(i)->width() > w)
380 rightPad=max (rightPad,rp.x()+floatimage.at(i)->width()-w);
390 w+=frame->getPadding();
391 h+=frame->getPadding();
394 bbox.setSize (QSizeF (w,h));
397 void BranchObj::setDockPos()
399 // Sets childpos and parpos depending on orientation
400 if (getOrientation()==LinkableMapObj::LeftOfCenter )
403 ornamentsBBox.bottomLeft().x(),
406 ornamentsBBox.bottomRight().x(),
411 ornamentsBBox.bottomRight().x(),
414 ornamentsBBox.bottomLeft().x(),
419 void BranchObj::updateHeading()
423 qWarning ("BranchObj::udpateHeading treeItem==NULL");
426 heading->setText (treeItem->getHeading() );
430 QString BranchObj::saveToDir (const QString &tmpdir,const QString &prefix, const QPointF& offset)
432 // Cloudy stuff can be hidden during exports
433 // FIXME-1 if (hidden) return "";
435 // Update of note is usually done while unselecting a branch
436 // if (isNoteInEditor) getNoteFromTextEditor(); //FIXME-2 moved to TreeItem
439 QString scrolledAttr;
440 if ( ((BranchItem*)treeItem)->isScrolled() )
441 scrolledAttr=attribut ("scrolled","yes");
445 // save area, if not scrolled
447 if (!((BranchItem*) (treeItem->parent()) )->isScrolled() )
450 attribut("x1",QString().setNum(absPos.x()-offset.x())) +
451 attribut("y1",QString().setNum(absPos.y()-offset.y())) +
452 attribut("x2",QString().setNum(absPos.x()+width()-offset.x())) +
453 attribut("y2",QString().setNum(absPos.y()+height()-offset.y()));
458 // Providing an ID for a branch makes export to XHTML easier
460 if (treeItem->xlinkCount()>0)
461 idAttr=attribut ("id",model->getSelectString(this)); //TODO directly access model
465 s=beginElement ("branch"
470 +getIncludeImageAttr() );
474 s+=valueElement("heading", treeItem->getHeading(),
475 attribut ("textColor",QColor(heading->getColor()).name()));
478 if (frame->getFrameType()!=FrameObj::NoFrame)
479 s+=frame->saveToDir ();
481 // save names of flags set
482 s+=standardFlags->saveToDir(tmpdir,prefix,0);
485 for (int i=0; i<floatimage.size(); ++i)
486 s+=floatimage.at(i)->saveToDir (tmpdir,prefix);
489 if (!treeItem->getNoteObj().isEmpty() )
490 s+=treeItem->getNoteObj().saveToDir();
493 for (int i=0; i<treeItem->branchCount(); ++i)
494 s+=treeItem->getBranchObjNum(i)->saveToDir(tmpdir,prefix,offset);
497 QString ol; // old link
498 QString cl; // current link
499 for (int i=0; i<xlink.size(); ++i)
501 cl=xlink.at(i)->saveToDir();
508 qWarning (QString("Ignoring of duplicate xLink in %1").arg(treeItem->getHeading()));
513 s+=endElement ("branch");
517 void BranchObj::addXLink (XLinkObj *xlo)
523 void BranchObj::removeXLinkRef (XLinkObj *xlo)
525 xlink.removeAt (xlink.indexOf(xlo));
528 void BranchObj::deleteXLink(XLinkObj *xlo)
531 if (!xlo->isUsed()) delete (xlo);
534 void BranchObj::deleteXLinkAt (int i)
536 XLinkObj *xlo=xlink.at(i);
538 if (!xlo->isUsed()) delete(xlo);
541 XLinkObj* BranchObj::XLinkAt (int i)
546 BranchObj* BranchObj::XLinkTargetAt (int i)
548 if (i>=0 && i<xlink.size())
551 return xlink.at(i)->otherBranch (this);
556 void BranchObj::setIncludeImagesVer(bool b)
564 bool BranchObj::getIncludeImagesVer()
566 return includeImagesVer;
569 void BranchObj::setIncludeImagesHor(bool b)
577 bool BranchObj::getIncludeImagesHor()
579 return includeImagesHor;
582 QString BranchObj::getIncludeImageAttr()
585 if (includeImagesVer)
586 a=attribut ("incImgV","true");
588 a=attribut ("incImgV","false");
589 if (includeImagesHor)
590 a+=attribut ("incImgH","true");
592 a+=attribut ("incImgH","false");
596 FloatImageObj* BranchObj::addFloatImage ()
598 FloatImageObj *newfi=new FloatImageObj (scene,this);
599 floatimage.append (newfi);
600 if ( ((BranchItem*)treeItem)->hasScrolledParent((BranchItem*)treeItem) )
601 newfi->setVisibility (false);
603 newfi->setVisibility(visible);
612 FloatImageObj* BranchObj::addFloatImage (FloatImageObj *fio)
614 FloatImageObj *newfi=new FloatImageObj (scene,this);
615 floatimage.append (newfi);
617 if (((BranchItem*)treeItem)->hasScrolledParent((BranchItem*)treeItem) )
618 newfi->setVisibility (false);
620 newfi->setVisibility(visible);
629 FloatImageObj* BranchObj::getFirstFloatImage ()
631 return floatimage.first();
634 FloatImageObj* BranchObj::getLastFloatImage ()
636 return floatimage.last();
639 FloatImageObj* BranchObj::getFloatImageNum (const uint &i)
641 return floatimage.at(i);
644 void BranchObj::removeFloatImage (FloatImageObj *fio)
646 int i=floatimage.indexOf (fio);
647 if (i>-1) delete (floatimage.takeAt (i));
653 void BranchObj::savePosInAngle ()
655 // Save position in angle
656 for (int i=0; i<treeItem->branchCount(); ++i)
657 treeItem->getBranchObjNum(i)->angle=i;
660 void BranchObj::setDefAttr (BranchModification mod)
663 switch (treeItem->depth())
665 case 0: fontsize=16; break;
666 case 1: fontsize=12; break;
667 default: fontsize=10; break;
671 setLinkStyle(getDefLinkStyle());
672 QFont font("Sans Serif,8,-1,5,50,0,0,0,0,0");
673 font.setPointSize(fontsize);
674 heading->setFont(font );
677 setColor (treeItem->getHeadingColor() );
681 void BranchObj::removeBranchHere(BranchObj* borem) // FIXME-2 getNum no longer available
684 // This removes the branch bo from list, but
685 // inserts its children at the place of bo
687 bo=borem->getLastBranch();
688 int pos=borem->getNum();
691 bo->linkTo (this,pos+1);
692 bo=borem->getLastBranch();
694 removeBranch (borem);
698 void BranchObj::removeChildren() // FIXME-3 not needed here
703 void BranchObj::removeBranch(BranchObj* bo) // FIXME-2 not needed here
706 // if bo is not in branch remove returns false, we
709 int i=branch.indexOf(bo);
715 qWarning ("BranchObj::removeBranch tried to remove non existing branch?!\n");
720 void BranchObj::removeBranchPtr(BranchObj* bo) // FIXME-3 not needed here
723 int i=branch.indexOf(bo);
728 qWarning ("BranchObj::removeBranchPtr tried to remove non existing branch?!\n");
733 bool BranchObj::canMoveBranchUp() // FIXME-1 move to BranchItem
736 if (!parObj || depth==1) return false;
737 BranchObj* par=(BranchObj*)parObj;
738 if (this==par->getTreeItem()->getFirstBranch())
746 BranchObj* BranchObj::moveBranchUp(BranchObj* bo1) // FIXME-1
750 int i=branch.indexOf(bo1);
752 { // -1 if bo1 not found
753 treeItem->getBranchObjNum(i)->angle--;
754 treeItem->getBranchObjNum(i-1)->angle++;
755 qSort (branch.begin(),branch.end(), isAbove);
756 return treeItem->getBranchObjNum(i);
762 bool BranchObj::canMoveBranchDown() //FIXME-1 move to BranchItem
765 if (!parObj|| depth==1) return false;
766 BranchObj* par=(BranchObj*)parObj;
767 if (this==par->getTreeItem()->getLastBranch())
775 BranchObj* BranchObj::moveBranchDown(BranchObj* bo1)// FIXME-1
779 int i=branch.indexOf(bo1);
781 if (i <treeItem->branchCount())
784 treeItem->getBranchObjNum(i)->angle++;
785 treeItem->getBranchObjNum(j)->angle--;
786 qSort (branch.begin(),branch.end(), isAbove);
787 return treeItem->getBranchObjNum(i);
793 void BranchObj::sortChildren() //FIXME-2
796 int childCount=branch.count();
798 bool madeChanges=false;
802 for(curChildIndex=1;curChildIndex<childCount;curChildIndex++){
803 BranchObj* curChild=(BranchObj*)treeItem->getBranchObjNum(curChildIndex);
804 BranchObj* prevChild=(BranchObj*)treeItem->getBranchObjNum(curChildIndex-1);
805 if(prevChild->heading->text().compare(curChild->heading->text())>0)
807 this->moveBranchUp(curChild);
815 void BranchObj::alignRelativeTo (QPointF ref,bool alignSelf)
817 qreal th = bboxTotal.height();
818 int depth=treeItem->depth();
822 QString h=QString (depth,' ');
823 h+=treeItem->getHeading();
826 QPointF pp; if (parObj) pp=parObj->getChildPos();
827 cout << "BO::alignRelTo ";
828 cout<<h.toStdString();
829 cout << " d="<<depth<<
830 //cout<< " ref="<<ref<<
831 " bbox.tL="<<bboxTotal.topLeft()<<
833 // " relPos="<<relPos<<
835 " w="<<bbox.width()<<
836 " h="<<bbox.height()<<
837 // " orient="<<orientation<<
838 // " alignSelf="<<alignSelf<<
839 // " scrolled="<<((BranchItem*)treeItem)->isScrolled()<<
840 // " pad="<<topPad<<","<<botPad<<","<<leftPad<<","<<rightPad<<
841 // " hidden="<<hidden<<
849 if (depth==1 && parObj)
851 // Position relatively, if needed
852 //if (useRelPos) move2RelPos (relPos.x(), relPos.y());
854 // Calc angle to mapCenter if I am a mainbranch
855 // needed for reordering the mainbranches clockwise
857 angle=getAngle (QPointF ((int)(x() - parObj->getChildPos().x() ),
858 (int)(y() - parObj->getChildPos().y() ) ) );
862 // Align myself depending on orientation and parent, but
863 // only if I am not a mainbranch or mapcenter itself
865 if (anim.isAnimated())
870 LinkableMapObj::Orientation o;
871 o=parObj->getOrientation();
875 case LinkableMapObj::LeftOfCenter:
876 move (ref.x() - bbox.width(), ref.y() + (th-bbox.height())/2 );
877 //move (ref.x() , ref.y() + (th-bbox.height())/2 );
879 case LinkableMapObj::RightOfCenter:
880 move (ref.x() , ref.y() + (th-bbox.height())/2 );
883 qWarning ("LMO::alignRelativeTo: oops, no orientation given...");
889 if ( ((BranchItem*)treeItem)->isScrolled() ) return;
891 // Set reference point for alignment of children
893 if (orientation==LinkableMapObj::LeftOfCenter)
894 ref2.setX(bbox.topLeft().x() - linkwidth);
896 ref2.setX(bbox.topRight().x() + linkwidth);
899 ref2.setY(absPos.y()-(bboxTotal.height()-bbox.height())/2);
903 // Align the children depending on reference point
904 for (int i=0; i<treeItem->branchCount(); ++i)
906 if (!treeItem->getBranchNum(i)->isHidden())
908 treeItem->getBranchObjNum(i)->alignRelativeTo (ref2,true);
910 // append next branch below current one
911 ref2.setY(ref2.y() + treeItem->getBranchObjNum(i)->getBBoxSizeWithChildren().height() );
917 void BranchObj::reposition()
920 if (!treeItem->getHeading().isEmpty())
921 cout << "BO::reposition "<<qPrintable(treeItem->getHeading())<<endl;
923 cout << "BO::reposition ???"<<endl;
924 // cout << " orient="<<orientation<<endl;
927 if (treeItem->depth()==0)
929 // only calculate the sizes once. If the deepest LMO
930 // changes its height,
931 // all upper LMOs have to change, too.
932 calcBBoxSizeWithChildren();
933 updateLink(); // This update is needed if the scene is resized
934 // due to excessive moving of a FIO
936 alignRelativeTo ( QPointF (absPos.x(),
937 absPos.y()-(bboxTotal.height()-bbox.height())/2) );
938 //FIXME-2 qSort (branch.begin(),branch.end(), isAbove);
939 positionBBox(); // Reposition bbox and contents
942 // This is only important for moving branches:
943 // For editing a branch it isn't called...
944 alignRelativeTo ( QPointF (absPos.x(),
945 absPos.y()-(bboxTotal.height()-bbox.height())/2) );
949 void BranchObj::unsetAllRepositionRequests()
951 repositionRequest=false;
952 for (int i=0; i<treeItem->branchCount(); ++i)
953 treeItem->getBranchObjNum(i)->unsetAllRepositionRequests();
957 QPolygonF BranchObj::shape()
961 QRectF r=getTotalBBox();
962 if (orientation==LinkableMapObj::LeftOfCenter)
965 <<QPointF (bbox.topLeft().x(), r.topLeft().y() )
968 <<QPointF (bbox.bottomLeft().x(), r.bottomLeft().y() ) ;
972 <<QPointF (bbox.topRight().x(), r.topRight().y() )
975 <<QPointF (bbox.bottomRight().x(), r.bottomRight().y() ) ;
979 QRectF BranchObj::getTotalBBox()
983 if ( ((BranchItem*)treeItem)->isScrolled() ) return r;
985 for (int i=0; i<treeItem->branchCount(); ++i)
986 if (!treeItem->getBranchNum(i)->isHidden())
987 r=addBBox(treeItem->getBranchObjNum(i)->getTotalBBox(),r);
989 /* FIXME-3 lots of occurences of treeItem->getBranchObjNum(i) in branchobj.cpp
990 better check if they are not NULL and maybe simplify...
991 (have been NULL at least in calcBBoxSizeWithChilds...)
995 FIXME-1 for (int i=0; i<floatimage.size(); ++i)
996 if (!floatimage.at(i)->isHidden())
997 r=addBBox(floatimage.at(i)->getTotalBBox(),r);
1002 QRectF BranchObj::getBBoxSizeWithChildren()
1007 void BranchObj::calcBBoxSizeWithChildren()
1009 // This is initially called only from reposition and
1010 // and only for mapcenter. So it won't be
1011 // called more than once for a single user
1015 // Calculate size of LMO including all children (to align them later)
1016 bboxTotal.setX(bbox.x() );
1017 bboxTotal.setY(bbox.y() );
1019 // if branch is scrolled, ignore children, but still consider floatimages
1020 BranchItem *bi=(BranchItem*)treeItem;
1021 if ( bi->isScrolled() )
1023 bboxTotal.setWidth (bbox.width());
1024 bboxTotal.setHeight(bbox.height());
1030 bboxTotal.setWidth (0);
1031 bboxTotal.setHeight(0);
1034 bboxTotal.setX (parObj->x());
1035 bboxTotal.setY (parObj->y());
1038 bboxTotal.setX (bbox.x());
1039 bboxTotal.setY (bbox.y());
1046 // Now calculate recursivly
1048 // maximum of widths
1050 for (int i=0; i<treeItem->branchCount(); i++)
1052 if (!bi->getBranchNum(i)->isHidden())
1054 bi->getBranchObjNum(i)->calcBBoxSizeWithChildren();
1055 br=bi->getBranchObjNum(i)->getBBoxSizeWithChildren();
1056 r.setWidth( max (br.width(), r.width() ));
1057 r.setHeight(br.height() + r.height() );
1058 if (br.y()<bboxTotal.y()) bboxTotal.setY(br.y());
1061 // Add myself and also
1062 // add width of link to sum if necessary
1063 if (bi->branchCount()<1)
1064 bboxTotal.setWidth (bbox.width() + r.width() );
1066 bboxTotal.setWidth (bbox.width() + r.width() + linkwidth);
1068 bboxTotal.setHeight(max (r.height(), bbox.height()));
1072 void BranchObj::select() // FIXME-4 try to get rid of this in BO completely
1074 cout << "BO::select()\n";
1075 textEditor->setText(treeItem->getNoteObj().getNote() );
1076 QString fnh=treeItem->getNoteObj().getFilenameHint();
1078 textEditor->setFilenameHint(treeItem->getNoteObj().getFilenameHint() );
1080 textEditor->setFilenameHint(getHeading() );
1081 textEditor->setFontHint (treeItem->getNoteObj().getFontHint() );
1082 //isNoteInEditor=true;
1084 // set selected and visible
1085 LinkableMapObj::select();
1087 //if (po) po->setLastSelectedBranch(this); needed?
1089 // temporary unscroll, if we have scrolled parents somewhere
1090 if (parObj) ((BranchObj*)(parObj))->tmpUnscroll();
1092 //moved to vymmodel or vymview...
1093 // Show URL and link in statusbar
1095 if (!url.isEmpty()) status+="URL: "+url+" ";
1096 if (!vymLink.isEmpty()) status+="Link: "+vymLink;
1097 if (!status.isEmpty()) mainWindow->statusMessage (status);
1100 updateFlagsToolbar();
1103 model->updateActions();
1108 void BranchObj::unselect() //FIXME-4 should not be needed
1110 cout << "BO::unselect()\n";
1111 LinkableMapObj::unselect();
1112 // Delete any messages like vymLink in StatusBar
1113 mainWindow->statusMessage (""); //this causes segfault, when MainWindow is already gone in global destructor on quitting vym
1115 // Save current note
1116 if (isNoteInEditor) getNoteFromTextEditor();
1117 isNoteInEditor=false;
1119 // reset temporary unscroll, if we have scrolled parents somewhere
1120 if (parObj) ((BranchObj*)(parObj))->resetTmpUnscroll();
1122 // Erase content of editor
1123 textEditor->setInactive();
1125 // unselect all buttons in toolbar
1126 standardFlagsDefault->updateToolbar();
1130 QString BranchObj::getSelectString()
1132 return model->getSelectString (this);
1135 void BranchObj::setAnimation(const AnimPoint &ap)
1140 bool BranchObj::animate()
1143 if ( anim.isAnimated() )
1148 parObj->reposition(); // we might have been relinked meanwhile