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