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 // TODO This should be done in TextObj later
99 QFont font("Sans Serif,8,-1,5,50,0,0,0,0,0");
100 heading->setFont(font );
102 lastSelectedBranch=-1;
113 void BranchObj::copy (BranchObj* other)
115 OrnamentedObj::copy(other);
119 for (b=other->branch.first(); b;b=other->branch.next() )
120 // Make deep copy of b
121 // Because addBranch again calls copy for the childs,
122 // Those will get a deep copy, too
126 for (fi=other->floatimage.first(); fi;fi=other->floatimage.next() )
129 scrolled=other->scrolled;
130 tmpUnscrolled=other->tmpUnscrolled;
131 setVisibility (other->visible);
134 vymLink=other->vymLink;
141 void BranchObj::clear()
144 while (!xlink.isEmpty())
145 deleteXLink (xlink.first() );
148 while (!branch.isEmpty())
151 branch.removeFirst();
156 int BranchObj::getNum()
159 return ((BranchObj*)(parObj))->getNum ((BranchObj*)(this));
164 int BranchObj::getNum(BranchObj *bo)
166 // keep current pointer in branch,
167 // otherwise save might fail
169 int ind=branch.findRef (bo);
174 int BranchObj::getFloatImageNum(FloatImageObj *fio)
176 return floatimage.findRef (fio);
179 int BranchObj::countBranches()
181 return branch.count();
184 int BranchObj::countFloatImages()
186 return floatimage.count();
189 int BranchObj::countXLinks()
191 return xlink.count();
194 void BranchObj::setParObjTmp(LinkableMapObj* lmo, QPoint m, int off)
196 // Temporary link to lmo
197 // m is position of mouse pointer
198 // offset 0: default 1: below lmo -1 above lmo (if possible)
201 BranchObj* o=(BranchObj*)(lmo);
205 // ignore mapcenter and mainbranch
206 if (lmo->getDepth()<2) off=0;
216 // parObj=o->getParObj();
218 // parObj=o->getParObj();
223 depth=parObj->getDepth()+1;
225 // setLinkStyle calls updateLink, only set it once
226 if (style!=getDefLinkStyle() ) setLinkStyle (getDefLinkStyle());
228 // Move temporary to new position at destination
229 // Usually the positioning would be done by reposition(),
230 // but then also the destination branch would "Jump" around...
231 // Better just do it approximately
233 { // new parent is the mapcenter itself
235 QPoint p= normalise ( QPoint (m.x() - o->getChildPos().x(),
236 m.y() - o->getChildPos().y() ));
237 if (p.x()<0) p.setX( p.x()-bbox.width() );
244 // new parent is just a branch, link to it
245 QRect t=o->getBBoxSizeWithChilds();
246 if (o->getLastBranch())
247 y=t.y() + t.height() ;
254 // we want to link above lmo
255 y=o->y() - height() + 5;
257 // we want to link below lmo
258 // Bottom of sel should be 5 pixels above
259 // the bottom of the branch _below_ the target:
260 // Don't try to find that branch, guess 12 pixels
261 y=o->getChildPos().y() -height() + 12;
263 if (o->getOrientation()==OrientLeftOfCenter)
264 move ( o->getChildPos().x() - linkwidth, y );
266 move (o->getChildPos().x() + linkwidth, y );
269 // updateLink is called implicitly in move
270 reposition(); // FIXME shouldn't be this a request?
273 void BranchObj::unsetParObjTmp()
280 depth=parObj->getDepth()+1;
281 setLinkStyle (getDefLinkStyle() );
286 void BranchObj::unScroll()
288 if (tmpUnscrolled) resetTmpUnscroll();
289 if (scrolled) toggleScroll();
292 void BranchObj::toggleScroll()
298 systemFlags->deactivate("scrolledright");
299 for (bo=branch.first(); bo; bo=branch.next() )
301 bo->setVisibility(true);
306 systemFlags->activate("scrolledright");
307 for (bo=branch.first(); bo; bo=branch.next() )
309 bo->setVisibility(false);
314 move (absPos.x(), absPos.y() );
318 bool BranchObj::isScrolled()
323 bool BranchObj::hasScrolledParent(BranchObj *start)
325 // Calls parents recursivly to
326 // find out, if we are scrolled at all.
327 // But ignore myself, just look at parents.
329 if (this !=start && scrolled) return true;
331 BranchObj* bo=(BranchObj*)(parObj);
333 return bo->hasScrolledParent(start);
338 void BranchObj::tmpUnscroll()
340 // Unscroll parent (recursivly)
341 BranchObj* bo=(BranchObj*)(parObj);
342 if (bo) bo->tmpUnscroll();
348 systemFlags->activate("tmpUnscrolledright");
353 void BranchObj::resetTmpUnscroll()
355 // Unscroll parent (recursivly)
356 BranchObj* bo=(BranchObj*)(parObj);
358 bo->resetTmpUnscroll();
364 systemFlags->deactivate("tmpUnscrolledright");
369 void BranchObj::setVisibility(bool v, int toDepth)
371 if (depth <= toDepth)
373 frame->setVisibility(v);
374 heading->setVisibility(v);
375 systemFlags->setVisibility(v);
376 standardFlags->setVisibility(v);
377 LinkableMapObj::setVisibility (v);
379 if (!scrolled && (depth < toDepth))
381 // Now go recursivly through all childs
383 for (b=branch.first(); b;b=branch.next() )
384 b->setVisibility (v,toDepth);
386 for (fio=floatimage.first(); fio; fio=floatimage.next())
387 fio->setVisibility (v);
389 for (xlo=xlink.first(); xlo;xlo=xlink.next() )
390 xlo->setVisibility ();
392 } // depth <= toDepth
396 void BranchObj::setVisibility(bool v)
398 setVisibility (v,MAX_DEPTH);
402 void BranchObj::setLinkColor ()
404 // Overloaded from LinkableMapObj
405 // BranchObj can use color of heading
407 if (mapEditor->getLinkColorHint()==HeadingColor)
408 LinkableMapObj::setLinkColor (heading->getColor() );
410 LinkableMapObj::setLinkColor ();
413 void BranchObj::setColor (QColor col, bool colorChilds)
415 heading->setColor(col);
420 for (bo=branch.first(); bo; bo=branch.next() )
421 bo->setColor(col,colorChilds);
425 QColor BranchObj::getColor()
427 return heading->getColor();
430 BranchObj* BranchObj::first()
436 BranchObj* BranchObj::next()
439 BranchObj *bo=branch.first();
440 BranchObj *po=(BranchObj*)(parObj);
443 { // We are just beginning at the mapCenter
457 { // We come from above
460 // there are childs, go there
465 { // no childs, try to go up again
477 // can't go up, I am mapCenter
484 // Try to find last child, we came from, in my own childs
486 while (bo && searching)
488 if (itLast==bo) searching=false;
492 { // found lastLMO in my childs
495 // found a brother of lastLMO
511 // can't go up, I am mapCenter
518 // couldn't find last child, it must be a nephew of mine
522 // proceed with my first child
528 // or go back to my parents
539 // can't go up, I am mapCenter
546 BranchObj* BranchObj::getLastIterator()
551 void BranchObj::setLastIterator(BranchObj* it)
557 void BranchObj::move (double x, double y)
559 OrnamentedObj::move (x,y);
563 void BranchObj::move (QPoint p)
568 void BranchObj::moveBy (double x, double y)
570 OrnamentedObj::moveBy (x,y);
573 for (b=branch.first(); b;b=branch.next() )
577 void BranchObj::moveBy (QPoint p)
579 moveBy (p.x(), p.y());
583 void BranchObj::positionBBox()
585 // FIXME testing (optimization)
587 QString h=getHeading();
589 cout << "BO::positionBBox("<<h<<")\n";
591 cout << "BO::positionBBox (noHeading)\n";
594 heading->positionBBox();
595 systemFlags->positionBBox();
596 standardFlags->positionBBox();
597 // It seems that setting x,y also affects width,height
598 int w_old=bbox.width();
599 int h_old=bbox.height();
600 bbox.setX (absPos.x() );
601 bbox.setY (absPos.y() );
602 bbox.setWidth(w_old);
603 bbox.setHeight(h_old);
608 frame->setRect(QRect(bbox.x(),bbox.y(),bbox.width(),bbox.height() ) );
610 // Update links to other branches
612 for (xlo=xlink.first(); xlo; xlo=xlink.next() )
616 void BranchObj::calcBBoxSize()
618 QSize heading_r=heading->getSize();
619 int heading_w=static_cast <int> (heading_r.width() );
620 int heading_h=static_cast <int> (heading_r.height() );
621 QSize sysflags_r=systemFlags->getSize();
622 int sysflags_h=sysflags_r.height();
623 int sysflags_w=sysflags_r.width();
624 QSize stanflags_r=standardFlags->getSize();
625 int stanflags_h=stanflags_r.height();
626 int stanflags_w=stanflags_r.width();
630 // set width to sum of all widths
631 w=heading_w + sysflags_w + stanflags_w;
632 // set height to maximum needed height
633 h=max (sysflags_h,stanflags_h);
636 w+=frame->getBorder();
637 h+=frame->getBorder();
638 bbox.setSize (QSize (w,h));
641 LinkableMapObj* BranchObj::findMapObj(QPoint p, LinkableMapObj* excludeLMO)
646 for (b=branch.first(); b; b=branch.next() )
648 lmo=b->findMapObj(p, excludeLMO);
649 if (lmo != NULL) return lmo;
653 if (inBBox (p) && (this != excludeLMO) && isVisibleObj() )
656 // Search float images
658 for (foi=floatimage.first(); foi; foi=floatimage.next() )
659 if (foi->inBBox(p) && (foi != excludeLMO) && foi->getParObj()!= excludeLMO) return foi;
664 void BranchObj::setHeading(QString s)
666 // Adjusting font size
667 QFont font=heading->getFont();
669 font.setPointSize(16);
672 font.setPointSize(10);
674 font.setPointSize(12);
675 heading->setFont(font);
676 heading->setText(s); // set new heading
677 calcBBoxSize(); // recalculate bbox
678 positionBBox(); // rearrange contents
682 void BranchObj::setURL(QString s)
686 systemFlags->activate("url");
688 systemFlags->deactivate("url");
689 calcBBoxSize(); // recalculate bbox
690 positionBBox(); // rearrange contents
694 QString BranchObj::getURL()
699 void BranchObj::setVymLink(QString s)
703 // We need the relative (from loading)
704 // or absolute path (from User event)
705 // and build the absolute path.
706 // Note: If we have relative, use path of
707 // current map to build absolute path
709 if (!d.path().startsWith ("/"))
711 QString p=mapEditor->getDestPath();
712 int i=p.findRev("/",-1);
713 d.setPath(p.left(i)+"/"+s);
717 systemFlags->activate("vymLink");
721 systemFlags->deactivate("vymLink");
724 calcBBoxSize(); // recalculate bbox
725 positionBBox(); // rearrange contents
729 QString BranchObj::getVymLink()
734 QString BranchObj::saveToDir (const QString &tmpdir,const QString &prefix, const QPoint& offset)
737 QString scrolledAttr;
739 scrolledAttr=attribut ("scrolled","yes");
744 if (depth<2) posAttr=
745 attribut("absPosX",QString().setNum(absPos.x(),10)) +
746 attribut("absPosY",QString().setNum(absPos.y(),10));
752 urlAttr=attribut ("url",url);
755 if (!vymLink.isEmpty())
756 vymLinkAttr=attribut ("vymLink",convertToRel(mapEditor->getDestPath(),vymLink) );
759 if (frame->getFrameType()!=NoFrame)
760 frameAttr=attribut ("frameType",frame->getFrameTypeName());
764 // save area, if not scrolled
766 if (!((BranchObj*)(parObj))->isScrolled() )
769 attribut("x1",QString().setNum(absPos.x()-offset.x(),10)) +
770 attribut("y1",QString().setNum(absPos.y()-offset.y(),10)) +
771 attribut("x2",QString().setNum(absPos.x()+width()-offset.x(),10)) +
772 attribut("y2",QString().setNum(absPos.y()+height()-offset.y(),10));
777 s=beginElement ("branch" +scrolledAttr +posAttr +urlAttr +vymLinkAttr +frameAttr +areaAttr );
781 s=s+valueElement("heading", getHeading(),
782 attribut ("textColor",QColor(heading->getColor()).name()));
784 // save names of flags set
785 s+=standardFlags->saveToDir(tmpdir,prefix,0);
788 if (!note.isEmpty() )
793 for (bo=branch.first(); bo; bo=branch.next() )
794 s+=bo->saveToDir(tmpdir,prefix,offset);
798 for (fio=floatimage.first(); fio; fio=floatimage.next() )
799 s+=fio->saveToDir (tmpdir,prefix);
803 for (xlo=xlink.first(); xlo; xlo=xlink.next() )
807 s+=endElement ("branch");
811 void BranchObj::addXLink (XLinkObj *xlo)
817 void BranchObj::removeXLinkRef (XLinkObj *xlo)
822 void BranchObj::deleteXLink(XLinkObj *xlo)
825 if (!xlo->isUsed()) delete (xlo);
828 void BranchObj::deleteXLinkAt (int i)
830 XLinkObj *xlo=xlink.at(i);
832 if (!xlo->isUsed()) delete(xlo);
835 XLinkObj* BranchObj::XLinkAt (int i)
840 int BranchObj::countXLink()
842 return xlink.count();
845 BranchObj* BranchObj::XLinkTargetAt (int i)
848 return xlink.at(i)->otherBranch (this);
853 LinkableMapObj* BranchObj::addFloatImage ()
855 FloatImageObj *newfi=new FloatImageObj (canvas,this);
856 floatimage.append (newfi);
857 if (hasScrolledParent(this) )
858 newfi->setVisibility (false);
860 newfi->setVisibility(visible);
865 LinkableMapObj* BranchObj::addFloatImage (FloatImageObj *fio)
867 FloatImageObj *newfi=new FloatImageObj (canvas,this);
868 floatimage.append (newfi);
870 if (hasScrolledParent(this) )
871 newfi->setVisibility (false);
873 newfi->setVisibility(visible);
878 FloatImageObj* BranchObj::getFirstFloatImage ()
880 return floatimage.first();
883 FloatImageObj* BranchObj::getLastFloatImage ()
885 return floatimage.last();
888 FloatImageObj* BranchObj::getFloatImageNum (const uint &i)
890 return floatimage.at(i);
893 void BranchObj::removeFloatImage (FloatImageObj *fio)
895 floatimage.remove (fio);
899 void BranchObj::savePosInAngle ()
901 // Save position in angle
904 for (b=branch.first(); b; b=branch.next() )
911 BranchObj* BranchObj::addBranch()
913 BranchObj* newbo=new BranchObj(canvas,this);
914 branch.append (newbo);
915 newbo->setParObj(this);
916 newbo->setColor(getColor(),false);
917 newbo->setLinkColor();
918 newbo->setHeading ("new");
919 newbo->setLinkStyle (newbo->getDefLinkStyle());
921 newbo->setVisibility (false);
923 newbo->setVisibility(visible);
929 BranchObj* BranchObj::addBranch(BranchObj* bo)
931 BranchObj* newbo=new BranchObj(canvas,this);
932 branch.append (newbo);
934 newbo->setParObj(this);
935 newbo->setHeading (newbo->getHeading()); // adjust fontsize to depth
936 newbo->setLinkStyle (newbo->getDefLinkStyle());
938 newbo->setVisibility (false);
940 newbo->setVisibility(bo->visible);
946 BranchObj* BranchObj::addBranchPtr(BranchObj* bo)
949 bo->setParObj (this);
951 bo->setLinkStyle (bo->getDefLinkStyle() );
952 if (scrolled) tmpUnscroll();
953 setLastSelectedBranch (bo);
957 BranchObj* BranchObj::insertBranch(int pos)
960 // Add new bo and resort branches
961 BranchObj *newbo=addBranch ();
962 newbo->angle=pos-0.5;
967 BranchObj* BranchObj::insertBranch(BranchObj* bo, int pos)
970 // Add new bo and resort branches
972 BranchObj *newbo=addBranch (bo);
977 BranchObj* BranchObj::insertBranchPtr (BranchObj* bo, int pos)
980 // Add new bo and resort branches
983 bo->setParObj (this);
985 bo->setLinkStyle (bo->getDefLinkStyle() );
986 if (scrolled) tmpUnscroll();
987 setLastSelectedBranch (bo);
992 void BranchObj::removeBranchHere(BranchObj* borem)
994 // This removes the branch bo from list, but
995 // inserts its childs at the place of bo
997 bo=borem->getLastBranch();
1000 bo->moveBranchTo (borem,1);
1001 bo=borem->getLastBranch();
1003 removeBranch (borem);
1006 void BranchObj::removeChilds()
1011 void BranchObj::removeBranch(BranchObj* bo)
1013 // if bo is not in branch remove returns false, we
1016 if (branch.remove (bo))
1019 qWarning ("BranchObj::removeBranch tried to remove non existing branch?!\n");
1020 requestReposition();
1023 void BranchObj::removeBranchPtr(BranchObj* bo)
1026 requestReposition();
1029 void BranchObj::setLastSelectedBranch (BranchObj* bo)
1031 lastSelectedBranch=branch.find(bo);
1034 BranchObj* BranchObj::getLastSelectedBranch ()
1036 if (lastSelectedBranch>=0)
1038 BranchObj* bo=branch.at(lastSelectedBranch);
1041 return branch.first();
1044 BranchObj* BranchObj::getFirstBranch ()
1046 return branch.first();
1049 BranchObj* BranchObj::getLastBranch ()
1051 return branch.last();
1054 BranchObj* BranchObj::getBranchNum (const uint &i)
1056 return branch.at(i);
1060 BranchObj* BranchObj::moveBranchUp(BranchObj* bo1) // move a branch up (modify myself)
1063 int i=branch.find(bo1);
1065 { // -1 if bo1 not found
1066 branch.at(i)->angle--;
1067 branch.at(i-1)->angle++;
1069 return branch.at(i-1);
1071 return branch.at(i);
1074 BranchObj* BranchObj::moveBranchDown(BranchObj* bo1)
1077 int i=branch.find(bo1);
1082 branch.at(i)->angle++;
1083 branch.at(j)->angle--;
1085 return branch.at(j);
1087 return branch.at(i);
1090 BranchObj* BranchObj::moveBranchTo (BranchObj* dst, int pos)
1092 // Find current parent and
1093 // remove pointer to myself there
1094 if (!dst) return NULL;
1095 BranchObj *par=(BranchObj*)(parObj);
1097 par->removeBranchPtr (this);
1101 // Create new pointer to myself at dst
1102 if (pos<0||dst->getDepth()==0)
1104 // links myself as last branch at dst
1105 dst->addBranchPtr (this);
1109 // inserts me at pos in parent of dst
1110 par=(BranchObj*)(dst->getParObj());
1112 return par->insertBranchPtr (this,pos);
1118 void BranchObj::alignRelativeTo (QPoint ref)
1121 if (!getHeading().isEmpty())
1122 cout << "BO::alignRelTo "<<getHeading()<<endl;
1124 cout << "BO::alignRelTo ???"<<endl;
1125 cout << " d="<<depth<<endl;
1127 int th = bboxTotal.height();
1129 // If I am the mapcenter or a mainbranch, reposition heading
1132 move (absPos.x(),absPos.y());
1135 // Calc angle to mapCenter if I am a mainbranch
1136 // needed for reordering the mainbranches clockwise
1138 angle=getAngle (QPoint ((int)(x() - parObj->getChildPos().x() ),
1139 (int)(y() - parObj->getChildPos().y() ) ) );
1144 // Align myself depending on orientation and parent, but
1145 // only if I am not the mainbranch or mapcenter itself
1146 switch (orientation)
1148 case OrientLeftOfCenter:
1149 move (ref.x()-bbox.width(), ref.y() + (th-bbox.height())/2 );
1151 case OrientRightOfCenter:
1152 move (ref.x(), ref.y() + (th-bbox.height())/2 );
1155 cout <<"LMO::alignRelativeTo: oops, no orientation given...\n";
1161 for (fio=floatimage.first(); fio; fio=floatimage.next() )
1164 if (scrolled) return;
1166 // Set reference point for alignment of childs
1168 if (orientation==OrientLeftOfCenter)
1169 ref2.setX(childPos.x() - linkwidth);
1171 ref2.setX(childPos.x() + linkwidth);
1174 ref2.setY(absPos.y()-(bboxTotal.height()-bbox.height())/2);
1176 ref2.setY(ref.y() );
1178 // Align the childs depending on reference point
1180 for (b=branch.first(); b; b=branch.next() )
1182 b->alignRelativeTo (ref2);
1183 ref2.setY(ref2.y() + b->getBBoxSizeWithChilds().height() );
1188 void BranchObj::reposition()
1191 if (!getHeading().isEmpty())
1192 cout << "BO::reposition "<<getHeading()<<endl;
1194 cout << "BO::reposition ???"<<endl;
1198 // only calculate the sizes once. If the deepest LMO
1199 // changes its height,
1200 // all upper LMOs have to change, too.
1201 calcBBoxSizeWithChilds();
1202 alignRelativeTo ( QPoint (absPos.x(),
1203 absPos.y()-(bboxTotal.height()-bbox.height())/2) );
1207 // This is only important for moving branches:
1208 // For editing a branch it isn't called...
1209 alignRelativeTo ( QPoint (absPos.x(),
1210 absPos.y()-(bboxTotal.height()-bbox.height())/2) );
1215 QRect BranchObj::getTotalBBox()
1219 if (scrolled) return r;
1222 for (b=branch.first();b ;b=branch.next() )
1223 r=addBBox(b->getTotalBBox(),r);
1226 for (fio=floatimage.first();fio ;fio=floatimage.next() )
1227 r=addBBox(fio->getTotalBBox(),r);
1232 QRect BranchObj::getBBoxSizeWithChilds()
1237 void BranchObj::calcBBoxSizeWithChilds()
1239 // This is called only from reposition and
1240 // and only for mapcenter. So it won't be
1241 // called more than once for a single user
1244 // Calculate size of LMO including all childs (to align them later)
1246 bboxTotal.setX(bbox.x() );
1247 bboxTotal.setY(bbox.y() );
1249 // if branch is scrolled, ignore childs, but still consider floatimages
1252 bboxTotal.setWidth (bbox.width());
1253 bboxTotal.setHeight(bbox.height());
1259 // Now calculate recursivly
1261 // maximum of widths
1264 for (b=branch.first();b ;b=branch.next() )
1266 b->calcBBoxSizeWithChilds();
1267 br=b->getBBoxSizeWithChilds();
1268 r.setWidth( max (br.width(), r.width() ));
1269 r.setHeight(br.height() + r.height() );
1270 if (br.y()<bboxTotal.y()) bboxTotal.setY(br.y());
1272 // Add myself and also
1273 // add width of link to sum if necessary
1274 if (branch.isEmpty())
1275 bboxTotal.setWidth (bbox.width() + r.width() );
1277 bboxTotal.setWidth (bbox.width() + r.width() + linkwidth);
1278 bboxTotal.setHeight(max (r.height(), bbox.height() ) );
1279 // frame->setRect(QRect(bbox.x(),bbox.y(),bbox.width(),bbox.height() ) );
1282 void BranchObj::select()
1284 LinkableMapObj::select();
1285 // Tell parent that I am selected now:
1286 BranchObj* po=(BranchObj*)(parObj);
1287 if (po) // TODO Try to get rid of this cast...
1288 po->setLastSelectedBranch(this);
1290 // temporary unscroll, if we have scrolled parents somewhere
1291 if (parObj) ((BranchObj*)(parObj))->tmpUnscroll();
1293 // set Text in Editor
1294 textEditor->setText(note.getNote() );
1295 QString fnh=note.getFilenameHint();
1297 textEditor->setFilenameHint(note.getFilenameHint() );
1299 textEditor->setFilenameHint(getHeading() );
1300 textEditor->setFontHint (note.getFontHint() );
1301 connect (textEditor, SIGNAL (textHasChanged() ), this, SLOT (updateNoteFlag() ) );
1302 connect (textEditor, SIGNAL (fontSizeHasChanged() ), this, SLOT (updateNoteFlag() ) );
1304 // Show URL and link in statusbar
1306 if (!url.isEmpty()) status+="URL: "+url+" ";
1307 if (!vymLink.isEmpty()) status+="Link: "+vymLink;
1308 if (!status.isEmpty()) mainWindow->statusMessage (status);
1311 standardFlags->updateToolbar();
1313 // Update Browserbutton
1315 actionEditOpenURL->setEnabled (true);
1317 actionEditOpenURL->setEnabled (false);
1319 // Update actions in mapeditor
1320 mapEditor->updateActions();
1323 void BranchObj::unselect()
1325 LinkableMapObj::unselect();
1326 // Delete any messages like vymLink in StatusBar
1327 mainWindow->statusMessage ("");
1329 // save note from editor and set flag
1330 // text is done by updateNoteFlag(), just save
1332 note.setFilenameHint (textEditor->getFilename());
1334 // reset temporary unscroll, if we have scrolled parents somewhere
1335 if (parObj) ((BranchObj*)(parObj))->resetTmpUnscroll();
1337 // Disconnect textEditor from this LMO
1338 disconnect( textEditor, SIGNAL(textHasChanged()), 0, 0 );
1339 disconnect( textEditor, SIGNAL (fontSizeHasChanged()),0,0 );
1341 // Erase content of editor
1342 textEditor->setInactive();
1344 // unselect all buttons in toolbar
1345 standardFlagsDefault->updateToolbar();
1348 QString BranchObj::getSelectString()
1354 s= "bo:" + QString("%1").arg(getNum());
1356 s= ((BranchObj*)(parObj))->getSelectString() + ",bo:" + QString("%1").arg(getNum());