branchobj.cpp
author insilmaril
Thu, 26 Mar 2009 07:50:32 +0000
changeset 747 008e72977ab8
parent 746 ee6b0f3a4c2f
child 748 edb78a44240b
permissions -rw-r--r--
Notes work again (to some degree)
     1 #include "branchobj.h"
     2 
     3 // #include "texteditor.h"
     4 #include "geometry.h"
     5 #include "mapeditor.h"
     6 #include "mainwindow.h"
     7 #include "misc.h"
     8 
     9 class TextEditor;
    10 
    11 extern TextEditor *textEditor;
    12 extern Main *mainWindow;
    13 extern FlagRowObj *standardFlagsDefault;
    14 
    15 
    16 /////////////////////////////////////////////////////////////////
    17 // BranchObj
    18 /////////////////////////////////////////////////////////////////
    19 
    20 BranchObj::BranchObj () :OrnamentedObj()	// FIXME-3 needed at all?
    21 {
    22 //    cout << "Const BranchObj ()\n";
    23     setParObj (this);	
    24     init();
    25     depth=-1;
    26 }
    27 
    28 BranchObj::BranchObj (QGraphicsScene* s):OrnamentedObj (s)
    29 {
    30 //    cout << "Const BranchObj (s)  called from MapCenterObj (s)\n";
    31 	parObj=NULL;
    32     scene=s;
    33 }
    34 
    35 BranchObj::BranchObj (QGraphicsScene* s, LinkableMapObj* p):OrnamentedObj (s)
    36 {
    37 //    cout << "Const BranchObj (s,p)\n";
    38     scene=s;
    39     setParObj (p);	
    40     depth=p->getDepth()+1;
    41 	if (depth==1)
    42 		// Calc angle to mapCenter if I am a mainbranch
    43 		// needed for reordering the mainbranches clockwise 
    44 		// around mapcenter 
    45 		angle=getAngle (QPointF (x() - parObj->getChildPos().x() , 
    46 								(y() - parObj->getChildPos().y() ) ) );
    47     init();
    48 }
    49 
    50 BranchObj::~BranchObj ()
    51 {
    52 	// If I'm animated, I need to un-animate myself first
    53 	if (anim.isAnimated() )
    54 	{
    55 		anim.setAnimated (false);
    56 		model->stopAnimation (this);
    57 	}
    58 
    59 	cout << "Destr BranchObj of "<<this<<endl;
    60 	// Check, if this branch was the last child to be deleted
    61 	// If so, unset the scrolled flags
    62 
    63 	BranchObj *po=(BranchObj*)parObj;
    64 	BranchObj *bo;
    65 	if (po)
    66 	{
    67 		bo=((BranchObj*)parObj)->getLastBranch();
    68 		if (bo) po->unScroll();
    69 	}
    70 	clear();
    71 }
    72 
    73 bool BranchObj::operator< ( const BranchObj & other )
    74 {
    75     return  angle < other.angle;
    76 }
    77 
    78 bool BranchObj::operator== ( const BranchObj & other )
    79 {
    80     return angle == other.angle;
    81 }
    82 
    83 void BranchObj::init () 
    84 {
    85 	if (parObj)
    86 	{
    87 		absPos=getRandPos();
    88 		absPos+=parObj->getChildPos();
    89 	}
    90 
    91     setChildObj(this);
    92 
    93 	scrolled=false;
    94 	tmpUnscrolled=false;
    95 
    96 	includeImagesVer=false;
    97 	includeImagesHor=false;
    98 }
    99 
   100 void BranchObj::copy (BranchObj* other)
   101 {
   102     OrnamentedObj::copy(other);
   103 
   104 	branch.clear();
   105 	for (int i=0; i<other->branch.size(); ++i)
   106 		// Make deep copy of b
   107 		// Because addBranch again calls copy for the children,
   108 		// Those will get a deep copy, too
   109 		addBranch(other->branch.at(i) );	
   110 
   111 	for (int i=0; i<other->floatimage.size(); ++i)
   112 		addFloatImage  (other->floatimage.at(i));
   113 	scrolled=other->scrolled;
   114 	tmpUnscrolled=other->tmpUnscrolled;
   115 	setVisibility (other->visible);
   116 
   117 	angle=other->angle;
   118 
   119     positionBBox();
   120 }
   121 
   122 void BranchObj::clear() 
   123 {
   124 	setVisibility (true);
   125 
   126 	while (!floatimage.isEmpty())
   127 		delete floatimage.takeFirst();
   128 
   129 	while (!xlink.isEmpty())
   130 		delete xlink.takeFirst();
   131 
   132 	while (!branch.isEmpty())
   133 		delete branch.takeFirst();
   134 }
   135 
   136 bool isAbove (BranchObj* a, BranchObj *b)
   137 {
   138 	if (a->angle < b->angle)
   139 		return true;
   140 	else	
   141 		return false;
   142 }
   143 
   144 int BranchObj::getNum()
   145 {
   146 	if (parObj)
   147 		return ((BranchObj*)parObj)->getNum (this);
   148 	else
   149 		return 0;
   150 }
   151 
   152 int BranchObj::getNum(BranchObj *bo)
   153 {
   154 	return branch.indexOf (bo);
   155 }
   156 
   157 int BranchObj::getFloatImageNum(FloatImageObj *fio)
   158 {
   159 	return floatimage.indexOf(fio);
   160 }
   161 
   162 int BranchObj::countBranches()
   163 {
   164 	return branch.count();
   165 }
   166 
   167 int BranchObj::countFloatImages()
   168 {
   169 	return floatimage.count();
   170 }
   171 
   172 int BranchObj::countXLinks()
   173 {
   174 	return xlink.count();
   175 }
   176 
   177 void BranchObj::setParObjTmp(LinkableMapObj* lmo, QPointF m, int off)
   178 {
   179 	// Temporary link to lmo
   180 	// m is position of mouse pointer 
   181 	// offset 0: default 1: below lmo   -1 above lmo  (if possible)
   182 
   183 
   184 	BranchObj* o=(BranchObj*)(lmo);
   185 	if (!parObjTmpBuf) 
   186 		parObjTmpBuf=parObj;
   187 
   188 	// ignore mapcenter and mainbranch
   189 	if (lmo->getDepth()<2) off=0;
   190 	if (off==0)
   191 		link2ParPos=false;
   192 	else
   193 		link2ParPos=true;
   194 	parObj=o;
   195 
   196 	depth=parObj->getDepth()+1;
   197 
   198 	// setLinkStyle calls updateLink, only set it once
   199 	if (style!=getDefLinkStyle() ) setLinkStyle (getDefLinkStyle());
   200 
   201 	// Move temporary to new position at destination
   202 	// Usually the positioning would be done by reposition(),
   203 	// but then also the destination branch would "Jump" around...
   204 	// Better just do it approximately
   205 	if (depth==1)
   206 	{	// new parent is the mapcenter itself
   207 
   208 		QPointF p= normalise ( QPointF (m.x() - o->getChildPos().x(),
   209 									  m.y() - o->getChildPos().y() ));
   210 		if (p.x()<0) p.setX( p.x()-bbox.width() );
   211 		move2RelPos (p);
   212 	} else
   213 	{	
   214 		qreal y;
   215 		if (off==0)
   216 		{
   217 			// new parent is just a branch, link to it
   218 			QRectF t=o->getBBoxSizeWithChildren();
   219 			if (o->getLastBranch())
   220 				y=t.y() + t.height() ;
   221 			else
   222 				y=t.y();
   223 
   224 		} else
   225 		{
   226 			if (off<0)
   227 				// we want to link above lmo
   228 				y=o->y() - height() + 5;
   229 			else	
   230 				// we want to link below lmo
   231 				// Bottom of sel should be 5 pixels above
   232 				// the bottom of the branch _below_ the target:
   233 				// Don't try to find that branch, guess 12 pixels
   234 				y=o->getChildPos().y()  -height() + 12; 
   235 		}	
   236 		if (o->getOrientation()==LinkableMapObj::LeftOfCenter)
   237 			move ( o->getChildPos().x() - linkwidth, y );
   238 		else	
   239 			move (o->getChildPos().x() + linkwidth, y );
   240 	}	
   241 
   242 	// updateLink is called implicitly in move
   243 	requestReposition();	
   244 }
   245 
   246 void BranchObj::unsetParObjTmp()
   247 {
   248 	if (parObjTmpBuf) 
   249 	{
   250 		link2ParPos=false;
   251 		parObj=parObjTmpBuf;
   252 		parObjTmpBuf=NULL;
   253 		depth=parObj->getDepth()+1;
   254 		setLinkStyle (getDefLinkStyle() );
   255 		updateLink();
   256 	}		
   257 }
   258 
   259 void BranchObj::unScroll()
   260 {
   261 	if (tmpUnscrolled) resetTmpUnscroll();
   262 	if (scrolled) toggleScroll();
   263 }
   264 
   265 void BranchObj::toggleScroll()
   266 {
   267 	if (scrolled)
   268 	{
   269 		scrolled=false;
   270 		systemFlags->deactivate("scrolledright");
   271 		for (int i=0; i<branch.size(); ++i)
   272 			branch.at(i)->setVisibility(true);
   273 	} else
   274 	{
   275 		scrolled=true;
   276 		systemFlags->activate("scrolledright");
   277 		for (int i=0; i<branch.size(); ++i)
   278 			branch.at(i)->setVisibility(false);
   279 	}
   280 	calcBBoxSize();
   281 	positionBBox();	
   282 	move (absPos.x(), absPos.y() );
   283 	forceReposition();
   284 }
   285 
   286 bool BranchObj::isScrolled()
   287 {
   288 	return scrolled;
   289 }
   290 
   291 bool BranchObj::hasScrolledParent(BranchObj *start)
   292 {
   293 	// Calls parents recursivly to
   294 	// find out, if we are scrolled at all.
   295 	// But ignore myself, just look at parents.
   296 
   297 	if (this !=start && scrolled) return true;
   298 
   299 	BranchObj* bo=(BranchObj*)(parObj);
   300 	if (bo) 
   301 		return bo->hasScrolledParent(start);
   302 	else
   303 		return false;
   304 }
   305 
   306 void BranchObj::tmpUnscroll()
   307 {
   308 	// Unscroll parent (recursivly)
   309 	BranchObj* bo=(BranchObj*)(parObj);
   310 	if (bo) bo->tmpUnscroll();
   311 		
   312 	// Unscroll myself
   313 	if (scrolled)
   314 	{
   315 		tmpUnscrolled=true;
   316 		systemFlags->activate("tmpUnscrolledright");
   317 		toggleScroll();
   318 	}	
   319 }
   320 
   321 void BranchObj::resetTmpUnscroll()
   322 {
   323 	// Unscroll parent (recursivly)
   324 	BranchObj* bo=(BranchObj*)(parObj);
   325 	if (bo)
   326 		bo->resetTmpUnscroll();
   327 		
   328 	// Unscroll myself
   329 	if (tmpUnscrolled)
   330 	{
   331 		tmpUnscrolled=false;
   332 		systemFlags->deactivate("tmpUnscrolledright");
   333 		toggleScroll();
   334 	}	
   335 }
   336 
   337 void BranchObj::setVisibility(bool v, int toDepth)
   338 {
   339     if (depth <= toDepth)
   340     {
   341 		frame->setVisibility(v);
   342 		heading->setVisibility(v);
   343 		systemFlags->setVisibility(v);
   344 		standardFlags->setVisibility(v);
   345 		LinkableMapObj::setVisibility (v);
   346 		
   347 		int i;
   348 		for (i=0; i<floatimage.size(); ++i)
   349 			floatimage.at(i)->setVisibility (v);
   350 		for (i=0; i<xlink.size(); ++i)	
   351 			xlink.at(i)->setVisibility ();	
   352 
   353 		// Only change children, if I am not scrolled
   354 		if (!scrolled && (depth < toDepth))
   355 		{
   356 			// Now go recursivly through all children
   357 			for (i=0; i<branch.size(); ++i)
   358 				branch.at(i)->setVisibility (v,toDepth);	
   359 		}
   360     } // depth <= toDepth	
   361 	requestReposition();
   362 }	
   363 
   364 void BranchObj::setVisibility(bool v)
   365 {
   366     setVisibility (v,MAX_DEPTH);
   367 }
   368 
   369 
   370 void BranchObj::setLinkColor ()
   371 {
   372 	// Overloaded from LinkableMapObj
   373 	// BranchObj can use color of heading
   374 
   375 	if (model)
   376 	{
   377 		if (model->getMapLinkColorHint()==HeadingColor)
   378 			LinkableMapObj::setLinkColor (heading->getColor() );
   379 		else	
   380 			LinkableMapObj::setLinkColor ();
   381 	}		
   382 }
   383 
   384 void BranchObj::setColorSubtree(QColor col)
   385 {
   386 	setColor (col);
   387 	for (int i=0; i<branch.size(); ++i)
   388 		branch.at(i)->setColorSubtree(col);
   389 }
   390 
   391 void BranchObj::positionContents()
   392 {
   393     for (int i=0; i<floatimage.size(); ++i )
   394 		floatimage.at(i)->reposition();
   395 	OrnamentedObj::positionContents();
   396 }
   397 
   398 void BranchObj::move (double x, double y)
   399 {
   400 	OrnamentedObj::move (x,y);
   401     for (int i=0; i<floatimage.size(); ++i )
   402 		floatimage.at(i)->reposition();
   403     positionBBox();
   404 }
   405 
   406 void BranchObj::move (QPointF p)
   407 {
   408 	move (p.x(), p.y());
   409 }
   410 
   411 void BranchObj::moveBy (double x, double y)
   412 {
   413 	OrnamentedObj::moveBy (x,y);
   414 	for (int i=0; i<branch.size(); ++i)
   415 		branch.at(i)->moveBy (x,y);
   416     positionBBox();
   417 }
   418 	
   419 void BranchObj::moveBy (QPointF p)
   420 {
   421 	moveBy (p.x(), p.y());
   422 }
   423 
   424 
   425 void BranchObj::positionBBox()
   426 {
   427 	QPointF ap=getAbsPos();
   428 	bbox.moveTopLeft (ap);
   429 	positionContents();
   430 
   431 	// set the frame
   432 	frame->setRect(QRectF(bbox.x(),bbox.y(),bbox.width(),bbox.height() ) );
   433 
   434 	// Update links to other branches
   435 	for (int i=0; i<xlink.size(); ++i)
   436 		xlink.at(i)->updateXLink();
   437 }
   438 
   439 void BranchObj::calcBBoxSize()
   440 {
   441     QSizeF heading_r=heading->getSize();
   442     qreal heading_w=(qreal) heading_r.width() ;
   443     qreal heading_h=(qreal) heading_r.height() ;
   444     QSizeF sysflags_r=systemFlags->getSize();
   445 	qreal sysflags_h=sysflags_r.height();
   446 	qreal sysflags_w=sysflags_r.width();
   447     QSizeF stanflags_r=standardFlags->getSize();
   448 	qreal stanflags_h=stanflags_r.height();
   449 	qreal stanflags_w=stanflags_r.width();
   450     qreal w;
   451     qreal h;
   452 
   453 	// set width to sum of all widths
   454 	w=heading_w + sysflags_w + stanflags_w;
   455 	// set height to maximum needed height
   456 	h=max (sysflags_h,stanflags_h);
   457 	h=max (h,heading_h);
   458 
   459 	// Save the dimension of flags and heading
   460 	ornamentsBBox.setSize ( QSizeF(w,h));
   461 
   462 	// clickBox includes Flags and Heading
   463     clickBox.setSize (ornamentsBBox.size() );
   464 
   465 	// Floatimages 
   466 	QPointF rp;
   467 
   468 	topPad=botPad=leftPad=rightPad=0;
   469 	if (includeImagesVer || includeImagesHor)
   470 	{
   471 		if (countFloatImages()>0)
   472 		{
   473 			for (int i=0; i<floatimage.size(); ++i )
   474 			{
   475 				rp=floatimage.at(i)->getRelPos();
   476 				if (includeImagesVer)
   477 				{
   478 					if (rp.y() < 0) 
   479 						topPad=max (topPad,-rp.y()-h);
   480 					if (rp.y()+floatimage.at(i)->height() > 0)
   481 						botPad=max (botPad,rp.y()+floatimage.at(i)->height());
   482 				}		
   483 				if (includeImagesHor)
   484 				{
   485 					if (orientation==LinkableMapObj::RightOfCenter)
   486 					{
   487 						if (-rp.x()-w > 0) 
   488 							leftPad=max (leftPad,-rp.x()-w);
   489 						if (rp.x()+floatimage.at(i)->width() > 0)
   490 							rightPad=max (rightPad,rp.x()+floatimage.at(i)->width());
   491 					} else
   492 					{
   493 						if (rp.x()< 0) 
   494 							leftPad=max (leftPad,-rp.x());
   495 						if (rp.x()+floatimage.at(i)->width() > w)
   496 							rightPad=max (rightPad,rp.x()+floatimage.at(i)->width()-w);
   497 					}
   498 				}		
   499 			}	
   500 		}	
   501 		h+=topPad+botPad;
   502 		w+=leftPad+rightPad;
   503 	}
   504 
   505 	// Frame thickness
   506     w+=frame->getPadding();
   507     h+=frame->getPadding();
   508 	
   509 	// Finally set size
   510     bbox.setSize (QSizeF (w,h));
   511 }
   512 
   513 void BranchObj::setDockPos()
   514 {
   515 	// Sets childpos and parpos depending on orientation
   516 	if (getOrientation()==LinkableMapObj::LeftOfCenter )
   517     {
   518 		childPos=QPointF (
   519 			ornamentsBBox.bottomLeft().x(), 
   520 			bottomlineY);
   521 		parPos=QPointF (
   522 			ornamentsBBox.bottomRight().x(),
   523 			bottomlineY);
   524     } else
   525     {
   526 		childPos=QPointF (
   527 			ornamentsBBox.bottomRight().x(), 
   528 			bottomlineY);
   529 		parPos=QPointF (
   530 			ornamentsBBox.bottomLeft().x(),
   531 			bottomlineY);
   532     }
   533 }
   534 
   535 LinkableMapObj* BranchObj::findMapObj(QPointF p, LinkableMapObj* excludeLMO)
   536 {
   537 	// Search branches
   538     LinkableMapObj *lmo;
   539 	for (int i=0; i<branch.size(); ++i)
   540     {	
   541 		lmo=branch.at(i)->findMapObj(p, excludeLMO);
   542 		if (lmo != NULL) return lmo;
   543     }
   544 	
   545 
   546 	// Search myself
   547     if (inBox (p,clickBox) && (this != excludeLMO) && isVisibleObj() ) 
   548 		return this;
   549 
   550 	// Search float images
   551     for (int i=0; i<floatimage.size(); ++i )
   552 		if (inBox(p,floatimage.at(i)->getClickBox()) && 
   553 			(floatimage.at(i) != excludeLMO) && 
   554 			floatimage.at(i)->getParObj()!= excludeLMO &&
   555 			floatimage.at(i)->isVisibleObj() 
   556 		) return floatimage.at(i);
   557 
   558     return NULL;
   559 }
   560 
   561 LinkableMapObj* BranchObj::findID (QString sid)
   562 {
   563 	// Search branches
   564     LinkableMapObj *lmo;
   565 	for (int i=0; i<branch.size(); ++i)
   566     {	
   567 		lmo=branch.at(i)->findID (sid);
   568 		if (lmo != NULL) return lmo;
   569     }
   570 	
   571 	// Search myself
   572 	if (sid==objID) return this;
   573 
   574 
   575 /*
   576 	// Search float images
   577     for (int i=0; i<floatimage.size(); ++i )
   578 		if (floatimage.at(i)->inBox(p) && 
   579 			(floatimage.at(i) != excludeLMO) && 
   580 			floatimage.at(i)->getParObj()!= excludeLMO &&
   581 			floatimage.at(i)->isVisibleObj() 
   582 		) return floatimage.at(i);
   583 */
   584     return NULL;
   585 }
   586 
   587 void BranchObj::setHeading(QString s)
   588 {
   589     heading->setText(s);	// set new heading
   590 	calcBBoxSize();			// recalculate bbox
   591     positionBBox();			// rearrange contents
   592 	requestReposition();
   593 }
   594 
   595 void BranchObj::setHideTmp (HideTmpMode mode)
   596 {
   597 	if (mode==HideExport && (hideExport|| hasHiddenExportParent() ) )
   598 	{
   599 		// Hide stuff according to hideExport flag and parents
   600 		setVisibility (false);
   601 		hidden=true;
   602 	}else
   603 	{
   604 		// Do not hide, but still take care of scrolled status
   605 		if (hasScrolledParent(this))
   606 			setVisibility (false);
   607 		else
   608 			setVisibility (true);
   609 		hidden=false;
   610 	}	
   611 
   612 	// And take care of my children
   613 	for (int i=0; i<branch.size(); ++i)
   614 		branch.at(i)->setHideTmp (mode);
   615 }
   616 
   617 bool BranchObj::hasHiddenExportParent()
   618 {
   619 	// Calls parents recursivly to
   620 	// find out, if we or parents are temp. hidden
   621 
   622 	if (hidden || hideExport) return true;
   623 
   624 	BranchObj* bo=(BranchObj*)parObj;
   625 	if (bo) 
   626 		return bo->hasHiddenExportParent();
   627 	else
   628 		return false;
   629 }
   630 
   631 QString BranchObj::saveToDir (const QString &tmpdir,const QString &prefix, const QPointF& offset)
   632 {
   633 	// Cloudy stuff can be hidden during exports
   634 	if (hidden) return "";
   635 
   636 	// Update of note is usually done while unselecting a branch
   637 	// if (isNoteInEditor) getNoteFromTextEditor();		//FIXME-2 moved to TreeItem
   638 	
   639     QString s,a;
   640 	QString scrolledAttr;
   641 	if (scrolled) 
   642 		scrolledAttr=attribut ("scrolled","yes");
   643 	else
   644 		scrolledAttr="";
   645 
   646 	// save area, if not scrolled
   647 	QString areaAttr;
   648 	if (!((BranchObj*)(parObj))->isScrolled() )
   649 	{
   650 		areaAttr=
   651 			attribut("x1",QString().setNum(absPos.x()-offset.x())) +
   652 			attribut("y1",QString().setNum(absPos.y()-offset.y())) +
   653 			attribut("x2",QString().setNum(absPos.x()+width()-offset.x())) +
   654 			attribut("y2",QString().setNum(absPos.y()+height()-offset.y()));
   655 
   656 	} else
   657 		areaAttr="";
   658 	
   659 	// Providing an ID for a branch makes export to XHTML easier
   660 	QString idAttr;
   661 	if (countXLinks()>0)
   662 		idAttr=attribut ("id",model->getSelectString(this)); //TODO directly access model
   663 	else
   664 		idAttr="";
   665 
   666     s=beginElement ("branch" 
   667 		+getOrnXMLAttr() 
   668 		+scrolledAttr 
   669 		+areaAttr 
   670 		+idAttr 
   671 		+getIncludeImageAttr() );
   672     incIndent();
   673 
   674 	// save heading
   675     s+=valueElement("heading", getHeading(),
   676 		attribut ("textColor",QColor(heading->getColor()).name()));
   677 
   678 	// Save frame
   679 	if (frame->getFrameType()!=FrameObj::NoFrame) 
   680 		s+=frame->saveToDir ();
   681 
   682 	// save names of flags set
   683 	s+=standardFlags->saveToDir(tmpdir,prefix,0);
   684 	
   685 	// Save FloatImages
   686 	for (int i=0; i<floatimage.size(); ++i)
   687 		s+=floatimage.at(i)->saveToDir (tmpdir,prefix);
   688 
   689 	// save note
   690 	if (!treeItem->getNoteObj().isEmpty() )
   691 		s+=treeItem->getNoteObj().saveToDir();
   692 	
   693 	// Save branches
   694 	for (int i=0; i<branch.size(); ++i)
   695 		s+=branch.at(i)->saveToDir(tmpdir,prefix,offset);
   696 
   697 	// Save XLinks
   698 	QString ol;	// old link
   699 	QString cl;	// current link
   700 	for (int i=0; i<xlink.size(); ++i)
   701 	{
   702 		cl=xlink.at(i)->saveToDir();
   703 		if (cl!=ol)
   704 		{
   705 			s+=cl;
   706 			ol=cl;
   707 		} else
   708 		{
   709 			qWarning (QString("Ignoring of duplicate xLink in %1").arg(getHeading()));
   710 		}
   711 	}	
   712 
   713     decIndent();
   714     s+=endElement   ("branch");
   715     return s;
   716 }
   717 
   718 void BranchObj::addXLink (XLinkObj *xlo)
   719 {
   720 	xlink.append (xlo);
   721 	
   722 }
   723 
   724 void BranchObj::removeXLinkRef (XLinkObj *xlo)
   725 {
   726 	xlink.removeAt (xlink.indexOf(xlo));
   727 }
   728 
   729 void BranchObj::deleteXLink(XLinkObj *xlo)
   730 {
   731 	xlo->deactivate();
   732 	if (!xlo->isUsed()) delete (xlo);
   733 }
   734 
   735 void BranchObj::deleteXLinkAt (int i)
   736 {
   737 	XLinkObj *xlo=xlink.at(i);
   738 	xlo->deactivate();
   739 	if (!xlo->isUsed()) delete(xlo);
   740 }
   741 
   742 XLinkObj* BranchObj::XLinkAt (int i)
   743 {
   744 	return xlink.at(i);
   745 }
   746 
   747 int BranchObj::countXLink()
   748 {
   749 	return xlink.count();
   750 }
   751 
   752 
   753 BranchObj* BranchObj::XLinkTargetAt (int i)
   754 {
   755 	if (i>=0 && i<xlink.size())
   756 	{
   757 		if (xlink.at(i))
   758 			return xlink.at(i)->otherBranch (this);
   759 	}
   760 	return NULL;
   761 }
   762 
   763 void BranchObj::setIncludeImagesVer(bool b)
   764 {
   765 	includeImagesVer=b;
   766 	calcBBoxSize();
   767 	positionBBox();
   768 	requestReposition();
   769 }
   770 
   771 bool BranchObj::getIncludeImagesVer()
   772 {
   773 	return includeImagesVer;
   774 }
   775 
   776 void BranchObj::setIncludeImagesHor(bool b)
   777 {
   778 	includeImagesHor=b;
   779 	calcBBoxSize();
   780 	positionBBox();
   781 	requestReposition();
   782 }
   783 
   784 bool BranchObj::getIncludeImagesHor()
   785 {
   786 	return includeImagesHor;
   787 }
   788 
   789 QString BranchObj::getIncludeImageAttr()
   790 {
   791 	QString a;
   792 	if (includeImagesVer)
   793 		a=attribut ("incImgV","true");
   794 	else
   795 		a=attribut ("incImgV","false");
   796 	if (includeImagesHor)
   797 		a+=attribut ("incImgH","true");
   798 	else
   799 		a+=attribut ("incImgH","false");
   800 	return a;	
   801 }
   802 
   803 FloatImageObj* BranchObj::addFloatImage ()
   804 {
   805 	FloatImageObj *newfi=new FloatImageObj (scene,this);
   806 	floatimage.append (newfi);
   807 	if (hasScrolledParent(this) )
   808 		newfi->setVisibility (false);
   809 	else	
   810 		newfi->setVisibility(visible);
   811 		/*
   812 	calcBBoxSize();
   813 	positionBBox();
   814 	*/
   815 	requestReposition();
   816 	return newfi;
   817 }
   818 
   819 FloatImageObj* BranchObj::addFloatImage (FloatImageObj *fio)
   820 {
   821 	FloatImageObj *newfi=new FloatImageObj (scene,this);
   822 	floatimage.append (newfi);
   823 	newfi->copy (fio);
   824 	if (hasScrolledParent(this) )
   825 		newfi->setVisibility (false);
   826 	else	
   827 		newfi->setVisibility(visible);
   828 		/*
   829 	calcBBoxSize();
   830 	positionBBox();
   831 	*/
   832 	requestReposition();
   833 	return newfi;
   834 }
   835 
   836 FloatImageObj* BranchObj::getFirstFloatImage ()
   837 {
   838     return floatimage.first();
   839 }
   840 
   841 FloatImageObj* BranchObj::getLastFloatImage ()
   842 {
   843     return floatimage.last();
   844 }
   845 
   846 FloatImageObj* BranchObj::getFloatImageNum (const uint &i)
   847 {
   848     return floatimage.at(i);
   849 }
   850 
   851 void BranchObj::removeFloatImage (FloatImageObj *fio)
   852 {
   853 	int i=floatimage.indexOf (fio);
   854 	if (i>-1) delete (floatimage.takeAt (i));
   855 	calcBBoxSize();
   856 	positionBBox();
   857 	requestReposition();
   858 }
   859 
   860 void BranchObj::savePosInAngle ()
   861 {
   862 	// Save position in angle
   863 	for (int i=0; i<branch.size(); ++i)
   864 		branch.at(i)->angle=i;
   865 }
   866 
   867 void BranchObj::setDefAttr (BranchModification mod)
   868 {
   869 	int fontsize;
   870 	switch (depth)
   871 	{
   872 		case 0: fontsize=16; break;
   873 		case 1: fontsize=12; break;
   874 		default: fontsize=10; break;
   875 	}	
   876 
   877 	setLinkColor ();
   878 	setLinkStyle(getDefLinkStyle());
   879 	QFont font("Sans Serif,8,-1,5,50,0,0,0,0,0");
   880 	font.setPointSize(fontsize);
   881 	heading->setFont(font );
   882 
   883 	if (mod==NewBranch)
   884 		setColor (((BranchObj*)(parObj))->getColor());
   885 	
   886 	calcBBoxSize();
   887 }
   888 
   889 BranchObj* BranchObj::addBranch()
   890 {
   891     BranchObj* newbo=new BranchObj(scene,this);
   892     branch.append (newbo);
   893     newbo->setParObj(this);
   894 	newbo->setDefAttr(NewBranch);
   895     newbo->setHeading ("new");
   896 	if (scrolled)
   897 		newbo->setVisibility (false);
   898 	else	
   899 		newbo->setVisibility(visible);
   900 	newbo->updateLink();	
   901 	requestReposition();
   902 	return newbo;
   903 }
   904 
   905 BranchObj* BranchObj::addBranch(BranchObj* bo)
   906 {
   907     BranchObj* newbo=new BranchObj(scene,this);
   908     branch.append (newbo);
   909     newbo->copy(bo);
   910     newbo->setParObj(this);
   911 	newbo->setDefAttr(MovedBranch);
   912 	if (scrolled)
   913 		newbo->setVisibility (false);
   914 	else	
   915 		newbo->setVisibility(bo->visible);
   916 	newbo->updateLink();	
   917 	requestReposition();
   918 	return newbo;
   919 }
   920 
   921 BranchObj* BranchObj::addBranchPtr(BranchObj* bo)
   922 {
   923 	branch.append (bo);
   924 	bo->setParObj (this);
   925 	bo->depth=depth+1;
   926 	bo->setDefAttr(MovedBranch);
   927 	if (scrolled) tmpUnscroll();
   928 	//setLastSelectedBranch (bo);	//FIXME-3 needed?
   929 	return bo;
   930 }
   931 
   932 BranchObj* BranchObj::insertBranch(int pos)
   933 {
   934 	savePosInAngle();
   935 	// Add new bo and resort branches
   936 	BranchObj *newbo=addBranch ();
   937 	newbo->angle=pos-0.5;
   938 	qSort (branch.begin(),branch.end(), isAbove);
   939 	return newbo;
   940 }
   941 
   942 BranchObj* BranchObj::insertBranch(BranchObj* bo, int pos)
   943 {
   944 	savePosInAngle();
   945 	// Add new bo and resort branches
   946 	bo->angle=pos-0.5;
   947 	BranchObj *newbo=addBranch (bo);
   948 	qSort (branch.begin(),branch.end(), isAbove);
   949 	return newbo;
   950 }
   951 
   952 BranchObj* BranchObj::insertBranchPtr (BranchObj* bo, int pos)
   953 {
   954 	savePosInAngle();
   955 	// Add new bo and resort branches
   956 	bo->angle=pos-0.5;
   957 	branch.append (bo);
   958 	bo->setParObj (this);
   959 	bo->depth=depth+1;
   960 	bo->setDefAttr (MovedBranch);
   961 	if (scrolled) tmpUnscroll();
   962 	//setLastSelectedBranch (bo); //FIXME-3 needed?
   963 	qSort (branch.begin(),branch.end(), isAbove);
   964 	return bo;
   965 }
   966 
   967 void BranchObj::removeBranchHere(BranchObj* borem)
   968 {
   969 	// This removes the branch bo from list, but 
   970 	// inserts its children at the place of bo
   971 	BranchObj *bo;
   972 	bo=borem->getLastBranch();
   973 	int pos=borem->getNum();
   974 	while (bo)
   975 	{
   976 		bo->linkTo (this,pos+1);
   977 		bo=borem->getLastBranch();
   978 	}	
   979 	removeBranch (borem);
   980 }
   981 
   982 void BranchObj::removeChildren()
   983 {
   984 	clear();
   985 }
   986 
   987 void BranchObj::removeBranch(BranchObj* bo)
   988 {
   989     // if bo is not in branch remove returns false, we
   990     // don't care...
   991 	
   992 	int i=branch.indexOf(bo);
   993     if (i>=0)
   994 	{
   995 		delete (bo);
   996 		branch.removeAt (i);
   997 	} else
   998 		qWarning ("BranchObj::removeBranch tried to remove non existing branch?!\n");
   999 	requestReposition();
  1000 }
  1001 
  1002 void BranchObj::removeBranchPtr(BranchObj* bo)
  1003 {
  1004 	int i=branch.indexOf(bo);
  1005 	
  1006 	if (i>=0)
  1007 		branch.removeAt (i);
  1008 	else	
  1009 		qWarning ("BranchObj::removeBranchPtr tried to remove non existing branch?!\n");
  1010 	requestReposition();
  1011 }
  1012 
  1013 BranchObj* BranchObj::getFirstBranch ()
  1014 {
  1015 	if (branch.size()>0)
  1016 		return branch.first();
  1017 	else
  1018 		return NULL;
  1019 }
  1020 
  1021 BranchObj* BranchObj::getLastBranch ()
  1022 {
  1023 	if (branch.size()>0)
  1024 		return branch.last();
  1025 	else
  1026 		return NULL;
  1027 }
  1028 
  1029 BranchObj* BranchObj::getBranchNum (int i)
  1030 {
  1031 	if (i>=0 && i<branch.size())
  1032 		return branch.at(i);
  1033 	else	
  1034 		return	NULL;
  1035 }
  1036 
  1037 bool BranchObj::canMoveBranchUp() 
  1038 {
  1039 	if (!parObj || depth==1) return false;
  1040 	BranchObj* par=(BranchObj*)parObj;
  1041 	if (this==par->getFirstBranch())
  1042 		return false;
  1043 	else
  1044 		return true;
  1045 }
  1046 
  1047 BranchObj* BranchObj::moveBranchUp(BranchObj* bo1) // modify my childlist
  1048 {
  1049 	savePosInAngle();
  1050     int i=branch.indexOf(bo1);
  1051     if (i>0) 
  1052 	{	// -1 if bo1 not found 
  1053 		branch.at(i)->angle--;
  1054 		branch.at(i-1)->angle++;
  1055 		qSort (branch.begin(),branch.end(), isAbove);
  1056 		return branch.at(i);
  1057 	} else
  1058 		return NULL;
  1059 }
  1060 
  1061 bool BranchObj::canMoveBranchDown() 
  1062 {
  1063 	if (!parObj|| depth==1) return false;
  1064 	BranchObj* par=(BranchObj*)parObj;
  1065 	if (this==par->getLastBranch())
  1066 		return false;
  1067 	else
  1068 		return true;
  1069 }
  1070 
  1071 BranchObj* BranchObj::moveBranchDown(BranchObj* bo1)// modify my childlist
  1072 {
  1073 	savePosInAngle();
  1074     int i=branch.indexOf(bo1);
  1075 	int j;
  1076 	if (i <branch.size())
  1077 	{
  1078 		j = i+1;
  1079 		branch.at(i)->angle++;
  1080 		branch.at(j)->angle--;
  1081 		qSort (branch.begin(),branch.end(), isAbove);
  1082 		return branch.at(i);
  1083 	} else
  1084 		return NULL;
  1085 }
  1086 
  1087 void BranchObj::sortChildren()
  1088 {
  1089 	int childCount=branch.count();
  1090 	int curChildIndex;
  1091 	bool madeChanges=false;
  1092 	do
  1093 	{
  1094 		madeChanges=false;
  1095 		for(curChildIndex=1;curChildIndex<childCount;curChildIndex++){
  1096 			BranchObj* curChild=(BranchObj*)branch.at(curChildIndex);
  1097 			BranchObj* prevChild=(BranchObj*)branch.at(curChildIndex-1);
  1098 			if(prevChild->heading->text().compare(curChild->heading->text())>0)
  1099 			{
  1100 				this->moveBranchUp(curChild);
  1101 				madeChanges=true;
  1102 			}
  1103 		}
  1104 	}while(madeChanges);
  1105 }
  1106 
  1107 
  1108 BranchObj* BranchObj::linkTo (BranchObj* dst, int pos)
  1109 {
  1110 	// Find current parent and 
  1111 	// remove pointer to myself there
  1112 	if (!dst) return NULL;
  1113 	BranchObj *par=(BranchObj*)parObj;
  1114 	if (par)
  1115 		par->removeBranchPtr (this);
  1116 	else
  1117 		return NULL;
  1118 
  1119 	// Create new pointer to myself at dst
  1120 	if (pos<0||dst->getDepth()==0)
  1121 	{	
  1122 		// links myself as last branch at dst
  1123 		dst->addBranchPtr (this);
  1124 		updateLink();
  1125 		return this;
  1126 	} else
  1127 	{
  1128 		// inserts me at pos in parent of dst
  1129 		if (par)
  1130 		{
  1131 			BranchObj *bo=dst->insertBranchPtr (this,pos);
  1132 			bo->setDefAttr(MovedBranch);
  1133 			updateLink();
  1134 			return bo;
  1135 
  1136 		} else
  1137 			return NULL;
  1138 	}	
  1139 }
  1140 
  1141 void BranchObj::alignRelativeTo (QPointF ref,bool alignSelf)
  1142 {
  1143 	qreal th = bboxTotal.height();	
  1144 // TODO testing
  1145 /*
  1146 	QPointF pp; if (parObj) pp=parObj->getChildPos();
  1147 	cout << "BO::alignRelTo "<<qPrintable (getHeading());
  1148 	cout << "    d="<<depth<<
  1149 		"  ref="<<ref<<
  1150 //		"  bbox.topLeft="<<bboxTotal.topLeft()<<
  1151 		"  absPos="<<absPos<<
  1152 //		"  relPos="<<relPos<<
  1153 //		"  parPos="<<pp<<
  1154 		"  width="<<bbox.width()<<
  1155 		"  orient="<<orientation<<
  1156 		"  alignSelf="<<alignSelf<<
  1157 //		"  pad="<<topPad<<","<<botPad<<","<<leftPad<<","<<rightPad<<
  1158 //		"  hidden="<<hidden<<
  1159 //		"  th="<<th<<
  1160 		endl;
  1161 */
  1162 
  1163 	setOrientation();
  1164 	//updateLink();
  1165 
  1166 	if (depth<2)
  1167 	{
  1168 		if (depth==1)
  1169 		{
  1170 			// Position relatively, if needed
  1171 			//if (useRelPos) move2RelPos (relPos.x(), relPos.y());
  1172 
  1173 			// Calc angle to mapCenter if I am a mainbranch
  1174 			// needed for reordering the mainbranches clockwise 
  1175 			// around mapcenter 
  1176 			angle=getAngle (QPointF ((int)(x() - parObj->getChildPos().x() ), 
  1177 									(int)(y() - parObj->getChildPos().y() ) ) );
  1178 		}							
  1179 	} 
  1180 	else
  1181     {
  1182 		// Align myself depending on orientation and parent, but
  1183 		// only if I am not a mainbranch or mapcenter itself
  1184 
  1185 		if (anim.isAnimated())
  1186 		{
  1187 			move2RelPos(anim);
  1188 		} else
  1189 		{
  1190 			LinkableMapObj::Orientation o;
  1191 			o=parObj->getOrientation();
  1192 			if (alignSelf)
  1193 				switch (orientation) 
  1194 				{
  1195 					case LinkableMapObj::LeftOfCenter:
  1196 						move (ref.x() - bbox.width(), ref.y() + (th-bbox.height())/2 );
  1197 						//move (ref.x() , ref.y() + (th-bbox.height())/2 );
  1198 					break;
  1199 					case LinkableMapObj::RightOfCenter:	
  1200 						move (ref.x() , ref.y() + (th-bbox.height())/2  );
  1201 					break;
  1202 					default:
  1203 						qWarning ("LMO::alignRelativeTo: oops, no orientation given...");
  1204 					break;
  1205 				}
  1206 		}
  1207     }		
  1208 
  1209 	if (scrolled) return;
  1210 
  1211     // Set reference point for alignment of children
  1212     QPointF ref2;
  1213     if (orientation==LinkableMapObj::LeftOfCenter)
  1214 		ref2.setX(bbox.topLeft().x() - linkwidth);
  1215     else	
  1216 		ref2.setX(bbox.topRight().x() + linkwidth);
  1217 
  1218 	if (depth==1)
  1219 		ref2.setY(absPos.y()-(bboxTotal.height()-bbox.height())/2);
  1220 	else	
  1221 		ref2.setY(ref.y() );	
  1222 
  1223     // Align the children depending on reference point 
  1224 	for (int i=0; i<branch.size(); ++i)
  1225     {	
  1226 		if (!branch.at(i)->isHidden())
  1227 		{
  1228 			branch.at(i)->alignRelativeTo (ref2,true);
  1229 
  1230 			// append next branch below current one
  1231 			ref2.setY(ref2.y() + branch.at(i)->getBBoxSizeWithChildren().height() );
  1232 		}
  1233     }
  1234 }
  1235 
  1236 
  1237 void BranchObj::reposition()
  1238 {	
  1239 /* TODO testing only
  1240 	if (!getHeading().isEmpty())
  1241 		cout << "BO::reposition  "<<qPrintable(getHeading())<<endl;
  1242 	else	
  1243 		cout << "BO::reposition  ???"<<endl;
  1244 
  1245 	cout << "  orient="<<orientation<<endl;
  1246 */		
  1247 
  1248 	if (depth==0)
  1249 	{
  1250 		// only calculate the sizes once. If the deepest LMO 
  1251 		// changes its height,
  1252 		// all upper LMOs have to change, too.
  1253 		calcBBoxSizeWithChildren();
  1254 		updateLink();	// This update is needed if the scene is resized 
  1255 						// due to excessive moving of a FIO
  1256 
  1257 	    alignRelativeTo ( QPointF (absPos.x(),
  1258 			absPos.y()-(bboxTotal.height()-bbox.height())/2) );
  1259 		qSort (branch.begin(),branch.end(), isAbove);
  1260 		positionBBox();	// Reposition bbox and contents
  1261 	} else
  1262 	{
  1263 		// This is only important for moving branches:
  1264 		// For editing a branch it isn't called...
  1265 	    alignRelativeTo ( QPointF (absPos.x(),
  1266 							absPos.y()-(bboxTotal.height()-bbox.height())/2) );
  1267 	}
  1268 }
  1269 
  1270 void BranchObj::unsetAllRepositionRequests()
  1271 {
  1272 	repositionRequest=false;
  1273 	for (int i=0; i<branch.size(); ++i)
  1274 		branch.at(i)->unsetAllRepositionRequests();
  1275 }
  1276 
  1277 
  1278 QPolygonF BranchObj::shape()
  1279 {
  1280 	QPolygonF p;
  1281 
  1282 	QRectF r=getTotalBBox();
  1283 	if (orientation==LinkableMapObj::LeftOfCenter)
  1284 		p   <<r.bottomLeft()
  1285 			<<r.topLeft()
  1286 			<<QPointF (bbox.topLeft().x(), r.topLeft().y() )
  1287 			<<bbox.topRight()
  1288 			<<bbox.bottomRight()
  1289 			<<QPointF (bbox.bottomLeft().x(), r.bottomLeft().y() ) ;
  1290 	else		
  1291 		p   <<r.bottomRight()
  1292 			<<r.topRight()
  1293 			<<QPointF (bbox.topRight().x(), r.topRight().y() )
  1294 			<<bbox.topLeft()
  1295 			<<bbox.bottomLeft()
  1296 			<<QPointF (bbox.bottomRight().x(), r.bottomRight().y() ) ;
  1297 	return p;
  1298 }
  1299 
  1300 QRectF BranchObj::getTotalBBox()
  1301 {
  1302 	QRectF r=bbox;
  1303 
  1304 	if (scrolled) return r;
  1305 
  1306 	for (int i=0; i<branch.size(); ++i)
  1307 		if (!branch.at(i)->isHidden())
  1308 			r=addBBox(branch.at(i)->getTotalBBox(),r);
  1309 
  1310 	for (int i=0; i<floatimage.size(); ++i)
  1311 		if (!floatimage.at(i)->isHidden())
  1312 			r=addBBox(floatimage.at(i)->getTotalBBox(),r);
  1313 		
  1314 	return r;
  1315 }
  1316 
  1317 QRectF BranchObj::getBBoxSizeWithChildren()
  1318 {
  1319 	return bboxTotal;
  1320 }
  1321 
  1322 void BranchObj::calcBBoxSizeWithChildren()
  1323 {	
  1324 	// This is initially called only from reposition and
  1325 	// and only for mapcenter. So it won't be
  1326 	// called more than once for a single user 
  1327 	// action
  1328 	
  1329 
  1330 	// Calculate size of LMO including all children (to align them later)
  1331 	bboxTotal.setX(bbox.x() );
  1332 	bboxTotal.setY(bbox.y() );
  1333 
  1334 	// if branch is scrolled, ignore children, but still consider floatimages
  1335 	if (scrolled)
  1336 	{
  1337 		bboxTotal.setWidth (bbox.width());
  1338 		bboxTotal.setHeight(bbox.height());
  1339 		return;
  1340 	}
  1341 	
  1342 	if (hidden)
  1343 	{
  1344 		bboxTotal.setWidth (0);
  1345 		bboxTotal.setHeight(0);
  1346 		if (parObj)
  1347 		{
  1348 			bboxTotal.setX (parObj->x());
  1349 			bboxTotal.setY (parObj->y());
  1350 		} else
  1351 		{
  1352 			bboxTotal.setX (bbox.x());
  1353 			bboxTotal.setY (bbox.y());
  1354 		}
  1355 		return;
  1356 	}
  1357 	
  1358 	QRectF r(0,0,0,0);
  1359 	QRectF br;
  1360 	// Now calculate recursivly
  1361 	// sum of heights 
  1362 	// maximum of widths 
  1363 	// minimum of y
  1364 	for (int i=0; i<branch.size(); ++i)
  1365 	{
  1366 		if (!branch.at(i)->isHidden())
  1367 		{
  1368 			branch.at(i)->calcBBoxSizeWithChildren();
  1369 			br=branch.at(i)->getBBoxSizeWithChildren();
  1370 			r.setWidth( max (br.width(), r.width() ));
  1371 			r.setHeight(br.height() + r.height() );
  1372 			if (br.y()<bboxTotal.y()) bboxTotal.setY(br.y());
  1373 		}
  1374 	}
  1375 	// Add myself and also
  1376 	// add width of link to sum if necessary
  1377 	if (branch.isEmpty())
  1378 		bboxTotal.setWidth (bbox.width() + r.width() );
  1379 	else	
  1380 		bboxTotal.setWidth (bbox.width() + r.width() + linkwidth);
  1381 	
  1382 	bboxTotal.setHeight(max (r.height(),  bbox.height()));
  1383 }
  1384 
  1385 void BranchObj::select()	// FIXME-2 try to get rid of this in BO completely
  1386 {
  1387 	cout << "BO::select()\n";
  1388 	textEditor->setText(treeItem->getNoteObj().getNote() );
  1389 	QString fnh=treeItem->getNoteObj().getFilenameHint();
  1390 	if (fnh!="")
  1391 		textEditor->setFilenameHint(treeItem->getNoteObj().getFilenameHint() );
  1392 	else	
  1393 		textEditor->setFilenameHint(getHeading() );
  1394 	textEditor->setFontHint (treeItem->getNoteObj().getFontHint() );
  1395 	//isNoteInEditor=true;
  1396 
  1397 	// set selected and visible
  1398     LinkableMapObj::select();
  1399 
  1400     //if (po)	po->setLastSelectedBranch(this);  needed?
  1401 		
  1402 	// temporary unscroll, if we have scrolled parents somewhere
  1403 	if (parObj) ((BranchObj*)(parObj))->tmpUnscroll();
  1404 
  1405 	/* moved to vymmodel or vymview...
  1406 	// Show URL and link in statusbar
  1407 	QString status;
  1408 	if (!url.isEmpty()) status+="URL: "+url+"  ";
  1409 	if (!vymLink.isEmpty()) status+="Link: "+vymLink;
  1410 	if (!status.isEmpty()) mainWindow->statusMessage (status);
  1411 
  1412 	// Update Toolbar
  1413 	updateFlagsToolbar();
  1414 
  1415 	// Update actions
  1416 	model->updateActions();
  1417 	*/
  1418 }
  1419 
  1420 void BranchObj::unselect()	//FIXME-3 should not be needed
  1421 {
  1422 	LinkableMapObj::unselect();
  1423 	// Delete any messages like vymLink in StatusBar
  1424 	mainWindow->statusMessage ("");		//this causes segfault, when MainWindow is already gone in global destructor on quitting vym
  1425 
  1426 /*
  1427 	// Save current note
  1428 	if (isNoteInEditor) getNoteFromTextEditor();
  1429 	isNoteInEditor=false;
  1430 */	
  1431 
  1432 	// reset temporary unscroll, if we have scrolled parents somewhere
  1433 	if (parObj) ((BranchObj*)(parObj))->resetTmpUnscroll();
  1434 
  1435 	// Erase content of editor 
  1436 	textEditor->setInactive();
  1437 
  1438 	// unselect all buttons in toolbar
  1439 	standardFlagsDefault->updateToolbar();
  1440 }
  1441 
  1442 QString BranchObj::getSelectString()
  1443 {
  1444 	return model->getSelectString (this);
  1445 }
  1446 
  1447 void BranchObj::setAnimation(const AnimPoint &ap)
  1448 {
  1449 	anim=ap;
  1450 }
  1451 
  1452 bool BranchObj::animate()
  1453 {
  1454 	anim.animate ();
  1455 	if ( anim.isAnimated() )
  1456 	{
  1457 		setRelPos (anim);
  1458 		return true;
  1459 	}
  1460 	parObj->reposition();	// we might have been relinked meanwhile
  1461 	return false;
  1462 }
  1463