Fixed editing of headings. Undo debug output still enabled
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 ((BranchObj*)(this));
158 int BranchObj::getNum(BranchObj *bo)
160 // keep current pointer in branch,
161 // otherwise save might fail
163 int ind=branch.findRef (bo);
168 int BranchObj::getFloatImageNum(FloatImageObj *fio)
170 return floatimage.findRef (fio);
173 int BranchObj::countBranches()
175 return branch.count();
178 int BranchObj::countFloatImages()
180 return floatimage.count();
183 int BranchObj::countXLinks()
185 return xlink.count();
188 void BranchObj::setParObjTmp(LinkableMapObj* lmo, QPoint m, int off)
190 // Temporary link to lmo
191 // m is position of mouse pointer
192 // offset 0: default 1: below lmo -1 above lmo (if possible)
195 BranchObj* o=(BranchObj*)(lmo);
199 // ignore mapcenter and mainbranch
200 if (lmo->getDepth()<2) off=0;
207 depth=parObj->getDepth()+1;
209 // setLinkStyle calls updateLink, only set it once
210 if (style!=getDefLinkStyle() ) setLinkStyle (getDefLinkStyle());
212 // Move temporary to new position at destination
213 // Usually the positioning would be done by reposition(),
214 // but then also the destination branch would "Jump" around...
215 // Better just do it approximately
217 { // new parent is the mapcenter itself
219 QPoint p= normalise ( QPoint (m.x() - o->getChildPos().x(),
220 m.y() - o->getChildPos().y() ));
221 if (p.x()<0) p.setX( p.x()-bbox.width() );
228 // new parent is just a branch, link to it
229 QRect t=o->getBBoxSizeWithChilds();
230 if (o->getLastBranch())
231 y=t.y() + t.height() ;
238 // we want to link above lmo
239 y=o->y() - height() + 5;
241 // we want to link below lmo
242 // Bottom of sel should be 5 pixels above
243 // the bottom of the branch _below_ the target:
244 // Don't try to find that branch, guess 12 pixels
245 y=o->getChildPos().y() -height() + 12;
247 if (o->getOrientation()==OrientLeftOfCenter)
248 move ( o->getChildPos().x() - linkwidth, y );
250 move (o->getChildPos().x() + linkwidth, y );
253 // updateLink is called implicitly in move
254 reposition(); // FIXME shouldn't be this a request?
257 void BranchObj::unsetParObjTmp()
264 depth=parObj->getDepth()+1;
265 setLinkStyle (getDefLinkStyle() );
270 void BranchObj::unScroll()
272 if (tmpUnscrolled) resetTmpUnscroll();
273 if (scrolled) toggleScroll();
276 void BranchObj::toggleScroll()
282 systemFlags->deactivate("scrolledright");
283 for (bo=branch.first(); bo; bo=branch.next() )
285 bo->setVisibility(true);
290 systemFlags->activate("scrolledright");
291 for (bo=branch.first(); bo; bo=branch.next() )
293 bo->setVisibility(false);
298 move (absPos.x(), absPos.y() );
302 bool BranchObj::isScrolled()
307 bool BranchObj::hasScrolledParent(BranchObj *start)
309 // Calls parents recursivly to
310 // find out, if we are scrolled at all.
311 // But ignore myself, just look at parents.
313 if (this !=start && scrolled) return true;
315 BranchObj* bo=(BranchObj*)(parObj);
317 return bo->hasScrolledParent(start);
322 void BranchObj::tmpUnscroll()
324 // Unscroll parent (recursivly)
325 BranchObj* bo=(BranchObj*)(parObj);
326 if (bo) bo->tmpUnscroll();
332 systemFlags->activate("tmpUnscrolledright");
337 void BranchObj::resetTmpUnscroll()
339 // Unscroll parent (recursivly)
340 BranchObj* bo=(BranchObj*)(parObj);
342 bo->resetTmpUnscroll();
348 systemFlags->deactivate("tmpUnscrolledright");
353 void BranchObj::setVisibility(bool v, int toDepth)
355 if (depth <= toDepth)
357 frame->setVisibility(v);
358 heading->setVisibility(v);
359 systemFlags->setVisibility(v);
360 standardFlags->setVisibility(v);
361 LinkableMapObj::setVisibility (v);
363 // Only change childs, if I am not scrolled
364 if (!scrolled && (depth < toDepth))
366 // Now go recursivly through all childs
368 for (b=branch.first(); b;b=branch.next() )
369 b->setVisibility (v,toDepth);
371 for (fio=floatimage.first(); fio; fio=floatimage.next())
372 fio->setVisibility (v);
374 for (xlo=xlink.first(); xlo;xlo=xlink.next() )
375 xlo->setVisibility ();
377 } // depth <= toDepth
381 void BranchObj::setVisibility(bool v)
383 setVisibility (v,MAX_DEPTH);
387 void BranchObj::setLinkColor ()
389 // Overloaded from LinkableMapObj
390 // BranchObj can use color of heading
393 if (mapEditor->getLinkColorHint()==HeadingColor)
394 LinkableMapObj::setLinkColor (heading->getColor() );
396 LinkableMapObj::setLinkColor ();
399 void BranchObj::setColorChilds (QColor col)
401 OrnamentedObj::setColor (col);
403 for (bo=branch.first(); bo; bo=branch.next() )
404 bo->setColorChilds(col);
407 BranchObj* BranchObj::first()
414 BranchObj* BranchObj::next()
417 BranchObj *bo=branch.first();
418 BranchObj *po=(BranchObj*)(parObj);
423 { // We are just beginning,
424 // return first child
437 { // We come from above
440 // there are childs, go there
445 { // no childs, try to go up again
457 // can't go up, I am mapCenter
464 // Try to find last child, where we came from, in my own childs
466 while (bo && searching)
468 if (itLast==bo) searching=false;
472 { // found lastLMO in my childs
475 // found a brother of lastLMO
483 if (this==itFirst) return NULL; // Stop at starting point
492 // can't go up, I am mapCenter
499 // couldn't find last child, it must be a nephew of mine
503 // proceed with my first child
509 // or go back to my parents
520 // can't go up, I am mapCenter
527 BranchObj* BranchObj::getLastIterator()
532 void BranchObj::setLastIterator(BranchObj* it)
537 void BranchObj::positionContents()
540 for (fio=floatimage.first(); fio; fio=floatimage.next() )
542 OrnamentedObj::positionContents();
545 void BranchObj::move (double x, double y)
547 OrnamentedObj::move (x,y);
549 for (fio=floatimage.first(); fio; fio=floatimage.next() )
554 void BranchObj::move (QPoint p)
559 void BranchObj::moveBy (double x, double y)
561 OrnamentedObj::moveBy (x,y);
563 for (b=branch.first(); b;b=branch.next() )
568 void BranchObj::moveBy (QPoint p)
570 moveBy (p.x(), p.y());
574 void BranchObj::positionBBox()
576 QPoint ap=getAbsPos();
577 bbox.moveTopLeft (ap);
582 frame->setRect(QRect(bbox.x(),bbox.y(),bbox.width(),bbox.height() ) );
584 // Update links to other branches
586 for (xlo=xlink.first(); xlo; xlo=xlink.next() )
590 void BranchObj::calcBBoxSize()
592 QSize heading_r=heading->getSize();
593 int heading_w=(int) heading_r.width() ;
594 int heading_h=(int) heading_r.height() ;
595 QSize sysflags_r=systemFlags->getSize();
596 int sysflags_h=sysflags_r.height();
597 int sysflags_w=sysflags_r.width();
598 QSize stanflags_r=standardFlags->getSize();
599 int stanflags_h=stanflags_r.height();
600 int stanflags_w=stanflags_r.width();
604 // set width to sum of all widths
605 w=heading_w + sysflags_w + stanflags_w;
606 // set height to maximum needed height
607 h=max (sysflags_h,stanflags_h);
610 // Save the dimension of flags and heading
611 ornamentsBBox.setSize ( QSize(w,h));
613 // clickBox includes Flags and Heading
614 clickBox.setSize (ornamentsBBox.size() );
620 topPad=botPad=leftPad=rightPad=0;
621 if (includeImagesVer || includeImagesHor)
623 if (countFloatImages()>0)
625 for (foi=floatimage.first(); foi; foi=floatimage.next() )
628 if (includeImagesVer)
631 topPad=max (topPad,-rp.y()-h);
632 if (rp.y()+foi->height() > 0)
633 botPad=max (botPad,rp.y()+foi->height());
635 if (includeImagesHor)
637 if (orientation==OrientRightOfCenter)
640 leftPad=max (leftPad,-rp.x()-w);
641 if (rp.x()+foi->width() > 0)
642 rightPad=max (rightPad,rp.x()+foi->width());
646 leftPad=max (leftPad,-rp.x());
647 if (rp.x()+foi->width() > w)
648 rightPad=max (rightPad,rp.x()+foi->width()-w);
658 w+=frame->getBorder();
659 h+=frame->getBorder();
662 bbox.setSize (QSize (w,h));
665 void BranchObj::setDockPos()
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() );
677 LinkableMapObj* BranchObj::findMapObj(QPoint p, LinkableMapObj* excludeLMO)
682 for (b=branch.first(); b; b=branch.next() )
684 lmo=b->findMapObj(p, excludeLMO);
685 if (lmo != NULL) return lmo;
689 if (inBox (p) && (this != excludeLMO) && isVisibleObj() )
692 // Search float images
694 for (foi=floatimage.first(); foi; foi=floatimage.next() )
696 (foi != excludeLMO) &&
697 foi->getParObj()!= excludeLMO &&
704 void BranchObj::setHeading(QString s)
706 heading->setText(s); // set new heading
707 calcBBoxSize(); // recalculate bbox
708 positionBBox(); // rearrange contents
712 void BranchObj::setHideTmp (HideTmpMode mode)
714 if (mode==HideExport && hasHiddenExportParent(this))
716 setVisibility (false);
720 if (hasScrolledParent(this))
721 setVisibility (false);
723 setVisibility (true);
728 for (bo=branch.first(); bo; bo=branch.next() )
729 bo->setHideTmp (mode);
732 bool BranchObj::hasHiddenExportParent(BranchObj *start)
734 // Calls parents recursivly to
735 // find out, if we are temp. hidden
737 if (hideExport) return true;
739 BranchObj* bo=(BranchObj*)(parObj);
741 return bo->hasHiddenExportParent(start);
746 QString BranchObj::saveToDir (const QString &tmpdir,const QString &prefix, const QPoint& offset)
748 if (hidden) return "";
751 QString scrolledAttr;
753 scrolledAttr=attribut ("scrolled","yes");
758 if (frame->getFrameType()!=NoFrame)
759 frameAttr=attribut ("frameType",frame->getFrameTypeName());
763 // save area, if not scrolled
765 if (!((BranchObj*)(parObj))->isScrolled() )
768 attribut("x1",QString().setNum(absPos.x()-offset.x(),10)) +
769 attribut("y1",QString().setNum(absPos.y()-offset.y(),10)) +
770 attribut("x2",QString().setNum(absPos.x()+width()-offset.x(),10)) +
771 attribut("y2",QString().setNum(absPos.y()+height()-offset.y(),10));
776 // Providing an ID for a branch makes export to XHTML easier
779 idAttr=attribut ("id",getSelectString());
783 s=beginElement ("branch"
789 +getIncludeImageAttr() );
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);
801 for (fio=floatimage.first(); fio; fio=floatimage.next() )
802 s+=fio->saveToDir (tmpdir,prefix,offset);
805 if (!note.isEmpty() )
810 for (bo=branch.first(); bo; bo=branch.next() )
811 s+=bo->saveToDir(tmpdir,prefix,offset);
815 //FIXME exponential increase in xlinks...
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)
888 bool BranchObj::getIncludeImagesVer()
890 return includeImagesVer;
893 void BranchObj::setIncludeImagesHor(bool b)
902 bool BranchObj::getIncludeImagesHor()
904 return includeImagesHor;
907 QString BranchObj::getIncludeImageAttr()
910 if (includeImagesVer)
911 a=attribut ("incImgV","true");
913 a=attribut ("incImgV","false");
914 if (includeImagesHor)
915 a+=attribut ("incImgH","true");
917 a+=attribut ("incImgH","false");
921 LinkableMapObj* BranchObj::addFloatImage ()
923 FloatImageObj *newfi=new FloatImageObj (canvas,this);
924 floatimage.append (newfi);
925 if (hasScrolledParent(this) )
926 newfi->setVisibility (false);
928 newfi->setVisibility(visible);
936 LinkableMapObj* BranchObj::addFloatImage (FloatImageObj *fio)
938 FloatImageObj *newfi=new FloatImageObj (canvas,this);
939 floatimage.append (newfi);
941 if (hasScrolledParent(this) )
942 newfi->setVisibility (false);
944 newfi->setVisibility(visible);
952 FloatImageObj* BranchObj::getFirstFloatImage ()
954 return floatimage.first();
957 FloatImageObj* BranchObj::getLastFloatImage ()
959 return floatimage.last();
962 FloatImageObj* BranchObj::getFloatImageNum (const uint &i)
964 return floatimage.at(i);
967 void BranchObj::removeFloatImage (FloatImageObj *fio)
969 floatimage.remove (fio);
976 void BranchObj::savePosInAngle ()
978 // Save position in angle
981 for (b=branch.first(); b; b=branch.next() )
988 void BranchObj::setDefAttr (BranchModification mod)
993 case 0: fontsize=16; break;
994 case 1: fontsize=12; break;
995 default: fontsize=10; break;
999 setLinkStyle(getDefLinkStyle());
1000 QFont font("Sans Serif,8,-1,5,50,0,0,0,0,0");
1001 font.setPointSize(fontsize);
1002 heading->setFont(font );
1005 setColor (((BranchObj*)(parObj))->getColor());
1010 BranchObj* BranchObj::addBranch()
1012 BranchObj* newbo=new BranchObj(canvas,this);
1013 branch.append (newbo);
1014 newbo->setParObj(this);
1015 newbo->setDefAttr(NewBranch);
1016 newbo->setHeading ("new");
1018 newbo->setVisibility (false);
1020 newbo->setVisibility(visible);
1021 newbo->updateLink();
1022 requestReposition();
1026 BranchObj* BranchObj::addBranch(BranchObj* bo)
1028 BranchObj* newbo=new BranchObj(canvas,this);
1029 branch.append (newbo);
1031 newbo->setParObj(this);
1032 newbo->setDefAttr(MovedBranch);
1034 newbo->setVisibility (false);
1036 newbo->setVisibility(bo->visible);
1037 newbo->updateLink();
1038 requestReposition();
1042 BranchObj* BranchObj::addBranchPtr(BranchObj* bo)
1045 bo->setParObj (this);
1047 bo->setDefAttr(MovedBranch);
1048 if (scrolled) tmpUnscroll();
1049 setLastSelectedBranch (bo);
1053 BranchObj* BranchObj::insertBranch(int pos)
1056 // Add new bo and resort branches
1057 BranchObj *newbo=addBranch ();
1058 newbo->angle=pos-0.5;
1063 BranchObj* BranchObj::insertBranch(BranchObj* bo, int pos)
1066 // Add new bo and resort branches
1068 BranchObj *newbo=addBranch (bo);
1073 BranchObj* BranchObj::insertBranchPtr (BranchObj* bo, int pos)
1076 // Add new bo and resort branches
1079 bo->setParObj (this);
1081 bo->setDefAttr (MovedBranch);
1082 if (scrolled) tmpUnscroll();
1083 setLastSelectedBranch (bo);
1088 void BranchObj::removeBranchHere(BranchObj* borem)
1090 // This removes the branch bo from list, but
1091 // inserts its childs at the place of bo
1093 bo=borem->getLastBranch();
1094 int pos=borem->getNum();
1097 bo->moveBranchTo (this,pos+1);
1098 bo=borem->getLastBranch();
1100 removeBranch (borem);
1103 void BranchObj::removeChilds()
1108 void BranchObj::removeBranch(BranchObj* bo)
1110 // if bo is not in branch remove returns false, we
1113 if (branch.remove (bo))
1116 qWarning ("BranchObj::removeBranch tried to remove non existing branch?!\n");
1117 requestReposition();
1120 void BranchObj::removeBranchPtr(BranchObj* bo)
1123 requestReposition();
1126 void BranchObj::setLastSelectedBranch (BranchObj* bo)
1128 lastSelectedBranch=branch.find(bo);
1131 BranchObj* BranchObj::getLastSelectedBranch ()
1133 if (lastSelectedBranch>=0)
1135 BranchObj* bo=branch.at(lastSelectedBranch);
1138 return branch.first();
1141 BranchObj* BranchObj::getFirstBranch ()
1143 return branch.first();
1146 BranchObj* BranchObj::getLastBranch ()
1148 return branch.last();
1151 BranchObj* BranchObj::getBranchNum (const uint &i)
1153 return branch.at(i);
1156 bool BranchObj::canMoveBranchUp()
1158 if (!parObj) return false;
1159 BranchObj* par=(BranchObj*)parObj;
1160 if (this==par->getFirstBranch())
1166 BranchObj* BranchObj::moveBranchUp(BranchObj* bo1) // move a branch up (modify myself)
1169 int i=branch.find(bo1);
1171 { // -1 if bo1 not found
1172 branch.at(i)->angle--;
1173 branch.at(i-1)->angle++;
1175 return branch.at(i-1);
1177 return branch.at(i);
1180 bool BranchObj::canMoveBranchDown()
1182 if (!parObj) return false;
1183 BranchObj* par=(BranchObj*)parObj;
1184 if (this==par->getLastBranch())
1190 BranchObj* BranchObj::moveBranchDown(BranchObj* bo1)
1193 int i=branch.find(bo1);
1198 branch.at(i)->angle++;
1199 branch.at(j)->angle--;
1201 return branch.at(j);
1203 return branch.at(i);
1206 BranchObj* BranchObj::moveBranchTo (BranchObj* dst, int pos)
1208 // Find current parent and
1209 // remove pointer to myself there
1210 if (!dst) return NULL;
1211 BranchObj *par=(BranchObj*)(parObj);
1213 par->removeBranchPtr (this);
1217 // Create new pointer to myself at dst
1218 if (pos<0||dst->getDepth()==0)
1220 // links myself as last branch at dst
1221 dst->addBranchPtr (this);
1226 // inserts me at pos in parent of dst
1229 BranchObj *bo=dst->insertBranchPtr (this,pos);
1230 bo->setDefAttr(MovedBranch);
1239 void BranchObj::alignRelativeTo (QPoint ref)
1241 int th = bboxTotal.height();
1244 cout << "BO::alignRelTo "<<getHeading()<<endl;
1245 cout << " d="<<depth<<
1247 // " bbox.topLeft="<<bboxTotal.topLeft()<<
1248 " absPos="<<absPos<<
1249 // " pad="<<topPad<<","<<botPad<<","<<leftPad<<","<<rightPad<<
1250 " hidden="<<hidden<<
1254 // If I am the mapcenter or a mainbranch, reposition heading
1256 { //FIXME ugly! optimize this move for MCO needed to initially position text in box...
1258 // Calc angle to mapCenter if I am a mainbranch
1259 // needed for reordering the mainbranches clockwise
1261 angle=getAngle (QPoint ((int)(x() - parObj->getChildPos().x() ),
1262 (int)(y() - parObj->getChildPos().y() ) ) );
1266 // Align myself depending on orientation and parent, but
1267 // only if I am not the mainbranch or mapcenter itself
1268 switch (orientation)
1270 case OrientLeftOfCenter:
1271 move (ref.x() - bbox.width(), ref.y() + (th-bbox.height())/2 );
1273 case OrientRightOfCenter:
1274 move (ref.x() , ref.y() + (th-bbox.height())/2 );
1277 qWarning ("LMO::alignRelativeTo: oops, no orientation given...");
1282 if (scrolled) return;
1284 // Set reference point for alignment of childs
1286 if (orientation==OrientLeftOfCenter)
1287 ref2.setX(bbox.topLeft().x() - linkwidth);
1289 ref2.setX(bbox.topRight().x() + linkwidth);
1292 ref2.setY(absPos.y()-(bboxTotal.height()-bbox.height())/2);
1294 ref2.setY(ref.y() );
1296 // Align the childs depending on reference point
1298 for (b=branch.first(); b; b=branch.next() )
1302 b->alignRelativeTo (ref2);
1303 ref2.setY(ref2.y() + b->getBBoxSizeWithChilds().height() );
1309 void BranchObj::reposition()
1311 /* TODO testing only
1312 if (!getHeading().isEmpty())
1313 cout << "BO::reposition "<<getHeading()<<endl;
1315 cout << "BO::reposition ???"<<endl;
1319 // only calculate the sizes once. If the deepest LMO
1320 // changes its height,
1321 // all upper LMOs have to change, too.
1322 calcBBoxSizeWithChilds();
1323 updateLink(); // This update is needed if the canvas is resized
1324 // due to excessive moving of a FIO
1326 alignRelativeTo ( QPoint (absPos.x(),
1327 absPos.y()-(bboxTotal.height()-bbox.height())/2) );
1329 positionBBox(); // Reposition bbox and contents
1332 // This is only important for moving branches:
1333 // For editing a branch it isn't called...
1334 alignRelativeTo ( QPoint (absPos.x(),
1335 absPos.y()-(bboxTotal.height()-bbox.height())/2) );
1340 QRect BranchObj::getTotalBBox()
1344 if (scrolled) return r;
1347 for (b=branch.first();b ;b=branch.next() )
1349 r=addBBox(b->getTotalBBox(),r);
1352 for (fio=floatimage.first();fio ;fio=floatimage.next() )
1353 if (!fio->isHidden())
1354 r=addBBox(fio->getTotalBBox(),r);
1359 QRect BranchObj::getBBoxSizeWithChilds()
1364 void BranchObj::calcBBoxSizeWithChilds()
1366 // This is initially called only from reposition and
1367 // and only for mapcenter. So it won't be
1368 // called more than once for a single user
1372 // Calculate size of LMO including all childs (to align them later)
1373 bboxTotal.setX(bbox.x() );
1374 bboxTotal.setY(bbox.y() );
1376 // if branch is scrolled, ignore childs, but still consider floatimages
1379 bboxTotal.setWidth (bbox.width());
1380 bboxTotal.setHeight(bbox.height());
1386 bboxTotal.setWidth (0);
1387 bboxTotal.setHeight(0);
1390 bboxTotal.setX (parObj->x());
1391 bboxTotal.setY (parObj->y());
1394 bboxTotal.setX (bbox.x());
1395 bboxTotal.setY (bbox.y());
1402 // Now calculate recursivly
1404 // maximum of widths
1407 for (b=branch.first();b ;b=branch.next() )
1411 b->calcBBoxSizeWithChilds();
1412 br=b->getBBoxSizeWithChilds();
1413 r.setWidth( max (br.width(), r.width() ));
1414 r.setHeight(br.height() + r.height() );
1415 if (br.y()<bboxTotal.y()) bboxTotal.setY(br.y());
1418 // Add myself and also
1419 // add width of link to sum if necessary
1420 if (branch.isEmpty())
1421 bboxTotal.setWidth (bbox.width() + r.width() );
1423 bboxTotal.setWidth (bbox.width() + r.width() + linkwidth);
1425 bboxTotal.setHeight(max (r.height(), bbox.height()));
1428 void BranchObj::select()
1430 // set Text in Editor
1431 textEditor->setText(note.getNote() );
1432 QString fnh=note.getFilenameHint();
1434 textEditor->setFilenameHint(note.getFilenameHint() );
1436 textEditor->setFilenameHint(getHeading() );
1437 textEditor->setFontHint (note.getFontHint() );
1439 LinkableMapObj::select();
1440 // Tell parent that I am selected now:
1441 BranchObj* po=(BranchObj*)(parObj);
1442 if (po) // TODO Try to get rid of this cast...
1443 po->setLastSelectedBranch(this);
1445 // temporary unscroll, if we have scrolled parents somewhere
1446 if (parObj) ((BranchObj*)(parObj))->tmpUnscroll();
1448 // Show URL and link in statusbar
1450 if (!url.isEmpty()) status+="URL: "+url+" ";
1451 if (!vymLink.isEmpty()) status+="Link: "+vymLink;
1452 if (!status.isEmpty()) mainWindow->statusMessage (status);
1455 standardFlags->updateToolbar();
1457 // Update actions in mapeditor
1458 mapEditor->updateActions();
1461 void BranchObj::unselect()
1463 LinkableMapObj::unselect();
1464 // Delete any messages like vymLink in StatusBar
1465 mainWindow->statusMessage ("");
1467 // save note from editor and set flag
1468 // text is done by updateNoteFlag(), just save
1470 note.setFilenameHint (textEditor->getFilename());
1472 // reset temporary unscroll, if we have scrolled parents somewhere
1473 if (parObj) ((BranchObj*)(parObj))->resetTmpUnscroll();
1475 // Erase content of editor
1476 textEditor->setInactive();
1478 // unselect all buttons in toolbar
1479 standardFlagsDefault->updateToolbar();
1482 QString BranchObj::getSelectString()
1488 s= "bo:" + QString("%1").arg(getNum());
1490 s= ((BranchObj*)(parObj))->getSelectString() + ",bo:" + QString("%1").arg(getNum());