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