Removed more QT3 stuff. Drag & Drop not 100% functional at the moment
2 #include "texteditor.h"
4 #include "mainwindow.h"
6 extern TextEditor *textEditor;
7 extern Main *mainWindow;
8 extern FlagRowObj *standardFlagsDefault;
11 /* FIXME not needed any longer in QT4
12 int BranchObjPointrList::compareItems ( Q3PtrCollection::Item i, Q3PtrCollection::Item j)
14 // Make sure PtrList::find works
17 if ( ((BranchObj*)(i))->angle > ((BranchObj*)(j))->angle )
24 /////////////////////////////////////////////////////////////////
26 /////////////////////////////////////////////////////////////////
28 BranchObj* BranchObj::itLast=NULL;
29 BranchObj* BranchObj::itFirst=NULL;
32 BranchObj::BranchObj () :OrnamentedObj()
34 // cout << "Const BranchObj ()\n";
40 BranchObj::BranchObj (Q3Canvas* c):OrnamentedObj (c)
42 // cout << "Const BranchObj (c) called from MapCenterObj (c)\n";
47 BranchObj::BranchObj (Q3Canvas* c, LinkableMapObj* p):OrnamentedObj (c)
49 // cout << "Const BranchObj (c,p)\n";
52 depth=p->getDepth()+1;
54 // Calc angle to mapCenter if I am a mainbranch
55 // needed for reordering the mainbranches clockwise
57 angle=getAngle (QPoint ((int)(x() - parObj->getChildPos().x() ),
58 (int)(y() - parObj->getChildPos().y() ) ) );
62 BranchObj::~BranchObj ()
64 // cout << "Destr BranchObj of "<<this<<endl;
65 // Check, if this branch was the last child to be deleted
66 // If so, unset the scrolled flags
68 BranchObj *po=(BranchObj*)(parObj);
72 bo=((BranchObj*)(parObj))->getLastBranch();
73 if (!bo) po->unScroll();
78 bool BranchObj::operator< ( const BranchObj & other )
80 return angle < other.angle;
83 bool BranchObj::operator== ( const BranchObj & other )
85 return angle == other.angle;
88 void BranchObj::init ()
93 absPos+=parObj->getChildPos();
96 lastSelectedBranch=-1;
103 includeImagesVer=false;
104 includeImagesHor=false;
107 void BranchObj::copy (BranchObj* other)
109 OrnamentedObj::copy(other);
112 for (int i=0; i<other->branch.size(); ++i)
113 // Make deep copy of b
114 // Because addBranch again calls copy for the childs,
115 // Those will get a deep copy, too
116 addBranch(other->branch.at(i) );
118 for (int i=0; i<other->floatimage.size(); ++i)
119 addFloatImage (other->floatimage.at(i));
120 scrolled=other->scrolled;
121 tmpUnscrolled=other->tmpUnscrolled;
122 setVisibility (other->visible);
129 void BranchObj::clear()
131 while (!floatimage.isEmpty())
132 delete floatimage.takeFirst();
134 while (!xlink.isEmpty())
135 delete xlink.takeFirst();
137 while (!branch.isEmpty())
138 delete branch.takeFirst();
141 int BranchObj::getNum()
144 return ((BranchObj*)parObj)->getNum (this);
149 int BranchObj::getNum(BranchObj *bo)
151 return branch.indexOf (bo);
154 int BranchObj::getFloatImageNum(FloatImageObj *fio)
156 return floatimage.indexOf(fio);
159 int BranchObj::countBranches()
161 return branch.count();
164 int BranchObj::countFloatImages()
166 return floatimage.count();
169 int BranchObj::countXLinks()
171 return xlink.count();
174 void BranchObj::setParObjTmp(LinkableMapObj* lmo, QPoint m, int off)
176 // Temporary link to lmo
177 // m is position of mouse pointer
178 // offset 0: default 1: below lmo -1 above lmo (if possible)
181 BranchObj* o=(BranchObj*)(lmo);
185 // ignore mapcenter and mainbranch
186 if (lmo->getDepth()<2) off=0;
193 depth=parObj->getDepth()+1;
195 // setLinkStyle calls updateLink, only set it once
196 if (style!=getDefLinkStyle() ) setLinkStyle (getDefLinkStyle());
198 // Move temporary to new position at destination
199 // Usually the positioning would be done by reposition(),
200 // but then also the destination branch would "Jump" around...
201 // Better just do it approximately
203 { // new parent is the mapcenter itself
205 QPoint p= normalise ( QPoint (m.x() - o->getChildPos().x(),
206 m.y() - o->getChildPos().y() ));
207 if (p.x()<0) p.setX( p.x()-bbox.width() );
214 // new parent is just a branch, link to it
215 QRect t=o->getBBoxSizeWithChilds();
216 if (o->getLastBranch())
217 y=t.y() + t.height() ;
224 // we want to link above lmo
225 y=o->y() - height() + 5;
227 // we want to link below lmo
228 // Bottom of sel should be 5 pixels above
229 // the bottom of the branch _below_ the target:
230 // Don't try to find that branch, guess 12 pixels
231 y=o->getChildPos().y() -height() + 12;
233 if (o->getOrientation()==OrientLeftOfCenter)
234 move ( o->getChildPos().x() - linkwidth, y );
236 move (o->getChildPos().x() + linkwidth, y );
239 // updateLink is called implicitly in move
240 reposition(); // FIXME shouldn't be this a request?
243 void BranchObj::unsetParObjTmp()
250 depth=parObj->getDepth()+1;
251 setLinkStyle (getDefLinkStyle() );
256 void BranchObj::unScroll()
258 if (tmpUnscrolled) resetTmpUnscroll();
259 if (scrolled) toggleScroll();
262 void BranchObj::toggleScroll()
267 systemFlags->deactivate("scrolledright");
268 for (int i=0; i<branch.size(); ++i)
269 branch.at(i)->setVisibility(true);
273 systemFlags->activate("scrolledright");
274 for (int i=0; i<branch.size(); ++i)
275 branch.at(i)->setVisibility(false);
279 move (absPos.x(), absPos.y() );
283 bool BranchObj::isScrolled()
288 bool BranchObj::hasScrolledParent(BranchObj *start)
290 // Calls parents recursivly to
291 // find out, if we are scrolled at all.
292 // But ignore myself, just look at parents.
294 if (this !=start && scrolled) return true;
296 BranchObj* bo=(BranchObj*)(parObj);
298 return bo->hasScrolledParent(start);
303 void BranchObj::tmpUnscroll()
305 // Unscroll parent (recursivly)
306 BranchObj* bo=(BranchObj*)(parObj);
307 if (bo) bo->tmpUnscroll();
313 systemFlags->activate("tmpUnscrolledright");
318 void BranchObj::resetTmpUnscroll()
320 // Unscroll parent (recursivly)
321 BranchObj* bo=(BranchObj*)(parObj);
323 bo->resetTmpUnscroll();
329 systemFlags->deactivate("tmpUnscrolledright");
334 void BranchObj::setVisibility(bool v, int toDepth)
336 if (depth <= toDepth)
338 frame->setVisibility(v);
339 heading->setVisibility(v);
340 systemFlags->setVisibility(v);
341 standardFlags->setVisibility(v);
342 LinkableMapObj::setVisibility (v);
344 // Only change childs, if I am not scrolled
345 if (!scrolled && (depth < toDepth))
347 // Now go recursivly through all childs
349 for (i=0; i<branch.size(); ++i)
350 branch.at(i)->setVisibility (v,toDepth);
351 for (i=0; i<floatimage.size(); ++i)
352 floatimage.at(i)->setVisibility (v);
353 for (i=0; i<xlink.size(); ++i)
354 xlink.at(i)->setVisibility ();
356 } // depth <= toDepth
360 void BranchObj::setVisibility(bool v)
362 setVisibility (v,MAX_DEPTH);
366 void BranchObj::setLinkColor ()
368 // Overloaded from LinkableMapObj
369 // BranchObj can use color of heading
372 if (mapEditor->getMapLinkColorHint()==HeadingColor)
373 LinkableMapObj::setLinkColor (heading->getColor() );
375 LinkableMapObj::setLinkColor ();
378 void BranchObj::setColorChilds (QColor col)
380 OrnamentedObj::setColor (col);
381 for (int i=0; i<branch.size(); ++i)
382 branch.at(i)->setColorChilds(col);
385 BranchObj* BranchObj::first()
392 BranchObj* BranchObj::next()
396 BranchObj *po=(BranchObj*)parObj;
398 if (branch.isEmpty())
405 // no itLast, we are just beginning
408 // we have childs, return first one
414 // No childs, so there is no next
422 { // We come from parent
425 // there are childs, go there
430 { // no childs, try to go up again
433 // go back to parent and try to find next there
442 // can't go up, I am mapCenter, no next
449 // We don't come from parent, but from brother or childs
451 // Try to find last child, where we came from, in my own childs
454 while (i<branch.size())
456 // Try to find itLast in my own childs
457 if (itLast==branch.at(i))
459 // ok, we come from my own childs
460 //xyz //FIXME need to proceed to NEXT child or up again
461 if (i<branch.size()-1)
471 { // found itLast in my childs
474 // found a brother of lastLMO
482 if (this==itFirst) return NULL; // Stop at starting point
491 // can't go up, I am mapCenter
498 // couldn't find last child, it must be a nephew of mine
501 // proceed with my first child
503 return branch.first();
507 // or go back to my parents
518 // can't go up, I am mapCenter
525 BranchObj* BranchObj::getLastIterator()
530 void BranchObj::setLastIterator(BranchObj* it)
535 void BranchObj::positionContents()
537 for (int i=0; i<floatimage.size(); ++i )
538 floatimage.at(i)->reposition();
539 OrnamentedObj::positionContents();
542 void BranchObj::move (double x, double y)
544 OrnamentedObj::move (x,y);
545 for (int i=0; i<floatimage.size(); ++i )
546 floatimage.at(i)->reposition();
550 void BranchObj::move (QPoint p)
555 void BranchObj::moveBy (double x, double y)
557 OrnamentedObj::moveBy (x,y);
558 for (int i=0; i<branch.size(); ++i)
559 branch.at(i)->moveBy (x,y);
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
580 for (int i=0; i<xlink.size(); ++i)
581 xlink.at(i)->updateXLink();
584 void BranchObj::calcBBoxSize()
586 QSize heading_r=heading->getSize();
587 int heading_w=(int) heading_r.width() ;
588 int heading_h=(int) heading_r.height() ;
589 QSize sysflags_r=systemFlags->getSize();
590 int sysflags_h=sysflags_r.height();
591 int sysflags_w=sysflags_r.width();
592 QSize stanflags_r=standardFlags->getSize();
593 int stanflags_h=stanflags_r.height();
594 int stanflags_w=stanflags_r.width();
598 // set width to sum of all widths
599 w=heading_w + sysflags_w + stanflags_w;
600 // set height to maximum needed height
601 h=max (sysflags_h,stanflags_h);
604 // Save the dimension of flags and heading
605 ornamentsBBox.setSize ( QSize(w,h));
607 // clickBox includes Flags and Heading
608 clickBox.setSize (ornamentsBBox.size() );
613 topPad=botPad=leftPad=rightPad=0;
614 if (includeImagesVer || includeImagesHor)
616 if (countFloatImages()>0)
618 for (int i=0; i<floatimage.size(); ++i )
620 rp=floatimage.at(i)->getRelPos();
621 if (includeImagesVer)
624 topPad=max (topPad,-rp.y()-h);
625 if (rp.y()+floatimage.at(i)->height() > 0)
626 botPad=max (botPad,rp.y()+floatimage.at(i)->height());
628 if (includeImagesHor)
630 if (orientation==OrientRightOfCenter)
633 leftPad=max (leftPad,-rp.x()-w);
634 if (rp.x()+floatimage.at(i)->width() > 0)
635 rightPad=max (rightPad,rp.x()+floatimage.at(i)->width());
639 leftPad=max (leftPad,-rp.x());
640 if (rp.x()+floatimage.at(i)->width() > w)
641 rightPad=max (rightPad,rp.x()+floatimage.at(i)->width()-w);
651 w+=frame->getBorder();
652 h+=frame->getBorder();
655 bbox.setSize (QSize (w,h));
658 void BranchObj::setDockPos()
660 // Sets childpos and parpos depending on orientation
661 if (getOrientation()==OrientLeftOfCenter )
663 childPos=QPoint (ornamentsBBox.bottomLeft().x(), ornamentsBBox.bottomLeft().y() );
664 parPos=QPoint (ornamentsBBox.bottomRight().x(),ornamentsBBox.bottomRight().y() );
667 childPos=QPoint (ornamentsBBox.bottomRight().x(), ornamentsBBox.bottomRight().y() );
668 parPos=QPoint (ornamentsBBox.bottomLeft().x(),ornamentsBBox.bottomLeft().y() );
672 LinkableMapObj* BranchObj::findMapObj(QPoint p, LinkableMapObj* excludeLMO)
676 for (int i=0; i<branch.size(); ++i)
678 lmo=branch.at(i)->findMapObj(p, excludeLMO);
679 if (lmo != NULL) return lmo;
683 if (inBox (p) && (this != excludeLMO) && isVisibleObj() )
686 // Search float images
687 for (int i=0; i<floatimage.size(); ++i )
688 if (floatimage.at(i)->inBox(p) &&
689 (floatimage.at(i) != excludeLMO) &&
690 floatimage.at(i)->getParObj()!= excludeLMO &&
691 floatimage.at(i)->isVisibleObj()
692 ) return floatimage.at(i);
697 void BranchObj::setHeading(QString s)
699 heading->setText(s); // set new heading
700 calcBBoxSize(); // recalculate bbox
701 positionBBox(); // rearrange contents
705 void BranchObj::setHideTmp (HideTmpMode mode)
707 if (mode==HideExport && hasHiddenExportParent(this))
709 setVisibility (false);
713 if (hasScrolledParent(this))
714 setVisibility (false);
716 setVisibility (true);
720 for (int i=0; i<branch.size(); ++i)
721 branch.at(i)->setHideTmp (mode);
724 bool BranchObj::hasHiddenExportParent(BranchObj *start)
726 // Calls parents recursivly to
727 // find out, if we are temp. hidden
729 if (hideExport) return true;
731 BranchObj* bo=(BranchObj*)(parObj);
733 return bo->hasHiddenExportParent(start);
738 QString BranchObj::saveToDir (const QString &tmpdir,const QString &prefix, const QPoint& offset)
740 if (hidden) return "";
743 QString scrolledAttr;
745 scrolledAttr=attribut ("scrolled","yes");
750 if (frame->getFrameType()!=NoFrame)
751 frameAttr=attribut ("frameType",frame->getFrameTypeName());
755 // save area, if not scrolled
757 if (!((BranchObj*)(parObj))->isScrolled() )
760 attribut("x1",QString().setNum(absPos.x()-offset.x(),10)) +
761 attribut("y1",QString().setNum(absPos.y()-offset.y(),10)) +
762 attribut("x2",QString().setNum(absPos.x()+width()-offset.x(),10)) +
763 attribut("y2",QString().setNum(absPos.y()+height()-offset.y(),10));
768 // Providing an ID for a branch makes export to XHTML easier
771 idAttr=attribut ("id",getSelectString());
775 s=beginElement ("branch"
781 +getIncludeImageAttr() );
785 for (int i=1; i<depth;i++) cout << " ";
786 cout <<getHeading().ascii()<<endl;
790 s+=valueElement("heading", getHeading(),
791 attribut ("textColor",QColor(heading->getColor()).name()));
793 // save names of flags set
794 s+=standardFlags->saveToDir(tmpdir,prefix,0);
797 for (int i=0; i<floatimage.size(); ++i)
798 s+=floatimage.at(i)->saveToDir (tmpdir,prefix);
801 if (!note.isEmpty() )
805 for (int i=0; i<branch.size(); ++i)
806 s+=branch.at(i)->saveToDir(tmpdir,prefix,offset);
809 QString ol; // old link
810 QString cl; // current link
811 for (int i=0; i<xlink.size(); ++i)
813 cl=xlink.at(i)->saveToDir();
820 qWarning (QString("Ignoring of duplicate xLink in %1").arg(getHeading()));
825 s+=endElement ("branch");
829 void BranchObj::addXLink (XLinkObj *xlo)
835 void BranchObj::removeXLinkRef (XLinkObj *xlo)
837 xlink.removeAt (xlink.indexOf(xlo));
840 void BranchObj::deleteXLink(XLinkObj *xlo)
843 if (!xlo->isUsed()) delete (xlo);
846 void BranchObj::deleteXLinkAt (int i)
848 XLinkObj *xlo=xlink.at(i);
850 if (!xlo->isUsed()) delete(xlo);
853 XLinkObj* BranchObj::XLinkAt (int i)
858 int BranchObj::countXLink()
860 return xlink.count();
864 BranchObj* BranchObj::XLinkTargetAt (int i)
866 if (i>=0 && i<xlink.size())
869 return xlink.at(i)->otherBranch (this);
874 void BranchObj::setIncludeImagesVer(bool b)
882 bool BranchObj::getIncludeImagesVer()
884 return includeImagesVer;
887 void BranchObj::setIncludeImagesHor(bool b)
895 bool BranchObj::getIncludeImagesHor()
897 return includeImagesHor;
900 QString BranchObj::getIncludeImageAttr()
903 if (includeImagesVer)
904 a=attribut ("incImgV","true");
906 a=attribut ("incImgV","false");
907 if (includeImagesHor)
908 a+=attribut ("incImgH","true");
910 a+=attribut ("incImgH","false");
914 FloatImageObj* BranchObj::addFloatImage ()
916 FloatImageObj *newfi=new FloatImageObj (canvas,this);
917 floatimage.append (newfi);
918 if (hasScrolledParent(this) )
919 newfi->setVisibility (false);
921 newfi->setVisibility(visible);
930 FloatImageObj* BranchObj::addFloatImage (FloatImageObj *fio)
932 FloatImageObj *newfi=new FloatImageObj (canvas,this);
933 floatimage.append (newfi);
935 if (hasScrolledParent(this) )
936 newfi->setVisibility (false);
938 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 int i=floatimage.indexOf (fio);
965 if (i!=-1) floatimage.takeAt (i);
972 void BranchObj::savePosInAngle ()
974 // Save position in angle
975 for (int i=0; i<branch.size(); ++i)
976 branch.at(i)->angle=i;
979 void BranchObj::setDefAttr (BranchModification mod)
984 case 0: fontsize=16; break;
985 case 1: fontsize=12; break;
986 default: fontsize=10; break;
990 setLinkStyle(getDefLinkStyle());
991 QFont font("Sans Serif,8,-1,5,50,0,0,0,0,0");
992 font.setPointSize(fontsize);
993 heading->setFont(font );
996 setColor (((BranchObj*)(parObj))->getColor());
1001 BranchObj* BranchObj::addBranch()
1003 BranchObj* newbo=new BranchObj(canvas,this);
1004 branch.append (newbo);
1005 newbo->setParObj(this);
1006 newbo->setDefAttr(NewBranch);
1007 newbo->setHeading ("new");
1009 newbo->setVisibility (false);
1011 newbo->setVisibility(visible);
1012 newbo->updateLink();
1013 requestReposition();
1017 BranchObj* BranchObj::addBranch(BranchObj* bo)
1019 BranchObj* newbo=new BranchObj(canvas,this);
1020 branch.append (newbo);
1022 newbo->setParObj(this);
1023 newbo->setDefAttr(MovedBranch);
1025 newbo->setVisibility (false);
1027 newbo->setVisibility(bo->visible);
1028 newbo->updateLink();
1029 requestReposition();
1033 BranchObj* BranchObj::addBranchPtr(BranchObj* bo)
1036 bo->setParObj (this);
1038 bo->setDefAttr(MovedBranch);
1039 if (scrolled) tmpUnscroll();
1040 setLastSelectedBranch (bo);
1044 BranchObj* BranchObj::insertBranch(int pos)
1047 // Add new bo and resort branches
1048 BranchObj *newbo=addBranch ();
1049 newbo->angle=pos-0.5;
1050 //FIXME branch.sort();
1054 BranchObj* BranchObj::insertBranch(BranchObj* bo, int pos)
1057 // Add new bo and resort branches
1059 BranchObj *newbo=addBranch (bo);
1060 //FIXME branch.sort();
1064 BranchObj* BranchObj::insertBranchPtr (BranchObj* bo, int pos)
1067 // Add new bo and resort branches
1070 bo->setParObj (this);
1072 bo->setDefAttr (MovedBranch);
1073 if (scrolled) tmpUnscroll();
1074 setLastSelectedBranch (bo);
1075 //FIXME branch.sort();
1079 void BranchObj::removeBranchHere(BranchObj* borem)
1081 // This removes the branch bo from list, but
1082 // inserts its childs at the place of bo
1084 bo=borem->getLastBranch();
1085 int pos=borem->getNum();
1088 bo->moveBranchTo (this,pos+1);
1089 bo=borem->getLastBranch();
1091 removeBranch (borem);
1094 void BranchObj::removeChilds()
1099 void BranchObj::removeBranch(BranchObj* bo)
1101 // if bo is not in branch remove returns false, we
1104 int i=branch.indexOf(bo);
1108 branch.removeAt (i);
1110 qWarning ("BranchObj::removeBranch tried to remove non existing branch?!\n");
1111 requestReposition();
1114 void BranchObj::removeBranchPtr(BranchObj* bo)
1116 int i=branch.indexOf(bo);
1119 branch.removeAt (i);
1121 qWarning ("BranchObj::removeBranchPtr tried to remove non existing branch?!\n");
1122 requestReposition();
1125 void BranchObj::setLastSelectedBranch (BranchObj* bo)
1127 lastSelectedBranch=branch.indexOf(bo);
1130 BranchObj* BranchObj::getLastSelectedBranch ()
1132 if (lastSelectedBranch>=0)
1134 BranchObj* bo=branch.at(lastSelectedBranch);
1137 return branch.first();
1140 BranchObj* BranchObj::getFirstBranch ()
1142 return branch.first();
1145 BranchObj* BranchObj::getLastBranch ()
1147 return branch.last();
1150 BranchObj* BranchObj::getBranchNum (int i)
1152 if (i>=0 && i<branch.size())
1153 return branch.at(i);
1158 bool BranchObj::canMoveBranchUp()
1160 if (!parObj || depth==1) return false;
1161 BranchObj* par=(BranchObj*)parObj;
1162 if (this==par->getFirstBranch())
1168 BranchObj* BranchObj::moveBranchUp(BranchObj* bo1) // modify my childlist
1171 int i=branch.indexOf(bo1);
1173 { // -1 if bo1 not found
1174 branch.at(i)->angle--;
1175 branch.at(i-1)->angle++;
1176 //FIXME branch.sort();
1177 return branch.at(i);
1182 bool BranchObj::canMoveBranchDown()
1184 if (!parObj|| depth==1) return false;
1185 BranchObj* par=(BranchObj*)parObj;
1186 if (this==par->getLastBranch())
1192 BranchObj* BranchObj::moveBranchDown(BranchObj* bo1)// modify my childlist
1195 int i=branch.indexOf(bo1);
1197 if (i <branch.size())
1200 branch.at(i)->angle++;
1201 branch.at(j)->angle--;
1202 //FIXME branch.sort();
1203 return branch.at(i);
1208 BranchObj* BranchObj::moveBranchTo (BranchObj* dst, int pos)
1210 // Find current parent and
1211 // remove pointer to myself there
1212 if (!dst) return NULL;
1213 BranchObj *par=(BranchObj*)parObj;
1215 par->removeBranchPtr (this);
1219 // Create new pointer to myself at dst
1220 if (pos<0||dst->getDepth()==0)
1222 // links myself as last branch at dst
1223 dst->addBranchPtr (this);
1228 // inserts me at pos in parent of dst
1231 BranchObj *bo=dst->insertBranchPtr (this,pos);
1232 bo->setDefAttr(MovedBranch);
1241 void BranchObj::alignRelativeTo (QPoint ref)
1243 int th = bboxTotal.height();
1246 cout << "BO::alignRelTo "<<getHeading().ascii()<<endl;
1247 cout << " d="<<depth<<
1249 // " bbox.topLeft="<<bboxTotal.topLeft()<<
1250 " absPos="<<absPos<<
1251 " relPos="<<relPos<<
1252 " orient="<<orientation<<
1253 // " pad="<<topPad<<","<<botPad<<","<<leftPad<<","<<rightPad<<
1254 // " hidden="<<hidden<<
1266 // Position relatively, if needed
1267 //if (useRelPos) move2RelPos (relPos.x(), relPos.y());
1269 // Calc angle to mapCenter if I am a mainbranch
1270 // needed for reordering the mainbranches clockwise
1272 angle=getAngle (QPoint ((int)(x() - parObj->getChildPos().x() ),
1273 (int)(y() - parObj->getChildPos().y() ) ) );
1278 // Align myself depending on orientation and parent, but
1279 // only if I am not a mainbranch or mapcenter itself
1281 o=parObj->getOrientation();
1282 switch (orientation)
1284 case OrientLeftOfCenter:
1285 move (ref.x() - bbox.width(), ref.y() + (th-bbox.height())/2 );
1287 case OrientRightOfCenter:
1288 move (ref.x() , ref.y() + (th-bbox.height())/2 );
1291 qWarning ("LMO::alignRelativeTo: oops, no orientation given...");
1296 if (scrolled) return;
1298 // Set reference point for alignment of childs
1300 if (orientation==OrientLeftOfCenter)
1301 ref2.setX(bbox.topLeft().x() - linkwidth);
1303 ref2.setX(bbox.topRight().x() + linkwidth);
1306 ref2.setY(absPos.y()-(bboxTotal.height()-bbox.height())/2);
1308 ref2.setY(ref.y() );
1310 // Align the childs depending on reference point
1311 for (int i=0; i<branch.size(); ++i)
1313 if (!branch.at(i)->isHidden())
1315 branch.at(i)->alignRelativeTo (ref2);
1316 ref2.setY(ref2.y() + branch.at(i)->getBBoxSizeWithChilds().height() );
1322 void BranchObj::reposition()
1324 /* TODO testing only
1325 if (!getHeading().isEmpty())
1326 cout << "BO::reposition "<<getHeading().ascii()<<endl;
1328 cout << "BO::reposition ???"<<endl;
1330 cout << " orient="<<orientation<<endl;
1335 // only calculate the sizes once. If the deepest LMO
1336 // changes its height,
1337 // all upper LMOs have to change, too.
1338 calcBBoxSizeWithChilds();
1339 updateLink(); // This update is needed if the canvas is resized
1340 // due to excessive moving of a FIO
1341 // FIXME really needed? reposition is also called from updateLink...
1343 alignRelativeTo ( QPoint (absPos.x(),
1344 absPos.y()-(bboxTotal.height()-bbox.height())/2) );
1345 //FIXME branch.sort();
1346 positionBBox(); // Reposition bbox and contents
1349 // This is only important for moving branches:
1350 // For editing a branch it isn't called...
1351 alignRelativeTo ( QPoint (absPos.x(),
1352 absPos.y()-(bboxTotal.height()-bbox.height())/2) );
1356 void BranchObj::unsetAllRepositionRequests()
1358 repositionRequest=false;
1359 for (int i=0; i<branch.size(); ++i)
1360 branch.at(i)->unsetAllRepositionRequests();
1364 QRect BranchObj::getTotalBBox()
1368 if (scrolled) return r;
1370 for (int i=0; i<branch.size(); ++i)
1371 if (!branch.at(i)->isHidden())
1372 r=addBBox(branch.at(i)->getTotalBBox(),r);
1374 for (int i=0; i<floatimage.size(); ++i)
1375 if (!floatimage.at(i)->isHidden())
1376 r=addBBox(floatimage.at(i)->getTotalBBox(),r);
1381 QRect BranchObj::getBBoxSizeWithChilds()
1386 void BranchObj::calcBBoxSizeWithChilds()
1388 // This is initially called only from reposition and
1389 // and only for mapcenter. So it won't be
1390 // called more than once for a single user
1394 // Calculate size of LMO including all childs (to align them later)
1395 bboxTotal.setX(bbox.x() );
1396 bboxTotal.setY(bbox.y() );
1398 // if branch is scrolled, ignore childs, but still consider floatimages
1401 bboxTotal.setWidth (bbox.width());
1402 bboxTotal.setHeight(bbox.height());
1408 bboxTotal.setWidth (0);
1409 bboxTotal.setHeight(0);
1412 bboxTotal.setX (parObj->x());
1413 bboxTotal.setY (parObj->y());
1416 bboxTotal.setX (bbox.x());
1417 bboxTotal.setY (bbox.y());
1424 // Now calculate recursivly
1426 // maximum of widths
1428 for (int i=0; i<branch.size(); ++i)
1430 if (!branch.at(i)->isHidden())
1432 branch.at(i)->calcBBoxSizeWithChilds();
1433 br=branch.at(i)->getBBoxSizeWithChilds();
1434 r.setWidth( max (br.width(), r.width() ));
1435 r.setHeight(br.height() + r.height() );
1436 if (br.y()<bboxTotal.y()) bboxTotal.setY(br.y());
1439 // Add myself and also
1440 // add width of link to sum if necessary
1441 if (branch.isEmpty())
1442 bboxTotal.setWidth (bbox.width() + r.width() );
1444 bboxTotal.setWidth (bbox.width() + r.width() + linkwidth);
1446 bboxTotal.setHeight(max (r.height(), bbox.height()));
1449 void BranchObj::select()
1451 // set Text in Editor
1452 textEditor->setText(note.getNote() );
1453 QString fnh=note.getFilenameHint();
1455 textEditor->setFilenameHint(note.getFilenameHint() );
1457 textEditor->setFilenameHint(getHeading() );
1458 textEditor->setFontHint (note.getFontHint() );
1460 LinkableMapObj::select();
1461 // Tell parent that I am selected now:
1462 BranchObj* po=(BranchObj*)(parObj);
1463 if (po) // TODO Try to get rid of this cast...
1464 po->setLastSelectedBranch(this);
1466 // temporary unscroll, if we have scrolled parents somewhere
1467 if (parObj) ((BranchObj*)(parObj))->tmpUnscroll();
1469 // Show URL and link in statusbar
1471 if (!url.isEmpty()) status+="URL: "+url+" ";
1472 if (!vymLink.isEmpty()) status+="Link: "+vymLink;
1473 if (!status.isEmpty()) mainWindow->statusMessage (status);
1476 updateFlagsToolbar();
1479 mapEditor->updateActions();
1482 void BranchObj::unselect()
1484 LinkableMapObj::unselect();
1485 // Delete any messages like vymLink in StatusBar
1486 mainWindow->statusMessage ("");
1488 // save note from editor and set flag
1489 // text is done by updateNoteFlag(), just save
1491 note.setFilenameHint (textEditor->getFilename());
1493 // reset temporary unscroll, if we have scrolled parents somewhere
1494 if (parObj) ((BranchObj*)(parObj))->resetTmpUnscroll();
1496 // Erase content of editor
1497 textEditor->setInactive();
1499 // unselect all buttons in toolbar
1500 standardFlagsDefault->updateToolbar();
1503 QString BranchObj::getSelectString()
1509 s= "bo:" + QString("%1").arg(getNum());
1511 s= ((BranchObj*)(parObj))->getSelectString() + ",bo:" + QString("%1").arg(getNum());