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;
209 depth=parObj->getDepth()+1;
211 // setLinkStyle calls updateLink, only set it once
212 if (style!=getDefLinkStyle() ) setLinkStyle (getDefLinkStyle());
214 // Move temporary to new position at destination
215 // Usually the positioning would be done by reposition(),
216 // but then also the destination branch would "Jump" around...
217 // Better just do it approximately
219 { // new parent is the mapcenter itself
221 QPoint p= normalise ( QPoint (m.x() - o->getChildPos().x(),
222 m.y() - o->getChildPos().y() ));
223 if (p.x()<0) p.setX( p.x()-bbox.width() );
230 // new parent is just a branch, link to it
231 QRect t=o->getBBoxSizeWithChilds();
232 if (o->getLastBranch())
233 y=t.y() + t.height() ;
240 // we want to link above lmo
241 y=o->y() - height() + 5;
243 // we want to link below lmo
244 // Bottom of sel should be 5 pixels above
245 // the bottom of the branch _below_ the target:
246 // Don't try to find that branch, guess 12 pixels
247 y=o->getChildPos().y() -height() + 12;
249 if (o->getOrientation()==OrientLeftOfCenter)
250 move ( o->getChildPos().x() - linkwidth, y );
252 move (o->getChildPos().x() + linkwidth, y );
255 // updateLink is called implicitly in move
256 reposition(); // FIXME shouldn't be this a request?
259 void BranchObj::unsetParObjTmp()
266 depth=parObj->getDepth()+1;
267 setLinkStyle (getDefLinkStyle() );
272 void BranchObj::unScroll()
274 if (tmpUnscrolled) resetTmpUnscroll();
275 if (scrolled) toggleScroll();
278 void BranchObj::toggleScroll()
284 systemFlags->deactivate("scrolledright");
285 for (bo=branch.first(); bo; bo=branch.next() )
287 bo->setVisibility(true);
292 systemFlags->activate("scrolledright");
293 for (bo=branch.first(); bo; bo=branch.next() )
295 bo->setVisibility(false);
300 move (absPos.x(), absPos.y() );
304 bool BranchObj::isScrolled()
309 bool BranchObj::hasScrolledParent(BranchObj *start)
311 // Calls parents recursivly to
312 // find out, if we are scrolled at all.
313 // But ignore myself, just look at parents.
315 if (this !=start && scrolled) return true;
317 BranchObj* bo=(BranchObj*)(parObj);
319 return bo->hasScrolledParent(start);
324 void BranchObj::tmpUnscroll()
326 // Unscroll parent (recursivly)
327 BranchObj* bo=(BranchObj*)(parObj);
328 if (bo) bo->tmpUnscroll();
334 systemFlags->activate("tmpUnscrolledright");
339 void BranchObj::resetTmpUnscroll()
341 // Unscroll parent (recursivly)
342 BranchObj* bo=(BranchObj*)(parObj);
344 bo->resetTmpUnscroll();
350 systemFlags->deactivate("tmpUnscrolledright");
355 void BranchObj::setVisibility(bool v, int toDepth)
357 if (depth <= toDepth)
359 frame->setVisibility(v);
360 heading->setVisibility(v);
361 systemFlags->setVisibility(v);
362 standardFlags->setVisibility(v);
363 LinkableMapObj::setVisibility (v);
365 if (!scrolled && (depth < toDepth))
367 // Now go recursivly through all childs
369 for (b=branch.first(); b;b=branch.next() )
370 b->setVisibility (v,toDepth);
372 for (fio=floatimage.first(); fio; fio=floatimage.next())
373 fio->setVisibility (v);
375 for (xlo=xlink.first(); xlo;xlo=xlink.next() )
376 xlo->setVisibility ();
378 } // depth <= toDepth
382 void BranchObj::setVisibility(bool v)
384 setVisibility (v,MAX_DEPTH);
388 void BranchObj::setLinkColor ()
390 // Overloaded from LinkableMapObj
391 // BranchObj can use color of heading
394 if (mapEditor->getLinkColorHint()==HeadingColor)
395 LinkableMapObj::setLinkColor (heading->getColor() );
397 LinkableMapObj::setLinkColor ();
400 void BranchObj::setColor (QColor col, bool colorChilds)
402 heading->setColor(col);
407 for (bo=branch.first(); bo; bo=branch.next() )
408 bo->setColor(col,colorChilds);
412 QColor BranchObj::getColor()
414 return heading->getColor();
417 BranchObj* BranchObj::first()
423 BranchObj* BranchObj::next()
426 BranchObj *bo=branch.first();
427 BranchObj *po=(BranchObj*)(parObj);
430 { // We are just beginning at the mapCenter
444 { // We come from above
447 // there are childs, go there
452 { // no childs, try to go up again
464 // can't go up, I am mapCenter
471 // Try to find last child, we came from, in my own childs
473 while (bo && searching)
475 if (itLast==bo) searching=false;
479 { // found lastLMO in my childs
482 // found a brother of lastLMO
498 // can't go up, I am mapCenter
505 // couldn't find last child, it must be a nephew of mine
509 // proceed with my first child
515 // or go back to my parents
526 // can't go up, I am mapCenter
533 BranchObj* BranchObj::getLastIterator()
538 void BranchObj::setLastIterator(BranchObj* it)
544 void BranchObj::move (double x, double y)
546 OrnamentedObj::move (x,y);
550 void BranchObj::move (QPoint p)
555 void BranchObj::moveBy (double x, double y)
557 OrnamentedObj::moveBy (x,y);
560 for (b=branch.first(); b;b=branch.next() )
564 void BranchObj::moveBy (QPoint p)
566 moveBy (p.x(), p.y());
570 void BranchObj::positionBBox()
572 /*// TODO testing (optimization)
573 QString h=getHeading();
575 cout << "BO::positionBBox("<<h<<")\n";
577 cout << "BO::positionBBox (noHeading)\n";
580 // Position contents by moving OO
581 OrnamentedObj::move (absPos.x(),absPos.y());
583 // It seems that setting x,y also affects width,height
584 int w_old=bbox.width();
585 int h_old=bbox.height();
586 bbox.setX (absPos.x() );
587 bbox.setY (absPos.y() );
588 bbox.setWidth(w_old);
589 bbox.setHeight(h_old);
594 frame->setRect(QRect(bbox.x(),bbox.y(),bbox.width(),bbox.height() ) );
596 // Update links to other branches
598 for (xlo=xlink.first(); xlo; xlo=xlink.next() )
602 void BranchObj::calcBBoxSize()
604 QSize heading_r=heading->getSize();
605 int heading_w=static_cast <int> (heading_r.width() );
606 int heading_h=static_cast <int> (heading_r.height() );
607 QSize sysflags_r=systemFlags->getSize();
608 int sysflags_h=sysflags_r.height();
609 int sysflags_w=sysflags_r.width();
610 QSize stanflags_r=standardFlags->getSize();
611 int stanflags_h=stanflags_r.height();
612 int stanflags_w=stanflags_r.width();
616 // set width to sum of all widths
617 w=heading_w + sysflags_w + stanflags_w;
618 // set height to maximum needed height
619 h=max (sysflags_h,stanflags_h);
622 w+=frame->getBorder();
623 h+=frame->getBorder();
624 bbox.setSize (QSize (w,h));
627 LinkableMapObj* BranchObj::findMapObj(QPoint p, LinkableMapObj* excludeLMO)
632 for (b=branch.first(); b; b=branch.next() )
634 lmo=b->findMapObj(p, excludeLMO);
635 if (lmo != NULL) return lmo;
639 if (inBBox (p) && (this != excludeLMO) && isVisibleObj() )
642 // Search float images
644 for (foi=floatimage.first(); foi; foi=floatimage.next() )
645 if (foi->inBBox(p) &&
646 (foi != excludeLMO) &&
647 foi->getParObj()!= excludeLMO &&
654 void BranchObj::setHeading(QString s)
656 /* FIXME testing only
657 cout << "BO::setHeading ("<<s<<")\n";
658 cout << " bo.pos="<<absPos<<endl;
659 cout << " ho.pos="<<heading->getPos()<<endl;
661 heading->setText(s); // set new heading
662 calcBBoxSize(); // recalculate bbox
663 positionBBox(); // rearrange contents
667 void BranchObj::setURL(QString s)
671 systemFlags->activate("url");
673 systemFlags->deactivate("url");
674 calcBBoxSize(); // recalculate bbox
675 positionBBox(); // rearrange contents
679 QString BranchObj::getURL()
684 void BranchObj::setVymLink(QString s)
688 // We need the relative (from loading)
689 // or absolute path (from User event)
690 // and build the absolute path.
691 // Note: If we have relative, use path of
692 // current map to build absolute path
694 if (!d.path().startsWith ("/"))
696 QString p=mapEditor->getDestPath();
697 int i=p.findRev("/",-1);
698 d.setPath(p.left(i)+"/"+s);
702 systemFlags->activate("vymLink");
706 systemFlags->deactivate("vymLink");
709 calcBBoxSize(); // recalculate bbox
710 positionBBox(); // rearrange contents
714 QString BranchObj::getVymLink()
719 QString BranchObj::saveToDir (const QString &tmpdir,const QString &prefix, const QPoint& offset)
722 QString scrolledAttr;
724 scrolledAttr=attribut ("scrolled","yes");
729 if (depth<2) posAttr=
730 attribut("absPosX",QString().setNum(absPos.x(),10)) +
731 attribut("absPosY",QString().setNum(absPos.y(),10));
735 QString linkAttr=getLinkAttr();
739 urlAttr=attribut ("url",url);
742 if (!vymLink.isEmpty())
743 vymLinkAttr=attribut ("vymLink",convertToRel(mapEditor->getDestPath(),vymLink) );
746 if (frame->getFrameType()!=NoFrame)
747 frameAttr=attribut ("frameType",frame->getFrameTypeName());
751 // save area, if not scrolled
753 if (!((BranchObj*)(parObj))->isScrolled() )
756 attribut("x1",QString().setNum(absPos.x()-offset.x(),10)) +
757 attribut("y1",QString().setNum(absPos.y()-offset.y(),10)) +
758 attribut("x2",QString().setNum(absPos.x()+width()-offset.x(),10)) +
759 attribut("y2",QString().setNum(absPos.y()+height()-offset.y(),10));
764 s=beginElement ("branch" +scrolledAttr +posAttr +linkAttr +urlAttr +vymLinkAttr +frameAttr +areaAttr );
768 s+=valueElement("heading", getHeading(),
769 attribut ("textColor",QColor(heading->getColor()).name()));
771 // save names of flags set
772 s+=standardFlags->saveToDir(tmpdir,prefix,0);
775 if (!note.isEmpty() )
780 for (bo=branch.first(); bo; bo=branch.next() )
781 s+=bo->saveToDir(tmpdir,prefix,offset);
785 for (fio=floatimage.first(); fio; fio=floatimage.next() )
786 s+=fio->saveToDir (tmpdir,prefix,offset);
790 for (xlo=xlink.first(); xlo; xlo=xlink.next() )
794 s+=endElement ("branch");
798 void BranchObj::addXLink (XLinkObj *xlo)
804 void BranchObj::removeXLinkRef (XLinkObj *xlo)
809 void BranchObj::deleteXLink(XLinkObj *xlo)
812 if (!xlo->isUsed()) delete (xlo);
815 void BranchObj::deleteXLinkAt (int i)
817 XLinkObj *xlo=xlink.at(i);
819 if (!xlo->isUsed()) delete(xlo);
822 XLinkObj* BranchObj::XLinkAt (int i)
827 int BranchObj::countXLink()
829 return xlink.count();
832 BranchObj* BranchObj::XLinkTargetAt (int i)
835 return xlink.at(i)->otherBranch (this);
840 LinkableMapObj* BranchObj::addFloatImage ()
842 FloatImageObj *newfi=new FloatImageObj (canvas,this);
843 floatimage.append (newfi);
844 if (hasScrolledParent(this) )
845 newfi->setVisibility (false);
847 newfi->setVisibility(visible);
852 LinkableMapObj* BranchObj::addFloatImage (FloatImageObj *fio)
854 FloatImageObj *newfi=new FloatImageObj (canvas,this);
855 floatimage.append (newfi);
857 if (hasScrolledParent(this) )
858 newfi->setVisibility (false);
860 newfi->setVisibility(visible);
865 FloatImageObj* BranchObj::getFirstFloatImage ()
867 return floatimage.first();
870 FloatImageObj* BranchObj::getLastFloatImage ()
872 return floatimage.last();
875 FloatImageObj* BranchObj::getFloatImageNum (const uint &i)
877 return floatimage.at(i);
880 void BranchObj::removeFloatImage (FloatImageObj *fio)
882 floatimage.remove (fio);
886 void BranchObj::savePosInAngle ()
888 // Save position in angle
891 for (b=branch.first(); b; b=branch.next() )
898 void BranchObj::setDefAttr (BranchModification mod)
903 case 0: fontsize=16; break;
904 case 1: fontsize=12; break;
905 default: fontsize=10; break;
909 setLinkStyle(getDefLinkStyle());
910 QFont font("Sans Serif,8,-1,5,50,0,0,0,0,0");
911 font.setPointSize(fontsize);
912 heading->setFont(font );
915 setColor (((BranchObj*)(parObj))->getColor(),false);
920 BranchObj* BranchObj::addBranch()
922 BranchObj* newbo=new BranchObj(canvas,this);
923 branch.append (newbo);
924 newbo->setParObj(this);
925 newbo->setDefAttr(NewBranch);
926 newbo->setHeading ("new");
928 newbo->setVisibility (false);
930 newbo->setVisibility(visible);
936 BranchObj* BranchObj::addBranch(BranchObj* bo)
938 BranchObj* newbo=new BranchObj(canvas,this);
939 branch.append (newbo);
941 newbo->setParObj(this);
942 newbo->setDefAttr(MovedBranch);
944 newbo->setVisibility (false);
946 newbo->setVisibility(bo->visible);
952 BranchObj* BranchObj::addBranchPtr(BranchObj* bo)
955 bo->setParObj (this);
957 bo->setDefAttr(MovedBranch);
958 if (scrolled) tmpUnscroll();
959 setLastSelectedBranch (bo);
963 BranchObj* BranchObj::insertBranch(int pos)
966 // Add new bo and resort branches
967 BranchObj *newbo=addBranch ();
968 newbo->angle=pos-0.5;
973 BranchObj* BranchObj::insertBranch(BranchObj* bo, int pos)
976 // Add new bo and resort branches
978 BranchObj *newbo=addBranch (bo);
983 BranchObj* BranchObj::insertBranchPtr (BranchObj* bo, int pos)
986 // Add new bo and resort branches
989 bo->setParObj (this);
991 bo->setDefAttr (MovedBranch);
992 if (scrolled) tmpUnscroll();
993 setLastSelectedBranch (bo);
998 void BranchObj::removeBranchHere(BranchObj* borem)
1000 // This removes the branch bo from list, but
1001 // inserts its childs at the place of bo
1003 bo=borem->getLastBranch();
1004 int pos=borem->getNum();
1007 bo->moveBranchTo (this,pos+1);
1008 bo=borem->getLastBranch();
1010 removeBranch (borem);
1013 void BranchObj::removeChilds()
1018 void BranchObj::removeBranch(BranchObj* bo)
1020 // if bo is not in branch remove returns false, we
1023 if (branch.remove (bo))
1026 qWarning ("BranchObj::removeBranch tried to remove non existing branch?!\n");
1027 requestReposition();
1030 void BranchObj::removeBranchPtr(BranchObj* bo)
1033 requestReposition();
1036 void BranchObj::setLastSelectedBranch (BranchObj* bo)
1038 lastSelectedBranch=branch.find(bo);
1041 BranchObj* BranchObj::getLastSelectedBranch ()
1043 if (lastSelectedBranch>=0)
1045 BranchObj* bo=branch.at(lastSelectedBranch);
1048 return branch.first();
1051 BranchObj* BranchObj::getFirstBranch ()
1053 return branch.first();
1056 BranchObj* BranchObj::getLastBranch ()
1058 return branch.last();
1061 BranchObj* BranchObj::getBranchNum (const uint &i)
1063 return branch.at(i);
1067 BranchObj* BranchObj::moveBranchUp(BranchObj* bo1) // move a branch up (modify myself)
1070 int i=branch.find(bo1);
1072 { // -1 if bo1 not found
1073 branch.at(i)->angle--;
1074 branch.at(i-1)->angle++;
1076 return branch.at(i-1);
1078 return branch.at(i);
1081 BranchObj* BranchObj::moveBranchDown(BranchObj* bo1)
1084 int i=branch.find(bo1);
1089 branch.at(i)->angle++;
1090 branch.at(j)->angle--;
1092 return branch.at(j);
1094 return branch.at(i);
1097 BranchObj* BranchObj::moveBranchTo (BranchObj* dst, int pos)
1099 // Find current parent and
1100 // remove pointer to myself there
1101 if (!dst) return NULL;
1102 BranchObj *par=(BranchObj*)(parObj);
1104 par->removeBranchPtr (this);
1108 // Create new pointer to myself at dst
1109 if (pos<0||dst->getDepth()==0)
1111 // links myself as last branch at dst
1112 dst->addBranchPtr (this);
1117 // inserts me at pos in parent of dst
1120 BranchObj *bo=dst->insertBranchPtr (this,pos);
1121 bo->setDefAttr(MovedBranch);
1130 void BranchObj::alignRelativeTo (QPoint ref)
1133 if (!getHeading().isEmpty())
1134 cout << "BO::alignRelTo "<<getHeading()<<endl;
1136 cout << "BO::alignRelTo ???"<<endl;
1137 cout << " d="<<depth<<endl;
1139 int th = bboxTotal.height();
1141 // If I am the mapcenter or a mainbranch, reposition heading
1143 { //FIXME optimize this move for MCO needed to initially position text in box...
1146 move (absPos.x(),absPos.y());
1147 // Calc angle to mapCenter if I am a mainbranch
1148 // needed for reordering the mainbranches clockwise
1150 angle=getAngle (QPoint ((int)(x() - parObj->getChildPos().x() ),
1151 (int)(y() - parObj->getChildPos().y() ) ) );
1156 // Align myself depending on orientation and parent, but
1157 // only if I am not the mainbranch or mapcenter itself
1158 switch (orientation)
1160 case OrientLeftOfCenter:
1161 move (ref.x()-bbox.width(), ref.y() + (th-bbox.height())/2 );
1163 case OrientRightOfCenter:
1164 move (ref.x(), ref.y() + (th-bbox.height())/2 );
1167 cout <<"LMO::alignRelativeTo: oops, no orientation given...\n";
1173 for (fio=floatimage.first(); fio; fio=floatimage.next() )
1176 if (scrolled) return;
1178 // Set reference point for alignment of childs
1180 if (orientation==OrientLeftOfCenter)
1181 ref2.setX(childPos.x() - linkwidth);
1183 ref2.setX(childPos.x() + linkwidth);
1186 ref2.setY(absPos.y()-(bboxTotal.height()-bbox.height())/2);
1188 ref2.setY(ref.y() );
1190 // Align the childs depending on reference point
1192 for (b=branch.first(); b; b=branch.next() )
1194 b->alignRelativeTo (ref2);
1195 ref2.setY(ref2.y() + b->getBBoxSizeWithChilds().height() );
1200 void BranchObj::reposition()
1202 /* TODO testing only
1203 if (!getHeading().isEmpty())
1204 cout << "BO::reposition "<<getHeading()<<endl;
1206 cout << "BO::reposition ???"<<endl;
1210 // only calculate the sizes once. If the deepest LMO
1211 // changes its height,
1212 // all upper LMOs have to change, too.
1213 calcBBoxSizeWithChilds();
1214 alignRelativeTo ( QPoint (absPos.x(),
1215 absPos.y()-(bboxTotal.height()-bbox.height())/2) );
1219 // This is only important for moving branches:
1220 // For editing a branch it isn't called...
1221 alignRelativeTo ( QPoint (absPos.x(),
1222 absPos.y()-(bboxTotal.height()-bbox.height())/2) );
1227 QRect BranchObj::getTotalBBox()
1231 if (scrolled) return r;
1234 for (b=branch.first();b ;b=branch.next() )
1235 r=addBBox(b->getTotalBBox(),r);
1238 for (fio=floatimage.first();fio ;fio=floatimage.next() )
1239 r=addBBox(fio->getTotalBBox(),r);
1244 QRect BranchObj::getBBoxSizeWithChilds()
1249 void BranchObj::calcBBoxSizeWithChilds()
1251 // This is called only from reposition and
1252 // and only for mapcenter. So it won't be
1253 // called more than once for a single user
1256 // Calculate size of LMO including all childs (to align them later)
1258 bboxTotal.setX(bbox.x() );
1259 bboxTotal.setY(bbox.y() );
1261 // if branch is scrolled, ignore childs, but still consider floatimages
1264 bboxTotal.setWidth (bbox.width());
1265 bboxTotal.setHeight(bbox.height());
1271 // Now calculate recursivly
1273 // maximum of widths
1276 for (b=branch.first();b ;b=branch.next() )
1278 b->calcBBoxSizeWithChilds();
1279 br=b->getBBoxSizeWithChilds();
1280 r.setWidth( max (br.width(), r.width() ));
1281 r.setHeight(br.height() + r.height() );
1282 if (br.y()<bboxTotal.y()) bboxTotal.setY(br.y());
1284 // Add myself and also
1285 // add width of link to sum if necessary
1286 if (branch.isEmpty())
1287 bboxTotal.setWidth (bbox.width() + r.width() );
1289 bboxTotal.setWidth (bbox.width() + r.width() + linkwidth);
1290 bboxTotal.setHeight(max (r.height(), bbox.height() ) );
1291 // frame->setRect(QRect(bbox.x(),bbox.y(),bbox.width(),bbox.height() ) );
1294 void BranchObj::select()
1296 // set Text in Editor
1297 textEditor->setText(note.getNote() );
1298 QString fnh=note.getFilenameHint();
1300 textEditor->setFilenameHint(note.getFilenameHint() );
1302 textEditor->setFilenameHint(getHeading() );
1303 textEditor->setFontHint (note.getFontHint() );
1305 LinkableMapObj::select();
1306 // Tell parent that I am selected now:
1307 BranchObj* po=(BranchObj*)(parObj);
1308 if (po) // TODO Try to get rid of this cast...
1309 po->setLastSelectedBranch(this);
1311 // temporary unscroll, if we have scrolled parents somewhere
1312 if (parObj) ((BranchObj*)(parObj))->tmpUnscroll();
1314 // Show URL and link in statusbar
1316 if (!url.isEmpty()) status+="URL: "+url+" ";
1317 if (!vymLink.isEmpty()) status+="Link: "+vymLink;
1318 if (!status.isEmpty()) mainWindow->statusMessage (status);
1321 standardFlags->updateToolbar();
1323 // Update Browserbutton
1325 actionEditOpenURL->setEnabled (true);
1327 actionEditOpenURL->setEnabled (false);
1329 // Update actions in mapeditor
1330 mapEditor->updateActions();
1333 void BranchObj::unselect()
1335 LinkableMapObj::unselect();
1336 // Delete any messages like vymLink in StatusBar
1337 mainWindow->statusMessage ("");
1339 // save note from editor and set flag
1340 // text is done by updateNoteFlag(), just save
1342 note.setFilenameHint (textEditor->getFilename());
1344 // reset temporary unscroll, if we have scrolled parents somewhere
1345 if (parObj) ((BranchObj*)(parObj))->resetTmpUnscroll();
1347 // Erase content of editor
1348 textEditor->setInactive();
1350 // unselect all buttons in toolbar
1351 standardFlagsDefault->updateToolbar();
1354 QString BranchObj::getSelectString()
1360 s= "bo:" + QString("%1").arg(getNum());
1362 s= ((BranchObj*)(parObj))->getSelectString() + ",bo:" + QString("%1").arg(getNum());