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
440 QString scrolledAttr;
441 if ( ((BranchItem*)treeItem)->isScrolled() )
442 scrolledAttr=attribut ("scrolled","yes");
446 // save area, if not scrolled
448 if (!((BranchItem*) (treeItem->parent()) )->isScrolled() )
451 attribut("x1",QString().setNum(absPos.x()-offset.x())) +
452 attribut("y1",QString().setNum(absPos.y()-offset.y())) +
453 attribut("x2",QString().setNum(absPos.x()+width()-offset.x())) +
454 attribut("y2",QString().setNum(absPos.y()+height()-offset.y()));
459 // Providing an ID for a branch makes export to XHTML easier
461 if (treeItem->xlinkCount()>0)
462 idAttr=attribut ("id",model->getSelectString(this)); //TODO directly access model
466 s=beginElement ("branch"
471 +getIncludeImageAttr() );
475 s+=valueElement("heading", treeItem->getHeading(),
476 attribut ("textColor",QColor(heading->getColor()).name()));
479 if (frame->getFrameType()!=FrameObj::NoFrame)
480 s+=frame->saveToDir ();
482 // save names of flags set
483 s+=standardFlags->saveToDir(tmpdir,prefix,0);
486 for (int i=0; i<floatimage.size(); ++i)
487 s+=floatimage.at(i)->saveToDir (tmpdir,prefix);
490 if (!treeItem->getNoteObj().isEmpty() )
491 s+=treeItem->getNoteObj().saveToDir();
494 for (int i=0; i<treeItem->branchCount(); ++i)
495 s+=treeItem->getBranchObjNum(i)->saveToDir(tmpdir,prefix,offset);
498 QString ol; // old link
499 QString cl; // current link
500 for (int i=0; i<xlink.size(); ++i)
502 cl=xlink.at(i)->saveToDir();
509 qWarning (QString("Ignoring of duplicate xLink in %1").arg(treeItem->getHeading()));
514 s+=endElement ("branch");
519 void BranchObj::addXLink (XLinkObj *xlo)
525 void BranchObj::removeXLinkRef (XLinkObj *xlo)
527 xlink.removeAt (xlink.indexOf(xlo));
530 void BranchObj::deleteXLink(XLinkObj *xlo)
533 if (!xlo->isUsed()) delete (xlo);
536 void BranchObj::deleteXLinkAt (int i)
538 XLinkObj *xlo=xlink.at(i);
540 if (!xlo->isUsed()) delete(xlo);
543 XLinkObj* BranchObj::XLinkAt (int i)
548 BranchObj* BranchObj::XLinkTargetAt (int i)
550 if (i>=0 && i<xlink.size())
553 return xlink.at(i)->otherBranch (this);
558 void BranchObj::setIncludeImagesVer(bool b)
566 bool BranchObj::getIncludeImagesVer()
568 return includeImagesVer;
571 void BranchObj::setIncludeImagesHor(bool b)
579 bool BranchObj::getIncludeImagesHor()
581 return includeImagesHor;
584 QString BranchObj::getIncludeImageAttr()
587 if (includeImagesVer)
588 a=attribut ("incImgV","true");
590 a=attribut ("incImgV","false");
591 if (includeImagesHor)
592 a+=attribut ("incImgH","true");
594 a+=attribut ("incImgH","false");
598 FloatImageObj* BranchObj::addFloatImage ()
600 FloatImageObj *newfi=new FloatImageObj (scene,this);
601 floatimage.append (newfi);
602 if ( ((BranchItem*)treeItem)->hasScrolledParent((BranchItem*)treeItem) )
603 newfi->setVisibility (false);
605 newfi->setVisibility(visible);
614 FloatImageObj* BranchObj::addFloatImage (FloatImageObj *fio)
616 FloatImageObj *newfi=new FloatImageObj (scene,this);
617 floatimage.append (newfi);
619 if (((BranchItem*)treeItem)->hasScrolledParent((BranchItem*)treeItem) )
620 newfi->setVisibility (false);
622 newfi->setVisibility(visible);
631 FloatImageObj* BranchObj::getFirstFloatImage ()
633 return floatimage.first();
636 FloatImageObj* BranchObj::getLastFloatImage ()
638 return floatimage.last();
641 FloatImageObj* BranchObj::getFloatImageNum (const uint &i)
643 return floatimage.at(i);
646 void BranchObj::removeFloatImage (FloatImageObj *fio)
648 int i=floatimage.indexOf (fio);
649 if (i>-1) delete (floatimage.takeAt (i));
655 void BranchObj::savePosInAngle ()
657 // Save position in angle
658 for (int i=0; i<treeItem->branchCount(); ++i)
659 treeItem->getBranchObjNum(i)->angle=i;
662 void BranchObj::setDefAttr (BranchModification mod)
665 switch (treeItem->depth())
667 case 0: fontsize=16; break;
668 case 1: fontsize=12; break;
669 default: fontsize=10; break;
673 setLinkStyle(getDefLinkStyle());
674 QFont font("Sans Serif,8,-1,5,50,0,0,0,0,0");
675 font.setPointSize(fontsize);
676 heading->setFont(font );
679 setColor (treeItem->getHeadingColor() );
683 void BranchObj::removeBranchHere(BranchObj* borem) // FIXME-2 getNum no longer available
686 // This removes the branch bo from list, but
687 // inserts its children at the place of bo
689 bo=borem->getLastBranch();
690 int pos=borem->getNum();
693 bo->linkTo (this,pos+1);
694 bo=borem->getLastBranch();
696 removeBranch (borem);
700 void BranchObj::removeChildren() // FIXME-3 not needed here
705 void BranchObj::removeBranch(BranchObj* bo) // FIXME-2 not needed here
708 // if bo is not in branch remove returns false, we
711 int i=branch.indexOf(bo);
717 qWarning ("BranchObj::removeBranch tried to remove non existing branch?!\n");
722 void BranchObj::removeBranchPtr(BranchObj* bo) // FIXME-3 not needed here
725 int i=branch.indexOf(bo);
730 qWarning ("BranchObj::removeBranchPtr tried to remove non existing branch?!\n");
735 bool BranchObj::canMoveBranchUp() // FIXME-1 move to BranchItem
738 if (!parObj || depth==1) return false;
739 BranchObj* par=(BranchObj*)parObj;
740 if (this==par->getTreeItem()->getFirstBranch())
748 BranchObj* BranchObj::moveBranchUp(BranchObj* bo1) // FIXME-1
752 int i=branch.indexOf(bo1);
754 { // -1 if bo1 not found
755 treeItem->getBranchObjNum(i)->angle--;
756 treeItem->getBranchObjNum(i-1)->angle++;
757 qSort (branch.begin(),branch.end(), isAbove);
758 return treeItem->getBranchObjNum(i);
764 bool BranchObj::canMoveBranchDown() //FIXME-1 move to BranchItem
767 if (!parObj|| depth==1) return false;
768 BranchObj* par=(BranchObj*)parObj;
769 if (this==par->getTreeItem()->getLastBranch())
777 BranchObj* BranchObj::moveBranchDown(BranchObj* bo1)// FIXME-1
781 int i=branch.indexOf(bo1);
783 if (i <treeItem->branchCount())
786 treeItem->getBranchObjNum(i)->angle++;
787 treeItem->getBranchObjNum(j)->angle--;
788 qSort (branch.begin(),branch.end(), isAbove);
789 return treeItem->getBranchObjNum(i);
795 void BranchObj::sortChildren() //FIXME-2
798 int childCount=branch.count();
800 bool madeChanges=false;
804 for(curChildIndex=1;curChildIndex<childCount;curChildIndex++){
805 BranchObj* curChild=(BranchObj*)treeItem->getBranchObjNum(curChildIndex);
806 BranchObj* prevChild=(BranchObj*)treeItem->getBranchObjNum(curChildIndex-1);
807 if(prevChild->heading->text().compare(curChild->heading->text())>0)
809 this->moveBranchUp(curChild);
817 void BranchObj::alignRelativeTo (QPointF ref,bool alignSelf)
819 qreal th = bboxTotal.height();
820 int depth=treeItem->depth();
824 QString h=QString (depth,' ');
825 h+=treeItem->getHeading();
828 QPointF pp; if (parObj) pp=parObj->getChildPos();
829 cout << "BO::alignRelTo ";
830 cout<<h.toStdString();
831 cout << " d="<<depth<<
832 //cout<< " ref="<<ref<<
833 " bbox.tL="<<bboxTotal.topLeft()<<
835 // " relPos="<<relPos<<
837 " w="<<bbox.width()<<
838 " h="<<bbox.height()<<
839 // " orient="<<orientation<<
840 // " alignSelf="<<alignSelf<<
841 // " scrolled="<<((BranchItem*)treeItem)->isScrolled()<<
842 // " pad="<<topPad<<","<<botPad<<","<<leftPad<<","<<rightPad<<
843 // " hidden="<<hidden<<
851 if (depth==1 && parObj)
853 // Position relatively, if needed
854 //if (useRelPos) move2RelPos (relPos.x(), relPos.y());
856 // Calc angle to mapCenter if I am a mainbranch
857 // needed for reordering the mainbranches clockwise
859 angle=getAngle (QPointF ((int)(x() - parObj->getChildPos().x() ),
860 (int)(y() - parObj->getChildPos().y() ) ) );
864 // Align myself depending on orientation and parent, but
865 // only if I am not a mainbranch or mapcenter itself
867 if (anim.isAnimated())
872 LinkableMapObj::Orientation o;
873 o=parObj->getOrientation();
877 case LinkableMapObj::LeftOfCenter:
878 move (ref.x() - bbox.width(), ref.y() + (th-bbox.height())/2 );
879 //move (ref.x() , ref.y() + (th-bbox.height())/2 );
881 case LinkableMapObj::RightOfCenter:
882 move (ref.x() , ref.y() + (th-bbox.height())/2 );
885 qWarning ("LMO::alignRelativeTo: oops, no orientation given...");
891 if ( ((BranchItem*)treeItem)->isScrolled() ) return;
893 // Set reference point for alignment of children
895 if (orientation==LinkableMapObj::LeftOfCenter)
896 ref2.setX(bbox.topLeft().x() - linkwidth);
898 ref2.setX(bbox.topRight().x() + linkwidth);
901 ref2.setY(absPos.y()-(bboxTotal.height()-bbox.height())/2);
905 // Align the children depending on reference point
906 for (int i=0; i<treeItem->branchCount(); ++i)
908 if (!treeItem->getBranchNum(i)->isHidden())
910 treeItem->getBranchObjNum(i)->alignRelativeTo (ref2,true);
912 // append next branch below current one
913 ref2.setY(ref2.y() + treeItem->getBranchObjNum(i)->getBBoxSizeWithChildren().height() );
919 void BranchObj::reposition()
922 if (!treeItem->getHeading().isEmpty())
923 cout << "BO::reposition "<<qPrintable(treeItem->getHeading())<<endl;
925 cout << "BO::reposition ???"<<endl;
926 // cout << " orient="<<orientation<<endl;
929 if (treeItem->depth()==0)
931 // only calculate the sizes once. If the deepest LMO
932 // changes its height,
933 // all upper LMOs have to change, too.
934 calcBBoxSizeWithChildren();
935 updateLink(); // This update is needed if the scene is resized
936 // due to excessive moving of a FIO
938 alignRelativeTo ( QPointF (absPos.x(),
939 absPos.y()-(bboxTotal.height()-bbox.height())/2) );
940 //FIXME-2 qSort (branch.begin(),branch.end(), isAbove);
941 positionBBox(); // Reposition bbox and contents
944 // This is only important for moving branches:
945 // For editing a branch it isn't called...
946 alignRelativeTo ( QPointF (absPos.x(),
947 absPos.y()-(bboxTotal.height()-bbox.height())/2) );
951 void BranchObj::unsetAllRepositionRequests()
953 repositionRequest=false;
954 for (int i=0; i<treeItem->branchCount(); ++i)
955 treeItem->getBranchObjNum(i)->unsetAllRepositionRequests();
959 QPolygonF BranchObj::shape()
963 QRectF r=getTotalBBox();
964 if (orientation==LinkableMapObj::LeftOfCenter)
967 <<QPointF (bbox.topLeft().x(), r.topLeft().y() )
970 <<QPointF (bbox.bottomLeft().x(), r.bottomLeft().y() ) ;
974 <<QPointF (bbox.topRight().x(), r.topRight().y() )
977 <<QPointF (bbox.bottomRight().x(), r.bottomRight().y() ) ;
981 QRectF BranchObj::getTotalBBox()
985 if ( ((BranchItem*)treeItem)->isScrolled() ) return r;
987 for (int i=0; i<treeItem->branchCount(); ++i)
988 if (!treeItem->getBranchNum(i)->isHidden())
989 r=addBBox(treeItem->getBranchObjNum(i)->getTotalBBox(),r);
991 /* FIXME-3 lots of occurences of treeItem->getBranchObjNum(i) in branchobj.cpp
992 better check if they are not NULL and maybe simplify...
993 (have been NULL at least in calcBBoxSizeWithChilds...)
997 FIXME-1 for (int i=0; i<floatimage.size(); ++i)
998 if (!floatimage.at(i)->isHidden())
999 r=addBBox(floatimage.at(i)->getTotalBBox(),r);
1004 QRectF BranchObj::getBBoxSizeWithChildren()
1009 void BranchObj::calcBBoxSizeWithChildren()
1011 // This is initially called only from reposition and
1012 // and only for mapcenter. So it won't be
1013 // called more than once for a single user
1017 // Calculate size of LMO including all children (to align them later)
1018 bboxTotal.setX(bbox.x() );
1019 bboxTotal.setY(bbox.y() );
1021 // if branch is scrolled, ignore children, but still consider floatimages
1022 BranchItem *bi=(BranchItem*)treeItem;
1023 if ( bi->isScrolled() )
1025 bboxTotal.setWidth (bbox.width());
1026 bboxTotal.setHeight(bbox.height());
1032 bboxTotal.setWidth (0);
1033 bboxTotal.setHeight(0);
1036 bboxTotal.setX (parObj->x());
1037 bboxTotal.setY (parObj->y());
1040 bboxTotal.setX (bbox.x());
1041 bboxTotal.setY (bbox.y());
1048 // Now calculate recursivly
1050 // maximum of widths
1052 for (int i=0; i<treeItem->branchCount(); i++)
1054 if (!bi->getBranchNum(i)->isHidden())
1056 bi->getBranchObjNum(i)->calcBBoxSizeWithChildren();
1057 br=bi->getBranchObjNum(i)->getBBoxSizeWithChildren();
1058 r.setWidth( max (br.width(), r.width() ));
1059 r.setHeight(br.height() + r.height() );
1060 if (br.y()<bboxTotal.y()) bboxTotal.setY(br.y());
1063 // Add myself and also
1064 // add width of link to sum if necessary
1065 if (bi->branchCount()<1)
1066 bboxTotal.setWidth (bbox.width() + r.width() );
1068 bboxTotal.setWidth (bbox.width() + r.width() + linkwidth);
1070 bboxTotal.setHeight(max (r.height(), bbox.height()));
1074 void BranchObj::select() // FIXME-4 try to get rid of this in BO completely
1076 cout << "BO::select()\n";
1077 textEditor->setText(treeItem->getNoteObj().getNote() );
1078 QString fnh=treeItem->getNoteObj().getFilenameHint();
1080 textEditor->setFilenameHint(treeItem->getNoteObj().getFilenameHint() );
1082 textEditor->setFilenameHint(getHeading() );
1083 textEditor->setFontHint (treeItem->getNoteObj().getFontHint() );
1084 //isNoteInEditor=true;
1086 // set selected and visible
1087 LinkableMapObj::select();
1089 //if (po) po->setLastSelectedBranch(this); needed?
1091 // temporary unscroll, if we have scrolled parents somewhere
1092 if (parObj) ((BranchObj*)(parObj))->tmpUnscroll();
1094 //moved to vymmodel or vymview...
1095 // Show URL and link in statusbar
1097 if (!url.isEmpty()) status+="URL: "+url+" ";
1098 if (!vymLink.isEmpty()) status+="Link: "+vymLink;
1099 if (!status.isEmpty()) mainWindow->statusMessage (status);
1102 updateFlagsToolbar();
1105 model->updateActions();
1110 void BranchObj::unselect() //FIXME-4 should not be needed
1112 cout << "BO::unselect()\n";
1113 LinkableMapObj::unselect();
1114 // Delete any messages like vymLink in StatusBar
1115 mainWindow->statusMessage (""); //this causes segfault, when MainWindow is already gone in global destructor on quitting vym
1117 // Save current note
1118 if (isNoteInEditor) getNoteFromTextEditor();
1119 isNoteInEditor=false;
1121 // reset temporary unscroll, if we have scrolled parents somewhere
1122 if (parObj) ((BranchObj*)(parObj))->resetTmpUnscroll();
1124 // Erase content of editor
1125 textEditor->setInactive();
1127 // unselect all buttons in toolbar
1128 standardFlagsDefault->updateToolbar();
1132 QString BranchObj::getSelectString()
1134 return model->getSelectString (this);
1137 void BranchObj::setAnimation(const AnimPoint &ap)
1142 bool BranchObj::animate()
1145 if ( anim.isAnimated() )
1150 parObj->reposition(); // we might have been relinked meanwhile