historywindow moved to mainwindow. Started to get rid of Q3PtrList finally
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 xlink.setAutoDelete (false);
94 absPos+=parObj->getChildPos();
97 lastSelectedBranch=-1;
104 includeImagesVer=false;
105 includeImagesHor=false;
108 void BranchObj::copy (BranchObj* other)
110 OrnamentedObj::copy(other);
114 for (b=other->branch.first(); b;b=other->branch.next() )
115 // Make deep copy of b
116 // Because addBranch again calls copy for the childs,
117 // Those will get a deep copy, too
120 for (int i=0; i<other->floatimage.size(); ++i)
121 addFloatImage (other->floatimage.at(i));
122 scrolled=other->scrolled;
123 tmpUnscrolled=other->tmpUnscrolled;
124 setVisibility (other->visible);
131 void BranchObj::clear()
133 while (!floatimage.isEmpty())
134 delete floatimage.takeFirst();
136 while (!xlink.isEmpty())
137 deleteXLink (xlink.first() );
140 while (!branch.isEmpty())
143 branch.removeFirst();
148 int BranchObj::getNum()
151 return ((BranchObj*)parObj)->getNum (this);
156 int BranchObj::getNum(BranchObj *bo)
158 // keep current pointer in branch,
159 // otherwise saveToDir will fail
161 int ind=branch.findRef (bo);
166 int BranchObj::getFloatImageNum(FloatImageObj *fio)
168 return floatimage.indexOf(fio);
171 int BranchObj::countBranches()
173 return branch.count();
176 int BranchObj::countFloatImages()
178 return floatimage.count();
181 int BranchObj::countXLinks()
183 return xlink.count();
186 void BranchObj::setParObjTmp(LinkableMapObj* lmo, QPoint m, int off)
188 // Temporary link to lmo
189 // m is position of mouse pointer
190 // offset 0: default 1: below lmo -1 above lmo (if possible)
193 BranchObj* o=(BranchObj*)(lmo);
197 // ignore mapcenter and mainbranch
198 if (lmo->getDepth()<2) off=0;
205 depth=parObj->getDepth()+1;
207 // setLinkStyle calls updateLink, only set it once
208 if (style!=getDefLinkStyle() ) setLinkStyle (getDefLinkStyle());
210 // Move temporary to new position at destination
211 // Usually the positioning would be done by reposition(),
212 // but then also the destination branch would "Jump" around...
213 // Better just do it approximately
215 { // new parent is the mapcenter itself
217 QPoint p= normalise ( QPoint (m.x() - o->getChildPos().x(),
218 m.y() - o->getChildPos().y() ));
219 if (p.x()<0) p.setX( p.x()-bbox.width() );
226 // new parent is just a branch, link to it
227 QRect t=o->getBBoxSizeWithChilds();
228 if (o->getLastBranch())
229 y=t.y() + t.height() ;
236 // we want to link above lmo
237 y=o->y() - height() + 5;
239 // we want to link below lmo
240 // Bottom of sel should be 5 pixels above
241 // the bottom of the branch _below_ the target:
242 // Don't try to find that branch, guess 12 pixels
243 y=o->getChildPos().y() -height() + 12;
245 if (o->getOrientation()==OrientLeftOfCenter)
246 move ( o->getChildPos().x() - linkwidth, y );
248 move (o->getChildPos().x() + linkwidth, y );
251 // updateLink is called implicitly in move
252 reposition(); // FIXME shouldn't be this a request?
255 void BranchObj::unsetParObjTmp()
262 depth=parObj->getDepth()+1;
263 setLinkStyle (getDefLinkStyle() );
268 void BranchObj::unScroll()
270 if (tmpUnscrolled) resetTmpUnscroll();
271 if (scrolled) toggleScroll();
274 void BranchObj::toggleScroll()
280 systemFlags->deactivate("scrolledright");
281 for (bo=branch.first(); bo; bo=branch.next() )
283 bo->setVisibility(true);
288 systemFlags->activate("scrolledright");
289 for (bo=branch.first(); bo; bo=branch.next() )
291 bo->setVisibility(false);
296 move (absPos.x(), absPos.y() );
300 bool BranchObj::isScrolled()
305 bool BranchObj::hasScrolledParent(BranchObj *start)
307 // Calls parents recursivly to
308 // find out, if we are scrolled at all.
309 // But ignore myself, just look at parents.
311 if (this !=start && scrolled) return true;
313 BranchObj* bo=(BranchObj*)(parObj);
315 return bo->hasScrolledParent(start);
320 void BranchObj::tmpUnscroll()
322 // Unscroll parent (recursivly)
323 BranchObj* bo=(BranchObj*)(parObj);
324 if (bo) bo->tmpUnscroll();
330 systemFlags->activate("tmpUnscrolledright");
335 void BranchObj::resetTmpUnscroll()
337 // Unscroll parent (recursivly)
338 BranchObj* bo=(BranchObj*)(parObj);
340 bo->resetTmpUnscroll();
346 systemFlags->deactivate("tmpUnscrolledright");
351 void BranchObj::setVisibility(bool v, int toDepth)
353 if (depth <= toDepth)
355 frame->setVisibility(v);
356 heading->setVisibility(v);
357 systemFlags->setVisibility(v);
358 standardFlags->setVisibility(v);
359 LinkableMapObj::setVisibility (v);
361 // Only change childs, if I am not scrolled
362 if (!scrolled && (depth < toDepth))
364 // Now go recursivly through all childs
366 for (b=branch.first(); b;b=branch.next() )
367 b->setVisibility (v,toDepth);
368 for (int i=0; i<floatimage.size(); ++i)
369 floatimage.at(i)->setVisibility (v);
371 for (xlo=xlink.first(); xlo;xlo=xlink.next() )
372 xlo->setVisibility ();
374 } // depth <= toDepth
378 void BranchObj::setVisibility(bool v)
380 setVisibility (v,MAX_DEPTH);
384 void BranchObj::setLinkColor ()
386 // Overloaded from LinkableMapObj
387 // BranchObj can use color of heading
390 if (mapEditor->getMapLinkColorHint()==HeadingColor)
391 LinkableMapObj::setLinkColor (heading->getColor() );
393 LinkableMapObj::setLinkColor ();
396 void BranchObj::setColorChilds (QColor col)
398 OrnamentedObj::setColor (col);
400 for (bo=branch.first(); bo; bo=branch.next() )
401 bo->setColorChilds(col);
404 BranchObj* BranchObj::first()
411 BranchObj* BranchObj::next()
414 BranchObj *bo=branch.first();
415 BranchObj *po=(BranchObj*)(parObj);
420 { // We are just beginning,
421 // return first child
434 { // We come from above
437 // there are childs, go there
442 { // no childs, try to go up again
454 // can't go up, I am mapCenter
461 // Try to find last child, where we came from, in my own childs
463 while (bo && searching)
465 if (itLast==bo) searching=false;
469 { // found lastLMO in my childs
472 // found a brother of lastLMO
480 if (this==itFirst) return NULL; // Stop at starting point
489 // can't go up, I am mapCenter
496 // couldn't find last child, it must be a nephew of mine
500 // proceed with my first child
506 // or go back to my parents
517 // can't go up, I am mapCenter
524 BranchObj* BranchObj::getLastIterator()
529 void BranchObj::setLastIterator(BranchObj* it)
534 void BranchObj::positionContents()
536 for (int i=0; i<floatimage.size(); ++i )
537 floatimage.at(i)->reposition();
538 OrnamentedObj::positionContents();
541 void BranchObj::move (double x, double y)
543 OrnamentedObj::move (x,y);
544 for (int i=0; i<floatimage.size(); ++i )
545 floatimage.at(i)->reposition();
549 void BranchObj::move (QPoint p)
554 void BranchObj::moveBy (double x, double y)
556 OrnamentedObj::moveBy (x,y);
558 for (b=branch.first(); b;b=branch.next() )
563 void BranchObj::moveBy (QPoint p)
565 moveBy (p.x(), p.y());
569 void BranchObj::positionBBox()
571 QPoint ap=getAbsPos();
572 bbox.moveTopLeft (ap);
577 frame->setRect(QRect(bbox.x(),bbox.y(),bbox.width(),bbox.height() ) );
579 // Update links to other branches
581 for (xlo=xlink.first(); xlo; xlo=xlink.next() )
585 void BranchObj::calcBBoxSize()
587 QSize heading_r=heading->getSize();
588 int heading_w=(int) heading_r.width() ;
589 int heading_h=(int) heading_r.height() ;
590 QSize sysflags_r=systemFlags->getSize();
591 int sysflags_h=sysflags_r.height();
592 int sysflags_w=sysflags_r.width();
593 QSize stanflags_r=standardFlags->getSize();
594 int stanflags_h=stanflags_r.height();
595 int stanflags_w=stanflags_r.width();
599 // set width to sum of all widths
600 w=heading_w + sysflags_w + stanflags_w;
601 // set height to maximum needed height
602 h=max (sysflags_h,stanflags_h);
605 // Save the dimension of flags and heading
606 ornamentsBBox.setSize ( QSize(w,h));
608 // clickBox includes Flags and Heading
609 clickBox.setSize (ornamentsBBox.size() );
614 topPad=botPad=leftPad=rightPad=0;
615 if (includeImagesVer || includeImagesHor)
617 if (countFloatImages()>0)
619 for (int i=0; i<floatimage.size(); ++i )
621 rp=floatimage.at(i)->getRelPos();
622 if (includeImagesVer)
625 topPad=max (topPad,-rp.y()-h);
626 if (rp.y()+floatimage.at(i)->height() > 0)
627 botPad=max (botPad,rp.y()+floatimage.at(i)->height());
629 if (includeImagesHor)
631 if (orientation==OrientRightOfCenter)
634 leftPad=max (leftPad,-rp.x()-w);
635 if (rp.x()+floatimage.at(i)->width() > 0)
636 rightPad=max (rightPad,rp.x()+floatimage.at(i)->width());
640 leftPad=max (leftPad,-rp.x());
641 if (rp.x()+floatimage.at(i)->width() > w)
642 rightPad=max (rightPad,rp.x()+floatimage.at(i)->width()-w);
652 w+=frame->getBorder();
653 h+=frame->getBorder();
656 bbox.setSize (QSize (w,h));
659 void BranchObj::setDockPos()
661 // Sets childpos and parpos depending on orientation
662 if (getOrientation()==OrientLeftOfCenter )
664 childPos=QPoint (ornamentsBBox.bottomLeft().x(), ornamentsBBox.bottomLeft().y() );
665 parPos=QPoint (ornamentsBBox.bottomRight().x(),ornamentsBBox.bottomRight().y() );
668 childPos=QPoint (ornamentsBBox.bottomRight().x(), ornamentsBBox.bottomRight().y() );
669 parPos=QPoint (ornamentsBBox.bottomLeft().x(),ornamentsBBox.bottomLeft().y() );
673 LinkableMapObj* BranchObj::findMapObj(QPoint p, LinkableMapObj* excludeLMO)
678 for (b=branch.first(); b; b=branch.next() )
680 lmo=b->findMapObj(p, excludeLMO);
681 if (lmo != NULL) return lmo;
685 if (inBox (p) && (this != excludeLMO) && isVisibleObj() )
688 // Search float images
689 for (int i=0; i<floatimage.size(); ++i )
690 if (floatimage.at(i)->inBox(p) &&
691 (floatimage.at(i) != excludeLMO) &&
692 floatimage.at(i)->getParObj()!= excludeLMO &&
693 floatimage.at(i)->isVisibleObj()
694 ) return floatimage.at(i);
699 void BranchObj::setHeading(QString s)
701 heading->setText(s); // set new heading
702 calcBBoxSize(); // recalculate bbox
703 positionBBox(); // rearrange contents
707 void BranchObj::setHideTmp (HideTmpMode mode)
709 if (mode==HideExport && hasHiddenExportParent(this))
711 setVisibility (false);
715 if (hasScrolledParent(this))
716 setVisibility (false);
718 setVisibility (true);
723 for (bo=branch.first(); bo; bo=branch.next() )
724 bo->setHideTmp (mode);
727 bool BranchObj::hasHiddenExportParent(BranchObj *start)
729 // Calls parents recursivly to
730 // find out, if we are temp. hidden
732 if (hideExport) return true;
734 BranchObj* bo=(BranchObj*)(parObj);
736 return bo->hasHiddenExportParent(start);
741 QString BranchObj::saveToDir (const QString &tmpdir,const QString &prefix, const QPoint& offset)
743 if (hidden) return "";
746 QString scrolledAttr;
748 scrolledAttr=attribut ("scrolled","yes");
753 if (frame->getFrameType()!=NoFrame)
754 frameAttr=attribut ("frameType",frame->getFrameTypeName());
758 // save area, if not scrolled
760 if (!((BranchObj*)(parObj))->isScrolled() )
763 attribut("x1",QString().setNum(absPos.x()-offset.x(),10)) +
764 attribut("y1",QString().setNum(absPos.y()-offset.y(),10)) +
765 attribut("x2",QString().setNum(absPos.x()+width()-offset.x(),10)) +
766 attribut("y2",QString().setNum(absPos.y()+height()-offset.y(),10));
771 // Providing an ID for a branch makes export to XHTML easier
774 idAttr=attribut ("id",getSelectString());
778 s=beginElement ("branch"
784 +getIncludeImageAttr() );
788 for (int i=1; i<depth;i++) cout << " ";
789 cout <<getHeading().ascii()<<endl;
793 s+=valueElement("heading", getHeading(),
794 attribut ("textColor",QColor(heading->getColor()).name()));
796 // save names of flags set
797 s+=standardFlags->saveToDir(tmpdir,prefix,0);
800 for (int i=0; i<floatimage.size(); ++i)
801 s+=floatimage.at(i)->saveToDir (tmpdir,prefix);
804 if (!note.isEmpty() )
809 for (bo=branch.first(); bo; bo=branch.next() )
810 s+=bo->saveToDir(tmpdir,prefix,offset);
814 QString ol; // old link
815 QString cl; // current link
816 for (xlo=xlink.first(); xlo; xlo=xlink.next() )
825 qWarning (QString("Ignoring of duplicate xLink in %1").arg(getHeading()));
830 s+=endElement ("branch");
834 void BranchObj::addXLink (XLinkObj *xlo)
840 void BranchObj::removeXLinkRef (XLinkObj *xlo)
845 void BranchObj::deleteXLink(XLinkObj *xlo)
848 if (!xlo->isUsed()) delete (xlo);
851 void BranchObj::deleteXLinkAt (int i)
853 XLinkObj *xlo=xlink.at(i);
855 if (!xlo->isUsed()) delete(xlo);
858 XLinkObj* BranchObj::XLinkAt (int i)
863 int BranchObj::countXLink()
865 return xlink.count();
869 BranchObj* BranchObj::XLinkTargetAt (int i)
872 return xlink.at(i)->otherBranch (this);
877 void BranchObj::setIncludeImagesVer(bool b)
885 bool BranchObj::getIncludeImagesVer()
887 return includeImagesVer;
890 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 FloatImageObj* 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);
933 FloatImageObj* 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);
950 FloatImageObj* BranchObj::getFirstFloatImage ()
952 return floatimage.first();
955 FloatImageObj* BranchObj::getLastFloatImage ()
957 return floatimage.last();
960 FloatImageObj* BranchObj::getFloatImageNum (const uint &i)
962 return floatimage.at(i);
965 void BranchObj::removeFloatImage (FloatImageObj *fio)
967 int i=floatimage.indexOf (fio);
968 if (i!=-1) floatimage.takeAt (i);
975 void BranchObj::savePosInAngle ()
977 // Save position in angle
980 for (b=branch.first(); b; b=branch.next() )
987 void BranchObj::setDefAttr (BranchModification mod)
992 case 0: fontsize=16; break;
993 case 1: fontsize=12; break;
994 default: fontsize=10; break;
998 setLinkStyle(getDefLinkStyle());
999 QFont font("Sans Serif,8,-1,5,50,0,0,0,0,0");
1000 font.setPointSize(fontsize);
1001 heading->setFont(font );
1004 setColor (((BranchObj*)(parObj))->getColor());
1009 BranchObj* BranchObj::addBranch()
1011 BranchObj* newbo=new BranchObj(canvas,this);
1012 branch.append (newbo);
1013 newbo->setParObj(this);
1014 newbo->setDefAttr(NewBranch);
1015 newbo->setHeading ("new");
1017 newbo->setVisibility (false);
1019 newbo->setVisibility(visible);
1020 newbo->updateLink();
1021 requestReposition();
1025 BranchObj* BranchObj::addBranch(BranchObj* bo)
1027 BranchObj* newbo=new BranchObj(canvas,this);
1028 branch.append (newbo);
1030 newbo->setParObj(this);
1031 newbo->setDefAttr(MovedBranch);
1033 newbo->setVisibility (false);
1035 newbo->setVisibility(bo->visible);
1036 newbo->updateLink();
1037 requestReposition();
1041 BranchObj* BranchObj::addBranchPtr(BranchObj* bo)
1044 bo->setParObj (this);
1046 bo->setDefAttr(MovedBranch);
1047 if (scrolled) tmpUnscroll();
1048 setLastSelectedBranch (bo);
1052 BranchObj* BranchObj::insertBranch(int pos)
1055 // Add new bo and resort branches
1056 BranchObj *newbo=addBranch ();
1057 newbo->angle=pos-0.5;
1062 BranchObj* BranchObj::insertBranch(BranchObj* bo, int pos)
1065 // Add new bo and resort branches
1067 BranchObj *newbo=addBranch (bo);
1072 BranchObj* BranchObj::insertBranchPtr (BranchObj* bo, int pos)
1075 // Add new bo and resort branches
1078 bo->setParObj (this);
1080 bo->setDefAttr (MovedBranch);
1081 if (scrolled) tmpUnscroll();
1082 setLastSelectedBranch (bo);
1087 void BranchObj::removeBranchHere(BranchObj* borem)
1089 // This removes the branch bo from list, but
1090 // inserts its childs at the place of bo
1092 bo=borem->getLastBranch();
1093 int pos=borem->getNum();
1096 bo->moveBranchTo (this,pos+1);
1097 bo=borem->getLastBranch();
1099 removeBranch (borem);
1102 void BranchObj::removeChilds()
1107 void BranchObj::removeBranch(BranchObj* bo)
1109 // if bo is not in branch remove returns false, we
1112 if (branch.remove (bo))
1115 qWarning ("BranchObj::removeBranch tried to remove non existing branch?!\n");
1116 requestReposition();
1119 void BranchObj::removeBranchPtr(BranchObj* bo)
1122 requestReposition();
1125 void BranchObj::setLastSelectedBranch (BranchObj* bo)
1127 lastSelectedBranch=branch.find(bo);
1130 BranchObj* BranchObj::getLastSelectedBranch ()
1132 if (lastSelectedBranch>=0)
1134 BranchObj* bo=branch.at(lastSelectedBranch);
1137 return branch.first();
1140 BranchObj* BranchObj::getFirstBranch ()
1142 return branch.first();
1145 BranchObj* BranchObj::getLastBranch ()
1147 return branch.last();
1150 BranchObj* BranchObj::getBranchNum (const uint &i)
1152 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.find(bo1);
1170 { // -1 if bo1 not found
1171 branch.at(i)->angle--;
1172 branch.at(i-1)->angle++;
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.find(bo1);
1197 branch.at(i)->angle++;
1198 branch.at(j)->angle--;
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 (QPoint ref)
1240 int 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 (QPoint ((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
1309 for (b=branch.first(); b; b=branch.next() )
1313 b->alignRelativeTo (ref2);
1314 ref2.setY(ref2.y() + b->getBBoxSizeWithChilds().height() );
1320 void BranchObj::reposition()
1322 /* TODO testing only
1323 if (!getHeading().isEmpty())
1324 cout << "BO::reposition "<<getHeading().ascii()<<endl;
1326 cout << "BO::reposition ???"<<endl;
1328 cout << " orient="<<orientation<<endl;
1333 // only calculate the sizes once. If the deepest LMO
1334 // changes its height,
1335 // all upper LMOs have to change, too.
1336 calcBBoxSizeWithChilds();
1337 updateLink(); // This update is needed if the canvas is resized
1338 // due to excessive moving of a FIO
1339 // FIXME really needed? reposition is also called from updateLink...
1341 alignRelativeTo ( QPoint (absPos.x(),
1342 absPos.y()-(bboxTotal.height()-bbox.height())/2) );
1344 positionBBox(); // Reposition bbox and contents
1347 // This is only important for moving branches:
1348 // For editing a branch it isn't called...
1349 alignRelativeTo ( QPoint (absPos.x(),
1350 absPos.y()-(bboxTotal.height()-bbox.height())/2) );
1354 void BranchObj::unsetAllRepositionRequests()
1356 repositionRequest=false;
1358 for (b=branch.first(); b; b=branch.next() )
1360 b->unsetAllRepositionRequests();
1365 QRect BranchObj::getTotalBBox()
1369 if (scrolled) return r;
1372 for (b=branch.first();b ;b=branch.next() )
1374 r=addBBox(b->getTotalBBox(),r);
1376 for (int i=0; i<floatimage.size(); ++i)
1377 if (!floatimage.at(i)->isHidden())
1378 r=addBBox(floatimage.at(i)->getTotalBBox(),r);
1383 QRect BranchObj::getBBoxSizeWithChilds()
1388 void BranchObj::calcBBoxSizeWithChilds()
1390 // This is initially called only from reposition and
1391 // and only for mapcenter. So it won't be
1392 // called more than once for a single user
1396 // Calculate size of LMO including all childs (to align them later)
1397 bboxTotal.setX(bbox.x() );
1398 bboxTotal.setY(bbox.y() );
1400 // if branch is scrolled, ignore childs, but still consider floatimages
1403 bboxTotal.setWidth (bbox.width());
1404 bboxTotal.setHeight(bbox.height());
1410 bboxTotal.setWidth (0);
1411 bboxTotal.setHeight(0);
1414 bboxTotal.setX (parObj->x());
1415 bboxTotal.setY (parObj->y());
1418 bboxTotal.setX (bbox.x());
1419 bboxTotal.setY (bbox.y());
1426 // Now calculate recursivly
1428 // maximum of widths
1431 for (b=branch.first();b ;b=branch.next() )
1435 b->calcBBoxSizeWithChilds();
1436 br=b->getBBoxSizeWithChilds();
1437 r.setWidth( max (br.width(), r.width() ));
1438 r.setHeight(br.height() + r.height() );
1439 if (br.y()<bboxTotal.y()) bboxTotal.setY(br.y());
1442 // Add myself and also
1443 // add width of link to sum if necessary
1444 if (branch.isEmpty())
1445 bboxTotal.setWidth (bbox.width() + r.width() );
1447 bboxTotal.setWidth (bbox.width() + r.width() + linkwidth);
1449 bboxTotal.setHeight(max (r.height(), bbox.height()));
1452 void BranchObj::select()
1454 // set Text in Editor
1455 textEditor->setText(note.getNote() );
1456 QString fnh=note.getFilenameHint();
1458 textEditor->setFilenameHint(note.getFilenameHint() );
1460 textEditor->setFilenameHint(getHeading() );
1461 textEditor->setFontHint (note.getFontHint() );
1463 LinkableMapObj::select();
1464 // Tell parent that I am selected now:
1465 BranchObj* po=(BranchObj*)(parObj);
1466 if (po) // TODO Try to get rid of this cast...
1467 po->setLastSelectedBranch(this);
1469 // temporary unscroll, if we have scrolled parents somewhere
1470 if (parObj) ((BranchObj*)(parObj))->tmpUnscroll();
1472 // Show URL and link in statusbar
1474 if (!url.isEmpty()) status+="URL: "+url+" ";
1475 if (!vymLink.isEmpty()) status+="Link: "+vymLink;
1476 if (!status.isEmpty()) mainWindow->statusMessage (status);
1479 updateFlagsToolbar();
1481 // Update actions in mapeditor
1482 mapEditor->updateActions();
1485 void BranchObj::unselect()
1487 LinkableMapObj::unselect();
1488 // Delete any messages like vymLink in StatusBar
1489 mainWindow->statusMessage ("");
1491 // save note from editor and set flag
1492 // text is done by updateNoteFlag(), just save
1494 note.setFilenameHint (textEditor->getFilename());
1496 // reset temporary unscroll, if we have scrolled parents somewhere
1497 if (parObj) ((BranchObj*)(parObj))->resetTmpUnscroll();
1499 // Erase content of editor
1500 textEditor->setInactive();
1502 // unselect all buttons in toolbar
1503 standardFlagsDefault->updateToolbar();
1506 QString BranchObj::getSelectString()
1512 s= "bo:" + QString("%1").arg(getNum());
1514 s= ((BranchObj*)(parObj))->getSelectString() + ",bo:" + QString("%1").arg(getNum());