2 #include "texteditor.h"
4 #include "mainwindow.h"
6 extern TextEditor *textEditor;
7 extern Main *mainWindow;
8 extern FlagRowObj *standardFlagsDefault;
9 extern QAction *actionEditOpenURL;
12 /////////////////////////////////////////////////////////////////
14 /////////////////////////////////////////////////////////////////
16 BranchObj* BranchObj::itLast=NULL;
19 BranchObj::BranchObj () :OrnamentedObj()
21 // cout << "Const BranchObj ()\n";
27 BranchObj::BranchObj (QCanvas* c):OrnamentedObj (c)
29 // cout << "Const BranchObj (c) called from MapCenterObj (c)\n";
34 BranchObj::BranchObj (QCanvas* c, LinkableMapObj* p):OrnamentedObj (c)
36 // cout << "Const BranchObj (c,p)\n";
39 depth=p->getDepth()+1;
41 // Calc angle to mapCenter if I am a mainbranch
42 // needed for reordering the mainbranches clockwise
44 angle=getAngle (QPoint ((int)(x() - parObj->getChildPos().x() ),
45 (int)(y() - parObj->getChildPos().y() ) ) );
49 BranchObj::~BranchObj ()
51 // cout << "Destr BranchObj of "<<this<<endl;
52 // Check, if this branch was the last child to be deleted
53 // If so, unset the scrolled flags
55 BranchObj *po=(BranchObj*)(parObj);
59 bo=((BranchObj*)(parObj))->getLastBranch();
60 if (!bo) po->unScroll();
65 bool BranchObj::operator< ( const BranchObj & other )
67 return angle < other.angle;
70 bool BranchObj::operator== ( const BranchObj & other )
72 return angle == other.angle;
75 int BranchObjPtrList::compareItems ( QPtrCollection::Item i, QPtrCollection::Item j)
77 // Make sure PtrList::find works
80 if ( ((BranchObj*)(i))->angle > ((BranchObj*)(j))->angle )
86 void BranchObj::init ()
88 branch.setAutoDelete (false);
89 floatimage.setAutoDelete (true);
90 xlink.setAutoDelete (false);
95 absPos+=parObj->getChildPos();
98 lastSelectedBranch=-1;
109 void BranchObj::copy (BranchObj* other)
111 OrnamentedObj::copy(other);
115 for (b=other->branch.first(); b;b=other->branch.next() )
116 // Make deep copy of b
117 // Because addBranch again calls copy for the childs,
118 // Those will get a deep copy, too
122 for (fi=other->floatimage.first(); fi;fi=other->floatimage.next() )
125 scrolled=other->scrolled;
126 tmpUnscrolled=other->tmpUnscrolled;
127 setVisibility (other->visible);
130 vymLink=other->vymLink;
137 void BranchObj::clear()
140 while (!xlink.isEmpty())
141 deleteXLink (xlink.first() );
144 while (!branch.isEmpty())
147 branch.removeFirst();
152 int BranchObj::getNum()
155 return ((BranchObj*)(parObj))->getNum ((BranchObj*)(this));
160 int BranchObj::getNum(BranchObj *bo)
162 // keep current pointer in branch,
163 // otherwise save might fail
165 int ind=branch.findRef (bo);
170 int BranchObj::getFloatImageNum(FloatImageObj *fio)
172 return floatimage.findRef (fio);
175 int BranchObj::countBranches()
177 return branch.count();
180 int BranchObj::countFloatImages()
182 return floatimage.count();
185 int BranchObj::countXLinks()
187 return xlink.count();
190 void BranchObj::setParObjTmp(LinkableMapObj* lmo, QPoint m, int off)
192 // Temporary link to lmo
193 // m is position of mouse pointer
194 // offset 0: default 1: below lmo -1 above lmo (if possible)
197 BranchObj* o=(BranchObj*)(lmo);
201 // ignore mapcenter and mainbranch
202 if (lmo->getDepth()<2) off=0;
212 // parObj=o->getParObj();
214 // parObj=o->getParObj();
219 depth=parObj->getDepth()+1;
221 // setLinkStyle calls updateLink, only set it once
222 if (style!=getDefLinkStyle() ) setLinkStyle (getDefLinkStyle());
224 // Move temporary to new position at destination
225 // Usually the positioning would be done by reposition(),
226 // but then also the destination branch would "Jump" around...
227 // Better just do it approximately
229 { // new parent is the mapcenter itself
231 QPoint p= normalise ( QPoint (m.x() - o->getChildPos().x(),
232 m.y() - o->getChildPos().y() ));
233 if (p.x()<0) p.setX( p.x()-bbox.width() );
240 // new parent is just a branch, link to it
241 QRect t=o->getBBoxSizeWithChilds();
242 if (o->getLastBranch())
243 y=t.y() + t.height() ;
250 // we want to link above lmo
251 y=o->y() - height() + 5;
253 // we want to link below lmo
254 // Bottom of sel should be 5 pixels above
255 // the bottom of the branch _below_ the target:
256 // Don't try to find that branch, guess 12 pixels
257 y=o->getChildPos().y() -height() + 12;
259 if (o->getOrientation()==OrientLeftOfCenter)
260 move ( o->getChildPos().x() - linkwidth, y );
262 move (o->getChildPos().x() + linkwidth, y );
265 // updateLink is called implicitly in move
266 reposition(); // FIXME shouldn't be this a request?
269 void BranchObj::unsetParObjTmp()
276 depth=parObj->getDepth()+1;
277 setLinkStyle (getDefLinkStyle() );
282 void BranchObj::unScroll()
284 if (tmpUnscrolled) resetTmpUnscroll();
285 if (scrolled) toggleScroll();
288 void BranchObj::toggleScroll()
294 systemFlags->deactivate("scrolledright");
295 for (bo=branch.first(); bo; bo=branch.next() )
297 bo->setVisibility(true);
302 systemFlags->activate("scrolledright");
303 for (bo=branch.first(); bo; bo=branch.next() )
305 bo->setVisibility(false);
310 move (absPos.x(), absPos.y() );
314 bool BranchObj::isScrolled()
319 bool BranchObj::hasScrolledParent(BranchObj *start)
321 // Calls parents recursivly to
322 // find out, if we are scrolled at all.
323 // But ignore myself, just look at parents.
325 if (this !=start && scrolled) return true;
327 BranchObj* bo=(BranchObj*)(parObj);
329 return bo->hasScrolledParent(start);
334 void BranchObj::tmpUnscroll()
336 // Unscroll parent (recursivly)
337 BranchObj* bo=(BranchObj*)(parObj);
338 if (bo) bo->tmpUnscroll();
344 systemFlags->activate("tmpUnscrolledright");
349 void BranchObj::resetTmpUnscroll()
351 // Unscroll parent (recursivly)
352 BranchObj* bo=(BranchObj*)(parObj);
354 bo->resetTmpUnscroll();
360 systemFlags->deactivate("tmpUnscrolledright");
365 void BranchObj::setVisibility(bool v, int toDepth)
367 if (depth <= toDepth)
369 frame->setVisibility(v);
370 heading->setVisibility(v);
371 systemFlags->setVisibility(v);
372 standardFlags->setVisibility(v);
373 LinkableMapObj::setVisibility (v);
375 if (!scrolled && (depth < toDepth))
377 // Now go recursivly through all childs
379 for (b=branch.first(); b;b=branch.next() )
380 b->setVisibility (v,toDepth);
382 for (fio=floatimage.first(); fio; fio=floatimage.next())
383 fio->setVisibility (v);
385 for (xlo=xlink.first(); xlo;xlo=xlink.next() )
386 xlo->setVisibility ();
388 } // depth <= toDepth
392 void BranchObj::setVisibility(bool v)
394 setVisibility (v,MAX_DEPTH);
398 void BranchObj::setLinkColor ()
400 // Overloaded from LinkableMapObj
401 // BranchObj can use color of heading
403 if (mapEditor->getLinkColorHint()==HeadingColor)
404 LinkableMapObj::setLinkColor (heading->getColor() );
406 LinkableMapObj::setLinkColor ();
409 void BranchObj::setColor (QColor col, bool colorChilds)
411 heading->setColor(col);
416 for (bo=branch.first(); bo; bo=branch.next() )
417 bo->setColor(col,colorChilds);
421 QColor BranchObj::getColor()
423 return heading->getColor();
426 BranchObj* BranchObj::first()
432 BranchObj* BranchObj::next()
435 BranchObj *bo=branch.first();
436 BranchObj *po=(BranchObj*)(parObj);
439 { // We are just beginning at the mapCenter
453 { // We come from above
456 // there are childs, go there
461 { // no childs, try to go up again
473 // can't go up, I am mapCenter
480 // Try to find last child, we came from, in my own childs
482 while (bo && searching)
484 if (itLast==bo) searching=false;
488 { // found lastLMO in my childs
491 // found a brother of lastLMO
507 // can't go up, I am mapCenter
514 // couldn't find last child, it must be a nephew of mine
518 // proceed with my first child
524 // or go back to my parents
535 // can't go up, I am mapCenter
542 BranchObj* BranchObj::getLastIterator()
547 void BranchObj::setLastIterator(BranchObj* it)
553 void BranchObj::move (double x, double y)
555 OrnamentedObj::move (x,y);
559 void BranchObj::move (QPoint p)
564 void BranchObj::moveBy (double x, double y)
566 OrnamentedObj::moveBy (x,y);
569 for (b=branch.first(); b;b=branch.next() )
573 void BranchObj::moveBy (QPoint p)
575 moveBy (p.x(), p.y());
579 void BranchObj::positionBBox()
581 // FIXME testing (optimization)
583 QString h=getHeading();
585 cout << "BO::positionBBox("<<h<<")\n";
587 cout << "BO::positionBBox (noHeading)\n";
590 heading->positionBBox();
591 systemFlags->positionBBox();
592 standardFlags->positionBBox();
593 // It seems that setting x,y also affects width,height
594 int w_old=bbox.width();
595 int h_old=bbox.height();
596 bbox.setX (absPos.x() );
597 bbox.setY (absPos.y() );
598 bbox.setWidth(w_old);
599 bbox.setHeight(h_old);
604 frame->setRect(QRect(bbox.x(),bbox.y(),bbox.width(),bbox.height() ) );
606 // Update links to other branches
608 for (xlo=xlink.first(); xlo; xlo=xlink.next() )
612 void BranchObj::calcBBoxSize()
614 QSize heading_r=heading->getSize();
615 int heading_w=static_cast <int> (heading_r.width() );
616 int heading_h=static_cast <int> (heading_r.height() );
617 QSize sysflags_r=systemFlags->getSize();
618 int sysflags_h=sysflags_r.height();
619 int sysflags_w=sysflags_r.width();
620 QSize stanflags_r=standardFlags->getSize();
621 int stanflags_h=stanflags_r.height();
622 int stanflags_w=stanflags_r.width();
626 // set width to sum of all widths
627 w=heading_w + sysflags_w + stanflags_w;
628 // set height to maximum needed height
629 h=max (sysflags_h,stanflags_h);
632 w+=frame->getBorder();
633 h+=frame->getBorder();
634 bbox.setSize (QSize (w,h));
637 LinkableMapObj* BranchObj::findMapObj(QPoint p, LinkableMapObj* excludeLMO)
642 for (b=branch.first(); b; b=branch.next() )
644 lmo=b->findMapObj(p, excludeLMO);
645 if (lmo != NULL) return lmo;
649 if (inBBox (p) && (this != excludeLMO) && isVisibleObj() )
652 // Search float images
654 for (foi=floatimage.first(); foi; foi=floatimage.next() )
655 if (foi->inBBox(p) && (foi != excludeLMO) && foi->getParObj()!= excludeLMO) return foi;
660 void BranchObj::setHeading(QString s)
663 // Adjusting font size
664 QFont font=heading->getFont();
665 font.setPointSize(getDefHeadingSize() );
666 heading->setFont(font);
668 heading->setText(s); // set new heading
669 calcBBoxSize(); // recalculate bbox
670 positionBBox(); // rearrange contents
674 void BranchObj::setURL(QString s)
678 systemFlags->activate("url");
680 systemFlags->deactivate("url");
681 calcBBoxSize(); // recalculate bbox
682 positionBBox(); // rearrange contents
686 QString BranchObj::getURL()
691 void BranchObj::setVymLink(QString s)
695 // We need the relative (from loading)
696 // or absolute path (from User event)
697 // and build the absolute path.
698 // Note: If we have relative, use path of
699 // current map to build absolute path
701 if (!d.path().startsWith ("/"))
703 QString p=mapEditor->getDestPath();
704 int i=p.findRev("/",-1);
705 d.setPath(p.left(i)+"/"+s);
709 systemFlags->activate("vymLink");
713 systemFlags->deactivate("vymLink");
716 calcBBoxSize(); // recalculate bbox
717 positionBBox(); // rearrange contents
721 QString BranchObj::getVymLink()
726 QString BranchObj::saveToDir (const QString &tmpdir,const QString &prefix, const QPoint& offset)
729 QString scrolledAttr;
731 scrolledAttr=attribut ("scrolled","yes");
736 if (depth<2) posAttr=
737 attribut("absPosX",QString().setNum(absPos.x(),10)) +
738 attribut("absPosY",QString().setNum(absPos.y(),10));
744 urlAttr=attribut ("url",url);
747 if (!vymLink.isEmpty())
748 vymLinkAttr=attribut ("vymLink",convertToRel(mapEditor->getDestPath(),vymLink) );
751 if (frame->getFrameType()!=NoFrame)
752 frameAttr=attribut ("frameType",frame->getFrameTypeName());
756 // save area, if not scrolled
758 if (!((BranchObj*)(parObj))->isScrolled() )
761 attribut("x1",QString().setNum(absPos.x()-offset.x(),10)) +
762 attribut("y1",QString().setNum(absPos.y()-offset.y(),10)) +
763 attribut("x2",QString().setNum(absPos.x()+width()-offset.x(),10)) +
764 attribut("y2",QString().setNum(absPos.y()+height()-offset.y(),10));
769 s=beginElement ("branch" +scrolledAttr +posAttr +urlAttr +vymLinkAttr +frameAttr +areaAttr );
773 s=s+valueElement("heading", getHeading(),
774 attribut ("textColor",QColor(heading->getColor()).name()));
776 // save names of flags set
777 s+=standardFlags->saveToDir(tmpdir,prefix,0);
780 if (!note.isEmpty() )
785 for (bo=branch.first(); bo; bo=branch.next() )
786 s+=bo->saveToDir(tmpdir,prefix,offset);
790 for (fio=floatimage.first(); fio; fio=floatimage.next() )
791 s+=fio->saveToDir (tmpdir,prefix);
795 for (xlo=xlink.first(); xlo; xlo=xlink.next() )
799 s+=endElement ("branch");
803 void BranchObj::addXLink (XLinkObj *xlo)
809 void BranchObj::removeXLinkRef (XLinkObj *xlo)
814 void BranchObj::deleteXLink(XLinkObj *xlo)
817 if (!xlo->isUsed()) delete (xlo);
820 void BranchObj::deleteXLinkAt (int i)
822 XLinkObj *xlo=xlink.at(i);
824 if (!xlo->isUsed()) delete(xlo);
827 XLinkObj* BranchObj::XLinkAt (int i)
832 int BranchObj::countXLink()
834 return xlink.count();
837 BranchObj* BranchObj::XLinkTargetAt (int i)
840 return xlink.at(i)->otherBranch (this);
845 LinkableMapObj* BranchObj::addFloatImage ()
847 FloatImageObj *newfi=new FloatImageObj (canvas,this);
848 floatimage.append (newfi);
849 if (hasScrolledParent(this) )
850 newfi->setVisibility (false);
852 newfi->setVisibility(visible);
857 LinkableMapObj* BranchObj::addFloatImage (FloatImageObj *fio)
859 FloatImageObj *newfi=new FloatImageObj (canvas,this);
860 floatimage.append (newfi);
862 if (hasScrolledParent(this) )
863 newfi->setVisibility (false);
865 newfi->setVisibility(visible);
870 FloatImageObj* BranchObj::getFirstFloatImage ()
872 return floatimage.first();
875 FloatImageObj* BranchObj::getLastFloatImage ()
877 return floatimage.last();
880 FloatImageObj* BranchObj::getFloatImageNum (const uint &i)
882 return floatimage.at(i);
885 void BranchObj::removeFloatImage (FloatImageObj *fio)
887 floatimage.remove (fio);
891 void BranchObj::savePosInAngle ()
893 // Save position in angle
896 for (b=branch.first(); b; b=branch.next() )
903 void BranchObj::setDefAttr (BranchModification mod)
908 case 0: fontsize=16; break;
909 case 1: fontsize=12; break;
910 default: fontsize=10; break;
914 setLinkStyle(getDefLinkStyle());
915 QFont font("Sans Serif,8,-1,5,50,0,0,0,0,0");
916 font.setPointSize(fontsize);
917 heading->setFont(font );
920 setColor (((BranchObj*)(parObj))->getColor(),false);
925 BranchObj* BranchObj::addBranch()
927 BranchObj* newbo=new BranchObj(canvas,this);
928 branch.append (newbo);
929 newbo->setParObj(this);
930 newbo->setDefAttr(NewBranch);
931 newbo->setHeading ("new");
933 newbo->setVisibility (false);
935 newbo->setVisibility(visible);
941 BranchObj* BranchObj::addBranch(BranchObj* bo)
943 BranchObj* newbo=new BranchObj(canvas,this);
944 branch.append (newbo);
946 newbo->setParObj(this);
947 newbo->setDefAttr(NewBranch);
949 newbo->setVisibility (false);
951 newbo->setVisibility(bo->visible);
957 BranchObj* BranchObj::addBranchPtr(BranchObj* bo)
960 bo->setParObj (this);
962 bo->setDefAttr(MovedBranch);
963 if (scrolled) tmpUnscroll();
964 setLastSelectedBranch (bo);
968 BranchObj* BranchObj::insertBranch(int pos)
971 // Add new bo and resort branches
972 BranchObj *newbo=addBranch ();
973 newbo->angle=pos-0.5;
978 BranchObj* BranchObj::insertBranch(BranchObj* bo, int pos)
981 // Add new bo and resort branches
983 BranchObj *newbo=addBranch (bo);
988 BranchObj* BranchObj::insertBranchPtr (BranchObj* bo, int pos)
991 // Add new bo and resort branches
994 bo->setParObj (this);
996 bo->setDefAttr (MovedBranch);
997 if (scrolled) tmpUnscroll();
998 setLastSelectedBranch (bo);
1003 void BranchObj::removeBranchHere(BranchObj* borem)
1005 // This removes the branch bo from list, but
1006 // inserts its childs at the place of bo
1008 bo=borem->getLastBranch();
1009 int pos=borem->getNum();
1012 bo->moveBranchTo (this,pos+1);
1013 bo=borem->getLastBranch();
1015 removeBranch (borem);
1018 void BranchObj::removeChilds()
1023 void BranchObj::removeBranch(BranchObj* bo)
1025 // if bo is not in branch remove returns false, we
1028 if (branch.remove (bo))
1031 qWarning ("BranchObj::removeBranch tried to remove non existing branch?!\n");
1032 requestReposition();
1035 void BranchObj::removeBranchPtr(BranchObj* bo)
1038 requestReposition();
1041 void BranchObj::setLastSelectedBranch (BranchObj* bo)
1043 lastSelectedBranch=branch.find(bo);
1046 BranchObj* BranchObj::getLastSelectedBranch ()
1048 if (lastSelectedBranch>=0)
1050 BranchObj* bo=branch.at(lastSelectedBranch);
1053 return branch.first();
1056 BranchObj* BranchObj::getFirstBranch ()
1058 return branch.first();
1061 BranchObj* BranchObj::getLastBranch ()
1063 return branch.last();
1066 BranchObj* BranchObj::getBranchNum (const uint &i)
1068 return branch.at(i);
1072 BranchObj* BranchObj::moveBranchUp(BranchObj* bo1) // move a branch up (modify myself)
1075 int i=branch.find(bo1);
1077 { // -1 if bo1 not found
1078 branch.at(i)->angle--;
1079 branch.at(i-1)->angle++;
1081 return branch.at(i-1);
1083 return branch.at(i);
1086 BranchObj* BranchObj::moveBranchDown(BranchObj* bo1)
1089 int i=branch.find(bo1);
1094 branch.at(i)->angle++;
1095 branch.at(j)->angle--;
1097 return branch.at(j);
1099 return branch.at(i);
1102 BranchObj* BranchObj::moveBranchTo (BranchObj* dst, int pos)
1104 // Find current parent and
1105 // remove pointer to myself there
1106 if (!dst) return NULL;
1107 BranchObj *par=(BranchObj*)(parObj);
1109 par->removeBranchPtr (this);
1113 // Create new pointer to myself at dst
1114 if (pos<0||dst->getDepth()==0)
1116 // links myself as last branch at dst
1117 dst->addBranchPtr (this);
1122 // inserts me at pos in parent of dst
1125 BranchObj *bo=dst->insertBranchPtr (this,pos);
1126 bo->setDefAttr(MovedBranch);
1135 void BranchObj::alignRelativeTo (QPoint ref)
1138 if (!getHeading().isEmpty())
1139 cout << "BO::alignRelTo "<<getHeading()<<endl;
1141 cout << "BO::alignRelTo ???"<<endl;
1142 cout << " d="<<depth<<endl;
1144 int th = bboxTotal.height();
1146 // If I am the mapcenter or a mainbranch, reposition heading
1149 move (absPos.x(),absPos.y());
1152 // Calc angle to mapCenter if I am a mainbranch
1153 // needed for reordering the mainbranches clockwise
1155 angle=getAngle (QPoint ((int)(x() - parObj->getChildPos().x() ),
1156 (int)(y() - parObj->getChildPos().y() ) ) );
1161 // Align myself depending on orientation and parent, but
1162 // only if I am not the mainbranch or mapcenter itself
1163 switch (orientation)
1165 case OrientLeftOfCenter:
1166 move (ref.x()-bbox.width(), ref.y() + (th-bbox.height())/2 );
1168 case OrientRightOfCenter:
1169 move (ref.x(), ref.y() + (th-bbox.height())/2 );
1172 cout <<"LMO::alignRelativeTo: oops, no orientation given...\n";
1178 for (fio=floatimage.first(); fio; fio=floatimage.next() )
1181 if (scrolled) return;
1183 // Set reference point for alignment of childs
1185 if (orientation==OrientLeftOfCenter)
1186 ref2.setX(childPos.x() - linkwidth);
1188 ref2.setX(childPos.x() + linkwidth);
1191 ref2.setY(absPos.y()-(bboxTotal.height()-bbox.height())/2);
1193 ref2.setY(ref.y() );
1195 // Align the childs depending on reference point
1197 for (b=branch.first(); b; b=branch.next() )
1199 b->alignRelativeTo (ref2);
1200 ref2.setY(ref2.y() + b->getBBoxSizeWithChilds().height() );
1205 void BranchObj::reposition()
1208 if (!getHeading().isEmpty())
1209 cout << "BO::reposition "<<getHeading()<<endl;
1211 cout << "BO::reposition ???"<<endl;
1215 // only calculate the sizes once. If the deepest LMO
1216 // changes its height,
1217 // all upper LMOs have to change, too.
1218 calcBBoxSizeWithChilds();
1219 alignRelativeTo ( QPoint (absPos.x(),
1220 absPos.y()-(bboxTotal.height()-bbox.height())/2) );
1224 // This is only important for moving branches:
1225 // For editing a branch it isn't called...
1226 alignRelativeTo ( QPoint (absPos.x(),
1227 absPos.y()-(bboxTotal.height()-bbox.height())/2) );
1232 QRect BranchObj::getTotalBBox()
1236 if (scrolled) return r;
1239 for (b=branch.first();b ;b=branch.next() )
1240 r=addBBox(b->getTotalBBox(),r);
1243 for (fio=floatimage.first();fio ;fio=floatimage.next() )
1244 r=addBBox(fio->getTotalBBox(),r);
1249 QRect BranchObj::getBBoxSizeWithChilds()
1254 void BranchObj::calcBBoxSizeWithChilds()
1256 // This is called only from reposition and
1257 // and only for mapcenter. So it won't be
1258 // called more than once for a single user
1261 // Calculate size of LMO including all childs (to align them later)
1263 bboxTotal.setX(bbox.x() );
1264 bboxTotal.setY(bbox.y() );
1266 // if branch is scrolled, ignore childs, but still consider floatimages
1269 bboxTotal.setWidth (bbox.width());
1270 bboxTotal.setHeight(bbox.height());
1276 // Now calculate recursivly
1278 // maximum of widths
1281 for (b=branch.first();b ;b=branch.next() )
1283 b->calcBBoxSizeWithChilds();
1284 br=b->getBBoxSizeWithChilds();
1285 r.setWidth( max (br.width(), r.width() ));
1286 r.setHeight(br.height() + r.height() );
1287 if (br.y()<bboxTotal.y()) bboxTotal.setY(br.y());
1289 // Add myself and also
1290 // add width of link to sum if necessary
1291 if (branch.isEmpty())
1292 bboxTotal.setWidth (bbox.width() + r.width() );
1294 bboxTotal.setWidth (bbox.width() + r.width() + linkwidth);
1295 bboxTotal.setHeight(max (r.height(), bbox.height() ) );
1296 // frame->setRect(QRect(bbox.x(),bbox.y(),bbox.width(),bbox.height() ) );
1299 void BranchObj::select()
1301 LinkableMapObj::select();
1302 // Tell parent that I am selected now:
1303 BranchObj* po=(BranchObj*)(parObj);
1304 if (po) // TODO Try to get rid of this cast...
1305 po->setLastSelectedBranch(this);
1307 // temporary unscroll, if we have scrolled parents somewhere
1308 if (parObj) ((BranchObj*)(parObj))->tmpUnscroll();
1310 // set Text in Editor
1311 textEditor->setText(note.getNote() );
1312 QString fnh=note.getFilenameHint();
1314 textEditor->setFilenameHint(note.getFilenameHint() );
1316 textEditor->setFilenameHint(getHeading() );
1317 textEditor->setFontHint (note.getFontHint() );
1318 connect (textEditor, SIGNAL (textHasChanged() ), this, SLOT (updateNoteFlag() ) );
1319 connect (textEditor, SIGNAL (fontSizeHasChanged() ), this, SLOT (updateNoteFlag() ) );
1321 // Show URL and link in statusbar
1323 if (!url.isEmpty()) status+="URL: "+url+" ";
1324 if (!vymLink.isEmpty()) status+="Link: "+vymLink;
1325 if (!status.isEmpty()) mainWindow->statusMessage (status);
1328 standardFlags->updateToolbar();
1330 // Update Browserbutton
1332 actionEditOpenURL->setEnabled (true);
1334 actionEditOpenURL->setEnabled (false);
1336 // Update actions in mapeditor
1337 mapEditor->updateActions();
1340 void BranchObj::unselect()
1342 LinkableMapObj::unselect();
1343 // Delete any messages like vymLink in StatusBar
1344 mainWindow->statusMessage ("");
1346 // save note from editor and set flag
1347 // text is done by updateNoteFlag(), just save
1349 note.setFilenameHint (textEditor->getFilename());
1351 // reset temporary unscroll, if we have scrolled parents somewhere
1352 if (parObj) ((BranchObj*)(parObj))->resetTmpUnscroll();
1354 // Disconnect textEditor from this LMO
1355 disconnect( textEditor, SIGNAL(textHasChanged()), 0, 0 );
1356 disconnect( textEditor, SIGNAL (fontSizeHasChanged()),0,0 );
1358 // Erase content of editor
1359 textEditor->setInactive();
1361 // unselect all buttons in toolbar
1362 standardFlagsDefault->updateToolbar();
1365 QString BranchObj::getSelectString()
1371 s= "bo:" + QString("%1").arg(getNum());
1373 s= ((BranchObj*)(parObj))->getSelectString() + ",bo:" + QString("%1").arg(getNum());