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