2 #include "texteditor.h"
4 #include "mainwindow.h"
6 extern TextEditor *textEditor;
7 extern Main *mainWindow;
8 extern FlagRowObj *standardFlagsDefault;
11 /////////////////////////////////////////////////////////////////
13 /////////////////////////////////////////////////////////////////
15 BranchObj* BranchObj::itLast=NULL;
16 BranchObj* BranchObj::itFirst=NULL;
19 BranchObj::BranchObj () :OrnamentedObj()
21 // cout << "Const BranchObj ()\n";
27 BranchObj::BranchObj (Q3Canvas* c):OrnamentedObj (c)
29 // cout << "Const BranchObj (c) called from MapCenterObj (c)\n";
34 BranchObj::BranchObj (Q3Canvas* 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 ( Q3PtrCollection::Item i, Q3PtrCollection::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;
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);
134 void BranchObj::clear()
137 while (!xlink.isEmpty())
138 deleteXLink (xlink.first() );
141 while (!branch.isEmpty())
144 branch.removeFirst();
149 int BranchObj::getNum()
152 return ((BranchObj*)parObj)->getNum (this);
157 int BranchObj::getNum(BranchObj *bo)
159 // keep current pointer in branch,
160 // otherwise saveToDir will fail
162 int ind=branch.findRef (bo);
167 int BranchObj::getFloatImageNum(FloatImageObj *fio)
169 return floatimage.findRef (fio);
172 int BranchObj::countBranches()
174 return branch.count();
177 int BranchObj::countFloatImages()
179 return floatimage.count();
182 int BranchObj::countXLinks()
184 return xlink.count();
187 void BranchObj::setParObjTmp(LinkableMapObj* lmo, QPoint m, int off)
189 // Temporary link to lmo
190 // m is position of mouse pointer
191 // offset 0: default 1: below lmo -1 above lmo (if possible)
194 BranchObj* o=(BranchObj*)(lmo);
198 // ignore mapcenter and mainbranch
199 if (lmo->getDepth()<2) off=0;
206 depth=parObj->getDepth()+1;
208 // setLinkStyle calls updateLink, only set it once
209 if (style!=getDefLinkStyle() ) setLinkStyle (getDefLinkStyle());
211 // Move temporary to new position at destination
212 // Usually the positioning would be done by reposition(),
213 // but then also the destination branch would "Jump" around...
214 // Better just do it approximately
216 { // new parent is the mapcenter itself
218 QPoint p= normalise ( QPoint (m.x() - o->getChildPos().x(),
219 m.y() - o->getChildPos().y() ));
220 if (p.x()<0) p.setX( p.x()-bbox.width() );
227 // new parent is just a branch, link to it
228 QRect t=o->getBBoxSizeWithChilds();
229 if (o->getLastBranch())
230 y=t.y() + t.height() ;
237 // we want to link above lmo
238 y=o->y() - height() + 5;
240 // we want to link below lmo
241 // Bottom of sel should be 5 pixels above
242 // the bottom of the branch _below_ the target:
243 // Don't try to find that branch, guess 12 pixels
244 y=o->getChildPos().y() -height() + 12;
246 if (o->getOrientation()==OrientLeftOfCenter)
247 move ( o->getChildPos().x() - linkwidth, y );
249 move (o->getChildPos().x() + linkwidth, y );
252 // updateLink is called implicitly in move
253 reposition(); // FIXME shouldn't be this a request?
256 void BranchObj::unsetParObjTmp()
263 depth=parObj->getDepth()+1;
264 setLinkStyle (getDefLinkStyle() );
269 void BranchObj::unScroll()
271 if (tmpUnscrolled) resetTmpUnscroll();
272 if (scrolled) toggleScroll();
275 void BranchObj::toggleScroll()
281 systemFlags->deactivate("scrolledright");
282 for (bo=branch.first(); bo; bo=branch.next() )
284 bo->setVisibility(true);
289 systemFlags->activate("scrolledright");
290 for (bo=branch.first(); bo; bo=branch.next() )
292 bo->setVisibility(false);
297 move (absPos.x(), absPos.y() );
301 bool BranchObj::isScrolled()
306 bool BranchObj::hasScrolledParent(BranchObj *start)
308 // Calls parents recursivly to
309 // find out, if we are scrolled at all.
310 // But ignore myself, just look at parents.
312 if (this !=start && scrolled) return true;
314 BranchObj* bo=(BranchObj*)(parObj);
316 return bo->hasScrolledParent(start);
321 void BranchObj::tmpUnscroll()
323 // Unscroll parent (recursivly)
324 BranchObj* bo=(BranchObj*)(parObj);
325 if (bo) bo->tmpUnscroll();
331 systemFlags->activate("tmpUnscrolledright");
336 void BranchObj::resetTmpUnscroll()
338 // Unscroll parent (recursivly)
339 BranchObj* bo=(BranchObj*)(parObj);
341 bo->resetTmpUnscroll();
347 systemFlags->deactivate("tmpUnscrolledright");
352 void BranchObj::setVisibility(bool v, int toDepth)
354 if (depth <= toDepth)
356 frame->setVisibility(v);
357 heading->setVisibility(v);
358 systemFlags->setVisibility(v);
359 standardFlags->setVisibility(v);
360 LinkableMapObj::setVisibility (v);
362 // Only change childs, if I am not scrolled
363 if (!scrolled && (depth < toDepth))
365 // Now go recursivly through all childs
367 for (b=branch.first(); b;b=branch.next() )
368 b->setVisibility (v,toDepth);
370 for (fio=floatimage.first(); fio; fio=floatimage.next())
371 fio->setVisibility (v);
373 for (xlo=xlink.first(); xlo;xlo=xlink.next() )
374 xlo->setVisibility ();
376 } // depth <= toDepth
380 void BranchObj::setVisibility(bool v)
382 setVisibility (v,MAX_DEPTH);
386 void BranchObj::setLinkColor ()
388 // Overloaded from LinkableMapObj
389 // BranchObj can use color of heading
392 if (mapEditor->getMapLinkColorHint()==HeadingColor)
393 LinkableMapObj::setLinkColor (heading->getColor() );
395 LinkableMapObj::setLinkColor ();
398 void BranchObj::setColorChilds (QColor col)
400 OrnamentedObj::setColor (col);
402 for (bo=branch.first(); bo; bo=branch.next() )
403 bo->setColorChilds(col);
406 BranchObj* BranchObj::first()
413 BranchObj* BranchObj::next()
416 BranchObj *bo=branch.first();
417 BranchObj *po=(BranchObj*)(parObj);
422 { // We are just beginning,
423 // return first child
436 { // We come from above
439 // there are childs, go there
444 { // no childs, try to go up again
456 // can't go up, I am mapCenter
463 // Try to find last child, where we came from, in my own childs
465 while (bo && searching)
467 if (itLast==bo) searching=false;
471 { // found lastLMO in my childs
474 // found a brother of lastLMO
482 if (this==itFirst) return NULL; // Stop at starting point
491 // can't go up, I am mapCenter
498 // couldn't find last child, it must be a nephew of mine
502 // proceed with my first child
508 // or go back to my parents
519 // can't go up, I am mapCenter
526 BranchObj* BranchObj::getLastIterator()
531 void BranchObj::setLastIterator(BranchObj* it)
536 void BranchObj::positionContents()
539 for (fio=floatimage.first(); fio; fio=floatimage.next() )
541 OrnamentedObj::positionContents();
544 void BranchObj::move (double x, double y)
546 OrnamentedObj::move (x,y);
548 for (fio=floatimage.first(); fio; fio=floatimage.next() )
553 void BranchObj::move (QPoint p)
558 void BranchObj::moveBy (double x, double y)
560 OrnamentedObj::moveBy (x,y);
562 for (b=branch.first(); b;b=branch.next() )
567 void BranchObj::moveBy (QPoint p)
569 moveBy (p.x(), p.y());
573 void BranchObj::positionBBox()
575 QPoint ap=getAbsPos();
576 bbox.moveTopLeft (ap);
581 frame->setRect(QRect(bbox.x(),bbox.y(),bbox.width(),bbox.height() ) );
583 // Update links to other branches
585 for (xlo=xlink.first(); xlo; xlo=xlink.next() )
589 void BranchObj::calcBBoxSize()
591 QSize heading_r=heading->getSize();
592 int heading_w=(int) heading_r.width() ;
593 int heading_h=(int) heading_r.height() ;
594 QSize sysflags_r=systemFlags->getSize();
595 int sysflags_h=sysflags_r.height();
596 int sysflags_w=sysflags_r.width();
597 QSize stanflags_r=standardFlags->getSize();
598 int stanflags_h=stanflags_r.height();
599 int stanflags_w=stanflags_r.width();
603 // set width to sum of all widths
604 w=heading_w + sysflags_w + stanflags_w;
605 // set height to maximum needed height
606 h=max (sysflags_h,stanflags_h);
609 // Save the dimension of flags and heading
610 ornamentsBBox.setSize ( QSize(w,h));
612 // clickBox includes Flags and Heading
613 clickBox.setSize (ornamentsBBox.size() );
619 topPad=botPad=leftPad=rightPad=0;
620 if (includeImagesVer || includeImagesHor)
622 if (countFloatImages()>0)
624 for (foi=floatimage.first(); foi; foi=floatimage.next() )
627 if (includeImagesVer)
630 topPad=max (topPad,-rp.y()-h);
631 if (rp.y()+foi->height() > 0)
632 botPad=max (botPad,rp.y()+foi->height());
634 if (includeImagesHor)
636 if (orientation==OrientRightOfCenter)
639 leftPad=max (leftPad,-rp.x()-w);
640 if (rp.x()+foi->width() > 0)
641 rightPad=max (rightPad,rp.x()+foi->width());
645 leftPad=max (leftPad,-rp.x());
646 if (rp.x()+foi->width() > w)
647 rightPad=max (rightPad,rp.x()+foi->width()-w);
657 w+=frame->getBorder();
658 h+=frame->getBorder();
661 bbox.setSize (QSize (w,h));
664 void BranchObj::setDockPos()
666 // Sets childpos and parpos depending on orientation
667 if (getOrientation()==OrientLeftOfCenter )
669 childPos=QPoint (ornamentsBBox.bottomLeft().x(), ornamentsBBox.bottomLeft().y() );
670 parPos=QPoint (ornamentsBBox.bottomRight().x(),ornamentsBBox.bottomRight().y() );
673 childPos=QPoint (ornamentsBBox.bottomRight().x(), ornamentsBBox.bottomRight().y() );
674 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 for (int i=1; i<depth;i++) cout << " ";
795 cout <<getHeading().ascii()<<endl;
799 s+=valueElement("heading", getHeading(),
800 attribut ("textColor",QColor(heading->getColor()).name()));
802 // save names of flags set
803 s+=standardFlags->saveToDir(tmpdir,prefix,0);
807 for (fio=floatimage.first(); fio; fio=floatimage.next() )
808 s+=fio->saveToDir (tmpdir,prefix);
811 if (!note.isEmpty() )
816 for (bo=branch.first(); bo; bo=branch.next() )
817 s+=bo->saveToDir(tmpdir,prefix,offset);
821 QString ol; // old link
822 QString cl; // current link
823 for (xlo=xlink.first(); xlo; xlo=xlink.next() )
832 qWarning (QString("Ignoring of duplicate xLink in %1").arg(getHeading()));
837 s+=endElement ("branch");
841 void BranchObj::addXLink (XLinkObj *xlo)
847 void BranchObj::removeXLinkRef (XLinkObj *xlo)
852 void BranchObj::deleteXLink(XLinkObj *xlo)
855 if (!xlo->isUsed()) delete (xlo);
858 void BranchObj::deleteXLinkAt (int i)
860 XLinkObj *xlo=xlink.at(i);
862 if (!xlo->isUsed()) delete(xlo);
865 XLinkObj* BranchObj::XLinkAt (int i)
870 int BranchObj::countXLink()
872 return xlink.count();
876 BranchObj* BranchObj::XLinkTargetAt (int i)
879 return xlink.at(i)->otherBranch (this);
884 void BranchObj::setIncludeImagesVer(bool b)
892 bool BranchObj::getIncludeImagesVer()
894 return includeImagesVer;
897 void BranchObj::setIncludeImagesHor(bool b)
905 bool BranchObj::getIncludeImagesHor()
907 return includeImagesHor;
910 QString BranchObj::getIncludeImageAttr()
913 if (includeImagesVer)
914 a=attribut ("incImgV","true");
916 a=attribut ("incImgV","false");
917 if (includeImagesHor)
918 a+=attribut ("incImgH","true");
920 a+=attribut ("incImgH","false");
924 FloatImageObj* BranchObj::addFloatImage ()
926 FloatImageObj *newfi=new FloatImageObj (canvas,this);
927 floatimage.append (newfi);
928 if (hasScrolledParent(this) )
929 newfi->setVisibility (false);
931 newfi->setVisibility(visible);
940 FloatImageObj* BranchObj::addFloatImage (FloatImageObj *fio)
942 FloatImageObj *newfi=new FloatImageObj (canvas,this);
943 floatimage.append (newfi);
945 if (hasScrolledParent(this) )
946 newfi->setVisibility (false);
948 newfi->setVisibility(visible);
957 FloatImageObj* BranchObj::getFirstFloatImage ()
959 return floatimage.first();
962 FloatImageObj* BranchObj::getLastFloatImage ()
964 return floatimage.last();
967 FloatImageObj* BranchObj::getFloatImageNum (const uint &i)
969 return floatimage.at(i);
972 void BranchObj::removeFloatImage (FloatImageObj *fio)
974 floatimage.remove (fio);
981 void BranchObj::savePosInAngle ()
983 // Save position in angle
986 for (b=branch.first(); b; b=branch.next() )
993 void BranchObj::setDefAttr (BranchModification mod)
998 case 0: fontsize=16; break;
999 case 1: fontsize=12; break;
1000 default: fontsize=10; break;
1004 setLinkStyle(getDefLinkStyle());
1005 QFont font("Sans Serif,8,-1,5,50,0,0,0,0,0");
1006 font.setPointSize(fontsize);
1007 heading->setFont(font );
1010 setColor (((BranchObj*)(parObj))->getColor());
1015 BranchObj* BranchObj::addBranch()
1017 BranchObj* newbo=new BranchObj(canvas,this);
1018 branch.append (newbo);
1019 newbo->setParObj(this);
1020 newbo->setDefAttr(NewBranch);
1021 newbo->setHeading ("new");
1023 newbo->setVisibility (false);
1025 newbo->setVisibility(visible);
1026 newbo->updateLink();
1027 requestReposition();
1031 BranchObj* BranchObj::addBranch(BranchObj* bo)
1033 BranchObj* newbo=new BranchObj(canvas,this);
1034 branch.append (newbo);
1036 newbo->setParObj(this);
1037 newbo->setDefAttr(MovedBranch);
1039 newbo->setVisibility (false);
1041 newbo->setVisibility(bo->visible);
1042 newbo->updateLink();
1043 requestReposition();
1047 BranchObj* BranchObj::addBranchPtr(BranchObj* bo)
1050 bo->setParObj (this);
1052 bo->setDefAttr(MovedBranch);
1053 if (scrolled) tmpUnscroll();
1054 setLastSelectedBranch (bo);
1058 BranchObj* BranchObj::insertBranch(int pos)
1061 // Add new bo and resort branches
1062 BranchObj *newbo=addBranch ();
1063 newbo->angle=pos-0.5;
1068 BranchObj* BranchObj::insertBranch(BranchObj* bo, int pos)
1071 // Add new bo and resort branches
1073 BranchObj *newbo=addBranch (bo);
1078 BranchObj* BranchObj::insertBranchPtr (BranchObj* bo, int pos)
1081 // Add new bo and resort branches
1084 bo->setParObj (this);
1086 bo->setDefAttr (MovedBranch);
1087 if (scrolled) tmpUnscroll();
1088 setLastSelectedBranch (bo);
1093 void BranchObj::removeBranchHere(BranchObj* borem)
1095 // This removes the branch bo from list, but
1096 // inserts its childs at the place of bo
1098 bo=borem->getLastBranch();
1099 int pos=borem->getNum();
1102 bo->moveBranchTo (this,pos+1);
1103 bo=borem->getLastBranch();
1105 removeBranch (borem);
1108 void BranchObj::removeChilds()
1113 void BranchObj::removeBranch(BranchObj* bo)
1115 // if bo is not in branch remove returns false, we
1118 if (branch.remove (bo))
1121 qWarning ("BranchObj::removeBranch tried to remove non existing branch?!\n");
1122 requestReposition();
1125 void BranchObj::removeBranchPtr(BranchObj* bo)
1128 requestReposition();
1131 void BranchObj::setLastSelectedBranch (BranchObj* bo)
1133 lastSelectedBranch=branch.find(bo);
1136 BranchObj* BranchObj::getLastSelectedBranch ()
1138 if (lastSelectedBranch>=0)
1140 BranchObj* bo=branch.at(lastSelectedBranch);
1143 return branch.first();
1146 BranchObj* BranchObj::getFirstBranch ()
1148 return branch.first();
1151 BranchObj* BranchObj::getLastBranch ()
1153 return branch.last();
1156 BranchObj* BranchObj::getBranchNum (const uint &i)
1158 return branch.at(i);
1161 bool BranchObj::canMoveBranchUp()
1163 if (!parObj || depth==1) return false;
1164 BranchObj* par=(BranchObj*)parObj;
1165 if (this==par->getFirstBranch())
1171 BranchObj* BranchObj::moveBranchUp(BranchObj* bo1) // modify my childlist
1174 int i=branch.find(bo1);
1176 { // -1 if bo1 not found
1177 branch.at(i)->angle--;
1178 branch.at(i-1)->angle++;
1180 return branch.at(i);
1185 bool BranchObj::canMoveBranchDown()
1187 if (!parObj|| depth==1) return false;
1188 BranchObj* par=(BranchObj*)parObj;
1189 if (this==par->getLastBranch())
1195 BranchObj* BranchObj::moveBranchDown(BranchObj* bo1)// modify my childlist
1198 int i=branch.find(bo1);
1203 branch.at(i)->angle++;
1204 branch.at(j)->angle--;
1206 return branch.at(i);
1211 BranchObj* BranchObj::moveBranchTo (BranchObj* dst, int pos)
1213 // Find current parent and
1214 // remove pointer to myself there
1215 if (!dst) return NULL;
1216 BranchObj *par=(BranchObj*)parObj;
1218 par->removeBranchPtr (this);
1222 // Create new pointer to myself at dst
1223 if (pos<0||dst->getDepth()==0)
1225 // links myself as last branch at dst
1226 dst->addBranchPtr (this);
1231 // inserts me at pos in parent of dst
1234 BranchObj *bo=dst->insertBranchPtr (this,pos);
1235 bo->setDefAttr(MovedBranch);
1244 void BranchObj::alignRelativeTo (QPoint ref)
1246 int th = bboxTotal.height();
1249 cout << "BO::alignRelTo "<<getHeading().ascii()<<endl;
1250 cout << " d="<<depth<<
1252 // " bbox.topLeft="<<bboxTotal.topLeft()<<
1253 " absPos="<<absPos<<
1254 " relPos="<<relPos<<
1255 " orient="<<orientation<<
1256 // " pad="<<topPad<<","<<botPad<<","<<leftPad<<","<<rightPad<<
1257 // " hidden="<<hidden<<
1269 // Position relatively, if needed
1270 //if (useRelPos) move2RelPos (relPos.x(), relPos.y());
1272 // Calc angle to mapCenter if I am a mainbranch
1273 // needed for reordering the mainbranches clockwise
1275 angle=getAngle (QPoint ((int)(x() - parObj->getChildPos().x() ),
1276 (int)(y() - parObj->getChildPos().y() ) ) );
1281 // Align myself depending on orientation and parent, but
1282 // only if I am not a mainbranch or mapcenter itself
1284 o=parObj->getOrientation();
1285 switch (orientation)
1287 case OrientLeftOfCenter:
1288 move (ref.x() - bbox.width(), ref.y() + (th-bbox.height())/2 );
1290 case OrientRightOfCenter:
1291 move (ref.x() , ref.y() + (th-bbox.height())/2 );
1294 qWarning ("LMO::alignRelativeTo: oops, no orientation given...");
1299 if (scrolled) return;
1301 // Set reference point for alignment of childs
1303 if (orientation==OrientLeftOfCenter)
1304 ref2.setX(bbox.topLeft().x() - linkwidth);
1306 ref2.setX(bbox.topRight().x() + linkwidth);
1309 ref2.setY(absPos.y()-(bboxTotal.height()-bbox.height())/2);
1311 ref2.setY(ref.y() );
1313 // Align the childs depending on reference point
1315 for (b=branch.first(); b; b=branch.next() )
1319 b->alignRelativeTo (ref2);
1320 ref2.setY(ref2.y() + b->getBBoxSizeWithChilds().height() );
1326 void BranchObj::reposition()
1328 /* TODO testing only
1329 if (!getHeading().isEmpty())
1330 cout << "BO::reposition "<<getHeading().ascii()<<endl;
1332 cout << "BO::reposition ???"<<endl;
1334 cout << " orient="<<orientation<<endl;
1339 // only calculate the sizes once. If the deepest LMO
1340 // changes its height,
1341 // all upper LMOs have to change, too.
1342 calcBBoxSizeWithChilds();
1343 updateLink(); // This update is needed if the canvas is resized
1344 // due to excessive moving of a FIO
1345 // FIXME really needed? reposition is also called from updateLink...
1347 alignRelativeTo ( QPoint (absPos.x(),
1348 absPos.y()-(bboxTotal.height()-bbox.height())/2) );
1350 positionBBox(); // Reposition bbox and contents
1353 // This is only important for moving branches:
1354 // For editing a branch it isn't called...
1355 alignRelativeTo ( QPoint (absPos.x(),
1356 absPos.y()-(bboxTotal.height()-bbox.height())/2) );
1360 void BranchObj::unsetAllRepositionRequests()
1362 repositionRequest=false;
1364 for (b=branch.first(); b; b=branch.next() )
1366 b->unsetAllRepositionRequests();
1371 QRect BranchObj::getTotalBBox()
1375 if (scrolled) return r;
1378 for (b=branch.first();b ;b=branch.next() )
1380 r=addBBox(b->getTotalBBox(),r);
1383 for (fio=floatimage.first();fio ;fio=floatimage.next() )
1384 if (!fio->isHidden())
1385 r=addBBox(fio->getTotalBBox(),r);
1390 QRect BranchObj::getBBoxSizeWithChilds()
1395 void BranchObj::calcBBoxSizeWithChilds()
1397 // This is initially called only from reposition and
1398 // and only for mapcenter. So it won't be
1399 // called more than once for a single user
1403 // Calculate size of LMO including all childs (to align them later)
1404 bboxTotal.setX(bbox.x() );
1405 bboxTotal.setY(bbox.y() );
1407 // if branch is scrolled, ignore childs, but still consider floatimages
1410 bboxTotal.setWidth (bbox.width());
1411 bboxTotal.setHeight(bbox.height());
1417 bboxTotal.setWidth (0);
1418 bboxTotal.setHeight(0);
1421 bboxTotal.setX (parObj->x());
1422 bboxTotal.setY (parObj->y());
1425 bboxTotal.setX (bbox.x());
1426 bboxTotal.setY (bbox.y());
1433 // Now calculate recursivly
1435 // maximum of widths
1438 for (b=branch.first();b ;b=branch.next() )
1442 b->calcBBoxSizeWithChilds();
1443 br=b->getBBoxSizeWithChilds();
1444 r.setWidth( max (br.width(), r.width() ));
1445 r.setHeight(br.height() + r.height() );
1446 if (br.y()<bboxTotal.y()) bboxTotal.setY(br.y());
1449 // Add myself and also
1450 // add width of link to sum if necessary
1451 if (branch.isEmpty())
1452 bboxTotal.setWidth (bbox.width() + r.width() );
1454 bboxTotal.setWidth (bbox.width() + r.width() + linkwidth);
1456 bboxTotal.setHeight(max (r.height(), bbox.height()));
1459 void BranchObj::select()
1461 // set Text in Editor
1462 textEditor->setText(note.getNote() );
1463 QString fnh=note.getFilenameHint();
1465 textEditor->setFilenameHint(note.getFilenameHint() );
1467 textEditor->setFilenameHint(getHeading() );
1468 textEditor->setFontHint (note.getFontHint() );
1470 LinkableMapObj::select();
1471 // Tell parent that I am selected now:
1472 BranchObj* po=(BranchObj*)(parObj);
1473 if (po) // TODO Try to get rid of this cast...
1474 po->setLastSelectedBranch(this);
1476 // temporary unscroll, if we have scrolled parents somewhere
1477 if (parObj) ((BranchObj*)(parObj))->tmpUnscroll();
1479 // Show URL and link in statusbar
1481 if (!url.isEmpty()) status+="URL: "+url+" ";
1482 if (!vymLink.isEmpty()) status+="Link: "+vymLink;
1483 if (!status.isEmpty()) mainWindow->statusMessage (status);
1486 updateFlagsToolbar();
1488 // Update actions in mapeditor
1489 mapEditor->updateActions();
1492 void BranchObj::unselect()
1494 LinkableMapObj::unselect();
1495 // Delete any messages like vymLink in StatusBar
1496 mainWindow->statusMessage ("");
1498 // save note from editor and set flag
1499 // text is done by updateNoteFlag(), just save
1501 note.setFilenameHint (textEditor->getFilename());
1503 // reset temporary unscroll, if we have scrolled parents somewhere
1504 if (parObj) ((BranchObj*)(parObj))->resetTmpUnscroll();
1506 // Erase content of editor
1507 textEditor->setInactive();
1509 // unselect all buttons in toolbar
1510 standardFlagsDefault->updateToolbar();
1513 QString BranchObj::getSelectString()
1519 s= "bo:" + QString("%1").arg(getNum());
1521 s= ((BranchObj*)(parObj))->getSelectString() + ",bo:" + QString("%1").arg(getNum());