branchobj.cpp
author insilmaril
Fri, 08 Dec 2006 20:18:58 +0000
changeset 410 ceb4532eae34
parent 408 c2a05fa925a1
child 411 910ba9fab728
permissions -rw-r--r--
1.6.1 Port to QGraphics
     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 /* FIXME not needed any longer in QT4
    12 int BranchObjPointrList::compareItems ( Q3PtrCollection::Item i, Q3PtrCollection::Item j)
    13 {
    14 	// Make sure PtrList::find works
    15 	if (i==j) return 0;
    16 
    17 	if ( ((BranchObj*)(i))->angle > ((BranchObj*)(j))->angle )
    18 		return 1;
    19 	else
    20 		return -1;
    21 }
    22 */
    23 
    24 /////////////////////////////////////////////////////////////////
    25 // BranchObj
    26 /////////////////////////////////////////////////////////////////
    27 
    28 BranchObj* BranchObj::itLast=NULL;
    29 BranchObj* BranchObj::itFirst=NULL;
    30 
    31 
    32 BranchObj::BranchObj () :OrnamentedObj()
    33 {
    34 //    cout << "Const BranchObj ()\n";
    35     setParObj (this);	
    36     init();
    37     depth=-1;
    38 }
    39 
    40 BranchObj::BranchObj (QGraphicsScene* s):OrnamentedObj (s)
    41 {
    42 //    cout << "Const BranchObj (s)  called from MapCenterObj (s)\n";
    43 	parObj=NULL;
    44     scene=s;
    45 }
    46 
    47 BranchObj::BranchObj (QGraphicsScene* s, LinkableMapObj* p):OrnamentedObj (s)
    48 {
    49 //    cout << "Const BranchObj (s,p)\n";
    50     scene=s;
    51     setParObj (p);	
    52     depth=p->getDepth()+1;
    53 	if (depth==1)
    54 		// Calc angle to mapCenter if I am a mainbranch
    55 		// needed for reordering the mainbranches clockwise 
    56 		// around mapcenter 
    57 		angle=getAngle (QPointF (x() - parObj->getChildPos().x() , 
    58 								(y() - parObj->getChildPos().y() ) ) );
    59     init();
    60 }
    61 
    62 BranchObj::~BranchObj ()
    63 {
    64 //	cout << "Destr BranchObj of "<<this<<endl;
    65 	// Check, if this branch was the last child to be deleted
    66 	// If so, unset the scrolled flags
    67 
    68 	BranchObj *po=(BranchObj*)(parObj);
    69 	BranchObj *bo;
    70 	if (po)
    71 	{
    72 		bo=((BranchObj*)(parObj))->getLastBranch();
    73 		if (!bo) po->unScroll();
    74 	}
    75 	clear();
    76 }
    77 
    78 bool BranchObj::operator< ( const BranchObj & other )
    79 {
    80     return  angle < other.angle;
    81 }
    82 
    83 bool BranchObj::operator== ( const BranchObj & other )
    84 {
    85     return angle == other.angle;
    86 }
    87 
    88 void BranchObj::init () 
    89 {
    90 	if (parObj)
    91 	{
    92 		absPos=getRandPos();
    93 		absPos+=parObj->getChildPos();
    94 	}
    95 
    96     lastSelectedBranch=0;
    97 
    98     setChildObj(this);
    99 
   100 	scrolled=false;
   101 	tmpUnscrolled=false;
   102 
   103 	includeImagesVer=false;
   104 	includeImagesHor=false;
   105 }
   106 
   107 void BranchObj::copy (BranchObj* other)
   108 {
   109     OrnamentedObj::copy(other);
   110 
   111 	branch.clear();
   112 	for (int i=0; i<other->branch.size(); ++i)
   113 		// Make deep copy of b
   114 		// Because addBranch again calls copy for the childs,
   115 		// Those will get a deep copy, too
   116 		addBranch(other->branch.at(i) );	
   117 
   118 	for (int i=0; i<other->floatimage.size(); ++i)
   119 		addFloatImage  (other->floatimage.at(i));
   120 	scrolled=other->scrolled;
   121 	tmpUnscrolled=other->tmpUnscrolled;
   122 	setVisibility (other->visible);
   123 
   124 	angle=other->angle;
   125 
   126     positionBBox();
   127 }
   128 
   129 void BranchObj::clear() 
   130 {
   131 	while (!floatimage.isEmpty())
   132 		delete floatimage.takeFirst();
   133 
   134 	while (!xlink.isEmpty())
   135 		delete xlink.takeFirst();
   136 
   137 	while (!branch.isEmpty())
   138 		delete branch.takeFirst();
   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 	reposition();	// FIXME shouldn't be this a request?
   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::setColorChilds (QColor col)
   379 {
   380 	OrnamentedObj::setColor (col);
   381 	for (int i=0; i<branch.size(); ++i)
   382 		branch.at(i)->setColorChilds(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 			//xyz  //FIXME  need to proceed to NEXT child or up again
   461 			if (i<branch.size()-1)
   462 				bo=branch.at(i+1);
   463 			 else
   464 				bo=NULL;
   465 			searching=false;
   466 			i=branch.size();
   467 		} 	
   468 		++i;	
   469 	}
   470 	if (!searching)
   471 	{	// found itLast in my childs
   472 		if (bo)
   473 		{
   474 			// found a brother of lastLMO 
   475 			itLast=this;
   476 			return bo;
   477 		}	
   478 		else
   479 		{
   480 			if (po)
   481 			{
   482 				if (this==itFirst) return NULL;	// Stop at starting point
   483 				// go up
   484 				itLast=this;
   485 				lmo=po->next();
   486 				itLast=this;
   487 				return lmo;
   488 			}
   489 			else
   490 			{
   491 				// can't go up, I am mapCenter
   492 				itLast=NULL;
   493 				return NULL;
   494 			}	
   495 		}
   496 	}
   497 
   498 	// couldn't find last child, it must be a nephew of mine
   499 	if (branch.size()>0)
   500 	{
   501 		// proceed with my first child
   502 		itLast=this;	
   503 		return branch.first();
   504 	}	
   505 	else
   506 	{
   507 		// or go back to my parents
   508 		if (po)
   509 		{
   510 			// go up
   511 			itLast=this;
   512 			lmo=po->next();
   513 			itLast=this;
   514 			return lmo;
   515 		}	
   516 		else
   517 		{
   518 			// can't go up, I am mapCenter
   519 			itLast=NULL;
   520 			return NULL;
   521 		}	
   522 	}	
   523 }
   524 
   525 BranchObj* BranchObj::getLastIterator()
   526 {
   527 	return itLast;
   528 }
   529 
   530 void BranchObj::setLastIterator(BranchObj* it)
   531 {
   532 	itLast=it;
   533 }
   534 
   535 void BranchObj::positionContents()
   536 {
   537     for (int i=0; i<floatimage.size(); ++i )
   538 		floatimage.at(i)->reposition();
   539 	OrnamentedObj::positionContents();
   540 }
   541 
   542 void BranchObj::move (double x, double y)
   543 {
   544 	OrnamentedObj::move (x,y);
   545     for (int i=0; i<floatimage.size(); ++i )
   546 		floatimage.at(i)->reposition();
   547     positionBBox();
   548 }
   549 
   550 void BranchObj::move (QPointF p)
   551 {
   552 	move (p.x(), p.y());
   553 }
   554 
   555 void BranchObj::moveBy (double x, double y)
   556 {
   557 	OrnamentedObj::moveBy (x,y);
   558 	for (int i=0; i<branch.size(); ++i)
   559 		branch.at(i)->moveBy (x,y);
   560     positionBBox();
   561 }
   562 	
   563 void BranchObj::moveBy (QPointF p)
   564 {
   565 	moveBy (p.x(), p.y());
   566 }
   567 
   568 
   569 void BranchObj::positionBBox()
   570 {
   571 	QPointF ap=getAbsPos();
   572 	bbox.moveTopLeft (ap);
   573 	positionContents();
   574 	setSelBox();
   575 
   576 	// set the frame
   577 	frame->setRect(QRectF(bbox.x(),bbox.y(),bbox.width(),bbox.height() ) );
   578 
   579 	// Update links to other branches
   580 	for (int i=0; i<xlink.size(); ++i)
   581 		xlink.at(i)->updateXLink();
   582 }
   583 
   584 void BranchObj::calcBBoxSize()
   585 {
   586     QSizeF heading_r=heading->getSize();
   587     qreal heading_w=(qreal) heading_r.width() ;
   588     qreal heading_h=(qreal) heading_r.height() ;
   589     QSizeF sysflags_r=systemFlags->getSize();
   590 	qreal sysflags_h=sysflags_r.height();
   591 	qreal sysflags_w=sysflags_r.width();
   592     QSizeF stanflags_r=standardFlags->getSize();
   593 	qreal stanflags_h=stanflags_r.height();
   594 	qreal stanflags_w=stanflags_r.width();
   595     qreal w;
   596     qreal h;
   597 
   598 	// set width to sum of all widths
   599 	w=heading_w + sysflags_w + stanflags_w;
   600 	// set height to maximum needed height
   601 	h=max (sysflags_h,stanflags_h);
   602 	h=max (h,heading_h);
   603 
   604 	// Save the dimension of flags and heading
   605 	ornamentsBBox.setSize ( QSizeF(w,h));
   606 
   607 	// clickBox includes Flags and Heading
   608     clickBox.setSize (ornamentsBBox.size() );
   609 
   610 	// Floatimages 
   611 	QPointF rp;
   612 
   613 	topPad=botPad=leftPad=rightPad=0;
   614 	if (includeImagesVer || includeImagesHor)
   615 	{
   616 		if (countFloatImages()>0)
   617 		{
   618 			for (int i=0; i<floatimage.size(); ++i )
   619 			{
   620 				rp=floatimage.at(i)->getRelPos();
   621 				if (includeImagesVer)
   622 				{
   623 					if (rp.y() < 0) 
   624 						topPad=max (topPad,-rp.y()-h);
   625 					if (rp.y()+floatimage.at(i)->height() > 0)
   626 						botPad=max (botPad,rp.y()+floatimage.at(i)->height());
   627 				}		
   628 				if (includeImagesHor)
   629 				{
   630 					if (orientation==OrientRightOfCenter)
   631 					{
   632 						if (-rp.x()-w > 0) 
   633 							leftPad=max (leftPad,-rp.x()-w);
   634 						if (rp.x()+floatimage.at(i)->width() > 0)
   635 							rightPad=max (rightPad,rp.x()+floatimage.at(i)->width());
   636 					} else
   637 					{
   638 						if (rp.x()< 0) 
   639 							leftPad=max (leftPad,-rp.x());
   640 						if (rp.x()+floatimage.at(i)->width() > w)
   641 							rightPad=max (rightPad,rp.x()+floatimage.at(i)->width()-w);
   642 					}
   643 				}		
   644 			}	
   645 		}	
   646 		h+=topPad+botPad;
   647 		w+=leftPad+rightPad;
   648 	}
   649 
   650 	// Frame thickness
   651     w+=frame->getBorder();
   652     h+=frame->getBorder();
   653 	
   654 	// Finally set size
   655     bbox.setSize (QSizeF (w,h));
   656 }
   657 
   658 void BranchObj::setDockPos()
   659 {
   660 	// Sets childpos and parpos depending on orientation
   661 	if (getOrientation()==OrientLeftOfCenter )
   662     {
   663 		childPos=QPointF (ornamentsBBox.bottomLeft().x(), ornamentsBBox.bottomLeft().y() );
   664 		parPos=QPointF (ornamentsBBox.bottomRight().x(),ornamentsBBox.bottomRight().y() );
   665     } else
   666     {
   667 		childPos=QPointF (ornamentsBBox.bottomRight().x(), ornamentsBBox.bottomRight().y() );
   668 		parPos=QPointF (ornamentsBBox.bottomLeft().x(),ornamentsBBox.bottomLeft().y() );
   669     }
   670 }
   671 
   672 LinkableMapObj* BranchObj::findMapObj(QPointF p, LinkableMapObj* excludeLMO)
   673 {
   674 	// Search branches
   675     LinkableMapObj *lmo;
   676 	for (int i=0; i<branch.size(); ++i)
   677     {	
   678 		lmo=branch.at(i)->findMapObj(p, excludeLMO);
   679 		if (lmo != NULL) return lmo;
   680     }
   681 	
   682 	// Search myself
   683     if (inBox (p) && (this != excludeLMO) && isVisibleObj() ) 
   684 		return this;
   685 
   686 	// Search float images
   687     for (int i=0; i<floatimage.size(); ++i )
   688 		if (floatimage.at(i)->inBox(p) && 
   689 			(floatimage.at(i) != excludeLMO) && 
   690 			floatimage.at(i)->getParObj()!= excludeLMO &&
   691 			floatimage.at(i)->isVisibleObj() 
   692 		) return floatimage.at(i);
   693 
   694     return NULL;
   695 }
   696 
   697 void BranchObj::setHeading(QString s)
   698 {
   699     heading->setText(s);	// set new heading
   700 	calcBBoxSize();			// recalculate bbox
   701     positionBBox();			// rearrange contents
   702 	requestReposition();
   703 }
   704 
   705 void BranchObj::setHideTmp (HideTmpMode mode)
   706 {
   707 	if (mode==HideExport && hasHiddenExportParent(this))
   708 	{
   709 		setVisibility (false);
   710 		hidden=true;
   711 	}else
   712 	{
   713 		if (hasScrolledParent(this))
   714 			setVisibility (false);
   715 		else
   716 			setVisibility (true);
   717 		hidden=false;
   718 	}	
   719 
   720 	for (int i=0; i<branch.size(); ++i)
   721 		branch.at(i)->setHideTmp (mode);
   722 }
   723 
   724 bool BranchObj::hasHiddenExportParent(BranchObj *start)
   725 {
   726 	// Calls parents recursivly to
   727 	// find out, if we are temp. hidden
   728 
   729 	if (hideExport) return true;
   730 
   731 	BranchObj* bo=(BranchObj*)(parObj);
   732 	if (bo) 
   733 		return bo->hasHiddenExportParent(start);
   734 	else
   735 		return false;
   736 }
   737 
   738 QString BranchObj::saveToDir (const QString &tmpdir,const QString &prefix, const QPointF& offset)
   739 {
   740 	if (hidden) return "";
   741 
   742     QString s,a;
   743 	QString scrolledAttr;
   744 	if (scrolled) 
   745 		scrolledAttr=attribut ("scrolled","yes");
   746 	else
   747 		scrolledAttr="";
   748 
   749 	QString frameAttr;
   750 	if (frame->getFrameType()!=NoFrame)
   751 		frameAttr=attribut ("frameType",frame->getFrameTypeName());
   752 	else
   753 		frameAttr="";
   754 
   755 	// save area, if not scrolled
   756 	QString areaAttr;
   757 	if (!((BranchObj*)(parObj))->isScrolled() )
   758 	{
   759 		areaAttr=
   760 			attribut("x1",QString().setNum(absPos.x()-offset.x())) +
   761 			attribut("y1",QString().setNum(absPos.y()-offset.y())) +
   762 			attribut("x2",QString().setNum(absPos.x()+width()-offset.x())) +
   763 			attribut("y2",QString().setNum(absPos.y()+height()-offset.y()));
   764 
   765 	} else
   766 		areaAttr="";
   767 	
   768 	// Providing an ID for a branch makes export to XHTML easier
   769 	QString idAttr;
   770 	if (countXLinks()>0)
   771 		idAttr=attribut ("id",getSelectString());
   772 	else
   773 		idAttr="";
   774 
   775     s=beginElement ("branch" 
   776 		+getOrnAttr() 
   777 		+scrolledAttr 
   778 		+frameAttr 
   779 		+areaAttr 
   780 		+idAttr 
   781 		+getIncludeImageAttr() );
   782     incIndent();
   783 
   784 	/* Testing
   785 	for (int i=1; i<depth;i++) cout << "  ";
   786 	cout <<getHeading().ascii()<<endl;
   787 	*/
   788 
   789 	// save heading
   790     s+=valueElement("heading", getHeading(),
   791 		attribut ("textColor",QColor(heading->getColor()).name()));
   792 
   793 	// save names of flags set
   794 	s+=standardFlags->saveToDir(tmpdir,prefix,0);
   795 	
   796 	// Save FloatImages
   797 	for (int i=0; i<floatimage.size(); ++i)
   798 		s+=floatimage.at(i)->saveToDir (tmpdir,prefix);
   799 
   800 	// save note
   801 	if (!note.isEmpty() )
   802 		s+=note.saveToDir();
   803 	
   804 	// Save branches
   805 	for (int i=0; i<branch.size(); ++i)
   806 		s+=branch.at(i)->saveToDir(tmpdir,prefix,offset);
   807 
   808 	// Save XLinks
   809 	QString ol;	// old link
   810 	QString cl;	// current link
   811 	for (int i=0; i<xlink.size(); ++i)
   812 	{
   813 		cl=xlink.at(i)->saveToDir();
   814 		if (cl!=ol)
   815 		{
   816 			s+=cl;
   817 			ol=cl;
   818 		} else
   819 		{
   820 			qWarning (QString("Ignoring of duplicate xLink in %1").arg(getHeading()));
   821 		}
   822 	}	
   823 
   824     decIndent();
   825     s+=endElement   ("branch");
   826     return s;
   827 }
   828 
   829 void BranchObj::addXLink (XLinkObj *xlo)
   830 {
   831 	xlink.append (xlo);
   832 	
   833 }
   834 
   835 void BranchObj::removeXLinkRef (XLinkObj *xlo)
   836 {
   837 	xlink.removeAt (xlink.indexOf(xlo));
   838 }
   839 
   840 void BranchObj::deleteXLink(XLinkObj *xlo)
   841 {
   842 	xlo->deactivate();
   843 	if (!xlo->isUsed()) delete (xlo);
   844 }
   845 
   846 void BranchObj::deleteXLinkAt (int i)
   847 {
   848 	XLinkObj *xlo=xlink.at(i);
   849 	xlo->deactivate();
   850 	if (!xlo->isUsed()) delete(xlo);
   851 }
   852 
   853 XLinkObj* BranchObj::XLinkAt (int i)
   854 {
   855 	return xlink.at(i);
   856 }
   857 
   858 int BranchObj::countXLink()
   859 {
   860 	return xlink.count();
   861 }
   862 
   863 
   864 BranchObj* BranchObj::XLinkTargetAt (int i)
   865 {
   866 	if (i>=0 && i<xlink.size())
   867 	{
   868 		if (xlink.at(i))
   869 			return xlink.at(i)->otherBranch (this);
   870 	}
   871 	return NULL;
   872 }
   873 
   874 void BranchObj::setIncludeImagesVer(bool b)
   875 {
   876 	includeImagesVer=b;
   877 	calcBBoxSize();
   878 	positionBBox();
   879 	requestReposition();
   880 }
   881 
   882 bool BranchObj::getIncludeImagesVer()
   883 {
   884 	return includeImagesVer;
   885 }
   886 
   887 void BranchObj::setIncludeImagesHor(bool b)
   888 {
   889 	includeImagesHor=b;
   890 	calcBBoxSize();
   891 	positionBBox();
   892 	requestReposition();
   893 }
   894 
   895 bool BranchObj::getIncludeImagesHor()
   896 {
   897 	return includeImagesHor;
   898 }
   899 
   900 QString BranchObj::getIncludeImageAttr()
   901 {
   902 	QString a;
   903 	if (includeImagesVer)
   904 		a=attribut ("incImgV","true");
   905 	else
   906 		a=attribut ("incImgV","false");
   907 	if (includeImagesHor)
   908 		a+=attribut ("incImgH","true");
   909 	else
   910 		a+=attribut ("incImgH","false");
   911 	return a;	
   912 }
   913 
   914 FloatImageObj* BranchObj::addFloatImage ()
   915 {
   916 	FloatImageObj *newfi=new FloatImageObj (scene,this);
   917 	floatimage.append (newfi);
   918 	if (hasScrolledParent(this) )
   919 		newfi->setVisibility (false);
   920 	else	
   921 		newfi->setVisibility(visible);
   922 		/*
   923 	calcBBoxSize();
   924 	positionBBox();
   925 	*/
   926 	requestReposition();
   927 	return newfi;
   928 }
   929 
   930 FloatImageObj* BranchObj::addFloatImage (FloatImageObj *fio)
   931 {
   932 	FloatImageObj *newfi=new FloatImageObj (scene,this);
   933 	floatimage.append (newfi);
   934 	newfi->copy (fio);
   935 	if (hasScrolledParent(this) )
   936 		newfi->setVisibility (false);
   937 	else	
   938 		newfi->setVisibility(visible);
   939 		/*
   940 	calcBBoxSize();
   941 	positionBBox();
   942 	*/
   943 	requestReposition();
   944 	return newfi;
   945 }
   946 
   947 FloatImageObj* BranchObj::getFirstFloatImage ()
   948 {
   949     return floatimage.first();
   950 }
   951 
   952 FloatImageObj* BranchObj::getLastFloatImage ()
   953 {
   954     return floatimage.last();
   955 }
   956 
   957 FloatImageObj* BranchObj::getFloatImageNum (const uint &i)
   958 {
   959     return floatimage.at(i);
   960 }
   961 
   962 void BranchObj::removeFloatImage (FloatImageObj *fio)
   963 {
   964 	int i=floatimage.indexOf (fio);
   965 	if (i!=-1) floatimage.takeAt (i);
   966 	calcBBoxSize();
   967 	positionBBox();
   968 	requestReposition();
   969 	// FIMXE undo needed
   970 }
   971 
   972 void BranchObj::savePosInAngle ()
   973 {
   974 	// Save position in angle
   975 	for (int i=0; i<branch.size(); ++i)
   976 		branch.at(i)->angle=i;
   977 }
   978 
   979 void BranchObj::setDefAttr (BranchModification mod)
   980 {
   981 	int fontsize;
   982 	switch (depth)
   983 	{
   984 		case 0: fontsize=16; break;
   985 		case 1: fontsize=12; break;
   986 		default: fontsize=10; break;
   987 	}	
   988 
   989 	setLinkColor ();
   990 	setLinkStyle(getDefLinkStyle());
   991 	QFont font("Sans Serif,8,-1,5,50,0,0,0,0,0");
   992 	font.setPointSize(fontsize);
   993 	heading->setFont(font );
   994 
   995 	if (mod==NewBranch)
   996 		setColor (((BranchObj*)(parObj))->getColor());
   997 	
   998 	calcBBoxSize();
   999 }
  1000 
  1001 BranchObj* BranchObj::addBranch()
  1002 {
  1003     BranchObj* newbo=new BranchObj(scene,this);
  1004     branch.append (newbo);
  1005     newbo->setParObj(this);
  1006 	newbo->setDefAttr(NewBranch);
  1007     newbo->setHeading ("new");
  1008 	if (scrolled)
  1009 		newbo->setVisibility (false);
  1010 	else	
  1011 		newbo->setVisibility(visible);
  1012 	newbo->updateLink();	
  1013 	requestReposition();
  1014 	return newbo;
  1015 }
  1016 
  1017 BranchObj* BranchObj::addBranch(BranchObj* bo)
  1018 {
  1019     BranchObj* newbo=new BranchObj(scene,this);
  1020     branch.append (newbo);
  1021     newbo->copy(bo);
  1022     newbo->setParObj(this);
  1023 	newbo->setDefAttr(MovedBranch);
  1024 	if (scrolled)
  1025 		newbo->setVisibility (false);
  1026 	else	
  1027 		newbo->setVisibility(bo->visible);
  1028 	newbo->updateLink();	
  1029 	requestReposition();
  1030 	return newbo;
  1031 }
  1032 
  1033 BranchObj* BranchObj::addBranchPtr(BranchObj* bo)
  1034 {
  1035 	branch.append (bo);
  1036 	bo->setParObj (this);
  1037 	bo->depth=depth+1;
  1038 	bo->setDefAttr(MovedBranch);
  1039 	if (scrolled) tmpUnscroll();
  1040 	setLastSelectedBranch (bo);
  1041 	return bo;
  1042 }
  1043 
  1044 BranchObj* BranchObj::insertBranch(int pos)
  1045 {
  1046 	savePosInAngle();
  1047 	// Add new bo and resort branches
  1048 	BranchObj *newbo=addBranch ();
  1049 	newbo->angle=pos-0.5;
  1050 	//FIXME   branch.sort();
  1051 	return newbo;
  1052 }
  1053 
  1054 BranchObj* BranchObj::insertBranch(BranchObj* bo, int pos)
  1055 {
  1056 	savePosInAngle();
  1057 	// Add new bo and resort branches
  1058 	bo->angle=pos-0.5;
  1059 	BranchObj *newbo=addBranch (bo);
  1060 	//FIXME   branch.sort();
  1061 	return newbo;
  1062 }
  1063 
  1064 BranchObj* BranchObj::insertBranchPtr (BranchObj* bo, int pos)
  1065 {
  1066 	savePosInAngle();
  1067 	// Add new bo and resort branches
  1068 	bo->angle=pos-0.5;
  1069 	branch.append (bo);
  1070 	bo->setParObj (this);
  1071 	bo->depth=depth+1;
  1072 	bo->setDefAttr (MovedBranch);
  1073 	if (scrolled) tmpUnscroll();
  1074 	setLastSelectedBranch (bo);
  1075 	//FIXME branch.sort();
  1076 	return bo;
  1077 }
  1078 
  1079 void BranchObj::removeBranchHere(BranchObj* borem)
  1080 {
  1081 	// This removes the branch bo from list, but 
  1082 	// inserts its childs at the place of bo
  1083 	BranchObj *bo;
  1084 	bo=borem->getLastBranch();
  1085 	int pos=borem->getNum();
  1086 	while (bo)
  1087 	{
  1088 		bo->moveBranchTo (this,pos+1);
  1089 		bo=borem->getLastBranch();
  1090 	}	
  1091 	removeBranch (borem);
  1092 }
  1093 
  1094 void BranchObj::removeChilds()
  1095 {
  1096 	clear();
  1097 }
  1098 
  1099 void BranchObj::removeBranch(BranchObj* bo)
  1100 {
  1101     // if bo is not in branch remove returns false, we
  1102     // don't care...
  1103 	
  1104 	int i=branch.indexOf(bo);
  1105     if (i>=0)
  1106 	{
  1107 		delete (bo);
  1108 		branch.removeAt (i);
  1109 	} else
  1110 		qWarning ("BranchObj::removeBranch tried to remove non existing branch?!\n");
  1111 	requestReposition();
  1112 }
  1113 
  1114 void BranchObj::removeBranchPtr(BranchObj* bo)
  1115 {
  1116 	int i=branch.indexOf(bo);
  1117 	
  1118 	if (i>=0)
  1119 		branch.removeAt (i);
  1120 	else	
  1121 		qWarning ("BranchObj::removeBranchPtr tried to remove non existing branch?!\n");
  1122 	requestReposition();
  1123 }
  1124 
  1125 void BranchObj::setLastSelectedBranch (BranchObj* bo)
  1126 {
  1127     lastSelectedBranch=branch.indexOf(bo);
  1128 }
  1129 
  1130 BranchObj* BranchObj::getLastSelectedBranch ()
  1131 {
  1132     if (lastSelectedBranch>=0 && branch.size()>0) 
  1133 		return branch.at(lastSelectedBranch);
  1134     return NULL;
  1135 }
  1136 
  1137 BranchObj* BranchObj::getFirstBranch ()
  1138 {
  1139 	if (branch.size()>0)
  1140 		return branch.first();
  1141 	else
  1142 		return NULL;
  1143 }
  1144 
  1145 BranchObj* BranchObj::getLastBranch ()
  1146 {
  1147 	if (branch.size()>0)
  1148 		return branch.last();
  1149 	else
  1150 		return NULL;
  1151 }
  1152 
  1153 BranchObj* BranchObj::getBranchNum (int i)
  1154 {
  1155 	if (i>=0 && i<branch.size())
  1156 		return branch.at(i);
  1157 	else	
  1158 		return	NULL;
  1159 }
  1160 
  1161 bool BranchObj::canMoveBranchUp() 
  1162 {
  1163 	if (!parObj || depth==1) return false;
  1164 	BranchObj* par=(BranchObj*)parObj;
  1165 	if (this==par->getFirstBranch())
  1166 		return false;
  1167 	else
  1168 		return true;
  1169 }
  1170 
  1171 BranchObj* BranchObj::moveBranchUp(BranchObj* bo1) // modify my childlist
  1172 {
  1173 	savePosInAngle();
  1174     int i=branch.indexOf(bo1);
  1175     if (i>0) 
  1176 	{	// -1 if bo1 not found 
  1177 		branch.at(i)->angle--;
  1178 		branch.at(i-1)->angle++;
  1179 		//FIXME branch.sort();
  1180 		return branch.at(i);
  1181 	} else
  1182 		return NULL;
  1183 }
  1184 
  1185 bool BranchObj::canMoveBranchDown() 
  1186 {
  1187 	if (!parObj|| depth==1) return false;
  1188 	BranchObj* par=(BranchObj*)parObj;
  1189 	if (this==par->getLastBranch())
  1190 		return false;
  1191 	else
  1192 		return true;
  1193 }
  1194 
  1195 BranchObj* BranchObj::moveBranchDown(BranchObj* bo1)// modify my childlist
  1196 {
  1197 	savePosInAngle();
  1198     int i=branch.indexOf(bo1);
  1199 	int j;
  1200 	if (i <branch.size())
  1201 	{
  1202 		j = i+1;
  1203 		branch.at(i)->angle++;
  1204 		branch.at(j)->angle--;
  1205 		//FIXME branch.sort();
  1206 		return branch.at(i);
  1207 	} else
  1208 		return NULL;
  1209 }
  1210 
  1211 BranchObj* BranchObj::moveBranchTo (BranchObj* dst, int pos)
  1212 {
  1213 	// Find current parent and 
  1214 	// remove pointer to myself there
  1215 	if (!dst) return NULL;
  1216 	BranchObj *par=(BranchObj*)parObj;
  1217 	if (par)
  1218 		par->removeBranchPtr (this);
  1219 	else
  1220 		return NULL;
  1221 
  1222 	// Create new pointer to myself at dst
  1223 	if (pos<0||dst->getDepth()==0)
  1224 	{	
  1225 		// links myself as last branch at dst
  1226 		dst->addBranchPtr (this);
  1227 		updateLink();
  1228 		return this;
  1229 	} else
  1230 	{
  1231 		// inserts me at pos in parent of dst
  1232 		if (par)
  1233 		{
  1234 			BranchObj *bo=dst->insertBranchPtr (this,pos);
  1235 			bo->setDefAttr(MovedBranch);
  1236 			updateLink();
  1237 			return bo;
  1238 
  1239 		} else
  1240 			return NULL;
  1241 	}	
  1242 }
  1243 
  1244 void BranchObj::alignRelativeTo (QPointF ref)
  1245 {
  1246 	qreal th = bboxTotal.height();	
  1247 // TODO testing
  1248 /*
  1249 	cout << "BO::alignRelTo "<<getHeading().ascii()<<endl;
  1250 	cout << "  d="<<depth<<
  1251 		"  ref="<<ref<<
  1252 //		"  bbox.topLeft="<<bboxTotal.topLeft()<<
  1253 		"  absPos="<<absPos<<
  1254 		"  relPos="<<relPos<<
  1255 		"  orient="<<orientation<<
  1256 //		"  pad="<<topPad<<","<<botPad<<","<<leftPad<<","<<rightPad<<
  1257 //		"  hidden="<<hidden<<
  1258 //		"  th="<<th<<
  1259 		endl;
  1260 */
  1261 
  1262 	setOrientation();
  1263 	//updateLink();
  1264 
  1265 	if (depth<2)
  1266 	{
  1267 		if (depth==1)
  1268 		{
  1269 			// Position relatively, if needed
  1270 			//if (useRelPos) move2RelPos (relPos.x(), relPos.y());
  1271 
  1272 			// Calc angle to mapCenter if I am a mainbranch
  1273 			// needed for reordering the mainbranches clockwise 
  1274 			// around mapcenter 
  1275 			angle=getAngle (QPointF ((int)(x() - parObj->getChildPos().x() ), 
  1276 									(int)(y() - parObj->getChildPos().y() ) ) );
  1277 		}							
  1278 	} 
  1279 	else
  1280     {
  1281 		// Align myself depending on orientation and parent, but
  1282 		// only if I am not a mainbranch or mapcenter itself
  1283 		LinkOrient o;
  1284 		o=parObj->getOrientation();
  1285 		switch (orientation) 
  1286 		{
  1287 			case OrientLeftOfCenter:
  1288 				move (ref.x() - bbox.width(), ref.y() + (th-bbox.height())/2 );
  1289 			break;
  1290 			case OrientRightOfCenter:	
  1291 				move (ref.x() , ref.y() + (th-bbox.height())/2  );
  1292 			break;
  1293 			default:
  1294 				qWarning ("LMO::alignRelativeTo: oops, no orientation given...");
  1295 			break;
  1296 		}		
  1297     }		
  1298 
  1299 	if (scrolled) return;
  1300 
  1301     // Set reference point for alignment of childs
  1302     QPointF ref2;
  1303     if (orientation==OrientLeftOfCenter)
  1304 		ref2.setX(bbox.topLeft().x() - linkwidth);
  1305     else	
  1306 		ref2.setX(bbox.topRight().x() + linkwidth);
  1307 
  1308 	if (depth==1)
  1309 		ref2.setY(absPos.y()-(bboxTotal.height()-bbox.height())/2);
  1310 	else	
  1311 		ref2.setY(ref.y() );	
  1312 
  1313     // Align the childs depending on reference point 
  1314 	for (int i=0; i<branch.size(); ++i)
  1315     {	
  1316 		if (!branch.at(i)->isHidden())
  1317 		{
  1318 			branch.at(i)->alignRelativeTo (ref2);
  1319 			ref2.setY(ref2.y() + branch.at(i)->getBBoxSizeWithChilds().height() );
  1320 		}
  1321     }
  1322 }
  1323 
  1324 
  1325 void BranchObj::reposition()
  1326 {	
  1327 /* TODO testing only
  1328 	if (!getHeading().isEmpty())
  1329 		cout << "BO::reposition  "<<getHeading().ascii()<<endl;
  1330 	else	
  1331 		cout << "BO::reposition  ???"<<endl;
  1332 
  1333 	cout << "  orient="<<orientation<<endl;
  1334 */		
  1335 
  1336 	if (depth==0)
  1337 	{
  1338 		// only calculate the sizes once. If the deepest LMO 
  1339 		// changes its height,
  1340 		// all upper LMOs have to change, too.
  1341 		calcBBoxSizeWithChilds();
  1342 		updateLink();	// This update is needed if the scene is resized 
  1343 						// due to excessive moving of a FIO
  1344 						// FIXME really needed? reposition is also called from updateLink...
  1345 
  1346 	    alignRelativeTo ( QPointF (absPos.x(),
  1347 			absPos.y()-(bboxTotal.height()-bbox.height())/2) );
  1348 		//FIXME branch.sort();	
  1349 		positionBBox();	// Reposition bbox and contents
  1350 	} else
  1351 	{
  1352 		// This is only important for moving branches:
  1353 		// For editing a branch it isn't called...
  1354 	    alignRelativeTo ( QPointF (absPos.x(),
  1355 							absPos.y()-(bboxTotal.height()-bbox.height())/2) );
  1356 	}
  1357 }
  1358 
  1359 void BranchObj::unsetAllRepositionRequests()
  1360 {
  1361 	repositionRequest=false;
  1362 	for (int i=0; i<branch.size(); ++i)
  1363 		branch.at(i)->unsetAllRepositionRequests();
  1364 }
  1365 
  1366 
  1367 QRectF BranchObj::getTotalBBox()
  1368 {
  1369 	QRectF r=bbox;
  1370 
  1371 	if (scrolled) return r;
  1372 
  1373 	for (int i=0; i<branch.size(); ++i)
  1374 		if (!branch.at(i)->isHidden())
  1375 			r=addBBox(branch.at(i)->getTotalBBox(),r);
  1376 
  1377 	for (int i=0; i<floatimage.size(); ++i)
  1378 		if (!floatimage.at(i)->isHidden())
  1379 			r=addBBox(floatimage.at(i)->getTotalBBox(),r);
  1380 		
  1381 	return r;
  1382 }
  1383 
  1384 QRectF BranchObj::getBBoxSizeWithChilds()
  1385 {
  1386 	return bboxTotal;
  1387 }
  1388 
  1389 void BranchObj::calcBBoxSizeWithChilds()
  1390 {	
  1391 	// This is initially called only from reposition and
  1392 	// and only for mapcenter. So it won't be
  1393 	// called more than once for a single user 
  1394 	// action
  1395 	
  1396 
  1397 	// Calculate size of LMO including all childs (to align them later)
  1398 	bboxTotal.setX(bbox.x() );
  1399 	bboxTotal.setY(bbox.y() );
  1400 
  1401 	// if branch is scrolled, ignore childs, but still consider floatimages
  1402 	if (scrolled)
  1403 	{
  1404 		bboxTotal.setWidth (bbox.width());
  1405 		bboxTotal.setHeight(bbox.height());
  1406 		return;
  1407 	}
  1408 	
  1409 	if (hidden)
  1410 	{
  1411 		bboxTotal.setWidth (0);
  1412 		bboxTotal.setHeight(0);
  1413 		if (parObj)
  1414 		{
  1415 			bboxTotal.setX (parObj->x());
  1416 			bboxTotal.setY (parObj->y());
  1417 		} else
  1418 		{
  1419 			bboxTotal.setX (bbox.x());
  1420 			bboxTotal.setY (bbox.y());
  1421 		}
  1422 		return;
  1423 	}
  1424 	
  1425 	QRectF r(0,0,0,0);
  1426 	QRectF br;
  1427 	// Now calculate recursivly
  1428 	// sum of heights 
  1429 	// maximum of widths 
  1430 	// minimum of y
  1431 	for (int i=0; i<branch.size(); ++i)
  1432 	{
  1433 		if (!branch.at(i)->isHidden())
  1434 		{
  1435 			branch.at(i)->calcBBoxSizeWithChilds();
  1436 			br=branch.at(i)->getBBoxSizeWithChilds();
  1437 			r.setWidth( max (br.width(), r.width() ));
  1438 			r.setHeight(br.height() + r.height() );
  1439 			if (br.y()<bboxTotal.y()) bboxTotal.setY(br.y());
  1440 		}
  1441 	}
  1442 	// Add myself and also
  1443 	// add width of link to sum if necessary
  1444 	if (branch.isEmpty())
  1445 		bboxTotal.setWidth (bbox.width() + r.width() );
  1446 	else	
  1447 		bboxTotal.setWidth (bbox.width() + r.width() + linkwidth);
  1448 	
  1449 	bboxTotal.setHeight(max (r.height(),  bbox.height()));
  1450 }
  1451 
  1452 void BranchObj::select()
  1453 {
  1454 	// set Text in Editor	
  1455 	textEditor->setText(note.getNote() );
  1456 	QString fnh=note.getFilenameHint();
  1457 	if (fnh!="")
  1458 		textEditor->setFilenameHint(note.getFilenameHint() );
  1459 	else	
  1460 		textEditor->setFilenameHint(getHeading() );
  1461 	textEditor->setFontHint (note.getFontHint() );
  1462 
  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
  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