Removed some FIXMEs. Added translations
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 (QGraphicsScene* s):OrnamentedObj (s)
29 // cout << "Const BranchObj (s) called from MapCenterObj (s)\n";
34 BranchObj::BranchObj (QGraphicsScene* s, LinkableMapObj* p):OrnamentedObj (s)
36 // cout << "Const BranchObj (s,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 (QPointF (x() - parObj->getChildPos().x() ,
45 (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 void BranchObj::init ()
80 absPos+=parObj->getChildPos();
90 includeImagesVer=false;
91 includeImagesHor=false;
94 void BranchObj::copy (BranchObj* other)
96 OrnamentedObj::copy(other);
99 for (int i=0; i<other->branch.size(); ++i)
100 // Make deep copy of b
101 // Because addBranch again calls copy for the childs,
102 // Those will get a deep copy, too
103 addBranch(other->branch.at(i) );
105 for (int i=0; i<other->floatimage.size(); ++i)
106 addFloatImage (other->floatimage.at(i));
107 scrolled=other->scrolled;
108 tmpUnscrolled=other->tmpUnscrolled;
109 setVisibility (other->visible);
116 void BranchObj::clear()
118 while (!floatimage.isEmpty())
119 delete floatimage.takeFirst();
121 while (!xlink.isEmpty())
122 delete xlink.takeFirst();
124 while (!branch.isEmpty())
125 delete branch.takeFirst();
128 bool isAbove (BranchObj* a, BranchObj *b)
130 if (a->angle < b->angle)
136 int BranchObj::getNum()
139 return ((BranchObj*)parObj)->getNum (this);
144 int BranchObj::getNum(BranchObj *bo)
146 return branch.indexOf (bo);
149 int BranchObj::getFloatImageNum(FloatImageObj *fio)
151 return floatimage.indexOf(fio);
154 int BranchObj::countBranches()
156 return branch.count();
159 int BranchObj::countFloatImages()
161 return floatimage.count();
164 int BranchObj::countXLinks()
166 return xlink.count();
169 void BranchObj::setParObjTmp(LinkableMapObj* lmo, QPointF m, int off)
171 // Temporary link to lmo
172 // m is position of mouse pointer
173 // offset 0: default 1: below lmo -1 above lmo (if possible)
176 BranchObj* o=(BranchObj*)(lmo);
180 // ignore mapcenter and mainbranch
181 if (lmo->getDepth()<2) off=0;
188 depth=parObj->getDepth()+1;
190 // setLinkStyle calls updateLink, only set it once
191 if (style!=getDefLinkStyle() ) setLinkStyle (getDefLinkStyle());
193 // Move temporary to new position at destination
194 // Usually the positioning would be done by reposition(),
195 // but then also the destination branch would "Jump" around...
196 // Better just do it approximately
198 { // new parent is the mapcenter itself
200 QPointF p= normalise ( QPointF (m.x() - o->getChildPos().x(),
201 m.y() - o->getChildPos().y() ));
202 if (p.x()<0) p.setX( p.x()-bbox.width() );
209 // new parent is just a branch, link to it
210 QRectF t=o->getBBoxSizeWithChilds();
211 if (o->getLastBranch())
212 y=t.y() + t.height() ;
219 // we want to link above lmo
220 y=o->y() - height() + 5;
222 // we want to link below lmo
223 // Bottom of sel should be 5 pixels above
224 // the bottom of the branch _below_ the target:
225 // Don't try to find that branch, guess 12 pixels
226 y=o->getChildPos().y() -height() + 12;
228 if (o->getOrientation()==OrientLeftOfCenter)
229 move ( o->getChildPos().x() - linkwidth, y );
231 move (o->getChildPos().x() + linkwidth, y );
234 // updateLink is called implicitly in move
235 requestReposition(); // FIXME shouldn't be this a request?
238 void BranchObj::unsetParObjTmp()
245 depth=parObj->getDepth()+1;
246 setLinkStyle (getDefLinkStyle() );
251 void BranchObj::unScroll()
253 if (tmpUnscrolled) resetTmpUnscroll();
254 if (scrolled) toggleScroll();
257 void BranchObj::toggleScroll()
262 systemFlags->deactivate("scrolledright");
263 for (int i=0; i<branch.size(); ++i)
264 branch.at(i)->setVisibility(true);
268 systemFlags->activate("scrolledright");
269 for (int i=0; i<branch.size(); ++i)
270 branch.at(i)->setVisibility(false);
274 move (absPos.x(), absPos.y() );
278 bool BranchObj::isScrolled()
283 bool BranchObj::hasScrolledParent(BranchObj *start)
285 // Calls parents recursivly to
286 // find out, if we are scrolled at all.
287 // But ignore myself, just look at parents.
289 if (this !=start && scrolled) return true;
291 BranchObj* bo=(BranchObj*)(parObj);
293 return bo->hasScrolledParent(start);
298 void BranchObj::tmpUnscroll()
300 // Unscroll parent (recursivly)
301 BranchObj* bo=(BranchObj*)(parObj);
302 if (bo) bo->tmpUnscroll();
308 systemFlags->activate("tmpUnscrolledright");
313 void BranchObj::resetTmpUnscroll()
315 // Unscroll parent (recursivly)
316 BranchObj* bo=(BranchObj*)(parObj);
318 bo->resetTmpUnscroll();
324 systemFlags->deactivate("tmpUnscrolledright");
329 void BranchObj::setVisibility(bool v, int toDepth)
331 if (depth <= toDepth)
333 frame->setVisibility(v);
334 heading->setVisibility(v);
335 systemFlags->setVisibility(v);
336 standardFlags->setVisibility(v);
337 LinkableMapObj::setVisibility (v);
339 // Only change childs, if I am not scrolled
340 if (!scrolled && (depth < toDepth))
342 // Now go recursivly through all childs
344 for (i=0; i<branch.size(); ++i)
345 branch.at(i)->setVisibility (v,toDepth);
346 for (i=0; i<floatimage.size(); ++i)
347 floatimage.at(i)->setVisibility (v);
348 for (i=0; i<xlink.size(); ++i)
349 xlink.at(i)->setVisibility ();
351 } // depth <= toDepth
355 void BranchObj::setVisibility(bool v)
357 setVisibility (v,MAX_DEPTH);
361 void BranchObj::setLinkColor ()
363 // Overloaded from LinkableMapObj
364 // BranchObj can use color of heading
367 if (mapEditor->getMapLinkColorHint()==HeadingColor)
368 LinkableMapObj::setLinkColor (heading->getColor() );
370 LinkableMapObj::setLinkColor ();
373 void BranchObj::setColorChilds (QColor col)
375 OrnamentedObj::setColor (col);
376 for (int i=0; i<branch.size(); ++i)
377 branch.at(i)->setColorChilds(col);
380 BranchObj* BranchObj::first()
387 BranchObj* BranchObj::next()
391 BranchObj *po=(BranchObj*)parObj;
393 if (branch.isEmpty())
400 // no itLast, we are just beginning
403 // we have childs, return first one
409 // No childs, so there is no next
417 { // We come from parent
420 // there are childs, go there
425 { // no childs, try to go up again
428 // go back to parent and try to find next there
437 // can't go up, I am mapCenter, no next
444 // We don't come from parent, but from brother or childs
446 // Try to find last child, where we came from, in my own childs
449 while (i<branch.size())
451 // Try to find itLast in my own childs
452 if (itLast==branch.at(i))
454 // ok, we come from my own childs
455 //xyz //FIXME need to proceed to NEXT child or up again
456 if (i<branch.size()-1)
466 { // found itLast in my childs
469 // found a brother of lastLMO
477 if (this==itFirst) return NULL; // Stop at starting point
486 // can't go up, I am mapCenter
493 // couldn't find last child, it must be a nephew of mine
496 // proceed with my first child
498 return branch.first();
502 // or go back to my parents
513 // can't go up, I am mapCenter
520 BranchObj* BranchObj::getLastIterator()
525 void BranchObj::setLastIterator(BranchObj* it)
530 void BranchObj::positionContents()
532 for (int i=0; i<floatimage.size(); ++i )
533 floatimage.at(i)->reposition();
534 OrnamentedObj::positionContents();
537 void BranchObj::move (double x, double y)
539 OrnamentedObj::move (x,y);
540 for (int i=0; i<floatimage.size(); ++i )
541 floatimage.at(i)->reposition();
545 void BranchObj::move (QPointF p)
550 void BranchObj::moveBy (double x, double y)
552 OrnamentedObj::moveBy (x,y);
553 for (int i=0; i<branch.size(); ++i)
554 branch.at(i)->moveBy (x,y);
558 void BranchObj::moveBy (QPointF p)
560 moveBy (p.x(), p.y());
564 void BranchObj::positionBBox()
566 QPointF ap=getAbsPos();
567 bbox.moveTopLeft (ap);
572 frame->setRect(QRectF(bbox.x(),bbox.y(),bbox.width(),bbox.height() ) );
574 // Update links to other branches
575 for (int i=0; i<xlink.size(); ++i)
576 xlink.at(i)->updateXLink();
579 void BranchObj::calcBBoxSize()
581 QSizeF heading_r=heading->getSize();
582 qreal heading_w=(qreal) heading_r.width() ;
583 qreal heading_h=(qreal) heading_r.height() ;
584 QSizeF sysflags_r=systemFlags->getSize();
585 qreal sysflags_h=sysflags_r.height();
586 qreal sysflags_w=sysflags_r.width();
587 QSizeF stanflags_r=standardFlags->getSize();
588 qreal stanflags_h=stanflags_r.height();
589 qreal stanflags_w=stanflags_r.width();
593 // set width to sum of all widths
594 w=heading_w + sysflags_w + stanflags_w;
595 // set height to maximum needed height
596 h=max (sysflags_h,stanflags_h);
599 // Save the dimension of flags and heading
600 ornamentsBBox.setSize ( QSizeF(w,h));
602 // clickBox includes Flags and Heading
603 clickBox.setSize (ornamentsBBox.size() );
608 topPad=botPad=leftPad=rightPad=0;
609 if (includeImagesVer || includeImagesHor)
611 if (countFloatImages()>0)
613 for (int i=0; i<floatimage.size(); ++i )
615 rp=floatimage.at(i)->getRelPos();
616 if (includeImagesVer)
619 topPad=max (topPad,-rp.y()-h);
620 if (rp.y()+floatimage.at(i)->height() > 0)
621 botPad=max (botPad,rp.y()+floatimage.at(i)->height());
623 if (includeImagesHor)
625 if (orientation==OrientRightOfCenter)
628 leftPad=max (leftPad,-rp.x()-w);
629 if (rp.x()+floatimage.at(i)->width() > 0)
630 rightPad=max (rightPad,rp.x()+floatimage.at(i)->width());
634 leftPad=max (leftPad,-rp.x());
635 if (rp.x()+floatimage.at(i)->width() > w)
636 rightPad=max (rightPad,rp.x()+floatimage.at(i)->width()-w);
646 w+=frame->getBorder();
647 h+=frame->getBorder();
650 bbox.setSize (QSizeF (w,h));
653 void BranchObj::setDockPos()
655 // Sets childpos and parpos depending on orientation
656 if (getOrientation()==OrientLeftOfCenter )
658 childPos=QPointF (ornamentsBBox.bottomLeft().x(), ornamentsBBox.bottomLeft().y() );
659 parPos=QPointF (ornamentsBBox.bottomRight().x(),ornamentsBBox.bottomRight().y() );
662 childPos=QPointF (ornamentsBBox.bottomRight().x(), ornamentsBBox.bottomRight().y() );
663 parPos=QPointF (ornamentsBBox.bottomLeft().x(),ornamentsBBox.bottomLeft().y() );
667 LinkableMapObj* BranchObj::findMapObj(QPointF p, LinkableMapObj* excludeLMO)
671 for (int i=0; i<branch.size(); ++i)
673 lmo=branch.at(i)->findMapObj(p, excludeLMO);
674 if (lmo != NULL) return lmo;
678 if (inBox (p) && (this != excludeLMO) && isVisibleObj() )
681 // Search float images
682 for (int i=0; i<floatimage.size(); ++i )
683 if (floatimage.at(i)->inBox(p) &&
684 (floatimage.at(i) != excludeLMO) &&
685 floatimage.at(i)->getParObj()!= excludeLMO &&
686 floatimage.at(i)->isVisibleObj()
687 ) return floatimage.at(i);
692 void BranchObj::setHeading(QString s)
694 heading->setText(s); // set new heading
695 calcBBoxSize(); // recalculate bbox
696 positionBBox(); // rearrange contents
700 void BranchObj::setHideTmp (HideTmpMode mode)
702 if (mode==HideExport && hasHiddenExportParent(this))
704 setVisibility (false);
708 if (hasScrolledParent(this))
709 setVisibility (false);
711 setVisibility (true);
715 for (int i=0; i<branch.size(); ++i)
716 branch.at(i)->setHideTmp (mode);
719 bool BranchObj::hasHiddenExportParent(BranchObj *start)
721 // Calls parents recursivly to
722 // find out, if we are temp. hidden
724 if (hideExport) return true;
726 BranchObj* bo=(BranchObj*)(parObj);
728 return bo->hasHiddenExportParent(start);
733 QString BranchObj::saveToDir (const QString &tmpdir,const QString &prefix, const QPointF& offset)
735 if (hidden) return "";
738 QString scrolledAttr;
740 scrolledAttr=attribut ("scrolled","yes");
745 if (frame->getFrameType()!=NoFrame)
746 frameAttr=attribut ("frameType",frame->getFrameTypeName());
750 // save area, if not scrolled
752 if (!((BranchObj*)(parObj))->isScrolled() )
755 attribut("x1",QString().setNum(absPos.x()-offset.x())) +
756 attribut("y1",QString().setNum(absPos.y()-offset.y())) +
757 attribut("x2",QString().setNum(absPos.x()+width()-offset.x())) +
758 attribut("y2",QString().setNum(absPos.y()+height()-offset.y()));
763 // Providing an ID for a branch makes export to XHTML easier
766 idAttr=attribut ("id",getSelectString());
770 s=beginElement ("branch"
776 +getIncludeImageAttr() );
780 for (int i=1; i<depth;i++) cout << " ";
781 cout <<getHeading().ascii()<<endl;
785 s+=valueElement("heading", getHeading(),
786 attribut ("textColor",QColor(heading->getColor()).name()));
788 // save names of flags set
789 s+=standardFlags->saveToDir(tmpdir,prefix,0);
792 for (int i=0; i<floatimage.size(); ++i)
793 s+=floatimage.at(i)->saveToDir (tmpdir,prefix);
796 if (!note.isEmpty() )
800 for (int i=0; i<branch.size(); ++i)
801 s+=branch.at(i)->saveToDir(tmpdir,prefix,offset);
804 QString ol; // old link
805 QString cl; // current link
806 for (int i=0; i<xlink.size(); ++i)
808 cl=xlink.at(i)->saveToDir();
815 qWarning (QString("Ignoring of duplicate xLink in %1").arg(getHeading()));
820 s+=endElement ("branch");
824 void BranchObj::addXLink (XLinkObj *xlo)
830 void BranchObj::removeXLinkRef (XLinkObj *xlo)
832 xlink.removeAt (xlink.indexOf(xlo));
835 void BranchObj::deleteXLink(XLinkObj *xlo)
838 if (!xlo->isUsed()) delete (xlo);
841 void BranchObj::deleteXLinkAt (int i)
843 XLinkObj *xlo=xlink.at(i);
845 if (!xlo->isUsed()) delete(xlo);
848 XLinkObj* BranchObj::XLinkAt (int i)
853 int BranchObj::countXLink()
855 return xlink.count();
859 BranchObj* BranchObj::XLinkTargetAt (int i)
861 if (i>=0 && i<xlink.size())
864 return xlink.at(i)->otherBranch (this);
869 void BranchObj::setIncludeImagesVer(bool b)
877 bool BranchObj::getIncludeImagesVer()
879 return includeImagesVer;
882 void BranchObj::setIncludeImagesHor(bool b)
890 bool BranchObj::getIncludeImagesHor()
892 return includeImagesHor;
895 QString BranchObj::getIncludeImageAttr()
898 if (includeImagesVer)
899 a=attribut ("incImgV","true");
901 a=attribut ("incImgV","false");
902 if (includeImagesHor)
903 a+=attribut ("incImgH","true");
905 a+=attribut ("incImgH","false");
909 FloatImageObj* BranchObj::addFloatImage ()
911 FloatImageObj *newfi=new FloatImageObj (scene,this);
912 floatimage.append (newfi);
913 if (hasScrolledParent(this) )
914 newfi->setVisibility (false);
916 newfi->setVisibility(visible);
925 FloatImageObj* BranchObj::addFloatImage (FloatImageObj *fio)
927 FloatImageObj *newfi=new FloatImageObj (scene,this);
928 floatimage.append (newfi);
930 if (hasScrolledParent(this) )
931 newfi->setVisibility (false);
933 newfi->setVisibility(visible);
942 FloatImageObj* BranchObj::getFirstFloatImage ()
944 return floatimage.first();
947 FloatImageObj* BranchObj::getLastFloatImage ()
949 return floatimage.last();
952 FloatImageObj* BranchObj::getFloatImageNum (const uint &i)
954 return floatimage.at(i);
957 void BranchObj::removeFloatImage (FloatImageObj *fio)
959 int i=floatimage.indexOf (fio);
960 if (i>-1) delete (floatimage.takeAt (i));
966 void BranchObj::savePosInAngle ()
968 // Save position in angle
969 for (int i=0; i<branch.size(); ++i)
970 branch.at(i)->angle=i;
973 void BranchObj::setDefAttr (BranchModification mod)
978 case 0: fontsize=16; break;
979 case 1: fontsize=12; break;
980 default: fontsize=10; break;
984 setLinkStyle(getDefLinkStyle());
985 QFont font("Sans Serif,8,-1,5,50,0,0,0,0,0");
986 font.setPointSize(fontsize);
987 heading->setFont(font );
990 setColor (((BranchObj*)(parObj))->getColor());
995 BranchObj* BranchObj::addBranch()
997 BranchObj* newbo=new BranchObj(scene,this);
998 branch.append (newbo);
999 newbo->setParObj(this);
1000 newbo->setDefAttr(NewBranch);
1001 newbo->setHeading ("new");
1003 newbo->setVisibility (false);
1005 newbo->setVisibility(visible);
1006 newbo->updateLink();
1007 requestReposition();
1011 BranchObj* BranchObj::addBranch(BranchObj* bo)
1013 BranchObj* newbo=new BranchObj(scene,this);
1014 branch.append (newbo);
1016 newbo->setParObj(this);
1017 newbo->setDefAttr(MovedBranch);
1019 newbo->setVisibility (false);
1021 newbo->setVisibility(bo->visible);
1022 newbo->updateLink();
1023 requestReposition();
1027 BranchObj* BranchObj::addBranchPtr(BranchObj* bo)
1030 bo->setParObj (this);
1032 bo->setDefAttr(MovedBranch);
1033 if (scrolled) tmpUnscroll();
1034 setLastSelectedBranch (bo);
1038 BranchObj* BranchObj::insertBranch(int pos)
1041 // Add new bo and resort branches
1042 BranchObj *newbo=addBranch ();
1043 newbo->angle=pos-0.5;
1044 qSort (branch.begin(),branch.end(), isAbove);
1048 BranchObj* BranchObj::insertBranch(BranchObj* bo, int pos)
1051 // Add new bo and resort branches
1053 BranchObj *newbo=addBranch (bo);
1054 qSort (branch.begin(),branch.end(), isAbove);
1058 BranchObj* BranchObj::insertBranchPtr (BranchObj* bo, int pos)
1061 // Add new bo and resort branches
1064 bo->setParObj (this);
1066 bo->setDefAttr (MovedBranch);
1067 if (scrolled) tmpUnscroll();
1068 setLastSelectedBranch (bo);
1069 qSort (branch.begin(),branch.end(), isAbove);
1073 void BranchObj::removeBranchHere(BranchObj* borem)
1075 // This removes the branch bo from list, but
1076 // inserts its childs at the place of bo
1078 bo=borem->getLastBranch();
1079 int pos=borem->getNum();
1082 bo->moveBranchTo (this,pos+1);
1083 bo=borem->getLastBranch();
1085 removeBranch (borem);
1088 void BranchObj::removeChilds()
1093 void BranchObj::removeBranch(BranchObj* bo)
1095 // if bo is not in branch remove returns false, we
1098 int i=branch.indexOf(bo);
1102 branch.removeAt (i);
1104 qWarning ("BranchObj::removeBranch tried to remove non existing branch?!\n");
1105 requestReposition();
1108 void BranchObj::removeBranchPtr(BranchObj* bo)
1110 int i=branch.indexOf(bo);
1113 branch.removeAt (i);
1115 qWarning ("BranchObj::removeBranchPtr tried to remove non existing branch?!\n");
1116 requestReposition();
1119 void BranchObj::setLastSelectedBranch (BranchObj* bo)
1121 lastSelectedBranch=branch.indexOf(bo);
1124 BranchObj* BranchObj::getLastSelectedBranch ()
1126 if (lastSelectedBranch>=0 && branch.size()>0)
1127 return branch.at(lastSelectedBranch);
1131 BranchObj* BranchObj::getFirstBranch ()
1133 if (branch.size()>0)
1134 return branch.first();
1139 BranchObj* BranchObj::getLastBranch ()
1141 if (branch.size()>0)
1142 return branch.last();
1147 BranchObj* BranchObj::getBranchNum (int i)
1149 if (i>=0 && i<branch.size())
1150 return branch.at(i);
1155 bool BranchObj::canMoveBranchUp()
1157 if (!parObj || depth==1) return false;
1158 BranchObj* par=(BranchObj*)parObj;
1159 if (this==par->getFirstBranch())
1165 BranchObj* BranchObj::moveBranchUp(BranchObj* bo1) // modify my childlist
1168 int i=branch.indexOf(bo1);
1170 { // -1 if bo1 not found
1171 branch.at(i)->angle--;
1172 branch.at(i-1)->angle++;
1173 qSort (branch.begin(),branch.end(), isAbove);
1174 return branch.at(i);
1179 bool BranchObj::canMoveBranchDown()
1181 if (!parObj|| depth==1) return false;
1182 BranchObj* par=(BranchObj*)parObj;
1183 if (this==par->getLastBranch())
1189 BranchObj* BranchObj::moveBranchDown(BranchObj* bo1)// modify my childlist
1192 int i=branch.indexOf(bo1);
1194 if (i <branch.size())
1197 branch.at(i)->angle++;
1198 branch.at(j)->angle--;
1199 qSort (branch.begin(),branch.end(), isAbove);
1200 return branch.at(i);
1205 BranchObj* BranchObj::moveBranchTo (BranchObj* dst, int pos)
1207 // Find current parent and
1208 // remove pointer to myself there
1209 if (!dst) return NULL;
1210 BranchObj *par=(BranchObj*)parObj;
1212 par->removeBranchPtr (this);
1216 // Create new pointer to myself at dst
1217 if (pos<0||dst->getDepth()==0)
1219 // links myself as last branch at dst
1220 dst->addBranchPtr (this);
1225 // inserts me at pos in parent of dst
1228 BranchObj *bo=dst->insertBranchPtr (this,pos);
1229 bo->setDefAttr(MovedBranch);
1238 void BranchObj::alignRelativeTo (QPointF ref)
1240 qreal th = bboxTotal.height();
1243 cout << "BO::alignRelTo "<<getHeading().ascii()<<endl;
1244 cout << " d="<<depth<<
1246 // " bbox.topLeft="<<bboxTotal.topLeft()<<
1247 " absPos="<<absPos<<
1248 " relPos="<<relPos<<
1249 " orient="<<orientation<<
1250 // " pad="<<topPad<<","<<botPad<<","<<leftPad<<","<<rightPad<<
1251 // " hidden="<<hidden<<
1263 // Position relatively, if needed
1264 //if (useRelPos) move2RelPos (relPos.x(), relPos.y());
1266 // Calc angle to mapCenter if I am a mainbranch
1267 // needed for reordering the mainbranches clockwise
1269 angle=getAngle (QPointF ((int)(x() - parObj->getChildPos().x() ),
1270 (int)(y() - parObj->getChildPos().y() ) ) );
1275 // Align myself depending on orientation and parent, but
1276 // only if I am not a mainbranch or mapcenter itself
1278 o=parObj->getOrientation();
1279 switch (orientation)
1281 case OrientLeftOfCenter:
1282 move (ref.x() - bbox.width(), ref.y() + (th-bbox.height())/2 );
1284 case OrientRightOfCenter:
1285 move (ref.x() , ref.y() + (th-bbox.height())/2 );
1288 qWarning ("LMO::alignRelativeTo: oops, no orientation given...");
1293 if (scrolled) return;
1295 // Set reference point for alignment of childs
1297 if (orientation==OrientLeftOfCenter)
1298 ref2.setX(bbox.topLeft().x() - linkwidth);
1300 ref2.setX(bbox.topRight().x() + linkwidth);
1303 ref2.setY(absPos.y()-(bboxTotal.height()-bbox.height())/2);
1305 ref2.setY(ref.y() );
1307 // Align the childs depending on reference point
1308 for (int i=0; i<branch.size(); ++i)
1310 if (!branch.at(i)->isHidden())
1312 branch.at(i)->alignRelativeTo (ref2);
1313 ref2.setY(ref2.y() + branch.at(i)->getBBoxSizeWithChilds().height() );
1319 void BranchObj::reposition()
1321 /* TODO testing only
1322 if (!getHeading().isEmpty())
1323 cout << "BO::reposition "<<getHeading().ascii()<<endl;
1325 cout << "BO::reposition ???"<<endl;
1327 cout << " orient="<<orientation<<endl;
1332 // only calculate the sizes once. If the deepest LMO
1333 // changes its height,
1334 // all upper LMOs have to change, too.
1335 calcBBoxSizeWithChilds();
1336 updateLink(); // This update is needed if the scene is resized
1337 // due to excessive moving of a FIO
1338 // FIXME really needed? reposition is also called from updateLink...
1340 alignRelativeTo ( QPointF (absPos.x(),
1341 absPos.y()-(bboxTotal.height()-bbox.height())/2) );
1342 qSort (branch.begin(),branch.end(), isAbove);
1343 positionBBox(); // Reposition bbox and contents
1346 // This is only important for moving branches:
1347 // For editing a branch it isn't called...
1348 alignRelativeTo ( QPointF (absPos.x(),
1349 absPos.y()-(bboxTotal.height()-bbox.height())/2) );
1353 void BranchObj::unsetAllRepositionRequests()
1355 repositionRequest=false;
1356 for (int i=0; i<branch.size(); ++i)
1357 branch.at(i)->unsetAllRepositionRequests();
1361 QRectF BranchObj::getTotalBBox()
1365 if (scrolled) return r;
1367 for (int i=0; i<branch.size(); ++i)
1368 if (!branch.at(i)->isHidden())
1369 r=addBBox(branch.at(i)->getTotalBBox(),r);
1371 for (int i=0; i<floatimage.size(); ++i)
1372 if (!floatimage.at(i)->isHidden())
1373 r=addBBox(floatimage.at(i)->getTotalBBox(),r);
1378 QRectF BranchObj::getBBoxSizeWithChilds()
1383 void BranchObj::calcBBoxSizeWithChilds()
1385 // This is initially called only from reposition and
1386 // and only for mapcenter. So it won't be
1387 // called more than once for a single user
1391 // Calculate size of LMO including all childs (to align them later)
1392 bboxTotal.setX(bbox.x() );
1393 bboxTotal.setY(bbox.y() );
1395 // if branch is scrolled, ignore childs, but still consider floatimages
1398 bboxTotal.setWidth (bbox.width());
1399 bboxTotal.setHeight(bbox.height());
1405 bboxTotal.setWidth (0);
1406 bboxTotal.setHeight(0);
1409 bboxTotal.setX (parObj->x());
1410 bboxTotal.setY (parObj->y());
1413 bboxTotal.setX (bbox.x());
1414 bboxTotal.setY (bbox.y());
1421 // Now calculate recursivly
1423 // maximum of widths
1425 for (int i=0; i<branch.size(); ++i)
1427 if (!branch.at(i)->isHidden())
1429 branch.at(i)->calcBBoxSizeWithChilds();
1430 br=branch.at(i)->getBBoxSizeWithChilds();
1431 r.setWidth( max (br.width(), r.width() ));
1432 r.setHeight(br.height() + r.height() );
1433 if (br.y()<bboxTotal.y()) bboxTotal.setY(br.y());
1436 // Add myself and also
1437 // add width of link to sum if necessary
1438 if (branch.isEmpty())
1439 bboxTotal.setWidth (bbox.width() + r.width() );
1441 bboxTotal.setWidth (bbox.width() + r.width() + linkwidth);
1443 bboxTotal.setHeight(max (r.height(), bbox.height()));
1446 void BranchObj::select()
1448 // set Text in Editor
1449 textEditor->setText(note.getNote() );
1450 QString fnh=note.getFilenameHint();
1452 textEditor->setFilenameHint(note.getFilenameHint() );
1454 textEditor->setFilenameHint(getHeading() );
1455 textEditor->setFontHint (note.getFontHint() );
1457 LinkableMapObj::select();
1458 // Tell parent that I am selected now:
1459 BranchObj* po=(BranchObj*)(parObj);
1460 if (po) // TODO Try to get rid of this cast...
1461 po->setLastSelectedBranch(this);
1463 // temporary unscroll, if we have scrolled parents somewhere
1464 if (parObj) ((BranchObj*)(parObj))->tmpUnscroll();
1466 // Show URL and link in statusbar
1468 if (!url.isEmpty()) status+="URL: "+url+" ";
1469 if (!vymLink.isEmpty()) status+="Link: "+vymLink;
1470 if (!status.isEmpty()) mainWindow->statusMessage (status);
1473 updateFlagsToolbar();
1476 mapEditor->updateActions();
1479 void BranchObj::unselect()
1481 LinkableMapObj::unselect();
1482 // Delete any messages like vymLink in StatusBar
1483 mainWindow->statusMessage ("");
1485 // save note from editor and set flag
1486 // text is done by updateNoteFlag(), just save
1488 note.setFilenameHint (textEditor->getFilename());
1490 // reset temporary unscroll, if we have scrolled parents somewhere
1491 if (parObj) ((BranchObj*)(parObj))->resetTmpUnscroll();
1493 // Erase content of editor
1494 textEditor->setInactive();
1496 // unselect all buttons in toolbar
1497 standardFlagsDefault->updateToolbar();
1500 QString BranchObj::getSelectString()
1506 s= "bo:" + QString("%1").arg(getNum());
1508 s= ((BranchObj*)(parObj))->getSelectString() + ",bo:" + QString("%1").arg(getNum());