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;
112 void BranchObj::copy (BranchObj* other)
114 OrnamentedObj::copy(other);
118 for (b=other->branch.first(); b;b=other->branch.next() )
119 // Make deep copy of b
120 // Because addBranch again calls copy for the childs,
121 // Those will get a deep copy, too
125 for (fi=other->floatimage.first(); fi;fi=other->floatimage.next() )
128 scrolled=other->scrolled;
129 tmpUnscrolled=other->tmpUnscrolled;
130 setVisibility (other->visible);
133 vymLink=other->vymLink;
140 void BranchObj::clear()
143 while (!xlink.isEmpty())
144 deleteXLink (xlink.first() );
147 while (!branch.isEmpty())
150 branch.removeFirst();
155 int BranchObj::getNum()
158 return ((BranchObj*)(parObj))->getNum ((BranchObj*)(this));
163 int BranchObj::getNum(BranchObj *bo)
165 // keep current pointer in branch,
166 // otherwise save might fail
168 int ind=branch.findRef (bo);
173 int BranchObj::getFloatImageNum(FloatImageObj *fio)
175 return floatimage.findRef (fio);
178 int BranchObj::countBranches()
180 return branch.count();
183 int BranchObj::countFloatImages()
185 return floatimage.count();
188 int BranchObj::countXLinks()
190 return xlink.count();
193 void BranchObj::setParObjTmp(LinkableMapObj* lmo, QPoint m, int off)
195 // Temporary link to lmo
196 // m is position of mouse pointer
197 // offset 0: default 1: below lmo -1 above lmo (if possible)
200 BranchObj* o=(BranchObj*)(lmo);
204 // ignore mapcenter and mainbranch
205 if (lmo->getDepth()<2) off=0;
212 depth=parObj->getDepth()+1;
214 // setLinkStyle calls updateLink, only set it once
215 if (style!=getDefLinkStyle() ) setLinkStyle (getDefLinkStyle());
217 // Move temporary to new position at destination
218 // Usually the positioning would be done by reposition(),
219 // but then also the destination branch would "Jump" around...
220 // Better just do it approximately
222 { // new parent is the mapcenter itself
224 QPoint p= normalise ( QPoint (m.x() - o->getChildPos().x(),
225 m.y() - o->getChildPos().y() ));
226 if (p.x()<0) p.setX( p.x()-bbox.width() );
233 // new parent is just a branch, link to it
234 QRect t=o->getBBoxSizeWithChilds();
235 if (o->getLastBranch())
236 y=t.y() + t.height() ;
243 // we want to link above lmo
244 y=o->y() - height() + 5;
246 // we want to link below lmo
247 // Bottom of sel should be 5 pixels above
248 // the bottom of the branch _below_ the target:
249 // Don't try to find that branch, guess 12 pixels
250 y=o->getChildPos().y() -height() + 12;
252 if (o->getOrientation()==OrientLeftOfCenter)
253 move ( o->getChildPos().x() - linkwidth, y );
255 move (o->getChildPos().x() + linkwidth, y );
258 // updateLink is called implicitly in move
259 reposition(); // FIXME shouldn't be this a request?
262 void BranchObj::unsetParObjTmp()
269 depth=parObj->getDepth()+1;
270 setLinkStyle (getDefLinkStyle() );
275 void BranchObj::unScroll()
277 if (tmpUnscrolled) resetTmpUnscroll();
278 if (scrolled) toggleScroll();
281 void BranchObj::toggleScroll()
287 systemFlags->deactivate("scrolledright");
288 for (bo=branch.first(); bo; bo=branch.next() )
290 bo->setVisibility(true);
295 systemFlags->activate("scrolledright");
296 for (bo=branch.first(); bo; bo=branch.next() )
298 bo->setVisibility(false);
303 move (absPos.x(), absPos.y() );
307 bool BranchObj::isScrolled()
312 bool BranchObj::hasScrolledParent(BranchObj *start)
314 // Calls parents recursivly to
315 // find out, if we are scrolled at all.
316 // But ignore myself, just look at parents.
318 if (this !=start && scrolled) return true;
320 BranchObj* bo=(BranchObj*)(parObj);
322 return bo->hasScrolledParent(start);
327 void BranchObj::tmpUnscroll()
329 // Unscroll parent (recursivly)
330 BranchObj* bo=(BranchObj*)(parObj);
331 if (bo) bo->tmpUnscroll();
337 systemFlags->activate("tmpUnscrolledright");
342 void BranchObj::resetTmpUnscroll()
344 // Unscroll parent (recursivly)
345 BranchObj* bo=(BranchObj*)(parObj);
347 bo->resetTmpUnscroll();
353 systemFlags->deactivate("tmpUnscrolledright");
358 void BranchObj::setVisibility(bool v, int toDepth)
360 if (depth <= toDepth)
362 frame->setVisibility(v);
363 heading->setVisibility(v);
364 systemFlags->setVisibility(v);
365 standardFlags->setVisibility(v);
366 LinkableMapObj::setVisibility (v);
368 if (!scrolled && (depth < toDepth))
370 // Now go recursivly through all childs
372 for (b=branch.first(); b;b=branch.next() )
373 b->setVisibility (v,toDepth);
375 for (fio=floatimage.first(); fio; fio=floatimage.next())
376 fio->setVisibility (v);
378 for (xlo=xlink.first(); xlo;xlo=xlink.next() )
379 xlo->setVisibility ();
381 } // depth <= toDepth
385 void BranchObj::setVisibility(bool v)
387 setVisibility (v,MAX_DEPTH);
391 void BranchObj::setLinkColor ()
393 // Overloaded from LinkableMapObj
394 // BranchObj can use color of heading
397 if (mapEditor->getLinkColorHint()==HeadingColor)
398 LinkableMapObj::setLinkColor (heading->getColor() );
400 LinkableMapObj::setLinkColor ();
403 void BranchObj::setColor (QColor col, bool colorChilds)
405 heading->setColor(col);
410 for (bo=branch.first(); bo; bo=branch.next() )
411 bo->setColor(col,colorChilds);
415 QColor BranchObj::getColor()
417 return heading->getColor();
420 BranchObj* BranchObj::first()
426 BranchObj* BranchObj::next()
429 BranchObj *bo=branch.first();
430 BranchObj *po=(BranchObj*)(parObj);
433 { // We are just beginning at the mapCenter
447 { // We come from above
450 // there are childs, go there
455 { // no childs, try to go up again
467 // can't go up, I am mapCenter
474 // Try to find last child, we came from, in my own childs
476 while (bo && searching)
478 if (itLast==bo) searching=false;
482 { // found lastLMO in my childs
485 // found a brother of lastLMO
501 // can't go up, I am mapCenter
508 // couldn't find last child, it must be a nephew of mine
512 // proceed with my first child
518 // or go back to my parents
529 // can't go up, I am mapCenter
536 BranchObj* BranchObj::getLastIterator()
541 void BranchObj::setLastIterator(BranchObj* it)
547 void BranchObj::move (double x, double y)
549 OrnamentedObj::move (x,y);
551 for (fio=floatimage.first(); fio; fio=floatimage.next() )
556 void BranchObj::move (QPoint p)
561 void BranchObj::moveBy (double x, double y)
563 OrnamentedObj::moveBy (x,y);
566 for (b=branch.first(); b;b=branch.next() )
570 void BranchObj::moveBy (QPoint p)
572 moveBy (p.x(), p.y());
576 void BranchObj::positionBBox()
578 /*// TODO testing (optimization)
579 QString h=getHeading();
581 cout << "BO::positionBBox("<<h<<")\n";
583 cout << "BO::positionBBox (noHeading)\n";
588 int d=frame->getBorder()/2;
590 bbox.moveTopLeft (QPoint (absPos.x(), absPos.y() - topPad));
591 clickBox.moveTopLeft(QPoint (absPos.x()+d, absPos.y()+d ));
596 frame->setRect(QRect(bbox.x(),bbox.y(),bbox.width(),bbox.height() ) );
598 // Update links to other branches
600 for (xlo=xlink.first(); xlo; xlo=xlink.next() )
604 void BranchObj::calcBBoxSize()
606 QSize heading_r=heading->getSize();
607 int heading_w=static_cast <int> (heading_r.width() );
608 int heading_h=static_cast <int> (heading_r.height() );
609 QSize sysflags_r=systemFlags->getSize();
610 int sysflags_h=sysflags_r.height();
611 int sysflags_w=sysflags_r.width();
612 QSize stanflags_r=standardFlags->getSize();
613 int stanflags_h=stanflags_r.height();
614 int stanflags_w=stanflags_r.width();
618 // set width to sum of all widths
619 w=heading_w + sysflags_w + stanflags_w;
620 // set height to maximum needed height
621 h=max (sysflags_h,stanflags_h);
624 clickBox.setSize (QSize (w,h));
630 topPad=botPad=leftPad=rightPad=0;
631 if (includeImagesVer || includeImagesHor)
633 if (countFloatImages()>0)
635 for (foi=floatimage.first(); foi; foi=floatimage.next() )
638 if (includeImagesVer)
641 topPad=max (topPad,-rp.y());
642 if (rp.y()+foi->height() > h)
643 botPad=max (botPad,rp.y()+foi->height()-h);
645 if (includeImagesHor)
648 leftPad=max (leftPad,-rp.x());
649 if (rp.x()+foi->width() > w)
650 rightPad=max (rightPad,rp.x()+foi->width()-w);
659 w+=frame->getBorder();
660 h+=frame->getBorder();
663 bbox.setSize (QSize (w,h));
666 LinkableMapObj* BranchObj::findMapObj(QPoint p, LinkableMapObj* excludeLMO)
671 for (b=branch.first(); b; b=branch.next() )
673 lmo=b->findMapObj(p, excludeLMO);
674 if (lmo != NULL) return lmo;
678 if (inBox (p) && (this != excludeLMO) && isVisibleObj() )
681 // Search float images
683 for (foi=floatimage.first(); foi; foi=floatimage.next() )
685 (foi != excludeLMO) &&
686 foi->getParObj()!= excludeLMO &&
693 void BranchObj::setHeading(QString s)
695 heading->setText(s); // set new heading
696 calcBBoxSize(); // recalculate bbox
697 positionBBox(); // rearrange contents
701 void BranchObj::setURL(QString s)
705 systemFlags->activate("url");
707 systemFlags->deactivate("url");
708 calcBBoxSize(); // recalculate bbox
709 positionBBox(); // rearrange contents
713 QString BranchObj::getURL()
718 void BranchObj::setVymLink(QString s)
722 // We need the relative (from loading)
723 // or absolute path (from User event)
724 // and build the absolute path.
725 // Note: If we have relative, use path of
726 // current map to build absolute path
728 if (!d.path().startsWith ("/"))
730 QString p=mapEditor->getDestPath();
731 int i=p.findRev("/",-1);
732 d.setPath(p.left(i)+"/"+s);
736 systemFlags->activate("vymLink");
740 systemFlags->deactivate("vymLink");
743 calcBBoxSize(); // recalculate bbox
744 positionBBox(); // rearrange contents
748 QString BranchObj::getVymLink()
753 QString BranchObj::saveToDir (const QString &tmpdir,const QString &prefix, const QPoint& offset)
756 QString scrolledAttr;
758 scrolledAttr=attribut ("scrolled","yes");
763 if (depth<2) posAttr=
764 attribut("absPosX",QString().setNum(absPos.x(),10)) +
765 attribut("absPosY",QString().setNum(absPos.y(),10));
769 QString linkAttr=getLinkAttr()+" "+getIncludeImageAttr();
774 urlAttr=attribut ("url",url);
777 if (!vymLink.isEmpty())
778 vymLinkAttr=attribut ("vymLink",convertToRel(mapEditor->getDestPath(),vymLink) );
781 if (frame->getFrameType()!=NoFrame)
782 frameAttr=attribut ("frameType",frame->getFrameTypeName());
786 // save area, if not scrolled
788 if (!((BranchObj*)(parObj))->isScrolled() )
791 attribut("x1",QString().setNum(absPos.x()-offset.x(),10)) +
792 attribut("y1",QString().setNum(absPos.y()-offset.y(),10)) +
793 attribut("x2",QString().setNum(absPos.x()+width()-offset.x(),10)) +
794 attribut("y2",QString().setNum(absPos.y()+height()-offset.y(),10));
799 // Providing an ID for a branch makes export to XHTML easier
802 idAttr=attribut ("id",getSelectString());
806 s=beginElement ("branch" +scrolledAttr +posAttr +linkAttr +urlAttr +vymLinkAttr +frameAttr +areaAttr +idAttr);
810 s+=valueElement("heading", getHeading(),
811 attribut ("textColor",QColor(heading->getColor()).name()));
813 // save names of flags set
814 s+=standardFlags->saveToDir(tmpdir,prefix,0);
817 if (!note.isEmpty() )
822 for (bo=branch.first(); bo; bo=branch.next() )
823 s+=bo->saveToDir(tmpdir,prefix,offset);
827 for (fio=floatimage.first(); fio; fio=floatimage.next() )
828 s+=fio->saveToDir (tmpdir,prefix,offset);
832 for (xlo=xlink.first(); xlo; xlo=xlink.next() )
836 s+=endElement ("branch");
840 void BranchObj::addXLink (XLinkObj *xlo)
846 void BranchObj::removeXLinkRef (XLinkObj *xlo)
851 void BranchObj::deleteXLink(XLinkObj *xlo)
854 if (!xlo->isUsed()) delete (xlo);
857 void BranchObj::deleteXLinkAt (int i)
859 XLinkObj *xlo=xlink.at(i);
861 if (!xlo->isUsed()) delete(xlo);
864 XLinkObj* BranchObj::XLinkAt (int i)
869 int BranchObj::countXLink()
871 return xlink.count();
874 BranchObj* BranchObj::XLinkTargetAt (int i)
877 return xlink.at(i)->otherBranch (this);
882 void BranchObj::setIncludeImagesVer(bool b)
891 bool BranchObj::getIncludeImagesVer()
893 return includeImagesVer;
896 void BranchObj::setIncludeImagesHor(bool b)
905 bool BranchObj::getIncludeImagesHor()
907 return includeImagesHor;
910 QString BranchObj::getIncludeImageAttr()
913 if (includeImagesVer)
914 a=attribut ("incImgV","true");
916 a=attribut ("incImgV","false");
917 if (includeImagesHor)
918 a+=attribut ("incImgH","true");
920 a+=attribut ("incImgH","false");
924 LinkableMapObj* BranchObj::addFloatImage ()
926 FloatImageObj *newfi=new FloatImageObj (canvas,this);
927 floatimage.append (newfi);
928 if (hasScrolledParent(this) )
929 newfi->setVisibility (false);
931 newfi->setVisibility(visible);
939 LinkableMapObj* BranchObj::addFloatImage (FloatImageObj *fio)
941 FloatImageObj *newfi=new FloatImageObj (canvas,this);
942 floatimage.append (newfi);
944 if (hasScrolledParent(this) )
945 newfi->setVisibility (false);
947 newfi->setVisibility(visible);
955 FloatImageObj* BranchObj::getFirstFloatImage ()
957 return floatimage.first();
960 FloatImageObj* BranchObj::getLastFloatImage ()
962 return floatimage.last();
965 FloatImageObj* BranchObj::getFloatImageNum (const uint &i)
967 return floatimage.at(i);
970 void BranchObj::removeFloatImage (FloatImageObj *fio)
972 floatimage.remove (fio);
979 void BranchObj::savePosInAngle ()
981 // Save position in angle
984 for (b=branch.first(); b; b=branch.next() )
991 void BranchObj::setDefAttr (BranchModification mod)
996 case 0: fontsize=16; break;
997 case 1: fontsize=12; break;
998 default: fontsize=10; break;
1002 setLinkStyle(getDefLinkStyle());
1003 QFont font("Sans Serif,8,-1,5,50,0,0,0,0,0");
1004 font.setPointSize(fontsize);
1005 heading->setFont(font );
1008 setColor (((BranchObj*)(parObj))->getColor(),false);
1013 BranchObj* BranchObj::addBranch()
1015 BranchObj* newbo=new BranchObj(canvas,this);
1016 branch.append (newbo);
1017 newbo->setParObj(this);
1018 newbo->setDefAttr(NewBranch);
1019 newbo->setHeading ("new");
1021 newbo->setVisibility (false);
1023 newbo->setVisibility(visible);
1024 newbo->updateLink();
1025 requestReposition();
1029 BranchObj* BranchObj::addBranch(BranchObj* bo)
1031 BranchObj* newbo=new BranchObj(canvas,this);
1032 branch.append (newbo);
1034 newbo->setParObj(this);
1035 newbo->setDefAttr(MovedBranch);
1037 newbo->setVisibility (false);
1039 newbo->setVisibility(bo->visible);
1040 newbo->updateLink();
1041 requestReposition();
1045 BranchObj* BranchObj::addBranchPtr(BranchObj* bo)
1048 bo->setParObj (this);
1050 bo->setDefAttr(MovedBranch);
1051 if (scrolled) tmpUnscroll();
1052 setLastSelectedBranch (bo);
1056 BranchObj* BranchObj::insertBranch(int pos)
1059 // Add new bo and resort branches
1060 BranchObj *newbo=addBranch ();
1061 newbo->angle=pos-0.5;
1066 BranchObj* BranchObj::insertBranch(BranchObj* bo, int pos)
1069 // Add new bo and resort branches
1071 BranchObj *newbo=addBranch (bo);
1076 BranchObj* BranchObj::insertBranchPtr (BranchObj* bo, int pos)
1079 // Add new bo and resort branches
1082 bo->setParObj (this);
1084 bo->setDefAttr (MovedBranch);
1085 if (scrolled) tmpUnscroll();
1086 setLastSelectedBranch (bo);
1091 void BranchObj::removeBranchHere(BranchObj* borem)
1093 // This removes the branch bo from list, but
1094 // inserts its childs at the place of bo
1096 bo=borem->getLastBranch();
1097 int pos=borem->getNum();
1100 bo->moveBranchTo (this,pos+1);
1101 bo=borem->getLastBranch();
1103 removeBranch (borem);
1106 void BranchObj::removeChilds()
1111 void BranchObj::removeBranch(BranchObj* bo)
1113 // if bo is not in branch remove returns false, we
1116 if (branch.remove (bo))
1119 qWarning ("BranchObj::removeBranch tried to remove non existing branch?!\n");
1120 requestReposition();
1123 void BranchObj::removeBranchPtr(BranchObj* bo)
1126 requestReposition();
1129 void BranchObj::setLastSelectedBranch (BranchObj* bo)
1131 lastSelectedBranch=branch.find(bo);
1134 BranchObj* BranchObj::getLastSelectedBranch ()
1136 if (lastSelectedBranch>=0)
1138 BranchObj* bo=branch.at(lastSelectedBranch);
1141 return branch.first();
1144 BranchObj* BranchObj::getFirstBranch ()
1146 return branch.first();
1149 BranchObj* BranchObj::getLastBranch ()
1151 return branch.last();
1154 BranchObj* BranchObj::getBranchNum (const uint &i)
1156 return branch.at(i);
1160 BranchObj* BranchObj::moveBranchUp(BranchObj* bo1) // move a branch up (modify myself)
1163 int i=branch.find(bo1);
1165 { // -1 if bo1 not found
1166 branch.at(i)->angle--;
1167 branch.at(i-1)->angle++;
1169 return branch.at(i-1);
1171 return branch.at(i);
1174 BranchObj* BranchObj::moveBranchDown(BranchObj* bo1)
1177 int i=branch.find(bo1);
1182 branch.at(i)->angle++;
1183 branch.at(j)->angle--;
1185 return branch.at(j);
1187 return branch.at(i);
1190 BranchObj* BranchObj::moveBranchTo (BranchObj* dst, int pos)
1192 // Find current parent and
1193 // remove pointer to myself there
1194 if (!dst) return NULL;
1195 BranchObj *par=(BranchObj*)(parObj);
1197 par->removeBranchPtr (this);
1201 // Create new pointer to myself at dst
1202 if (pos<0||dst->getDepth()==0)
1204 // links myself as last branch at dst
1205 dst->addBranchPtr (this);
1210 // inserts me at pos in parent of dst
1213 BranchObj *bo=dst->insertBranchPtr (this,pos);
1214 bo->setDefAttr(MovedBranch);
1223 void BranchObj::alignRelativeTo (QPoint ref)
1225 int th = bboxTotal.height();
1227 if (!getHeading().isEmpty())
1228 cout << "BO::alignRelTo "<<getHeading()<<endl;
1230 cout << "BO::alignRelTo ???"<<endl;
1231 cout << " d="<<depth<<
1233 // " bbTot="<<bboxTotal.topLeft()<<
1234 // " absPos="<<absPos<<
1235 " pad="<<topPad<<","<<botPad<<","<<leftPad<<","<<rightPad<<
1239 // If I am the mapcenter or a mainbranch, reposition heading
1241 { //FIXME optimize this move for MCO needed to initially position text in box...
1244 move (absPos.x(),absPos.y());
1245 // Calc angle to mapCenter if I am a mainbranch
1246 // needed for reordering the mainbranches clockwise
1248 angle=getAngle (QPoint ((int)(x() - parObj->getChildPos().x() ),
1249 (int)(y() - parObj->getChildPos().y() ) ) );
1254 // Align myself depending on orientation and parent, but
1255 // only if I am not the mainbranch or mapcenter itself
1256 switch (orientation)
1258 case OrientLeftOfCenter:
1259 move (ref.x() + rightPad - bbox.width(), ref.y() + (th-bbox.height())/2 +topPad);
1261 case OrientRightOfCenter:
1262 move (ref.x() + rightPad, ref.y() + (th-bbox.height())/2 + topPad);
1265 cout <<"LMO::alignRelativeTo: oops, no orientation given...\n";
1270 if (scrolled) return;
1272 // Set reference point for alignment of childs
1274 if (orientation==OrientLeftOfCenter)
1275 ref2.setX(childPos.x() - linkwidth);
1277 ref2.setX(childPos.x() + linkwidth);
1280 ref2.setY(absPos.y()-(bboxTotal.height()-bbox.height())/2);
1282 ref2.setY(ref.y() );
1284 // Align the childs depending on reference point
1286 for (b=branch.first(); b; b=branch.next() )
1288 b->alignRelativeTo (ref2);
1289 ref2.setY(ref2.y() + b->getBBoxSizeWithChilds().height() );
1294 void BranchObj::reposition()
1296 /* TODO testing only
1297 if (!getHeading().isEmpty())
1298 cout << "BO::reposition "<<getHeading()<<endl;
1300 cout << "BO::reposition ???"<<endl;
1304 // only calculate the sizes once. If the deepest LMO
1305 // changes its height,
1306 // all upper LMOs have to change, too.
1307 calcBBoxSizeWithChilds();
1308 alignRelativeTo ( QPoint (absPos.x(),
1309 absPos.y()-(bboxTotal.height()-bbox.height())/2) );
1312 // After load, the floats might be at wrong position, force
1313 // them to move, too
1317 // This is only important for moving branches:
1318 // For editing a branch it isn't called...
1319 alignRelativeTo ( QPoint (absPos.x(),
1320 absPos.y()-(bboxTotal.height()-bbox.height())/2) );
1325 QRect BranchObj::getTotalBBox()
1329 if (scrolled) return r;
1332 for (b=branch.first();b ;b=branch.next() )
1333 r=addBBox(b->getTotalBBox(),r);
1336 for (fio=floatimage.first();fio ;fio=floatimage.next() )
1337 r=addBBox(fio->getTotalBBox(),r);
1342 QRect BranchObj::getBBoxSizeWithChilds()
1347 void BranchObj::calcBBoxSizeWithChilds()
1349 // This is initially called only from reposition and
1350 // and only for mapcenter. So it won't be
1351 // called more than once for a single user
1355 // Calculate size of LMO including all childs (to align them later)
1356 bboxTotal.setX(bbox.x() );
1357 bboxTotal.setY(bbox.y() );
1359 // if branch is scrolled, ignore childs, but still consider floatimages
1362 bboxTotal.setWidth (bbox.width());
1363 bboxTotal.setHeight(bbox.height());
1369 // Now calculate recursivly
1371 // maximum of widths
1374 for (b=branch.first();b ;b=branch.next() )
1376 b->calcBBoxSizeWithChilds();
1377 br=b->getBBoxSizeWithChilds();
1378 r.setWidth( max (br.width(), r.width() ));
1379 r.setHeight(br.height() + r.height() );
1380 if (br.y()<bboxTotal.y()) bboxTotal.setY(br.y());
1382 // Add myself and also
1383 // add width of link to sum if necessary
1384 if (branch.isEmpty())
1385 bboxTotal.setWidth (bbox.width() + r.width() );
1387 bboxTotal.setWidth (bbox.width() + r.width() + linkwidth);
1389 bboxTotal.setHeight(max (r.height(), bbox.height()));
1390 // frame->setRect(QRect(bbox.x(),bbox.y(),bbox.width(),bbox.height() ) );
1394 void BranchObj::select()
1396 // set Text in Editor
1397 textEditor->setText(note.getNote() );
1398 QString fnh=note.getFilenameHint();
1400 textEditor->setFilenameHint(note.getFilenameHint() );
1402 textEditor->setFilenameHint(getHeading() );
1403 textEditor->setFontHint (note.getFontHint() );
1405 LinkableMapObj::select();
1406 // Tell parent that I am selected now:
1407 BranchObj* po=(BranchObj*)(parObj);
1408 if (po) // TODO Try to get rid of this cast...
1409 po->setLastSelectedBranch(this);
1411 // temporary unscroll, if we have scrolled parents somewhere
1412 if (parObj) ((BranchObj*)(parObj))->tmpUnscroll();
1414 // Show URL and link in statusbar
1416 if (!url.isEmpty()) status+="URL: "+url+" ";
1417 if (!vymLink.isEmpty()) status+="Link: "+vymLink;
1418 if (!status.isEmpty()) mainWindow->statusMessage (status);
1421 standardFlags->updateToolbar();
1423 // Update Browserbutton
1425 actionEditOpenURL->setEnabled (true);
1427 actionEditOpenURL->setEnabled (false);
1429 // Update actions in mapeditor
1430 mapEditor->updateActions();
1433 void BranchObj::unselect()
1435 LinkableMapObj::unselect();
1436 // Delete any messages like vymLink in StatusBar
1437 mainWindow->statusMessage ("");
1439 // save note from editor and set flag
1440 // text is done by updateNoteFlag(), just save
1442 note.setFilenameHint (textEditor->getFilename());
1444 // reset temporary unscroll, if we have scrolled parents somewhere
1445 if (parObj) ((BranchObj*)(parObj))->resetTmpUnscroll();
1447 // Erase content of editor
1448 textEditor->setInactive();
1450 // unselect all buttons in toolbar
1451 standardFlagsDefault->updateToolbar();
1454 QString BranchObj::getSelectString()
1460 s= "bo:" + QString("%1").arg(getNum());
1462 s= ((BranchObj*)(parObj))->getSelectString() + ",bo:" + QString("%1").arg(getNum());