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;
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 ((BranchObj*)(this));
157 int BranchObj::getNum(BranchObj *bo)
159 // keep current pointer in branch,
160 // otherwise save might 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->getLinkColorHint()==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()
412 BranchObj* BranchObj::next()
415 BranchObj *bo=branch.first();
416 BranchObj *po=(BranchObj*)(parObj);
419 { // We are just beginning at the mapCenter
433 { // We come from above
436 // there are childs, go there
441 { // no childs, try to go up again
453 // can't go up, I am mapCenter
460 // Try to find last child, we came from, in my own childs
462 while (bo && searching)
464 if (itLast==bo) searching=false;
468 { // found lastLMO in my childs
471 // found a brother of lastLMO
487 // can't go up, I am mapCenter
494 // couldn't find last child, it must be a nephew of mine
498 // proceed with my first child
504 // or go back to my parents
515 // can't go up, I am mapCenter
522 BranchObj* BranchObj::getLastIterator()
527 void BranchObj::setLastIterator(BranchObj* it)
532 void BranchObj::positionContents()
535 for (fio=floatimage.first(); fio; fio=floatimage.next() )
537 OrnamentedObj::positionContents();
540 void BranchObj::move (double x, double y)
542 OrnamentedObj::move (x,y);
544 for (fio=floatimage.first(); fio; fio=floatimage.next() )
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() );
615 topPad=botPad=leftPad=rightPad=0;
616 if (includeImagesVer || includeImagesHor)
618 if (countFloatImages()>0)
620 for (foi=floatimage.first(); foi; foi=floatimage.next() )
623 if (includeImagesVer)
626 topPad=max (topPad,-rp.y()-h);
627 if (rp.y()+foi->height() > 0)
628 botPad=max (botPad,rp.y()+foi->height());
630 if (includeImagesHor)
632 if (orientation==OrientRightOfCenter)
635 leftPad=max (leftPad,-rp.x()-w);
636 if (rp.x()+foi->width() > 0)
637 rightPad=max (rightPad,rp.x()+foi->width());
641 leftPad=max (leftPad,-rp.x());
642 if (rp.x()+foi->width() > w)
643 rightPad=max (rightPad,rp.x()+foi->width()-w);
653 w+=frame->getBorder();
654 h+=frame->getBorder();
657 bbox.setSize (QSize (w,h));
660 void BranchObj::setDockPos()
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() );
672 LinkableMapObj* BranchObj::findMapObj(QPoint p, LinkableMapObj* excludeLMO)
677 for (b=branch.first(); b; b=branch.next() )
679 lmo=b->findMapObj(p, excludeLMO);
680 if (lmo != NULL) return lmo;
684 if (inBox (p) && (this != excludeLMO) && isVisibleObj() )
687 // Search float images
689 for (foi=floatimage.first(); foi; foi=floatimage.next() )
691 (foi != excludeLMO) &&
692 foi->getParObj()!= excludeLMO &&
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 s+=valueElement("heading", getHeading(),
789 attribut ("textColor",QColor(heading->getColor()).name()));
791 // save names of flags set
792 s+=standardFlags->saveToDir(tmpdir,prefix,0);
795 if (!note.isEmpty() )
800 for (bo=branch.first(); bo; bo=branch.next() )
801 s+=bo->saveToDir(tmpdir,prefix,offset);
805 for (fio=floatimage.first(); fio; fio=floatimage.next() )
806 s+=fio->saveToDir (tmpdir,prefix,offset);
810 //FIXME exponential increase in xlinks...
811 QString ol; // old link
812 QString cl; // current link
813 for (xlo=xlink.first(); xlo; xlo=xlink.next() )
822 qWarning (QString("Ignoring of duplicate xLink in %1").arg(getHeading()));
827 s+=endElement ("branch");
831 void BranchObj::addXLink (XLinkObj *xlo)
837 void BranchObj::removeXLinkRef (XLinkObj *xlo)
842 void BranchObj::deleteXLink(XLinkObj *xlo)
845 if (!xlo->isUsed()) delete (xlo);
848 void BranchObj::deleteXLinkAt (int i)
850 XLinkObj *xlo=xlink.at(i);
852 if (!xlo->isUsed()) delete(xlo);
855 XLinkObj* BranchObj::XLinkAt (int i)
860 int BranchObj::countXLink()
862 return xlink.count();
866 BranchObj* BranchObj::XLinkTargetAt (int i)
869 return xlink.at(i)->otherBranch (this);
874 void BranchObj::setIncludeImagesVer(bool b)
883 bool BranchObj::getIncludeImagesVer()
885 return includeImagesVer;
888 void BranchObj::setIncludeImagesHor(bool b)
897 bool BranchObj::getIncludeImagesHor()
899 return includeImagesHor;
902 QString BranchObj::getIncludeImageAttr()
905 if (includeImagesVer)
906 a=attribut ("incImgV","true");
908 a=attribut ("incImgV","false");
909 if (includeImagesHor)
910 a+=attribut ("incImgH","true");
912 a+=attribut ("incImgH","false");
916 LinkableMapObj* BranchObj::addFloatImage ()
918 FloatImageObj *newfi=new FloatImageObj (canvas,this);
919 floatimage.append (newfi);
920 if (hasScrolledParent(this) )
921 newfi->setVisibility (false);
923 newfi->setVisibility(visible);
931 LinkableMapObj* BranchObj::addFloatImage (FloatImageObj *fio)
933 FloatImageObj *newfi=new FloatImageObj (canvas,this);
934 floatimage.append (newfi);
936 if (hasScrolledParent(this) )
937 newfi->setVisibility (false);
939 newfi->setVisibility(visible);
947 FloatImageObj* BranchObj::getFirstFloatImage ()
949 return floatimage.first();
952 FloatImageObj* BranchObj::getLastFloatImage ()
954 return floatimage.last();
957 FloatImageObj* BranchObj::getFloatImageNum (const uint &i)
959 return floatimage.at(i);
962 void BranchObj::removeFloatImage (FloatImageObj *fio)
964 floatimage.remove (fio);
971 void BranchObj::savePosInAngle ()
973 // Save position in angle
976 for (b=branch.first(); b; b=branch.next() )
983 void BranchObj::setDefAttr (BranchModification mod)
988 case 0: fontsize=16; break;
989 case 1: fontsize=12; break;
990 default: fontsize=10; break;
994 setLinkStyle(getDefLinkStyle());
995 QFont font("Sans Serif,8,-1,5,50,0,0,0,0,0");
996 font.setPointSize(fontsize);
997 heading->setFont(font );
1000 setColor (((BranchObj*)(parObj))->getColor());
1005 BranchObj* BranchObj::addBranch()
1007 BranchObj* newbo=new BranchObj(canvas,this);
1008 branch.append (newbo);
1009 newbo->setParObj(this);
1010 newbo->setDefAttr(NewBranch);
1011 newbo->setHeading ("new");
1013 newbo->setVisibility (false);
1015 newbo->setVisibility(visible);
1016 newbo->updateLink();
1017 requestReposition();
1021 BranchObj* BranchObj::addBranch(BranchObj* bo)
1023 BranchObj* newbo=new BranchObj(canvas,this);
1024 branch.append (newbo);
1026 newbo->setParObj(this);
1027 newbo->setDefAttr(MovedBranch);
1029 newbo->setVisibility (false);
1031 newbo->setVisibility(bo->visible);
1032 newbo->updateLink();
1033 requestReposition();
1037 BranchObj* BranchObj::addBranchPtr(BranchObj* bo)
1040 bo->setParObj (this);
1042 bo->setDefAttr(MovedBranch);
1043 if (scrolled) tmpUnscroll();
1044 setLastSelectedBranch (bo);
1048 BranchObj* BranchObj::insertBranch(int pos)
1051 // Add new bo and resort branches
1052 BranchObj *newbo=addBranch ();
1053 newbo->angle=pos-0.5;
1058 BranchObj* BranchObj::insertBranch(BranchObj* bo, int pos)
1061 // Add new bo and resort branches
1063 BranchObj *newbo=addBranch (bo);
1068 BranchObj* BranchObj::insertBranchPtr (BranchObj* bo, int pos)
1071 // Add new bo and resort branches
1074 bo->setParObj (this);
1076 bo->setDefAttr (MovedBranch);
1077 if (scrolled) tmpUnscroll();
1078 setLastSelectedBranch (bo);
1083 void BranchObj::removeBranchHere(BranchObj* borem)
1085 // This removes the branch bo from list, but
1086 // inserts its childs at the place of bo
1088 bo=borem->getLastBranch();
1089 int pos=borem->getNum();
1092 bo->moveBranchTo (this,pos+1);
1093 bo=borem->getLastBranch();
1095 removeBranch (borem);
1098 void BranchObj::removeChilds()
1103 void BranchObj::removeBranch(BranchObj* bo)
1105 // if bo is not in branch remove returns false, we
1108 if (branch.remove (bo))
1111 qWarning ("BranchObj::removeBranch tried to remove non existing branch?!\n");
1112 requestReposition();
1115 void BranchObj::removeBranchPtr(BranchObj* bo)
1118 requestReposition();
1121 void BranchObj::setLastSelectedBranch (BranchObj* bo)
1123 lastSelectedBranch=branch.find(bo);
1126 BranchObj* BranchObj::getLastSelectedBranch ()
1128 if (lastSelectedBranch>=0)
1130 BranchObj* bo=branch.at(lastSelectedBranch);
1133 return branch.first();
1136 BranchObj* BranchObj::getFirstBranch ()
1138 return branch.first();
1141 BranchObj* BranchObj::getLastBranch ()
1143 return branch.last();
1146 BranchObj* BranchObj::getBranchNum (const uint &i)
1148 return branch.at(i);
1151 bool BranchObj::canMoveBranchUp()
1153 if (!parObj) return false;
1154 BranchObj* par=(BranchObj*)parObj;
1155 if (this==par->getFirstBranch())
1161 BranchObj* BranchObj::moveBranchUp(BranchObj* bo1) // move a branch up (modify myself)
1164 int i=branch.find(bo1);
1166 { // -1 if bo1 not found
1167 branch.at(i)->angle--;
1168 branch.at(i-1)->angle++;
1170 return branch.at(i-1);
1172 return branch.at(i);
1175 bool BranchObj::canMoveBranchDown()
1177 if (!parObj) return false;
1178 BranchObj* par=(BranchObj*)parObj;
1179 if (this==par->getLastBranch())
1185 BranchObj* BranchObj::moveBranchDown(BranchObj* bo1)
1188 int i=branch.find(bo1);
1193 branch.at(i)->angle++;
1194 branch.at(j)->angle--;
1196 return branch.at(j);
1198 return branch.at(i);
1201 BranchObj* BranchObj::moveBranchTo (BranchObj* dst, int pos)
1203 // Find current parent and
1204 // remove pointer to myself there
1205 if (!dst) return NULL;
1206 BranchObj *par=(BranchObj*)(parObj);
1208 par->removeBranchPtr (this);
1212 // Create new pointer to myself at dst
1213 if (pos<0||dst->getDepth()==0)
1215 // links myself as last branch at dst
1216 dst->addBranchPtr (this);
1221 // inserts me at pos in parent of dst
1224 BranchObj *bo=dst->insertBranchPtr (this,pos);
1225 bo->setDefAttr(MovedBranch);
1234 void BranchObj::alignRelativeTo (QPoint ref)
1236 int th = bboxTotal.height();
1239 cout << "BO::alignRelTo "<<getHeading()<<endl;
1240 cout << " d="<<depth<<
1242 // " bbox.topLeft="<<bboxTotal.topLeft()<<
1243 " absPos="<<absPos<<
1244 // " pad="<<topPad<<","<<botPad<<","<<leftPad<<","<<rightPad<<
1245 " hidden="<<hidden<<
1249 // If I am the mapcenter or a mainbranch, reposition heading
1251 { //FIXME ugly! optimize this move for MCO needed to initially position text in box...
1253 // Calc angle to mapCenter if I am a mainbranch
1254 // needed for reordering the mainbranches clockwise
1256 angle=getAngle (QPoint ((int)(x() - parObj->getChildPos().x() ),
1257 (int)(y() - parObj->getChildPos().y() ) ) );
1261 // Align myself depending on orientation and parent, but
1262 // only if I am not the mainbranch or mapcenter itself
1263 switch (orientation)
1265 case OrientLeftOfCenter:
1266 move (ref.x() - bbox.width(), ref.y() + (th-bbox.height())/2 );
1268 case OrientRightOfCenter:
1269 move (ref.x() , ref.y() + (th-bbox.height())/2 );
1272 qWarning ("LMO::alignRelativeTo: oops, no orientation given...");
1277 if (scrolled) return;
1279 // Set reference point for alignment of childs
1281 if (orientation==OrientLeftOfCenter)
1282 ref2.setX(bbox.topLeft().x() - linkwidth);
1284 ref2.setX(bbox.topRight().x() + linkwidth);
1287 ref2.setY(absPos.y()-(bboxTotal.height()-bbox.height())/2);
1289 ref2.setY(ref.y() );
1291 // Align the childs depending on reference point
1293 for (b=branch.first(); b; b=branch.next() )
1297 b->alignRelativeTo (ref2);
1298 ref2.setY(ref2.y() + b->getBBoxSizeWithChilds().height() );
1304 void BranchObj::reposition()
1306 /* TODO testing only
1307 if (!getHeading().isEmpty())
1308 cout << "BO::reposition "<<getHeading()<<endl;
1310 cout << "BO::reposition ???"<<endl;
1314 // only calculate the sizes once. If the deepest LMO
1315 // changes its height,
1316 // all upper LMOs have to change, too.
1317 calcBBoxSizeWithChilds();
1318 updateLink(); // This update is needed if the canvas is resized
1319 // due to excessive moving of a FIO
1321 alignRelativeTo ( QPoint (absPos.x(),
1322 absPos.y()-(bboxTotal.height()-bbox.height())/2) );
1324 positionBBox(); // Reposition bbox and contents
1327 // This is only important for moving branches:
1328 // For editing a branch it isn't called...
1329 alignRelativeTo ( QPoint (absPos.x(),
1330 absPos.y()-(bboxTotal.height()-bbox.height())/2) );
1335 QRect BranchObj::getTotalBBox()
1339 if (scrolled) return r;
1342 for (b=branch.first();b ;b=branch.next() )
1344 r=addBBox(b->getTotalBBox(),r);
1347 for (fio=floatimage.first();fio ;fio=floatimage.next() )
1348 if (!fio->isHidden())
1349 r=addBBox(fio->getTotalBBox(),r);
1354 QRect BranchObj::getBBoxSizeWithChilds()
1359 void BranchObj::calcBBoxSizeWithChilds()
1361 // This is initially called only from reposition and
1362 // and only for mapcenter. So it won't be
1363 // called more than once for a single user
1367 // Calculate size of LMO including all childs (to align them later)
1368 bboxTotal.setX(bbox.x() );
1369 bboxTotal.setY(bbox.y() );
1371 // if branch is scrolled, ignore childs, but still consider floatimages
1374 bboxTotal.setWidth (bbox.width());
1375 bboxTotal.setHeight(bbox.height());
1381 bboxTotal.setWidth (0);
1382 bboxTotal.setHeight(0);
1385 bboxTotal.setX (parObj->x());
1386 bboxTotal.setY (parObj->y());
1389 bboxTotal.setX (bbox.x());
1390 bboxTotal.setY (bbox.y());
1397 // Now calculate recursivly
1399 // maximum of widths
1402 for (b=branch.first();b ;b=branch.next() )
1406 b->calcBBoxSizeWithChilds();
1407 br=b->getBBoxSizeWithChilds();
1408 r.setWidth( max (br.width(), r.width() ));
1409 r.setHeight(br.height() + r.height() );
1410 if (br.y()<bboxTotal.y()) bboxTotal.setY(br.y());
1413 // Add myself and also
1414 // add width of link to sum if necessary
1415 if (branch.isEmpty())
1416 bboxTotal.setWidth (bbox.width() + r.width() );
1418 bboxTotal.setWidth (bbox.width() + r.width() + linkwidth);
1420 bboxTotal.setHeight(max (r.height(), bbox.height()));
1423 void BranchObj::select()
1425 // set Text in Editor
1426 textEditor->setText(note.getNote() );
1427 QString fnh=note.getFilenameHint();
1429 textEditor->setFilenameHint(note.getFilenameHint() );
1431 textEditor->setFilenameHint(getHeading() );
1432 textEditor->setFontHint (note.getFontHint() );
1434 LinkableMapObj::select();
1435 // Tell parent that I am selected now:
1436 BranchObj* po=(BranchObj*)(parObj);
1437 if (po) // TODO Try to get rid of this cast...
1438 po->setLastSelectedBranch(this);
1440 // temporary unscroll, if we have scrolled parents somewhere
1441 if (parObj) ((BranchObj*)(parObj))->tmpUnscroll();
1443 // Show URL and link in statusbar
1445 if (!url.isEmpty()) status+="URL: "+url+" ";
1446 if (!vymLink.isEmpty()) status+="Link: "+vymLink;
1447 if (!status.isEmpty()) mainWindow->statusMessage (status);
1450 standardFlags->updateToolbar();
1452 // Update actions in mapeditor
1453 mapEditor->updateActions();
1456 void BranchObj::unselect()
1458 LinkableMapObj::unselect();
1459 // Delete any messages like vymLink in StatusBar
1460 mainWindow->statusMessage ("");
1462 // save note from editor and set flag
1463 // text is done by updateNoteFlag(), just save
1465 note.setFilenameHint (textEditor->getFilename());
1467 // reset temporary unscroll, if we have scrolled parents somewhere
1468 if (parObj) ((BranchObj*)(parObj))->resetTmpUnscroll();
1470 // Erase content of editor
1471 textEditor->setInactive();
1473 // unselect all buttons in toolbar
1474 standardFlagsDefault->updateToolbar();
1477 QString BranchObj::getSelectString()
1483 s= "bo:" + QString("%1").arg(getNum());
1485 s= ((BranchObj*)(parObj))->getSelectString() + ",bo:" + QString("%1").arg(getNum());