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