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 (QCanvas* c):OrnamentedObj (c)
29 // cout << "Const BranchObj (c) called from MapCenterObj (c)\n";
34 BranchObj::BranchObj (QCanvas* 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 ( QPtrCollection::Item i, QPtrCollection::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)
533 void BranchObj::move (double x, double y)
535 OrnamentedObj::move (x,y);
537 for (fio=floatimage.first(); fio; fio=floatimage.next() )
542 void BranchObj::move (QPoint p)
547 void BranchObj::moveBy (double x, double y)
549 OrnamentedObj::moveBy (x,y);
552 for (b=branch.first(); b;b=branch.next() )
556 void BranchObj::moveBy (QPoint p)
558 moveBy (p.x(), p.y());
562 void BranchObj::positionBBox()
564 QPoint ap=getAbsPos();
565 bbox.moveTopLeft (ap);
570 frame->setRect(QRect(bbox.x(),bbox.y(),bbox.width(),bbox.height() ) );
572 // Update links to other branches
574 for (xlo=xlink.first(); xlo; xlo=xlink.next() )
578 void BranchObj::calcBBoxSize()
580 QSize heading_r=heading->getSize();
581 int heading_w=(int) heading_r.width() ;
582 int heading_h=(int) heading_r.height() ;
583 QSize sysflags_r=systemFlags->getSize();
584 int sysflags_h=sysflags_r.height();
585 int sysflags_w=sysflags_r.width();
586 QSize stanflags_r=standardFlags->getSize();
587 int stanflags_h=stanflags_r.height();
588 int stanflags_w=stanflags_r.width();
592 // set width to sum of all widths
593 w=heading_w + sysflags_w + stanflags_w;
594 // set height to maximum needed height
595 h=max (sysflags_h,stanflags_h);
598 // Save the dimension of flags and heading
599 ornamentsBBox.setSize ( QSize(w,h));
601 // clickBox includes Flags and Heading
602 clickBox.setSize (ornamentsBBox.size() );
608 topPad=botPad=leftPad=rightPad=0;
609 if (includeImagesVer || includeImagesHor)
611 if (countFloatImages()>0)
613 for (foi=floatimage.first(); foi; foi=floatimage.next() )
616 if (includeImagesVer)
619 topPad=max (topPad,-rp.y()-h);
620 if (rp.y()+foi->height() > 0)
621 botPad=max (botPad,rp.y()+foi->height());
623 if (includeImagesHor)
625 if (orientation==OrientRightOfCenter)
628 leftPad=max (leftPad,-rp.x()-w);
629 if (rp.x()+foi->width() > 0)
630 rightPad=max (rightPad,rp.x()+foi->width());
634 leftPad=max (leftPad,-rp.x());
635 if (rp.x()+foi->width() > w)
636 rightPad=max (rightPad,rp.x()+foi->width()-w);
646 w+=frame->getBorder();
647 h+=frame->getBorder();
650 bbox.setSize (QSize (w,h));
653 void BranchObj::setDockPos()
655 if (getOrientation()==OrientLeftOfCenter )
657 childPos=QPoint (ornamentsBBox.bottomLeft().x(), ornamentsBBox.bottomLeft().y() );
658 parPos=QPoint (ornamentsBBox.bottomRight().x(),ornamentsBBox.bottomRight().y() );
661 childPos=QPoint (ornamentsBBox.bottomRight().x(), ornamentsBBox.bottomRight().y() );
662 parPos=QPoint (ornamentsBBox.bottomLeft().x(),ornamentsBBox.bottomLeft().y() );
665 LinkableMapObj* BranchObj::findMapObj(QPoint p, LinkableMapObj* excludeLMO)
670 for (b=branch.first(); b; b=branch.next() )
672 lmo=b->findMapObj(p, excludeLMO);
673 if (lmo != NULL) return lmo;
677 if (inBox (p) && (this != excludeLMO) && isVisibleObj() )
680 // Search float images
682 for (foi=floatimage.first(); foi; foi=floatimage.next() )
684 (foi != excludeLMO) &&
685 foi->getParObj()!= excludeLMO &&
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);
716 for (bo=branch.first(); bo; bo=branch.next() )
717 bo->setHideTmp (mode);
720 bool BranchObj::hasHiddenExportParent(BranchObj *start)
722 // Calls parents recursivly to
723 // find out, if we are temp. hidden
725 if (hideExport) return true;
727 BranchObj* bo=(BranchObj*)(parObj);
729 return bo->hasHiddenExportParent(start);
734 QString BranchObj::saveToDir (const QString &tmpdir,const QString &prefix, const QPoint& offset)
736 if (hidden) return "";
739 QString scrolledAttr;
741 scrolledAttr=attribut ("scrolled","yes");
746 if (frame->getFrameType()!=NoFrame)
747 frameAttr=attribut ("frameType",frame->getFrameTypeName());
751 // save area, if not scrolled
753 if (!((BranchObj*)(parObj))->isScrolled() )
756 attribut("x1",QString().setNum(absPos.x()-offset.x(),10)) +
757 attribut("y1",QString().setNum(absPos.y()-offset.y(),10)) +
758 attribut("x2",QString().setNum(absPos.x()+width()-offset.x(),10)) +
759 attribut("y2",QString().setNum(absPos.y()+height()-offset.y(),10));
764 // Providing an ID for a branch makes export to XHTML easier
767 idAttr=attribut ("id",getSelectString());
771 s=beginElement ("branch"
777 +getIncludeImageAttr() );
781 s+=valueElement("heading", getHeading(),
782 attribut ("textColor",QColor(heading->getColor()).name()));
784 // save names of flags set
785 s+=standardFlags->saveToDir(tmpdir,prefix,0);
788 if (!note.isEmpty() )
793 for (bo=branch.first(); bo; bo=branch.next() )
794 s+=bo->saveToDir(tmpdir,prefix,offset);
798 for (fio=floatimage.first(); fio; fio=floatimage.next() )
799 s+=fio->saveToDir (tmpdir,prefix,offset);
803 for (xlo=xlink.first(); xlo; xlo=xlink.next() )
807 s+=endElement ("branch");
811 void BranchObj::addXLink (XLinkObj *xlo)
817 void BranchObj::removeXLinkRef (XLinkObj *xlo)
822 void BranchObj::deleteXLink(XLinkObj *xlo)
825 if (!xlo->isUsed()) delete (xlo);
828 void BranchObj::deleteXLinkAt (int i)
830 XLinkObj *xlo=xlink.at(i);
832 if (!xlo->isUsed()) delete(xlo);
835 XLinkObj* BranchObj::XLinkAt (int i)
840 int BranchObj::countXLink()
842 return xlink.count();
846 BranchObj* BranchObj::XLinkTargetAt (int i)
849 return xlink.at(i)->otherBranch (this);
854 void BranchObj::setIncludeImagesVer(bool b)
863 bool BranchObj::getIncludeImagesVer()
865 return includeImagesVer;
868 void BranchObj::setIncludeImagesHor(bool b)
877 bool BranchObj::getIncludeImagesHor()
879 return includeImagesHor;
882 QString BranchObj::getIncludeImageAttr()
885 if (includeImagesVer)
886 a=attribut ("incImgV","true");
888 a=attribut ("incImgV","false");
889 if (includeImagesHor)
890 a+=attribut ("incImgH","true");
892 a+=attribut ("incImgH","false");
896 LinkableMapObj* BranchObj::addFloatImage ()
898 FloatImageObj *newfi=new FloatImageObj (canvas,this);
899 floatimage.append (newfi);
900 if (hasScrolledParent(this) )
901 newfi->setVisibility (false);
903 newfi->setVisibility(visible);
911 LinkableMapObj* BranchObj::addFloatImage (FloatImageObj *fio)
913 FloatImageObj *newfi=new FloatImageObj (canvas,this);
914 floatimage.append (newfi);
916 if (hasScrolledParent(this) )
917 newfi->setVisibility (false);
919 newfi->setVisibility(visible);
927 FloatImageObj* BranchObj::getFirstFloatImage ()
929 return floatimage.first();
932 FloatImageObj* BranchObj::getLastFloatImage ()
934 return floatimage.last();
937 FloatImageObj* BranchObj::getFloatImageNum (const uint &i)
939 return floatimage.at(i);
942 void BranchObj::removeFloatImage (FloatImageObj *fio)
944 floatimage.remove (fio);
951 void BranchObj::savePosInAngle ()
953 // Save position in angle
956 for (b=branch.first(); b; b=branch.next() )
963 void BranchObj::setDefAttr (BranchModification mod)
968 case 0: fontsize=16; break;
969 case 1: fontsize=12; break;
970 default: fontsize=10; break;
974 setLinkStyle(getDefLinkStyle());
975 QFont font("Sans Serif,8,-1,5,50,0,0,0,0,0");
976 font.setPointSize(fontsize);
977 heading->setFont(font );
980 setColor (((BranchObj*)(parObj))->getColor());
985 BranchObj* BranchObj::addBranch()
987 BranchObj* newbo=new BranchObj(canvas,this);
988 branch.append (newbo);
989 newbo->setParObj(this);
990 newbo->setDefAttr(NewBranch);
991 newbo->setHeading ("new");
993 newbo->setVisibility (false);
995 newbo->setVisibility(visible);
1001 BranchObj* BranchObj::addBranch(BranchObj* bo)
1003 BranchObj* newbo=new BranchObj(canvas,this);
1004 branch.append (newbo);
1006 newbo->setParObj(this);
1007 newbo->setDefAttr(MovedBranch);
1009 newbo->setVisibility (false);
1011 newbo->setVisibility(bo->visible);
1012 newbo->updateLink();
1013 requestReposition();
1017 BranchObj* BranchObj::addBranchPtr(BranchObj* bo)
1020 bo->setParObj (this);
1022 bo->setDefAttr(MovedBranch);
1023 if (scrolled) tmpUnscroll();
1024 setLastSelectedBranch (bo);
1028 BranchObj* BranchObj::insertBranch(int pos)
1031 // Add new bo and resort branches
1032 BranchObj *newbo=addBranch ();
1033 newbo->angle=pos-0.5;
1038 BranchObj* BranchObj::insertBranch(BranchObj* bo, int pos)
1041 // Add new bo and resort branches
1043 BranchObj *newbo=addBranch (bo);
1048 BranchObj* BranchObj::insertBranchPtr (BranchObj* bo, int pos)
1051 // Add new bo and resort branches
1054 bo->setParObj (this);
1056 bo->setDefAttr (MovedBranch);
1057 if (scrolled) tmpUnscroll();
1058 setLastSelectedBranch (bo);
1063 void BranchObj::removeBranchHere(BranchObj* borem)
1065 // This removes the branch bo from list, but
1066 // inserts its childs at the place of bo
1068 bo=borem->getLastBranch();
1069 int pos=borem->getNum();
1072 bo->moveBranchTo (this,pos+1);
1073 bo=borem->getLastBranch();
1075 removeBranch (borem);
1078 void BranchObj::removeChilds()
1083 void BranchObj::removeBranch(BranchObj* bo)
1085 // if bo is not in branch remove returns false, we
1088 if (branch.remove (bo))
1091 qWarning ("BranchObj::removeBranch tried to remove non existing branch?!\n");
1092 requestReposition();
1095 void BranchObj::removeBranchPtr(BranchObj* bo)
1098 requestReposition();
1101 void BranchObj::setLastSelectedBranch (BranchObj* bo)
1103 lastSelectedBranch=branch.find(bo);
1106 BranchObj* BranchObj::getLastSelectedBranch ()
1108 if (lastSelectedBranch>=0)
1110 BranchObj* bo=branch.at(lastSelectedBranch);
1113 return branch.first();
1116 BranchObj* BranchObj::getFirstBranch ()
1118 return branch.first();
1121 BranchObj* BranchObj::getLastBranch ()
1123 return branch.last();
1126 BranchObj* BranchObj::getBranchNum (const uint &i)
1128 return branch.at(i);
1132 BranchObj* BranchObj::moveBranchUp(BranchObj* bo1) // move a branch up (modify myself)
1135 int i=branch.find(bo1);
1137 { // -1 if bo1 not found
1138 branch.at(i)->angle--;
1139 branch.at(i-1)->angle++;
1141 return branch.at(i-1);
1143 return branch.at(i);
1146 BranchObj* BranchObj::moveBranchDown(BranchObj* bo1)
1149 int i=branch.find(bo1);
1154 branch.at(i)->angle++;
1155 branch.at(j)->angle--;
1157 return branch.at(j);
1159 return branch.at(i);
1162 BranchObj* BranchObj::moveBranchTo (BranchObj* dst, int pos)
1164 // Find current parent and
1165 // remove pointer to myself there
1166 if (!dst) return NULL;
1167 BranchObj *par=(BranchObj*)(parObj);
1169 par->removeBranchPtr (this);
1173 // Create new pointer to myself at dst
1174 if (pos<0||dst->getDepth()==0)
1176 // links myself as last branch at dst
1177 dst->addBranchPtr (this);
1182 // inserts me at pos in parent of dst
1185 BranchObj *bo=dst->insertBranchPtr (this,pos);
1186 bo->setDefAttr(MovedBranch);
1195 void BranchObj::alignRelativeTo (QPoint ref)
1197 int th = bboxTotal.height();
1200 cout << "BO::alignRelTo "<<getHeading()<<endl;
1201 cout << " d="<<depth<<
1203 // " bbox.topLeft="<<bboxTotal.topLeft()<<
1204 " absPos="<<absPos<<
1205 // " pad="<<topPad<<","<<botPad<<","<<leftPad<<","<<rightPad<<
1206 " hidden="<<hidden<<
1210 // If I am the mapcenter or a mainbranch, reposition heading
1212 { //FIXME optimize this move for MCO needed to initially position text in box...
1215 move (absPos.x(),absPos.y());
1216 // Calc angle to mapCenter if I am a mainbranch
1217 // needed for reordering the mainbranches clockwise
1219 angle=getAngle (QPoint ((int)(x() - parObj->getChildPos().x() ),
1220 (int)(y() - parObj->getChildPos().y() ) ) );
1225 // Align myself depending on orientation and parent, but
1226 // only if I am not the mainbranch or mapcenter itself
1227 switch (orientation)
1229 case OrientLeftOfCenter:
1230 move (ref.x() - bbox.width(), ref.y() + (th-bbox.height())/2 );
1232 case OrientRightOfCenter:
1233 move (ref.x() , ref.y() + (th-bbox.height())/2 );
1236 qWarning ("LMO::alignRelativeTo: oops, no orientation given...");
1241 if (scrolled) return;
1243 // Set reference point for alignment of childs
1245 if (orientation==OrientLeftOfCenter)
1246 ref2.setX(bbox.topLeft().x() - linkwidth);
1248 ref2.setX(bbox.topRight().x() + linkwidth);
1251 ref2.setY(absPos.y()-(bboxTotal.height()-bbox.height())/2);
1253 ref2.setY(ref.y() );
1255 // Align the childs depending on reference point
1257 for (b=branch.first(); b; b=branch.next() )
1261 b->alignRelativeTo (ref2);
1262 ref2.setY(ref2.y() + b->getBBoxSizeWithChilds().height() );
1268 void BranchObj::reposition()
1270 /* TODO testing only
1271 if (!getHeading().isEmpty())
1272 cout << "BO::reposition "<<getHeading()<<endl;
1274 cout << "BO::reposition ???"<<endl;
1278 // only calculate the sizes once. If the deepest LMO
1279 // changes its height,
1280 // all upper LMOs have to change, too.
1281 calcBBoxSizeWithChilds();
1282 alignRelativeTo ( QPoint (absPos.x(),
1283 absPos.y()-(bboxTotal.height()-bbox.height())/2) );
1285 updateLink(); // This update is needed if the canvas is resized
1286 // due to excessive moving of a FIO
1288 // After load, the floats might be at wrong position, force
1289 // them to move, too
1290 //move (absPos); // FIXME really still needed to position floats?
1293 // This is only important for moving branches:
1294 // For editing a branch it isn't called...
1295 alignRelativeTo ( QPoint (absPos.x(),
1296 absPos.y()-(bboxTotal.height()-bbox.height())/2) );
1301 QRect BranchObj::getTotalBBox()
1305 if (scrolled) return r;
1308 for (b=branch.first();b ;b=branch.next() )
1310 r=addBBox(b->getTotalBBox(),r);
1313 for (fio=floatimage.first();fio ;fio=floatimage.next() )
1314 if (!fio->isHidden())
1315 r=addBBox(fio->getTotalBBox(),r);
1320 QRect BranchObj::getBBoxSizeWithChilds()
1325 void BranchObj::calcBBoxSizeWithChilds()
1327 // This is initially called only from reposition and
1328 // and only for mapcenter. So it won't be
1329 // called more than once for a single user
1333 // Calculate size of LMO including all childs (to align them later)
1334 bboxTotal.setX(bbox.x() );
1335 bboxTotal.setY(bbox.y() );
1337 // if branch is scrolled, ignore childs, but still consider floatimages
1340 bboxTotal.setWidth (bbox.width());
1341 bboxTotal.setHeight(bbox.height());
1347 bboxTotal.setWidth (0);
1348 bboxTotal.setHeight(0);
1351 bboxTotal.setX (parObj->x());
1352 bboxTotal.setY (parObj->y());
1355 bboxTotal.setX (bbox.x());
1356 bboxTotal.setY (bbox.y());
1363 // Now calculate recursivly
1365 // maximum of widths
1368 for (b=branch.first();b ;b=branch.next() )
1372 b->calcBBoxSizeWithChilds();
1373 br=b->getBBoxSizeWithChilds();
1374 r.setWidth( max (br.width(), r.width() ));
1375 r.setHeight(br.height() + r.height() );
1376 if (br.y()<bboxTotal.y()) bboxTotal.setY(br.y());
1379 // Add myself and also
1380 // add width of link to sum if necessary
1381 if (branch.isEmpty())
1382 bboxTotal.setWidth (bbox.width() + r.width() );
1384 bboxTotal.setWidth (bbox.width() + r.width() + linkwidth);
1386 bboxTotal.setHeight(max (r.height(), bbox.height()));
1389 void BranchObj::select()
1391 // set Text in Editor
1392 textEditor->setText(note.getNote() );
1393 QString fnh=note.getFilenameHint();
1395 textEditor->setFilenameHint(note.getFilenameHint() );
1397 textEditor->setFilenameHint(getHeading() );
1398 textEditor->setFontHint (note.getFontHint() );
1400 LinkableMapObj::select();
1401 // Tell parent that I am selected now:
1402 BranchObj* po=(BranchObj*)(parObj);
1403 if (po) // TODO Try to get rid of this cast...
1404 po->setLastSelectedBranch(this);
1406 // temporary unscroll, if we have scrolled parents somewhere
1407 if (parObj) ((BranchObj*)(parObj))->tmpUnscroll();
1409 // Show URL and link in statusbar
1411 if (!url.isEmpty()) status+="URL: "+url+" ";
1412 if (!vymLink.isEmpty()) status+="Link: "+vymLink;
1413 if (!status.isEmpty()) mainWindow->statusMessage (status);
1416 standardFlags->updateToolbar();
1418 // Update actions in mapeditor
1419 mapEditor->updateActions();
1422 void BranchObj::unselect()
1424 LinkableMapObj::unselect();
1425 // Delete any messages like vymLink in StatusBar
1426 mainWindow->statusMessage ("");
1428 // save note from editor and set flag
1429 // text is done by updateNoteFlag(), just save
1431 note.setFilenameHint (textEditor->getFilename());
1433 // reset temporary unscroll, if we have scrolled parents somewhere
1434 if (parObj) ((BranchObj*)(parObj))->resetTmpUnscroll();
1436 // Erase content of editor
1437 textEditor->setInactive();
1439 // unselect all buttons in toolbar
1440 standardFlagsDefault->updateToolbar();
1443 QString BranchObj::getSelectString()
1449 s= "bo:" + QString("%1").arg(getNum());
1451 s= ((BranchObj*)(parObj))->getSelectString() + ",bo:" + QString("%1").arg(getNum());