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;
17 BranchObj* BranchObj::itFirst=NULL;
20 BranchObj::BranchObj () :OrnamentedObj()
22 // cout << "Const BranchObj ()\n";
28 BranchObj::BranchObj (Q3Canvas* c):OrnamentedObj (c)
30 // cout << "Const BranchObj (c) called from MapCenterObj (c)\n";
35 BranchObj::BranchObj (Q3Canvas* c, LinkableMapObj* p):OrnamentedObj (c)
37 // cout << "Const BranchObj (c,p)\n";
40 depth=p->getDepth()+1;
42 // Calc angle to mapCenter if I am a mainbranch
43 // needed for reordering the mainbranches clockwise
45 angle=getAngle (QPoint ((int)(x() - parObj->getChildPos().x() ),
46 (int)(y() - parObj->getChildPos().y() ) ) );
50 BranchObj::~BranchObj ()
52 // cout << "Destr BranchObj of "<<this<<endl;
53 // Check, if this branch was the last child to be deleted
54 // If so, unset the scrolled flags
56 BranchObj *po=(BranchObj*)(parObj);
60 bo=((BranchObj*)(parObj))->getLastBranch();
61 if (!bo) po->unScroll();
66 bool BranchObj::operator< ( const BranchObj & other )
68 return angle < other.angle;
71 bool BranchObj::operator== ( const BranchObj & other )
73 return angle == other.angle;
76 int BranchObjPtrList::compareItems ( Q3PtrCollection::Item i, Q3PtrCollection::Item j)
78 // Make sure PtrList::find works
81 if ( ((BranchObj*)(i))->angle > ((BranchObj*)(j))->angle )
87 void BranchObj::init ()
89 branch.setAutoDelete (false);
90 floatimage.setAutoDelete (true);
91 xlink.setAutoDelete (false);
96 absPos+=parObj->getChildPos();
99 lastSelectedBranch=-1;
106 includeImagesVer=false;
107 includeImagesHor=false;
110 void BranchObj::copy (BranchObj* other)
112 OrnamentedObj::copy(other);
116 for (b=other->branch.first(); b;b=other->branch.next() )
117 // Make deep copy of b
118 // Because addBranch again calls copy for the childs,
119 // Those will get a deep copy, too
123 for (fi=other->floatimage.first(); fi;fi=other->floatimage.next() )
126 scrolled=other->scrolled;
127 tmpUnscrolled=other->tmpUnscrolled;
128 setVisibility (other->visible);
135 void BranchObj::clear()
138 while (!xlink.isEmpty())
139 deleteXLink (xlink.first() );
142 while (!branch.isEmpty())
145 branch.removeFirst();
150 int BranchObj::getNum()
153 return ((BranchObj*)parObj)->getNum (this);
158 int BranchObj::getNum(BranchObj *bo)
160 // keep current pointer in branch,
161 // otherwise save might fail
162 // FIXME is this _really_ still true?
163 // int cur=branch.at();
164 int ind=branch.findRef (bo);
169 int BranchObj::getFloatImageNum(FloatImageObj *fio)
171 return floatimage.findRef (fio);
174 int BranchObj::countBranches()
176 return branch.count();
179 int BranchObj::countFloatImages()
181 return floatimage.count();
184 int BranchObj::countXLinks()
186 return xlink.count();
189 void BranchObj::setParObjTmp(LinkableMapObj* lmo, QPoint m, int off)
191 // Temporary link to lmo
192 // m is position of mouse pointer
193 // offset 0: default 1: below lmo -1 above lmo (if possible)
196 BranchObj* o=(BranchObj*)(lmo);
200 // ignore mapcenter and mainbranch
201 if (lmo->getDepth()<2) off=0;
208 depth=parObj->getDepth()+1;
210 // setLinkStyle calls updateLink, only set it once
211 if (style!=getDefLinkStyle() ) setLinkStyle (getDefLinkStyle());
213 // Move temporary to new position at destination
214 // Usually the positioning would be done by reposition(),
215 // but then also the destination branch would "Jump" around...
216 // Better just do it approximately
218 { // new parent is the mapcenter itself
220 QPoint p= normalise ( QPoint (m.x() - o->getChildPos().x(),
221 m.y() - o->getChildPos().y() ));
222 if (p.x()<0) p.setX( p.x()-bbox.width() );
229 // new parent is just a branch, link to it
230 QRect t=o->getBBoxSizeWithChilds();
231 if (o->getLastBranch())
232 y=t.y() + t.height() ;
239 // we want to link above lmo
240 y=o->y() - height() + 5;
242 // we want to link below lmo
243 // Bottom of sel should be 5 pixels above
244 // the bottom of the branch _below_ the target:
245 // Don't try to find that branch, guess 12 pixels
246 y=o->getChildPos().y() -height() + 12;
248 if (o->getOrientation()==OrientLeftOfCenter)
249 move ( o->getChildPos().x() - linkwidth, y );
251 move (o->getChildPos().x() + linkwidth, y );
254 // updateLink is called implicitly in move
255 reposition(); // FIXME shouldn't be this a request?
258 void BranchObj::unsetParObjTmp()
265 depth=parObj->getDepth()+1;
266 setLinkStyle (getDefLinkStyle() );
271 void BranchObj::unScroll()
273 if (tmpUnscrolled) resetTmpUnscroll();
274 if (scrolled) toggleScroll();
277 void BranchObj::toggleScroll()
283 systemFlags->deactivate("scrolledright");
284 for (bo=branch.first(); bo; bo=branch.next() )
286 bo->setVisibility(true);
291 systemFlags->activate("scrolledright");
292 for (bo=branch.first(); bo; bo=branch.next() )
294 bo->setVisibility(false);
299 move (absPos.x(), absPos.y() );
303 bool BranchObj::isScrolled()
308 bool BranchObj::hasScrolledParent(BranchObj *start)
310 // Calls parents recursivly to
311 // find out, if we are scrolled at all.
312 // But ignore myself, just look at parents.
314 if (this !=start && scrolled) return true;
316 BranchObj* bo=(BranchObj*)(parObj);
318 return bo->hasScrolledParent(start);
323 void BranchObj::tmpUnscroll()
325 // Unscroll parent (recursivly)
326 BranchObj* bo=(BranchObj*)(parObj);
327 if (bo) bo->tmpUnscroll();
333 systemFlags->activate("tmpUnscrolledright");
338 void BranchObj::resetTmpUnscroll()
340 // Unscroll parent (recursivly)
341 BranchObj* bo=(BranchObj*)(parObj);
343 bo->resetTmpUnscroll();
349 systemFlags->deactivate("tmpUnscrolledright");
354 void BranchObj::setVisibility(bool v, int toDepth)
356 if (depth <= toDepth)
358 frame->setVisibility(v);
359 heading->setVisibility(v);
360 systemFlags->setVisibility(v);
361 standardFlags->setVisibility(v);
362 LinkableMapObj::setVisibility (v);
364 // Only change childs, if I am not scrolled
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::setColorChilds (QColor col)
402 OrnamentedObj::setColor (col);
404 for (bo=branch.first(); bo; bo=branch.next() )
405 bo->setColorChilds(col);
408 BranchObj* BranchObj::first()
415 BranchObj* BranchObj::next()
418 BranchObj *bo=branch.first();
419 BranchObj *po=(BranchObj*)(parObj);
424 { // We are just beginning,
425 // return first child
438 { // We come from above
441 // there are childs, go there
446 { // no childs, try to go up again
458 // can't go up, I am mapCenter
465 // Try to find last child, where we came from, in my own childs
467 while (bo && searching)
469 if (itLast==bo) searching=false;
473 { // found lastLMO in my childs
476 // found a brother of lastLMO
484 if (this==itFirst) return NULL; // Stop at starting point
493 // can't go up, I am mapCenter
500 // couldn't find last child, it must be a nephew of mine
504 // proceed with my first child
510 // or go back to my parents
521 // can't go up, I am mapCenter
528 BranchObj* BranchObj::getLastIterator()
533 void BranchObj::setLastIterator(BranchObj* it)
538 void BranchObj::positionContents()
541 for (fio=floatimage.first(); fio; fio=floatimage.next() )
543 OrnamentedObj::positionContents();
546 void BranchObj::move (double x, double y)
548 OrnamentedObj::move (x,y);
550 for (fio=floatimage.first(); fio; fio=floatimage.next() )
555 void BranchObj::move (QPoint p)
560 void BranchObj::moveBy (double x, double y)
562 OrnamentedObj::moveBy (x,y);
564 for (b=branch.first(); b;b=branch.next() )
569 void BranchObj::moveBy (QPoint p)
571 moveBy (p.x(), p.y());
575 void BranchObj::positionBBox()
577 QPoint ap=getAbsPos();
578 bbox.moveTopLeft (ap);
583 frame->setRect(QRect(bbox.x(),bbox.y(),bbox.width(),bbox.height() ) );
585 // Update links to other branches
587 for (xlo=xlink.first(); xlo; xlo=xlink.next() )
591 void BranchObj::calcBBoxSize()
593 QSize heading_r=heading->getSize();
594 int heading_w=(int) heading_r.width() ;
595 int heading_h=(int) heading_r.height() ;
596 QSize sysflags_r=systemFlags->getSize();
597 int sysflags_h=sysflags_r.height();
598 int sysflags_w=sysflags_r.width();
599 QSize stanflags_r=standardFlags->getSize();
600 int stanflags_h=stanflags_r.height();
601 int stanflags_w=stanflags_r.width();
605 // set width to sum of all widths
606 w=heading_w + sysflags_w + stanflags_w;
607 // set height to maximum needed height
608 h=max (sysflags_h,stanflags_h);
611 // Save the dimension of flags and heading
612 ornamentsBBox.setSize ( QSize(w,h));
614 // clickBox includes Flags and Heading
615 clickBox.setSize (ornamentsBBox.size() );
621 topPad=botPad=leftPad=rightPad=0;
622 if (includeImagesVer || includeImagesHor)
624 if (countFloatImages()>0)
626 for (foi=floatimage.first(); foi; foi=floatimage.next() )
629 if (includeImagesVer)
632 topPad=max (topPad,-rp.y()-h);
633 if (rp.y()+foi->height() > 0)
634 botPad=max (botPad,rp.y()+foi->height());
636 if (includeImagesHor)
638 if (orientation==OrientRightOfCenter)
641 leftPad=max (leftPad,-rp.x()-w);
642 if (rp.x()+foi->width() > 0)
643 rightPad=max (rightPad,rp.x()+foi->width());
647 leftPad=max (leftPad,-rp.x());
648 if (rp.x()+foi->width() > w)
649 rightPad=max (rightPad,rp.x()+foi->width()-w);
659 w+=frame->getBorder();
660 h+=frame->getBorder();
663 bbox.setSize (QSize (w,h));
666 void BranchObj::setDockPos()
668 if (getOrientation()==OrientLeftOfCenter )
670 childPos=QPoint (ornamentsBBox.bottomLeft().x(), ornamentsBBox.bottomLeft().y() );
671 parPos=QPoint (ornamentsBBox.bottomRight().x(),ornamentsBBox.bottomRight().y() );
674 childPos=QPoint (ornamentsBBox.bottomRight().x(), ornamentsBBox.bottomRight().y() );
675 parPos=QPoint (ornamentsBBox.bottomLeft().x(),ornamentsBBox.bottomLeft().y() );
678 LinkableMapObj* BranchObj::findMapObj(QPoint p, LinkableMapObj* excludeLMO)
683 for (b=branch.first(); b; b=branch.next() )
685 lmo=b->findMapObj(p, excludeLMO);
686 if (lmo != NULL) return lmo;
690 if (inBox (p) && (this != excludeLMO) && isVisibleObj() )
693 // Search float images
695 for (foi=floatimage.first(); foi; foi=floatimage.next() )
697 (foi != excludeLMO) &&
698 foi->getParObj()!= excludeLMO &&
705 void BranchObj::setHeading(QString s)
707 heading->setText(s); // set new heading
708 calcBBoxSize(); // recalculate bbox
709 positionBBox(); // rearrange contents
713 void BranchObj::setHideTmp (HideTmpMode mode)
715 if (mode==HideExport && hasHiddenExportParent(this))
717 setVisibility (false);
721 if (hasScrolledParent(this))
722 setVisibility (false);
724 setVisibility (true);
729 for (bo=branch.first(); bo; bo=branch.next() )
730 bo->setHideTmp (mode);
733 bool BranchObj::hasHiddenExportParent(BranchObj *start)
735 // Calls parents recursivly to
736 // find out, if we are temp. hidden
738 if (hideExport) return true;
740 BranchObj* bo=(BranchObj*)(parObj);
742 return bo->hasHiddenExportParent(start);
747 QString BranchObj::saveToDir (const QString &tmpdir,const QString &prefix, const QPoint& offset)
749 if (hidden) return "";
752 QString scrolledAttr;
754 scrolledAttr=attribut ("scrolled","yes");
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 // Providing an ID for a branch makes export to XHTML easier
780 idAttr=attribut ("id",getSelectString());
784 s=beginElement ("branch"
790 +getIncludeImageAttr() );
794 s+=valueElement("heading", getHeading(),
795 attribut ("textColor",QColor(heading->getColor()).name()));
797 // save names of flags set
798 s+=standardFlags->saveToDir(tmpdir,prefix,0);
802 for (fio=floatimage.first(); fio; fio=floatimage.next() )
803 s+=fio->saveToDir (tmpdir,prefix,offset);
806 if (!note.isEmpty() )
811 for (bo=branch.first(); bo; bo=branch.next() )
812 s+=bo->saveToDir(tmpdir,prefix,offset);
816 QString ol; // old link
817 QString cl; // current link
818 for (xlo=xlink.first(); xlo; xlo=xlink.next() )
827 qWarning (QString("Ignoring of duplicate xLink in %1").arg(getHeading()));
832 s+=endElement ("branch");
836 void BranchObj::addXLink (XLinkObj *xlo)
842 void BranchObj::removeXLinkRef (XLinkObj *xlo)
847 void BranchObj::deleteXLink(XLinkObj *xlo)
850 if (!xlo->isUsed()) delete (xlo);
853 void BranchObj::deleteXLinkAt (int i)
855 XLinkObj *xlo=xlink.at(i);
857 if (!xlo->isUsed()) delete(xlo);
860 XLinkObj* BranchObj::XLinkAt (int i)
865 int BranchObj::countXLink()
867 return xlink.count();
871 BranchObj* BranchObj::XLinkTargetAt (int i)
874 return xlink.at(i)->otherBranch (this);
879 void BranchObj::setIncludeImagesVer(bool b)
887 bool BranchObj::getIncludeImagesVer()
889 return includeImagesVer;
892 void BranchObj::setIncludeImagesHor(bool b)
900 bool BranchObj::getIncludeImagesHor()
902 return includeImagesHor;
905 QString BranchObj::getIncludeImageAttr()
908 if (includeImagesVer)
909 a=attribut ("incImgV","true");
911 a=attribut ("incImgV","false");
912 if (includeImagesHor)
913 a+=attribut ("incImgH","true");
915 a+=attribut ("incImgH","false");
919 LinkableMapObj* BranchObj::addFloatImage ()
921 FloatImageObj *newfi=new FloatImageObj (canvas,this);
922 floatimage.append (newfi);
923 if (hasScrolledParent(this) )
924 newfi->setVisibility (false);
926 newfi->setVisibility(visible);
933 LinkableMapObj* BranchObj::addFloatImage (FloatImageObj *fio)
935 FloatImageObj *newfi=new FloatImageObj (canvas,this);
936 floatimage.append (newfi);
938 if (hasScrolledParent(this) )
939 newfi->setVisibility (false);
941 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());
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);
1152 bool BranchObj::canMoveBranchUp()
1154 if (!parObj || depth==1) return false;
1155 BranchObj* par=(BranchObj*)parObj;
1156 if (this==par->getFirstBranch())
1162 BranchObj* BranchObj::moveBranchUp(BranchObj* bo1) // modify my childlist
1165 int i=branch.find(bo1);
1166 cout << "BO: i="<<i<<endl;
1168 { // -1 if bo1 not found
1169 branch.at(i)->angle--;
1170 branch.at(i-1)->angle++;
1172 return branch.at(i);
1177 bool BranchObj::canMoveBranchDown()
1179 if (!parObj|| depth==1) return false;
1180 BranchObj* par=(BranchObj*)parObj;
1181 if (this==par->getLastBranch())
1187 BranchObj* BranchObj::moveBranchDown(BranchObj* bo1)// modify my childlist
1190 int i=branch.find(bo1);
1195 branch.at(i)->angle++;
1196 branch.at(j)->angle--;
1198 return branch.at(i);
1203 BranchObj* BranchObj::moveBranchTo (BranchObj* dst, int pos)
1205 // Find current parent and
1206 // remove pointer to myself there
1207 if (!dst) return NULL;
1208 BranchObj *par=(BranchObj*)parObj;
1210 par->removeBranchPtr (this);
1214 // Create new pointer to myself at dst
1215 if (pos<0||dst->getDepth()==0)
1217 // links myself as last branch at dst
1218 dst->addBranchPtr (this);
1223 // inserts me at pos in parent of dst
1226 BranchObj *bo=dst->insertBranchPtr (this,pos);
1227 bo->setDefAttr(MovedBranch);
1236 void BranchObj::alignRelativeTo (QPoint ref)
1238 int th = bboxTotal.height();
1241 cout << "BO::alignRelTo "<<getHeading()<<endl;
1242 cout << " d="<<depth<<
1244 // " bbox.topLeft="<<bboxTotal.topLeft()<<
1245 " absPos="<<absPos<<
1246 // " pad="<<topPad<<","<<botPad<<","<<leftPad<<","<<rightPad<<
1247 " hidden="<<hidden<<
1251 // If I am the mapcenter or a mainbranch, reposition heading
1255 // Calc angle to mapCenter if I am a mainbranch
1256 // needed for reordering the mainbranches clockwise
1258 angle=getAngle (QPoint ((int)(x() - parObj->getChildPos().x() ),
1259 (int)(y() - parObj->getChildPos().y() ) ) );
1263 // Align myself depending on orientation and parent, but
1264 // only if I am not the mainbranch or mapcenter itself
1265 switch (orientation)
1267 case OrientLeftOfCenter:
1268 move (ref.x() - bbox.width(), ref.y() + (th-bbox.height())/2 );
1270 case OrientRightOfCenter:
1271 move (ref.x() , ref.y() + (th-bbox.height())/2 );
1274 qWarning ("LMO::alignRelativeTo: oops, no orientation given...");
1279 if (scrolled) return;
1281 // Set reference point for alignment of childs
1283 if (orientation==OrientLeftOfCenter)
1284 ref2.setX(bbox.topLeft().x() - linkwidth);
1286 ref2.setX(bbox.topRight().x() + linkwidth);
1289 ref2.setY(absPos.y()-(bboxTotal.height()-bbox.height())/2);
1291 ref2.setY(ref.y() );
1293 // Align the childs depending on reference point
1295 for (b=branch.first(); b; b=branch.next() )
1299 b->alignRelativeTo (ref2);
1300 ref2.setY(ref2.y() + b->getBBoxSizeWithChilds().height() );
1306 void BranchObj::reposition()
1308 /* TODO testing only
1309 if (!getHeading().isEmpty())
1310 cout << "BO::reposition "<<getHeading()<<endl;
1312 cout << "BO::reposition ???"<<endl;
1316 // only calculate the sizes once. If the deepest LMO
1317 // changes its height,
1318 // all upper LMOs have to change, too.
1319 calcBBoxSizeWithChilds();
1320 updateLink(); // This update is needed if the canvas is resized
1321 // due to excessive moving of a FIO
1323 alignRelativeTo ( QPoint (absPos.x(),
1324 absPos.y()-(bboxTotal.height()-bbox.height())/2) );
1326 positionBBox(); // Reposition bbox and contents
1329 // This is only important for moving branches:
1330 // For editing a branch it isn't called...
1331 alignRelativeTo ( QPoint (absPos.x(),
1332 absPos.y()-(bboxTotal.height()-bbox.height())/2) );
1337 QRect BranchObj::getTotalBBox()
1341 if (scrolled) return r;
1344 for (b=branch.first();b ;b=branch.next() )
1346 r=addBBox(b->getTotalBBox(),r);
1349 for (fio=floatimage.first();fio ;fio=floatimage.next() )
1350 if (!fio->isHidden())
1351 r=addBBox(fio->getTotalBBox(),r);
1356 QRect BranchObj::getBBoxSizeWithChilds()
1361 void BranchObj::calcBBoxSizeWithChilds()
1363 // This is initially called only from reposition and
1364 // and only for mapcenter. So it won't be
1365 // called more than once for a single user
1369 // Calculate size of LMO including all childs (to align them later)
1370 bboxTotal.setX(bbox.x() );
1371 bboxTotal.setY(bbox.y() );
1373 // if branch is scrolled, ignore childs, but still consider floatimages
1376 bboxTotal.setWidth (bbox.width());
1377 bboxTotal.setHeight(bbox.height());
1383 bboxTotal.setWidth (0);
1384 bboxTotal.setHeight(0);
1387 bboxTotal.setX (parObj->x());
1388 bboxTotal.setY (parObj->y());
1391 bboxTotal.setX (bbox.x());
1392 bboxTotal.setY (bbox.y());
1399 // Now calculate recursivly
1401 // maximum of widths
1404 for (b=branch.first();b ;b=branch.next() )
1408 b->calcBBoxSizeWithChilds();
1409 br=b->getBBoxSizeWithChilds();
1410 r.setWidth( max (br.width(), r.width() ));
1411 r.setHeight(br.height() + r.height() );
1412 if (br.y()<bboxTotal.y()) bboxTotal.setY(br.y());
1415 // Add myself and also
1416 // add width of link to sum if necessary
1417 if (branch.isEmpty())
1418 bboxTotal.setWidth (bbox.width() + r.width() );
1420 bboxTotal.setWidth (bbox.width() + r.width() + linkwidth);
1422 bboxTotal.setHeight(max (r.height(), bbox.height()));
1425 void BranchObj::select()
1427 // set Text in Editor
1428 textEditor->setText(note.getNote() );
1429 QString fnh=note.getFilenameHint();
1431 textEditor->setFilenameHint(note.getFilenameHint() );
1433 textEditor->setFilenameHint(getHeading() );
1434 textEditor->setFontHint (note.getFontHint() );
1436 LinkableMapObj::select();
1437 // Tell parent that I am selected now:
1438 BranchObj* po=(BranchObj*)(parObj);
1439 if (po) // TODO Try to get rid of this cast...
1440 po->setLastSelectedBranch(this);
1442 // temporary unscroll, if we have scrolled parents somewhere
1443 if (parObj) ((BranchObj*)(parObj))->tmpUnscroll();
1445 // Show URL and link in statusbar
1447 if (!url.isEmpty()) status+="URL: "+url+" ";
1448 if (!vymLink.isEmpty()) status+="Link: "+vymLink;
1449 if (!status.isEmpty()) mainWindow->statusMessage (status);
1452 updateFlagsToolbar();
1454 // Update actions in mapeditor
1455 mapEditor->updateActions();
1458 void BranchObj::unselect()
1460 LinkableMapObj::unselect();
1461 // Delete any messages like vymLink in StatusBar
1462 mainWindow->statusMessage ("");
1464 // save note from editor and set flag
1465 // text is done by updateNoteFlag(), just save
1467 note.setFilenameHint (textEditor->getFilename());
1469 // reset temporary unscroll, if we have scrolled parents somewhere
1470 if (parObj) ((BranchObj*)(parObj))->resetTmpUnscroll();
1472 // Erase content of editor
1473 textEditor->setInactive();
1475 // unselect all buttons in toolbar
1476 standardFlagsDefault->updateToolbar();
1479 QString BranchObj::getSelectString()
1485 s= "bo:" + QString("%1").arg(getNum());
1487 s= ((BranchObj*)(parObj))->getSelectString() + ",bo:" + QString("%1").arg(getNum());