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;
105 includeImagesVer=false;
106 includeImagesHor=false;
112 void BranchObj::copy (BranchObj* other)
114 OrnamentedObj::copy(other);
118 for (b=other->branch.first(); b;b=other->branch.next() )
119 // Make deep copy of b
120 // Because addBranch again calls copy for the childs,
121 // Those will get a deep copy, too
125 for (fi=other->floatimage.first(); fi;fi=other->floatimage.next() )
128 scrolled=other->scrolled;
129 tmpUnscrolled=other->tmpUnscrolled;
130 setVisibility (other->visible);
133 vymLink=other->vymLink;
140 void BranchObj::clear()
143 while (!xlink.isEmpty())
144 deleteXLink (xlink.first() );
147 while (!branch.isEmpty())
150 branch.removeFirst();
155 int BranchObj::getNum()
158 return ((BranchObj*)(parObj))->getNum ((BranchObj*)(this));
163 int BranchObj::getNum(BranchObj *bo)
165 // keep current pointer in branch,
166 // otherwise save might fail
168 int ind=branch.findRef (bo);
173 int BranchObj::getFloatImageNum(FloatImageObj *fio)
175 return floatimage.findRef (fio);
178 int BranchObj::countBranches()
180 return branch.count();
183 int BranchObj::countFloatImages()
185 return floatimage.count();
188 int BranchObj::countXLinks()
190 return xlink.count();
193 void BranchObj::setParObjTmp(LinkableMapObj* lmo, QPoint m, int off)
195 // Temporary link to lmo
196 // m is position of mouse pointer
197 // offset 0: default 1: below lmo -1 above lmo (if possible)
200 BranchObj* o=(BranchObj*)(lmo);
204 // ignore mapcenter and mainbranch
205 if (lmo->getDepth()<2) off=0;
212 depth=parObj->getDepth()+1;
214 // setLinkStyle calls updateLink, only set it once
215 if (style!=getDefLinkStyle() ) setLinkStyle (getDefLinkStyle());
217 // Move temporary to new position at destination
218 // Usually the positioning would be done by reposition(),
219 // but then also the destination branch would "Jump" around...
220 // Better just do it approximately
222 { // new parent is the mapcenter itself
224 QPoint p= normalise ( QPoint (m.x() - o->getChildPos().x(),
225 m.y() - o->getChildPos().y() ));
226 if (p.x()<0) p.setX( p.x()-bbox.width() );
233 // new parent is just a branch, link to it
234 QRect t=o->getBBoxSizeWithChilds();
235 if (o->getLastBranch())
236 y=t.y() + t.height() ;
243 // we want to link above lmo
244 y=o->y() - height() + 5;
246 // we want to link below lmo
247 // Bottom of sel should be 5 pixels above
248 // the bottom of the branch _below_ the target:
249 // Don't try to find that branch, guess 12 pixels
250 y=o->getChildPos().y() -height() + 12;
252 if (o->getOrientation()==OrientLeftOfCenter)
253 move ( o->getChildPos().x() - linkwidth, y );
255 move (o->getChildPos().x() + linkwidth, y );
258 // updateLink is called implicitly in move
259 reposition(); // FIXME shouldn't be this a request?
262 void BranchObj::unsetParObjTmp()
269 depth=parObj->getDepth()+1;
270 setLinkStyle (getDefLinkStyle() );
275 void BranchObj::unScroll()
277 if (tmpUnscrolled) resetTmpUnscroll();
278 if (scrolled) toggleScroll();
281 void BranchObj::toggleScroll()
287 systemFlags->deactivate("scrolledright");
288 for (bo=branch.first(); bo; bo=branch.next() )
290 bo->setVisibility(true);
295 systemFlags->activate("scrolledright");
296 for (bo=branch.first(); bo; bo=branch.next() )
298 bo->setVisibility(false);
303 move (absPos.x(), absPos.y() );
307 bool BranchObj::isScrolled()
312 bool BranchObj::hasScrolledParent(BranchObj *start)
314 // Calls parents recursivly to
315 // find out, if we are scrolled at all.
316 // But ignore myself, just look at parents.
318 if (this !=start && scrolled) return true;
320 BranchObj* bo=(BranchObj*)(parObj);
322 return bo->hasScrolledParent(start);
327 void BranchObj::tmpUnscroll()
329 // Unscroll parent (recursivly)
330 BranchObj* bo=(BranchObj*)(parObj);
331 if (bo) bo->tmpUnscroll();
337 systemFlags->activate("tmpUnscrolledright");
342 void BranchObj::resetTmpUnscroll()
344 // Unscroll parent (recursivly)
345 BranchObj* bo=(BranchObj*)(parObj);
347 bo->resetTmpUnscroll();
353 systemFlags->deactivate("tmpUnscrolledright");
358 void BranchObj::setVisibility(bool v, int toDepth)
360 if (depth <= toDepth)
362 frame->setVisibility(v);
363 heading->setVisibility(v);
364 systemFlags->setVisibility(v);
365 standardFlags->setVisibility(v);
366 LinkableMapObj::setVisibility (v);
368 if (!scrolled && (depth < toDepth))
370 // Now go recursivly through all childs
372 for (b=branch.first(); b;b=branch.next() )
373 b->setVisibility (v,toDepth);
375 for (fio=floatimage.first(); fio; fio=floatimage.next())
376 fio->setVisibility (v);
378 for (xlo=xlink.first(); xlo;xlo=xlink.next() )
379 xlo->setVisibility ();
381 } // depth <= toDepth
385 void BranchObj::setVisibility(bool v)
387 setVisibility (v,MAX_DEPTH);
391 void BranchObj::setLinkColor ()
393 // Overloaded from LinkableMapObj
394 // BranchObj can use color of heading
397 if (mapEditor->getLinkColorHint()==HeadingColor)
398 LinkableMapObj::setLinkColor (heading->getColor() );
400 LinkableMapObj::setLinkColor ();
403 void BranchObj::setColor (QColor col, bool colorChilds)
405 heading->setColor(col);
410 for (bo=branch.first(); bo; bo=branch.next() )
411 bo->setColor(col,colorChilds);
415 QColor BranchObj::getColor()
417 return heading->getColor();
420 BranchObj* BranchObj::first()
426 BranchObj* BranchObj::next()
429 BranchObj *bo=branch.first();
430 BranchObj *po=(BranchObj*)(parObj);
433 { // We are just beginning at the mapCenter
447 { // We come from above
450 // there are childs, go there
455 { // no childs, try to go up again
467 // can't go up, I am mapCenter
474 // Try to find last child, we came from, in my own childs
476 while (bo && searching)
478 if (itLast==bo) searching=false;
482 { // found lastLMO in my childs
485 // found a brother of lastLMO
501 // can't go up, I am mapCenter
508 // couldn't find last child, it must be a nephew of mine
512 // proceed with my first child
518 // or go back to my parents
529 // can't go up, I am mapCenter
536 BranchObj* BranchObj::getLastIterator()
541 void BranchObj::setLastIterator(BranchObj* it)
547 void BranchObj::move (double x, double y)
549 OrnamentedObj::move (x,y);
551 for (fio=floatimage.first(); fio; fio=floatimage.next() )
556 void BranchObj::move (QPoint p)
561 void BranchObj::moveBy (double x, double y)
563 OrnamentedObj::moveBy (x,y);
566 for (b=branch.first(); b;b=branch.next() )
570 void BranchObj::moveBy (QPoint p)
572 moveBy (p.x(), p.y());
576 void BranchObj::positionBBox()
578 /*// TODO testing (optimization)
579 QString h=getHeading();
581 cout << "BO::positionBBox("<<h<<")\n";
583 cout << "BO::positionBBox (noHeading)\n";
588 int d=frame->getBorder()/2;
590 bbox.moveTopLeft (QPoint (absPos.x(), absPos.y() - topPad));
591 clickBox.moveTopLeft(QPoint (absPos.x()+d, absPos.y()+d ));
596 frame->setRect(QRect(bbox.x(),bbox.y(),bbox.width(),bbox.height() ) );
598 // Update links to other branches
600 for (xlo=xlink.first(); xlo; xlo=xlink.next() )
604 void BranchObj::calcBBoxSize()
606 QSize heading_r=heading->getSize();
607 int heading_w=static_cast <int> (heading_r.width() );
608 int heading_h=static_cast <int> (heading_r.height() );
609 QSize sysflags_r=systemFlags->getSize();
610 int sysflags_h=sysflags_r.height();
611 int sysflags_w=sysflags_r.width();
612 QSize stanflags_r=standardFlags->getSize();
613 int stanflags_h=stanflags_r.height();
614 int stanflags_w=stanflags_r.width();
618 // set width to sum of all widths
619 w=heading_w + sysflags_w + stanflags_w;
620 // set height to maximum needed height
621 h=max (sysflags_h,stanflags_h);
624 clickBox.setSize (QSize (w,h));
630 topPad=botPad=leftPad=rightPad=0;
631 if (includeImagesVer || includeImagesHor)
633 if (countFloatImages()>0)
635 for (foi=floatimage.first(); foi; foi=floatimage.next() )
638 if (includeImagesVer)
641 topPad=max (topPad,-rp.y());
642 if (rp.y()+foi->height() > h)
643 botPad=max (botPad,rp.y()+foi->height()-h);
652 w+=frame->getBorder();
653 h+=frame->getBorder();
656 bbox.setSize (QSize (w,h));
659 LinkableMapObj* BranchObj::findMapObj(QPoint p, LinkableMapObj* excludeLMO)
664 for (b=branch.first(); b; b=branch.next() )
666 lmo=b->findMapObj(p, excludeLMO);
667 if (lmo != NULL) return lmo;
671 if (inBox (p) && (this != excludeLMO) && isVisibleObj() )
674 // Search float images
676 for (foi=floatimage.first(); foi; foi=floatimage.next() )
678 (foi != excludeLMO) &&
679 foi->getParObj()!= excludeLMO &&
686 void BranchObj::setHeading(QString s)
688 heading->setText(s); // set new heading
689 calcBBoxSize(); // recalculate bbox
690 positionBBox(); // rearrange contents
694 void BranchObj::setURL(QString s)
698 systemFlags->activate("url");
700 systemFlags->deactivate("url");
701 calcBBoxSize(); // recalculate bbox
702 positionBBox(); // rearrange contents
706 QString BranchObj::getURL()
711 void BranchObj::setVymLink(QString s)
715 // We need the relative (from loading)
716 // or absolute path (from User event)
717 // and build the absolute path.
718 // Note: If we have relative, use path of
719 // current map to build absolute path
721 if (!d.path().startsWith ("/"))
723 QString p=mapEditor->getDestPath();
724 int i=p.findRev("/",-1);
725 d.setPath(p.left(i)+"/"+s);
729 systemFlags->activate("vymLink");
733 systemFlags->deactivate("vymLink");
736 calcBBoxSize(); // recalculate bbox
737 positionBBox(); // rearrange contents
741 QString BranchObj::getVymLink()
746 QString BranchObj::saveToDir (const QString &tmpdir,const QString &prefix, const QPoint& offset)
749 QString scrolledAttr;
751 scrolledAttr=attribut ("scrolled","yes");
756 if (depth<2) posAttr=
757 attribut("absPosX",QString().setNum(absPos.x(),10)) +
758 attribut("absPosY",QString().setNum(absPos.y(),10));
762 QString linkAttr=getLinkAttr()+" "+getIncludeImageAttr();
767 urlAttr=attribut ("url",url);
770 if (!vymLink.isEmpty())
771 vymLinkAttr=attribut ("vymLink",convertToRel(mapEditor->getDestPath(),vymLink) );
774 if (frame->getFrameType()!=NoFrame)
775 frameAttr=attribut ("frameType",frame->getFrameTypeName());
779 // save area, if not scrolled
781 if (!((BranchObj*)(parObj))->isScrolled() )
784 attribut("x1",QString().setNum(absPos.x()-offset.x(),10)) +
785 attribut("y1",QString().setNum(absPos.y()-offset.y(),10)) +
786 attribut("x2",QString().setNum(absPos.x()+width()-offset.x(),10)) +
787 attribut("y2",QString().setNum(absPos.y()+height()-offset.y(),10));
792 // Providing an ID for a branch makes export to XHTML easier
795 idAttr=attribut ("id",getSelectString());
799 s=beginElement ("branch" +scrolledAttr +posAttr +linkAttr +urlAttr +vymLinkAttr +frameAttr +areaAttr +idAttr);
803 s+=valueElement("heading", getHeading(),
804 attribut ("textColor",QColor(heading->getColor()).name()));
806 // save names of flags set
807 s+=standardFlags->saveToDir(tmpdir,prefix,0);
810 if (!note.isEmpty() )
815 for (bo=branch.first(); bo; bo=branch.next() )
816 s+=bo->saveToDir(tmpdir,prefix,offset);
820 for (fio=floatimage.first(); fio; fio=floatimage.next() )
821 s+=fio->saveToDir (tmpdir,prefix,offset);
825 for (xlo=xlink.first(); xlo; xlo=xlink.next() )
829 s+=endElement ("branch");
833 void BranchObj::addXLink (XLinkObj *xlo)
839 void BranchObj::removeXLinkRef (XLinkObj *xlo)
844 void BranchObj::deleteXLink(XLinkObj *xlo)
847 if (!xlo->isUsed()) delete (xlo);
850 void BranchObj::deleteXLinkAt (int i)
852 XLinkObj *xlo=xlink.at(i);
854 if (!xlo->isUsed()) delete(xlo);
857 XLinkObj* BranchObj::XLinkAt (int i)
862 int BranchObj::countXLink()
864 return xlink.count();
867 BranchObj* BranchObj::XLinkTargetAt (int i)
870 return xlink.at(i)->otherBranch (this);
875 void BranchObj::setIncludeImagesVer(bool b)
884 bool BranchObj::getIncludeImagesVer()
886 return includeImagesVer;
889 void BranchObj::setIncludeImagesHor(bool b)
898 bool BranchObj::getIncludeImagesHor()
900 return includeImagesHor;
903 QString BranchObj::getIncludeImageAttr()
906 if (includeImagesVer)
907 a=attribut ("incImgV","true");
909 a=attribut ("incImgV","false");
910 if (includeImagesHor)
911 a+=" "+attribut ("incImgH","true");
913 a+=" "+attribut ("incImgH","false");
917 LinkableMapObj* BranchObj::addFloatImage ()
919 FloatImageObj *newfi=new FloatImageObj (canvas,this);
920 floatimage.append (newfi);
921 if (hasScrolledParent(this) )
922 newfi->setVisibility (false);
924 newfi->setVisibility(visible);
932 LinkableMapObj* BranchObj::addFloatImage (FloatImageObj *fio)
934 FloatImageObj *newfi=new FloatImageObj (canvas,this);
935 floatimage.append (newfi);
937 if (hasScrolledParent(this) )
938 newfi->setVisibility (false);
940 newfi->setVisibility(visible);
948 FloatImageObj* BranchObj::getFirstFloatImage ()
950 return floatimage.first();
953 FloatImageObj* BranchObj::getLastFloatImage ()
955 return floatimage.last();
958 FloatImageObj* BranchObj::getFloatImageNum (const uint &i)
960 return floatimage.at(i);
963 void BranchObj::removeFloatImage (FloatImageObj *fio)
965 floatimage.remove (fio);
972 void BranchObj::savePosInAngle ()
974 // Save position in angle
977 for (b=branch.first(); b; b=branch.next() )
984 void BranchObj::setDefAttr (BranchModification mod)
989 case 0: fontsize=16; break;
990 case 1: fontsize=12; break;
991 default: fontsize=10; break;
995 setLinkStyle(getDefLinkStyle());
996 QFont font("Sans Serif,8,-1,5,50,0,0,0,0,0");
997 font.setPointSize(fontsize);
998 heading->setFont(font );
1001 setColor (((BranchObj*)(parObj))->getColor(),false);
1006 BranchObj* BranchObj::addBranch()
1008 BranchObj* newbo=new BranchObj(canvas,this);
1009 branch.append (newbo);
1010 newbo->setParObj(this);
1011 newbo->setDefAttr(NewBranch);
1012 newbo->setHeading ("new");
1014 newbo->setVisibility (false);
1016 newbo->setVisibility(visible);
1017 newbo->updateLink();
1018 requestReposition();
1022 BranchObj* BranchObj::addBranch(BranchObj* bo)
1024 BranchObj* newbo=new BranchObj(canvas,this);
1025 branch.append (newbo);
1027 newbo->setParObj(this);
1028 newbo->setDefAttr(MovedBranch);
1030 newbo->setVisibility (false);
1032 newbo->setVisibility(bo->visible);
1033 newbo->updateLink();
1034 requestReposition();
1038 BranchObj* BranchObj::addBranchPtr(BranchObj* bo)
1041 bo->setParObj (this);
1043 bo->setDefAttr(MovedBranch);
1044 if (scrolled) tmpUnscroll();
1045 setLastSelectedBranch (bo);
1049 BranchObj* BranchObj::insertBranch(int pos)
1052 // Add new bo and resort branches
1053 BranchObj *newbo=addBranch ();
1054 newbo->angle=pos-0.5;
1059 BranchObj* BranchObj::insertBranch(BranchObj* bo, int pos)
1062 // Add new bo and resort branches
1064 BranchObj *newbo=addBranch (bo);
1069 BranchObj* BranchObj::insertBranchPtr (BranchObj* bo, int pos)
1072 // Add new bo and resort branches
1075 bo->setParObj (this);
1077 bo->setDefAttr (MovedBranch);
1078 if (scrolled) tmpUnscroll();
1079 setLastSelectedBranch (bo);
1084 void BranchObj::removeBranchHere(BranchObj* borem)
1086 // This removes the branch bo from list, but
1087 // inserts its childs at the place of bo
1089 bo=borem->getLastBranch();
1090 int pos=borem->getNum();
1093 bo->moveBranchTo (this,pos+1);
1094 bo=borem->getLastBranch();
1096 removeBranch (borem);
1099 void BranchObj::removeChilds()
1104 void BranchObj::removeBranch(BranchObj* bo)
1106 // if bo is not in branch remove returns false, we
1109 if (branch.remove (bo))
1112 qWarning ("BranchObj::removeBranch tried to remove non existing branch?!\n");
1113 requestReposition();
1116 void BranchObj::removeBranchPtr(BranchObj* bo)
1119 requestReposition();
1122 void BranchObj::setLastSelectedBranch (BranchObj* bo)
1124 lastSelectedBranch=branch.find(bo);
1127 BranchObj* BranchObj::getLastSelectedBranch ()
1129 if (lastSelectedBranch>=0)
1131 BranchObj* bo=branch.at(lastSelectedBranch);
1134 return branch.first();
1137 BranchObj* BranchObj::getFirstBranch ()
1139 return branch.first();
1142 BranchObj* BranchObj::getLastBranch ()
1144 return branch.last();
1147 BranchObj* BranchObj::getBranchNum (const uint &i)
1149 return branch.at(i);
1153 BranchObj* BranchObj::moveBranchUp(BranchObj* bo1) // move a branch up (modify myself)
1156 int i=branch.find(bo1);
1158 { // -1 if bo1 not found
1159 branch.at(i)->angle--;
1160 branch.at(i-1)->angle++;
1162 return branch.at(i-1);
1164 return branch.at(i);
1167 BranchObj* BranchObj::moveBranchDown(BranchObj* bo1)
1170 int i=branch.find(bo1);
1175 branch.at(i)->angle++;
1176 branch.at(j)->angle--;
1178 return branch.at(j);
1180 return branch.at(i);
1183 BranchObj* BranchObj::moveBranchTo (BranchObj* dst, int pos)
1185 // Find current parent and
1186 // remove pointer to myself there
1187 if (!dst) return NULL;
1188 BranchObj *par=(BranchObj*)(parObj);
1190 par->removeBranchPtr (this);
1194 // Create new pointer to myself at dst
1195 if (pos<0||dst->getDepth()==0)
1197 // links myself as last branch at dst
1198 dst->addBranchPtr (this);
1203 // inserts me at pos in parent of dst
1206 BranchObj *bo=dst->insertBranchPtr (this,pos);
1207 bo->setDefAttr(MovedBranch);
1216 void BranchObj::alignRelativeTo (QPoint ref)
1218 int th = bboxTotal.height();
1220 if (!getHeading().isEmpty())
1221 cout << "BO::alignRelTo "<<getHeading()<<endl;
1223 cout << "BO::alignRelTo ???"<<endl;
1224 cout << " d="<<depth<<
1226 // " bbTot="<<bboxTotal.topLeft()<<
1227 // " absPos="<<absPos<<
1228 " pad="<<topPad<<","<<botPad<<","<<leftPad<<","<<rightPad<<
1232 // If I am the mapcenter or a mainbranch, reposition heading
1234 { //FIXME optimize this move for MCO needed to initially position text in box...
1237 move (absPos.x(),absPos.y());
1238 // Calc angle to mapCenter if I am a mainbranch
1239 // needed for reordering the mainbranches clockwise
1241 angle=getAngle (QPoint ((int)(x() - parObj->getChildPos().x() ),
1242 (int)(y() - parObj->getChildPos().y() ) ) );
1247 // Align myself depending on orientation and parent, but
1248 // only if I am not the mainbranch or mapcenter itself
1249 switch (orientation)
1251 case OrientLeftOfCenter:
1252 move (ref.x()-bbox.width(), ref.y() + (th-bbox.height())/2 +topPad);
1254 case OrientRightOfCenter:
1255 move (ref.x(), ref.y() + (th-bbox.height())/2 + topPad);
1258 cout <<"LMO::alignRelativeTo: oops, no orientation given...\n";
1263 if (scrolled) return;
1265 // Set reference point for alignment of childs
1267 if (orientation==OrientLeftOfCenter)
1268 ref2.setX(childPos.x() - linkwidth);
1270 ref2.setX(childPos.x() + linkwidth);
1273 ref2.setY(absPos.y()-(bboxTotal.height()-bbox.height())/2);
1275 ref2.setY(ref.y() );
1277 // Align the childs depending on reference point
1279 for (b=branch.first(); b; b=branch.next() )
1281 b->alignRelativeTo (ref2);
1282 ref2.setY(ref2.y() + b->getBBoxSizeWithChilds().height() );
1287 void BranchObj::reposition()
1289 /* TODO testing only
1290 if (!getHeading().isEmpty())
1291 cout << "BO::reposition "<<getHeading()<<endl;
1293 cout << "BO::reposition ???"<<endl;
1297 // only calculate the sizes once. If the deepest LMO
1298 // changes its height,
1299 // all upper LMOs have to change, too.
1300 calcBBoxSizeWithChilds();
1301 alignRelativeTo ( QPoint (absPos.x(),
1302 absPos.y()-(bboxTotal.height()-bbox.height())/2) );
1305 // After load, the floats might be at wrong position, force
1306 // them to move, too
1310 // This is only important for moving branches:
1311 // For editing a branch it isn't called...
1312 alignRelativeTo ( QPoint (absPos.x(),
1313 absPos.y()-(bboxTotal.height()-bbox.height())/2) );
1318 QRect BranchObj::getTotalBBox()
1322 if (scrolled) return r;
1325 for (b=branch.first();b ;b=branch.next() )
1326 r=addBBox(b->getTotalBBox(),r);
1329 for (fio=floatimage.first();fio ;fio=floatimage.next() )
1330 r=addBBox(fio->getTotalBBox(),r);
1335 QRect BranchObj::getBBoxSizeWithChilds()
1340 void BranchObj::calcBBoxSizeWithChilds()
1342 // This is initially called only from reposition and
1343 // and only for mapcenter. So it won't be
1344 // called more than once for a single user
1348 // Calculate size of LMO including all childs (to align them later)
1349 bboxTotal.setX(bbox.x() );
1350 bboxTotal.setY(bbox.y() );
1352 // if branch is scrolled, ignore childs, but still consider floatimages
1355 bboxTotal.setWidth (bbox.width());
1356 bboxTotal.setHeight(bbox.height());
1362 // Now calculate recursivly
1364 // maximum of widths
1367 for (b=branch.first();b ;b=branch.next() )
1369 b->calcBBoxSizeWithChilds();
1370 br=b->getBBoxSizeWithChilds();
1371 r.setWidth( max (br.width(), r.width() ));
1372 r.setHeight(br.height() + r.height() );
1373 if (br.y()<bboxTotal.y()) bboxTotal.setY(br.y());
1375 // Add myself and also
1376 // add width of link to sum if necessary
1377 if (branch.isEmpty())
1378 bboxTotal.setWidth (bbox.width() + r.width() );
1380 bboxTotal.setWidth (bbox.width() + r.width() + linkwidth);
1382 bboxTotal.setHeight(max (r.height(), bbox.height()));
1383 // frame->setRect(QRect(bbox.x(),bbox.y(),bbox.width(),bbox.height() ) );
1387 void BranchObj::select()
1389 // set Text in Editor
1390 textEditor->setText(note.getNote() );
1391 QString fnh=note.getFilenameHint();
1393 textEditor->setFilenameHint(note.getFilenameHint() );
1395 textEditor->setFilenameHint(getHeading() );
1396 textEditor->setFontHint (note.getFontHint() );
1398 LinkableMapObj::select();
1399 // Tell parent that I am selected now:
1400 BranchObj* po=(BranchObj*)(parObj);
1401 if (po) // TODO Try to get rid of this cast...
1402 po->setLastSelectedBranch(this);
1404 // temporary unscroll, if we have scrolled parents somewhere
1405 if (parObj) ((BranchObj*)(parObj))->tmpUnscroll();
1407 // Show URL and link in statusbar
1409 if (!url.isEmpty()) status+="URL: "+url+" ";
1410 if (!vymLink.isEmpty()) status+="Link: "+vymLink;
1411 if (!status.isEmpty()) mainWindow->statusMessage (status);
1414 standardFlags->updateToolbar();
1416 // Update Browserbutton
1418 actionEditOpenURL->setEnabled (true);
1420 actionEditOpenURL->setEnabled (false);
1422 // Update actions in mapeditor
1423 mapEditor->updateActions();
1426 void BranchObj::unselect()
1428 LinkableMapObj::unselect();
1429 // Delete any messages like vymLink in StatusBar
1430 mainWindow->statusMessage ("");
1432 // save note from editor and set flag
1433 // text is done by updateNoteFlag(), just save
1435 note.setFilenameHint (textEditor->getFilename());
1437 // reset temporary unscroll, if we have scrolled parents somewhere
1438 if (parObj) ((BranchObj*)(parObj))->resetTmpUnscroll();
1440 // Erase content of editor
1441 textEditor->setInactive();
1443 // unselect all buttons in toolbar
1444 standardFlagsDefault->updateToolbar();
1447 QString BranchObj::getSelectString()
1453 s= "bo:" + QString("%1").arg(getNum());
1455 s= ((BranchObj*)(parObj))->getSelectString() + ",bo:" + QString("%1").arg(getNum());