branchobj.cpp
author insilmaril
Mon, 19 Feb 2007 12:01:52 +0000
changeset 428 9ae68208e2ff
parent 425 7014be3ac7d0
child 440 c6a8651e6bbc
permissions -rw-r--r--
1.8.67 Bugfixes
     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 	setSelBox();
   576 
   577 	// set the frame
   578 	frame->setRect(QRectF(bbox.x(),bbox.y(),bbox.width(),bbox.height() ) );
   579 
   580 	// Update links to other branches
   581 	for (int i=0; i<xlink.size(); ++i)
   582 		xlink.at(i)->updateXLink();
   583 }
   584 
   585 void BranchObj::calcBBoxSize()
   586 {
   587     QSizeF heading_r=heading->getSize();
   588     qreal heading_w=(qreal) heading_r.width() ;
   589     qreal heading_h=(qreal) heading_r.height() ;
   590     QSizeF sysflags_r=systemFlags->getSize();
   591 	qreal sysflags_h=sysflags_r.height();
   592 	qreal sysflags_w=sysflags_r.width();
   593     QSizeF stanflags_r=standardFlags->getSize();
   594 	qreal stanflags_h=stanflags_r.height();
   595 	qreal stanflags_w=stanflags_r.width();
   596     qreal w;
   597     qreal h;
   598 
   599 	// set width to sum of all widths
   600 	w=heading_w + sysflags_w + stanflags_w;
   601 	// set height to maximum needed height
   602 	h=max (sysflags_h,stanflags_h);
   603 	h=max (h,heading_h);
   604 
   605 	// Save the dimension of flags and heading
   606 	ornamentsBBox.setSize ( QSizeF(w,h));
   607 
   608 	// clickBox includes Flags and Heading
   609     clickBox.setSize (ornamentsBBox.size() );
   610 
   611 	// Floatimages 
   612 	QPointF rp;
   613 
   614 	topPad=botPad=leftPad=rightPad=0;
   615 	if (includeImagesVer || includeImagesHor)
   616 	{
   617 		if (countFloatImages()>0)
   618 		{
   619 			for (int i=0; i<floatimage.size(); ++i )
   620 			{
   621 				rp=floatimage.at(i)->getRelPos();
   622 				if (includeImagesVer)
   623 				{
   624 					if (rp.y() < 0) 
   625 						topPad=max (topPad,-rp.y()-h);
   626 					if (rp.y()+floatimage.at(i)->height() > 0)
   627 						botPad=max (botPad,rp.y()+floatimage.at(i)->height());
   628 				}		
   629 				if (includeImagesHor)
   630 				{
   631 					if (orientation==OrientRightOfCenter)
   632 					{
   633 						if (-rp.x()-w > 0) 
   634 							leftPad=max (leftPad,-rp.x()-w);
   635 						if (rp.x()+floatimage.at(i)->width() > 0)
   636 							rightPad=max (rightPad,rp.x()+floatimage.at(i)->width());
   637 					} else
   638 					{
   639 						if (rp.x()< 0) 
   640 							leftPad=max (leftPad,-rp.x());
   641 						if (rp.x()+floatimage.at(i)->width() > w)
   642 							rightPad=max (rightPad,rp.x()+floatimage.at(i)->width()-w);
   643 					}
   644 				}		
   645 			}	
   646 		}	
   647 		h+=topPad+botPad;
   648 		w+=leftPad+rightPad;
   649 	}
   650 
   651 	// Frame thickness
   652     w+=frame->getBorder();
   653     h+=frame->getBorder();
   654 	
   655 	// Finally set size
   656     bbox.setSize (QSizeF (w,h));
   657 }
   658 
   659 void BranchObj::setDockPos()
   660 {
   661 	// Sets childpos and parpos depending on orientation
   662 	if (getOrientation()==OrientLeftOfCenter )
   663     {
   664 		childPos=QPointF (ornamentsBBox.bottomLeft().x(), ornamentsBBox.bottomLeft().y() );
   665 		parPos=QPointF (ornamentsBBox.bottomRight().x(),ornamentsBBox.bottomRight().y() );
   666     } else
   667     {
   668 		childPos=QPointF (ornamentsBBox.bottomRight().x(), ornamentsBBox.bottomRight().y() );
   669 		parPos=QPointF (ornamentsBBox.bottomLeft().x(),ornamentsBBox.bottomLeft().y() );
   670     }
   671 }
   672 
   673 LinkableMapObj* BranchObj::findMapObj(QPointF p, LinkableMapObj* excludeLMO)
   674 {
   675 	// Search branches
   676     LinkableMapObj *lmo;
   677 	for (int i=0; i<branch.size(); ++i)
   678     {	
   679 		lmo=branch.at(i)->findMapObj(p, excludeLMO);
   680 		if (lmo != NULL) return lmo;
   681     }
   682 	
   683 	// Search myself
   684     if (inBox (p) && (this != excludeLMO) && isVisibleObj() ) 
   685 		return this;
   686 
   687 	// Search float images
   688     for (int i=0; i<floatimage.size(); ++i )
   689 		if (floatimage.at(i)->inBox(p) && 
   690 			(floatimage.at(i) != excludeLMO) && 
   691 			floatimage.at(i)->getParObj()!= excludeLMO &&
   692 			floatimage.at(i)->isVisibleObj() 
   693 		) return floatimage.at(i);
   694 
   695     return NULL;
   696 }
   697 
   698 void BranchObj::setHeading(QString s)
   699 {
   700     heading->setText(s);	// set new heading
   701 	calcBBoxSize();			// recalculate bbox
   702     positionBBox();			// rearrange contents
   703 	requestReposition();
   704 }
   705 
   706 void BranchObj::setHideTmp (HideTmpMode mode)
   707 {
   708 	if (mode==HideExport && hasHiddenExportParent(this))
   709 	{
   710 		setVisibility (false);
   711 		hidden=true;
   712 	}else
   713 	{
   714 		if (hasScrolledParent(this))
   715 			setVisibility (false);
   716 		else
   717 			setVisibility (true);
   718 		hidden=false;
   719 	}	
   720 
   721 	for (int i=0; i<branch.size(); ++i)
   722 		branch.at(i)->setHideTmp (mode);
   723 }
   724 
   725 bool BranchObj::hasHiddenExportParent(BranchObj *start)
   726 {
   727 	// Calls parents recursivly to
   728 	// find out, if we are temp. hidden
   729 
   730 	if (hideExport) return true;
   731 
   732 	BranchObj* bo=(BranchObj*)(parObj);
   733 	if (bo) 
   734 		return bo->hasHiddenExportParent(start);
   735 	else
   736 		return false;
   737 }
   738 
   739 QString BranchObj::saveToDir (const QString &tmpdir,const QString &prefix, const QPointF& offset)
   740 {
   741 	// Cloudy stuff can be hidden during exports
   742 	if (hidden) return "";
   743 
   744 	// Update of note is usually done while unselecting a branch
   745 	if (isNoteInEditor) getNoteFromTextEditor();
   746 	
   747     QString s,a;
   748 	QString scrolledAttr;
   749 	if (scrolled) 
   750 		scrolledAttr=attribut ("scrolled","yes");
   751 	else
   752 		scrolledAttr="";
   753 
   754 	// save area, if not scrolled
   755 	QString areaAttr;
   756 	if (!((BranchObj*)(parObj))->isScrolled() )
   757 	{
   758 		areaAttr=
   759 			attribut("x1",QString().setNum(absPos.x()-offset.x())) +
   760 			attribut("y1",QString().setNum(absPos.y()-offset.y())) +
   761 			attribut("x2",QString().setNum(absPos.x()+width()-offset.x())) +
   762 			attribut("y2",QString().setNum(absPos.y()+height()-offset.y()));
   763 
   764 	} else
   765 		areaAttr="";
   766 	
   767 	// Providing an ID for a branch makes export to XHTML easier
   768 	QString idAttr;
   769 	if (countXLinks()>0)
   770 		idAttr=attribut ("id",getSelectString());
   771 	else
   772 		idAttr="";
   773 
   774     s=beginElement ("branch" 
   775 		+getOrnAttr() 
   776 		+scrolledAttr 
   777 		+areaAttr 
   778 		+idAttr 
   779 		+getIncludeImageAttr() );
   780     incIndent();
   781 
   782 	// save heading
   783     s+=valueElement("heading", getHeading(),
   784 		attribut ("textColor",QColor(heading->getColor()).name()));
   785 
   786 	// Save frame
   787 	if (frame->getFrameType()!=NoFrame) 
   788 		s+=frame->saveToDir ();
   789 
   790 	// save names of flags set
   791 	s+=standardFlags->saveToDir(tmpdir,prefix,0);
   792 	
   793 	// Save FloatImages
   794 	for (int i=0; i<floatimage.size(); ++i)
   795 		s+=floatimage.at(i)->saveToDir (tmpdir,prefix);
   796 
   797 	// save note
   798 	if (!note.isEmpty() )
   799 		s+=note.saveToDir();
   800 	
   801 	// Save branches
   802 	for (int i=0; i<branch.size(); ++i)
   803 		s+=branch.at(i)->saveToDir(tmpdir,prefix,offset);
   804 
   805 	// Save XLinks
   806 	QString ol;	// old link
   807 	QString cl;	// current link
   808 	for (int i=0; i<xlink.size(); ++i)
   809 	{
   810 		cl=xlink.at(i)->saveToDir();
   811 		if (cl!=ol)
   812 		{
   813 			s+=cl;
   814 			ol=cl;
   815 		} else
   816 		{
   817 			qWarning (QString("Ignoring of duplicate xLink in %1").arg(getHeading()));
   818 		}
   819 	}	
   820 
   821     decIndent();
   822     s+=endElement   ("branch");
   823     return s;
   824 }
   825 
   826 void BranchObj::addXLink (XLinkObj *xlo)
   827 {
   828 	xlink.append (xlo);
   829 	
   830 }
   831 
   832 void BranchObj::removeXLinkRef (XLinkObj *xlo)
   833 {
   834 	xlink.removeAt (xlink.indexOf(xlo));
   835 }
   836 
   837 void BranchObj::deleteXLink(XLinkObj *xlo)
   838 {
   839 	xlo->deactivate();
   840 	if (!xlo->isUsed()) delete (xlo);
   841 }
   842 
   843 void BranchObj::deleteXLinkAt (int i)
   844 {
   845 	XLinkObj *xlo=xlink.at(i);
   846 	xlo->deactivate();
   847 	if (!xlo->isUsed()) delete(xlo);
   848 }
   849 
   850 XLinkObj* BranchObj::XLinkAt (int i)
   851 {
   852 	return xlink.at(i);
   853 }
   854 
   855 int BranchObj::countXLink()
   856 {
   857 	return xlink.count();
   858 }
   859 
   860 
   861 BranchObj* BranchObj::XLinkTargetAt (int i)
   862 {
   863 	if (i>=0 && i<xlink.size())
   864 	{
   865 		if (xlink.at(i))
   866 			return xlink.at(i)->otherBranch (this);
   867 	}
   868 	return NULL;
   869 }
   870 
   871 void BranchObj::setIncludeImagesVer(bool b)
   872 {
   873 	includeImagesVer=b;
   874 	calcBBoxSize();
   875 	positionBBox();
   876 	requestReposition();
   877 }
   878 
   879 bool BranchObj::getIncludeImagesVer()
   880 {
   881 	return includeImagesVer;
   882 }
   883 
   884 void BranchObj::setIncludeImagesHor(bool b)
   885 {
   886 	includeImagesHor=b;
   887 	calcBBoxSize();
   888 	positionBBox();
   889 	requestReposition();
   890 }
   891 
   892 bool BranchObj::getIncludeImagesHor()
   893 {
   894 	return includeImagesHor;
   895 }
   896 
   897 QString BranchObj::getIncludeImageAttr()
   898 {
   899 	QString a;
   900 	if (includeImagesVer)
   901 		a=attribut ("incImgV","true");
   902 	else
   903 		a=attribut ("incImgV","false");
   904 	if (includeImagesHor)
   905 		a+=attribut ("incImgH","true");
   906 	else
   907 		a+=attribut ("incImgH","false");
   908 	return a;	
   909 }
   910 
   911 FloatImageObj* BranchObj::addFloatImage ()
   912 {
   913 	FloatImageObj *newfi=new FloatImageObj (scene,this);
   914 	floatimage.append (newfi);
   915 	if (hasScrolledParent(this) )
   916 		newfi->setVisibility (false);
   917 	else	
   918 		newfi->setVisibility(visible);
   919 		/*
   920 	calcBBoxSize();
   921 	positionBBox();
   922 	*/
   923 	requestReposition();
   924 	return newfi;
   925 }
   926 
   927 FloatImageObj* BranchObj::addFloatImage (FloatImageObj *fio)
   928 {
   929 	FloatImageObj *newfi=new FloatImageObj (scene,this);
   930 	floatimage.append (newfi);
   931 	newfi->copy (fio);
   932 	if (hasScrolledParent(this) )
   933 		newfi->setVisibility (false);
   934 	else	
   935 		newfi->setVisibility(visible);
   936 		/*
   937 	calcBBoxSize();
   938 	positionBBox();
   939 	*/
   940 	requestReposition();
   941 	return newfi;
   942 }
   943 
   944 FloatImageObj* BranchObj::getFirstFloatImage ()
   945 {
   946     return floatimage.first();
   947 }
   948 
   949 FloatImageObj* BranchObj::getLastFloatImage ()
   950 {
   951     return floatimage.last();
   952 }
   953 
   954 FloatImageObj* BranchObj::getFloatImageNum (const uint &i)
   955 {
   956     return floatimage.at(i);
   957 }
   958 
   959 void BranchObj::removeFloatImage (FloatImageObj *fio)
   960 {
   961 	int i=floatimage.indexOf (fio);
   962 	if (i>-1) delete (floatimage.takeAt (i));
   963 	calcBBoxSize();
   964 	positionBBox();
   965 	requestReposition();
   966 }
   967 
   968 void BranchObj::savePosInAngle ()
   969 {
   970 	// Save position in angle
   971 	for (int i=0; i<branch.size(); ++i)
   972 		branch.at(i)->angle=i;
   973 }
   974 
   975 void BranchObj::setDefAttr (BranchModification mod)
   976 {
   977 	int fontsize;
   978 	switch (depth)
   979 	{
   980 		case 0: fontsize=16; break;
   981 		case 1: fontsize=12; break;
   982 		default: fontsize=10; break;
   983 	}	
   984 
   985 	setLinkColor ();
   986 	setLinkStyle(getDefLinkStyle());
   987 	QFont font("Sans Serif,8,-1,5,50,0,0,0,0,0");
   988 	font.setPointSize(fontsize);
   989 	heading->setFont(font );
   990 
   991 	if (mod==NewBranch)
   992 		setColor (((BranchObj*)(parObj))->getColor());
   993 	
   994 	calcBBoxSize();
   995 }
   996 
   997 BranchObj* BranchObj::addBranch()
   998 {
   999     BranchObj* newbo=new BranchObj(scene,this);
  1000     branch.append (newbo);
  1001     newbo->setParObj(this);
  1002 	newbo->setDefAttr(NewBranch);
  1003     newbo->setHeading ("new");
  1004 	if (scrolled)
  1005 		newbo->setVisibility (false);
  1006 	else	
  1007 		newbo->setVisibility(visible);
  1008 	newbo->updateLink();	
  1009 	requestReposition();
  1010 	return newbo;
  1011 }
  1012 
  1013 BranchObj* BranchObj::addBranch(BranchObj* bo)
  1014 {
  1015     BranchObj* newbo=new BranchObj(scene,this);
  1016     branch.append (newbo);
  1017     newbo->copy(bo);
  1018     newbo->setParObj(this);
  1019 	newbo->setDefAttr(MovedBranch);
  1020 	if (scrolled)
  1021 		newbo->setVisibility (false);
  1022 	else	
  1023 		newbo->setVisibility(bo->visible);
  1024 	newbo->updateLink();	
  1025 	requestReposition();
  1026 	return newbo;
  1027 }
  1028 
  1029 BranchObj* BranchObj::addBranchPtr(BranchObj* bo)
  1030 {
  1031 	branch.append (bo);
  1032 	bo->setParObj (this);
  1033 	bo->depth=depth+1;
  1034 	bo->setDefAttr(MovedBranch);
  1035 	if (scrolled) tmpUnscroll();
  1036 	setLastSelectedBranch (bo);
  1037 	return bo;
  1038 }
  1039 
  1040 BranchObj* BranchObj::insertBranch(int pos)
  1041 {
  1042 	savePosInAngle();
  1043 	// Add new bo and resort branches
  1044 	BranchObj *newbo=addBranch ();
  1045 	newbo->angle=pos-0.5;
  1046 	qSort (branch.begin(),branch.end(), isAbove);
  1047 	return newbo;
  1048 }
  1049 
  1050 BranchObj* BranchObj::insertBranch(BranchObj* bo, int pos)
  1051 {
  1052 	savePosInAngle();
  1053 	// Add new bo and resort branches
  1054 	bo->angle=pos-0.5;
  1055 	BranchObj *newbo=addBranch (bo);
  1056 	qSort (branch.begin(),branch.end(), isAbove);
  1057 	return newbo;
  1058 }
  1059 
  1060 BranchObj* BranchObj::insertBranchPtr (BranchObj* bo, int pos)
  1061 {
  1062 	savePosInAngle();
  1063 	// Add new bo and resort branches
  1064 	bo->angle=pos-0.5;
  1065 	branch.append (bo);
  1066 	bo->setParObj (this);
  1067 	bo->depth=depth+1;
  1068 	bo->setDefAttr (MovedBranch);
  1069 	if (scrolled) tmpUnscroll();
  1070 	setLastSelectedBranch (bo);
  1071 	qSort (branch.begin(),branch.end(), isAbove);
  1072 	return bo;
  1073 }
  1074 
  1075 void BranchObj::removeBranchHere(BranchObj* borem)
  1076 {
  1077 	// This removes the branch bo from list, but 
  1078 	// inserts its childs at the place of bo
  1079 	BranchObj *bo;
  1080 	bo=borem->getLastBranch();
  1081 	int pos=borem->getNum();
  1082 	while (bo)
  1083 	{
  1084 		bo->linkTo (this,pos+1);
  1085 		bo=borem->getLastBranch();
  1086 	}	
  1087 	removeBranch (borem);
  1088 }
  1089 
  1090 void BranchObj::removeChilds()
  1091 {
  1092 	clear();
  1093 }
  1094 
  1095 void BranchObj::removeBranch(BranchObj* bo)
  1096 {
  1097     // if bo is not in branch remove returns false, we
  1098     // don't care...
  1099 	
  1100 	int i=branch.indexOf(bo);
  1101     if (i>=0)
  1102 	{
  1103 		delete (bo);
  1104 		branch.removeAt (i);
  1105 	} else
  1106 		qWarning ("BranchObj::removeBranch tried to remove non existing branch?!\n");
  1107 	requestReposition();
  1108 }
  1109 
  1110 void BranchObj::removeBranchPtr(BranchObj* bo)
  1111 {
  1112 	int i=branch.indexOf(bo);
  1113 	
  1114 	if (i>=0)
  1115 		branch.removeAt (i);
  1116 	else	
  1117 		qWarning ("BranchObj::removeBranchPtr tried to remove non existing branch?!\n");
  1118 	requestReposition();
  1119 }
  1120 
  1121 void BranchObj::setLastSelectedBranch (BranchObj* bo)
  1122 {
  1123     lastSelectedBranch=branch.indexOf(bo);
  1124 }
  1125 
  1126 BranchObj* BranchObj::getLastSelectedBranch ()
  1127 {
  1128     if (lastSelectedBranch>=0)
  1129 	{
  1130 		if ( branch.size()>lastSelectedBranch) 
  1131 			return branch.at(lastSelectedBranch);
  1132 		if (branch.size()>0)
  1133 			return branch.last();
  1134 	}	
  1135     return NULL;
  1136 }
  1137 
  1138 BranchObj* BranchObj::getFirstBranch ()
  1139 {
  1140 	if (branch.size()>0)
  1141 		return branch.first();
  1142 	else
  1143 		return NULL;
  1144 }
  1145 
  1146 BranchObj* BranchObj::getLastBranch ()
  1147 {
  1148 	if (branch.size()>0)
  1149 		return branch.last();
  1150 	else
  1151 		return NULL;
  1152 }
  1153 
  1154 BranchObj* BranchObj::getBranchNum (int i)
  1155 {
  1156 	if (i>=0 && i<branch.size())
  1157 		return branch.at(i);
  1158 	else	
  1159 		return	NULL;
  1160 }
  1161 
  1162 bool BranchObj::canMoveBranchUp() 
  1163 {
  1164 	if (!parObj || depth==1) return false;
  1165 	BranchObj* par=(BranchObj*)parObj;
  1166 	if (this==par->getFirstBranch())
  1167 		return false;
  1168 	else
  1169 		return true;
  1170 }
  1171 
  1172 BranchObj* BranchObj::moveBranchUp(BranchObj* bo1) // modify my childlist
  1173 {
  1174 	savePosInAngle();
  1175     int i=branch.indexOf(bo1);
  1176     if (i>0) 
  1177 	{	// -1 if bo1 not found 
  1178 		branch.at(i)->angle--;
  1179 		branch.at(i-1)->angle++;
  1180 		qSort (branch.begin(),branch.end(), isAbove);
  1181 		return branch.at(i);
  1182 	} else
  1183 		return NULL;
  1184 }
  1185 
  1186 bool BranchObj::canMoveBranchDown() 
  1187 {
  1188 	if (!parObj|| depth==1) return false;
  1189 	BranchObj* par=(BranchObj*)parObj;
  1190 	if (this==par->getLastBranch())
  1191 		return false;
  1192 	else
  1193 		return true;
  1194 }
  1195 
  1196 BranchObj* BranchObj::moveBranchDown(BranchObj* bo1)// modify my childlist
  1197 {
  1198 	savePosInAngle();
  1199     int i=branch.indexOf(bo1);
  1200 	int j;
  1201 	if (i <branch.size())
  1202 	{
  1203 		j = i+1;
  1204 		branch.at(i)->angle++;
  1205 		branch.at(j)->angle--;
  1206 		qSort (branch.begin(),branch.end(), isAbove);
  1207 		return branch.at(i);
  1208 	} else
  1209 		return NULL;
  1210 }
  1211 
  1212 BranchObj* BranchObj::linkTo (BranchObj* dst, int pos)
  1213 {
  1214 	// Find current parent and 
  1215 	// remove pointer to myself there
  1216 	if (!dst) return NULL;
  1217 	BranchObj *par=(BranchObj*)parObj;
  1218 	if (par)
  1219 		par->removeBranchPtr (this);
  1220 	else
  1221 		return NULL;
  1222 
  1223 	// Create new pointer to myself at dst
  1224 	if (pos<0||dst->getDepth()==0)
  1225 	{	
  1226 		// links myself as last branch at dst
  1227 		dst->addBranchPtr (this);
  1228 		updateLink();
  1229 		return this;
  1230 	} else
  1231 	{
  1232 		// inserts me at pos in parent of dst
  1233 		if (par)
  1234 		{
  1235 			BranchObj *bo=dst->insertBranchPtr (this,pos);
  1236 			bo->setDefAttr(MovedBranch);
  1237 			updateLink();
  1238 			return bo;
  1239 
  1240 		} else
  1241 			return NULL;
  1242 	}	
  1243 }
  1244 
  1245 void BranchObj::alignRelativeTo (QPointF ref)
  1246 {
  1247 	qreal th = bboxTotal.height();	
  1248 // TODO testing
  1249 /*
  1250 	cout << "BO::alignRelTo "<<getHeading().ascii()<<endl;
  1251 	cout << "  d="<<depth<<
  1252 		"  ref="<<ref<<
  1253 //		"  bbox.topLeft="<<bboxTotal.topLeft()<<
  1254 		"  absPos="<<absPos<<
  1255 		"  relPos="<<relPos<<
  1256 		"  orient="<<orientation<<
  1257 //		"  pad="<<topPad<<","<<botPad<<","<<leftPad<<","<<rightPad<<
  1258 //		"  hidden="<<hidden<<
  1259 //		"  th="<<th<<
  1260 		endl;
  1261 */
  1262 
  1263 	setOrientation();
  1264 	//updateLink();
  1265 
  1266 	if (depth<2)
  1267 	{
  1268 		if (depth==1)
  1269 		{
  1270 			// Position relatively, if needed
  1271 			//if (useRelPos) move2RelPos (relPos.x(), relPos.y());
  1272 
  1273 			// Calc angle to mapCenter if I am a mainbranch
  1274 			// needed for reordering the mainbranches clockwise 
  1275 			// around mapcenter 
  1276 			angle=getAngle (QPointF ((int)(x() - parObj->getChildPos().x() ), 
  1277 									(int)(y() - parObj->getChildPos().y() ) ) );
  1278 		}							
  1279 	} 
  1280 	else
  1281     {
  1282 		// Align myself depending on orientation and parent, but
  1283 		// only if I am not a mainbranch or mapcenter itself
  1284 		LinkOrient o;
  1285 		o=parObj->getOrientation();
  1286 		switch (orientation) 
  1287 		{
  1288 			case OrientLeftOfCenter:
  1289 				move (ref.x() - bbox.width(), ref.y() + (th-bbox.height())/2 );
  1290 			break;
  1291 			case OrientRightOfCenter:	
  1292 				move (ref.x() , ref.y() + (th-bbox.height())/2  );
  1293 			break;
  1294 			default:
  1295 				qWarning ("LMO::alignRelativeTo: oops, no orientation given...");
  1296 			break;
  1297 		}		
  1298     }		
  1299 
  1300 	if (scrolled) return;
  1301 
  1302     // Set reference point for alignment of childs
  1303     QPointF ref2;
  1304     if (orientation==OrientLeftOfCenter)
  1305 		ref2.setX(bbox.topLeft().x() - linkwidth);
  1306     else	
  1307 		ref2.setX(bbox.topRight().x() + linkwidth);
  1308 
  1309 	if (depth==1)
  1310 		ref2.setY(absPos.y()-(bboxTotal.height()-bbox.height())/2);
  1311 	else	
  1312 		ref2.setY(ref.y() );	
  1313 
  1314     // Align the childs depending on reference point 
  1315 	for (int i=0; i<branch.size(); ++i)
  1316     {	
  1317 		if (!branch.at(i)->isHidden())
  1318 		{
  1319 			branch.at(i)->alignRelativeTo (ref2);
  1320 			ref2.setY(ref2.y() + branch.at(i)->getBBoxSizeWithChilds().height() );
  1321 		}
  1322     }
  1323 }
  1324 
  1325 
  1326 void BranchObj::reposition()
  1327 {	
  1328 /* TODO testing only
  1329 	if (!getHeading().isEmpty())
  1330 		cout << "BO::reposition  "<<getHeading().ascii()<<endl;
  1331 	else	
  1332 		cout << "BO::reposition  ???"<<endl;
  1333 
  1334 	cout << "  orient="<<orientation<<endl;
  1335 */		
  1336 
  1337 	if (depth==0)
  1338 	{
  1339 		// only calculate the sizes once. If the deepest LMO 
  1340 		// changes its height,
  1341 		// all upper LMOs have to change, too.
  1342 		calcBBoxSizeWithChilds();
  1343 		updateLink();	// This update is needed if the scene is resized 
  1344 						// due to excessive moving of a FIO
  1345 
  1346 	    alignRelativeTo ( QPointF (absPos.x(),
  1347 			absPos.y()-(bboxTotal.height()-bbox.height())/2) );
  1348 		qSort (branch.begin(),branch.end(), isAbove);
  1349 		positionBBox();	// Reposition bbox and contents
  1350 	} else
  1351 	{
  1352 		// This is only important for moving branches:
  1353 		// For editing a branch it isn't called...
  1354 	    alignRelativeTo ( QPointF (absPos.x(),
  1355 							absPos.y()-(bboxTotal.height()-bbox.height())/2) );
  1356 	}
  1357 }
  1358 
  1359 void BranchObj::unsetAllRepositionRequests()
  1360 {
  1361 	repositionRequest=false;
  1362 	for (int i=0; i<branch.size(); ++i)
  1363 		branch.at(i)->unsetAllRepositionRequests();
  1364 }
  1365 
  1366 
  1367 QRectF BranchObj::getTotalBBox()
  1368 {
  1369 	QRectF r=bbox;
  1370 
  1371 	if (scrolled) return r;
  1372 
  1373 	for (int i=0; i<branch.size(); ++i)
  1374 		if (!branch.at(i)->isHidden())
  1375 			r=addBBox(branch.at(i)->getTotalBBox(),r);
  1376 
  1377 	for (int i=0; i<floatimage.size(); ++i)
  1378 		if (!floatimage.at(i)->isHidden())
  1379 			r=addBBox(floatimage.at(i)->getTotalBBox(),r);
  1380 		
  1381 	return r;
  1382 }
  1383 
  1384 QRectF BranchObj::getBBoxSizeWithChilds()
  1385 {
  1386 	return bboxTotal;
  1387 }
  1388 
  1389 void BranchObj::calcBBoxSizeWithChilds()
  1390 {	
  1391 	// This is initially called only from reposition and
  1392 	// and only for mapcenter. So it won't be
  1393 	// called more than once for a single user 
  1394 	// action
  1395 	
  1396 
  1397 	// Calculate size of LMO including all childs (to align them later)
  1398 	bboxTotal.setX(bbox.x() );
  1399 	bboxTotal.setY(bbox.y() );
  1400 
  1401 	// if branch is scrolled, ignore childs, but still consider floatimages
  1402 	if (scrolled)
  1403 	{
  1404 		bboxTotal.setWidth (bbox.width());
  1405 		bboxTotal.setHeight(bbox.height());
  1406 		return;
  1407 	}
  1408 	
  1409 	if (hidden)
  1410 	{
  1411 		bboxTotal.setWidth (0);
  1412 		bboxTotal.setHeight(0);
  1413 		if (parObj)
  1414 		{
  1415 			bboxTotal.setX (parObj->x());
  1416 			bboxTotal.setY (parObj->y());
  1417 		} else
  1418 		{
  1419 			bboxTotal.setX (bbox.x());
  1420 			bboxTotal.setY (bbox.y());
  1421 		}
  1422 		return;
  1423 	}
  1424 	
  1425 	QRectF r(0,0,0,0);
  1426 	QRectF br;
  1427 	// Now calculate recursivly
  1428 	// sum of heights 
  1429 	// maximum of widths 
  1430 	// minimum of y
  1431 	for (int i=0; i<branch.size(); ++i)
  1432 	{
  1433 		if (!branch.at(i)->isHidden())
  1434 		{
  1435 			branch.at(i)->calcBBoxSizeWithChilds();
  1436 			br=branch.at(i)->getBBoxSizeWithChilds();
  1437 			r.setWidth( max (br.width(), r.width() ));
  1438 			r.setHeight(br.height() + r.height() );
  1439 			if (br.y()<bboxTotal.y()) bboxTotal.setY(br.y());
  1440 		}
  1441 	}
  1442 	// Add myself and also
  1443 	// add width of link to sum if necessary
  1444 	if (branch.isEmpty())
  1445 		bboxTotal.setWidth (bbox.width() + r.width() );
  1446 	else	
  1447 		bboxTotal.setWidth (bbox.width() + r.width() + linkwidth);
  1448 	
  1449 	bboxTotal.setHeight(max (r.height(),  bbox.height()));
  1450 }
  1451 
  1452 void BranchObj::select()
  1453 {
  1454 	// set Text in Editor	
  1455 	textEditor->setText(note.getNote() );
  1456 	QString fnh=note.getFilenameHint();
  1457 	if (fnh!="")
  1458 		textEditor->setFilenameHint(note.getFilenameHint() );
  1459 	else	
  1460 		textEditor->setFilenameHint(getHeading() );
  1461 	textEditor->setFontHint (note.getFontHint() );
  1462 	isNoteInEditor=true;
  1463 
  1464     LinkableMapObj::select();
  1465 	// Tell parent that I am selected now:
  1466 	BranchObj* po=(BranchObj*)(parObj);
  1467     if (po)	// TODO	    Try to get rid of this cast...
  1468         po->setLastSelectedBranch(this);
  1469 		
  1470 	// temporary unscroll, if we have scrolled parents somewhere
  1471 	if (parObj) ((BranchObj*)(parObj))->tmpUnscroll();
  1472 
  1473 	// Show URL and link in statusbar
  1474 	QString status;
  1475 	if (!url.isEmpty()) status+="URL: "+url+"  ";
  1476 	if (!vymLink.isEmpty()) status+="Link: "+vymLink;
  1477 	if (!status.isEmpty()) mainWindow->statusMessage (status);
  1478 
  1479 	// Update Toolbar
  1480 	updateFlagsToolbar();
  1481 
  1482 	// Update actions
  1483 	mapEditor->updateActions();
  1484 }
  1485 
  1486 void BranchObj::unselect()
  1487 {
  1488 	LinkableMapObj::unselect();
  1489 	// Delete any messages like vymLink in StatusBar
  1490 	mainWindow->statusMessage ("");
  1491 
  1492 	// Save current note
  1493 	if (isNoteInEditor) getNoteFromTextEditor();
  1494 	isNoteInEditor=false;
  1495 
  1496 	// reset temporary unscroll, if we have scrolled parents somewhere
  1497 	if (parObj) ((BranchObj*)(parObj))->resetTmpUnscroll();
  1498 
  1499 	// Erase content of editor 
  1500 	textEditor->setInactive();
  1501 
  1502 	// unselect all buttons in toolbar
  1503 	standardFlagsDefault->updateToolbar();
  1504 }
  1505 
  1506 QString BranchObj::getSelectString()
  1507 {
  1508 	QString s;
  1509 	if (parObj)
  1510 	{
  1511 		if (depth==1)
  1512 			s= "bo:" + QString("%1").arg(getNum());
  1513 		else	
  1514 			s= ((BranchObj*)(parObj))->getSelectString() + ",bo:" + QString("%1").arg(getNum());
  1515 	} else
  1516 		s="mc:";
  1517 	return s;
  1518 }
  1519