branchobj.cpp
author insilmaril
Fri, 29 Dec 2006 13:52:17 +0000
changeset 414 bc23a0157a39
parent 412 8059b6aa74d7
child 417 1cc7bbf75f0b
permissions -rw-r--r--
Removed some FIXMEs. Added translations
     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();	// FIXME shouldn't be this a request?
   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::setColorChilds (QColor col)
   374 {
   375 	OrnamentedObj::setColor (col);
   376 	for (int i=0; i<branch.size(); ++i)
   377 		branch.at(i)->setColorChilds(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 			//xyz  //FIXME  need to proceed to NEXT child or up again
   456 			if (i<branch.size()-1)
   457 				bo=branch.at(i+1);
   458 			 else
   459 				bo=NULL;
   460 			searching=false;
   461 			i=branch.size();
   462 		} 	
   463 		++i;	
   464 	}
   465 	if (!searching)
   466 	{	// found itLast in my childs
   467 		if (bo)
   468 		{
   469 			// found a brother of lastLMO 
   470 			itLast=this;
   471 			return bo;
   472 		}	
   473 		else
   474 		{
   475 			if (po)
   476 			{
   477 				if (this==itFirst) return NULL;	// Stop at starting point
   478 				// go up
   479 				itLast=this;
   480 				lmo=po->next();
   481 				itLast=this;
   482 				return lmo;
   483 			}
   484 			else
   485 			{
   486 				// can't go up, I am mapCenter
   487 				itLast=NULL;
   488 				return NULL;
   489 			}	
   490 		}
   491 	}
   492 
   493 	// couldn't find last child, it must be a nephew of mine
   494 	if (branch.size()>0)
   495 	{
   496 		// proceed with my first child
   497 		itLast=this;	
   498 		return branch.first();
   499 	}	
   500 	else
   501 	{
   502 		// or go back to my parents
   503 		if (po)
   504 		{
   505 			// go up
   506 			itLast=this;
   507 			lmo=po->next();
   508 			itLast=this;
   509 			return lmo;
   510 		}	
   511 		else
   512 		{
   513 			// can't go up, I am mapCenter
   514 			itLast=NULL;
   515 			return NULL;
   516 		}	
   517 	}	
   518 }
   519 
   520 BranchObj* BranchObj::getLastIterator()
   521 {
   522 	return itLast;
   523 }
   524 
   525 void BranchObj::setLastIterator(BranchObj* it)
   526 {
   527 	itLast=it;
   528 }
   529 
   530 void BranchObj::positionContents()
   531 {
   532     for (int i=0; i<floatimage.size(); ++i )
   533 		floatimage.at(i)->reposition();
   534 	OrnamentedObj::positionContents();
   535 }
   536 
   537 void BranchObj::move (double x, double y)
   538 {
   539 	OrnamentedObj::move (x,y);
   540     for (int i=0; i<floatimage.size(); ++i )
   541 		floatimage.at(i)->reposition();
   542     positionBBox();
   543 }
   544 
   545 void BranchObj::move (QPointF p)
   546 {
   547 	move (p.x(), p.y());
   548 }
   549 
   550 void BranchObj::moveBy (double x, double y)
   551 {
   552 	OrnamentedObj::moveBy (x,y);
   553 	for (int i=0; i<branch.size(); ++i)
   554 		branch.at(i)->moveBy (x,y);
   555     positionBBox();
   556 }
   557 	
   558 void BranchObj::moveBy (QPointF p)
   559 {
   560 	moveBy (p.x(), p.y());
   561 }
   562 
   563 
   564 void BranchObj::positionBBox()
   565 {
   566 	QPointF ap=getAbsPos();
   567 	bbox.moveTopLeft (ap);
   568 	positionContents();
   569 	setSelBox();
   570 
   571 	// set the frame
   572 	frame->setRect(QRectF(bbox.x(),bbox.y(),bbox.width(),bbox.height() ) );
   573 
   574 	// Update links to other branches
   575 	for (int i=0; i<xlink.size(); ++i)
   576 		xlink.at(i)->updateXLink();
   577 }
   578 
   579 void BranchObj::calcBBoxSize()
   580 {
   581     QSizeF heading_r=heading->getSize();
   582     qreal heading_w=(qreal) heading_r.width() ;
   583     qreal heading_h=(qreal) heading_r.height() ;
   584     QSizeF sysflags_r=systemFlags->getSize();
   585 	qreal sysflags_h=sysflags_r.height();
   586 	qreal sysflags_w=sysflags_r.width();
   587     QSizeF stanflags_r=standardFlags->getSize();
   588 	qreal stanflags_h=stanflags_r.height();
   589 	qreal stanflags_w=stanflags_r.width();
   590     qreal w;
   591     qreal h;
   592 
   593 	// set width to sum of all widths
   594 	w=heading_w + sysflags_w + stanflags_w;
   595 	// set height to maximum needed height
   596 	h=max (sysflags_h,stanflags_h);
   597 	h=max (h,heading_h);
   598 
   599 	// Save the dimension of flags and heading
   600 	ornamentsBBox.setSize ( QSizeF(w,h));
   601 
   602 	// clickBox includes Flags and Heading
   603     clickBox.setSize (ornamentsBBox.size() );
   604 
   605 	// Floatimages 
   606 	QPointF rp;
   607 
   608 	topPad=botPad=leftPad=rightPad=0;
   609 	if (includeImagesVer || includeImagesHor)
   610 	{
   611 		if (countFloatImages()>0)
   612 		{
   613 			for (int i=0; i<floatimage.size(); ++i )
   614 			{
   615 				rp=floatimage.at(i)->getRelPos();
   616 				if (includeImagesVer)
   617 				{
   618 					if (rp.y() < 0) 
   619 						topPad=max (topPad,-rp.y()-h);
   620 					if (rp.y()+floatimage.at(i)->height() > 0)
   621 						botPad=max (botPad,rp.y()+floatimage.at(i)->height());
   622 				}		
   623 				if (includeImagesHor)
   624 				{
   625 					if (orientation==OrientRightOfCenter)
   626 					{
   627 						if (-rp.x()-w > 0) 
   628 							leftPad=max (leftPad,-rp.x()-w);
   629 						if (rp.x()+floatimage.at(i)->width() > 0)
   630 							rightPad=max (rightPad,rp.x()+floatimage.at(i)->width());
   631 					} else
   632 					{
   633 						if (rp.x()< 0) 
   634 							leftPad=max (leftPad,-rp.x());
   635 						if (rp.x()+floatimage.at(i)->width() > w)
   636 							rightPad=max (rightPad,rp.x()+floatimage.at(i)->width()-w);
   637 					}
   638 				}		
   639 			}	
   640 		}	
   641 		h+=topPad+botPad;
   642 		w+=leftPad+rightPad;
   643 	}
   644 
   645 	// Frame thickness
   646     w+=frame->getBorder();
   647     h+=frame->getBorder();
   648 	
   649 	// Finally set size
   650     bbox.setSize (QSizeF (w,h));
   651 }
   652 
   653 void BranchObj::setDockPos()
   654 {
   655 	// Sets childpos and parpos depending on orientation
   656 	if (getOrientation()==OrientLeftOfCenter )
   657     {
   658 		childPos=QPointF (ornamentsBBox.bottomLeft().x(), ornamentsBBox.bottomLeft().y() );
   659 		parPos=QPointF (ornamentsBBox.bottomRight().x(),ornamentsBBox.bottomRight().y() );
   660     } else
   661     {
   662 		childPos=QPointF (ornamentsBBox.bottomRight().x(), ornamentsBBox.bottomRight().y() );
   663 		parPos=QPointF (ornamentsBBox.bottomLeft().x(),ornamentsBBox.bottomLeft().y() );
   664     }
   665 }
   666 
   667 LinkableMapObj* BranchObj::findMapObj(QPointF p, LinkableMapObj* excludeLMO)
   668 {
   669 	// Search branches
   670     LinkableMapObj *lmo;
   671 	for (int i=0; i<branch.size(); ++i)
   672     {	
   673 		lmo=branch.at(i)->findMapObj(p, excludeLMO);
   674 		if (lmo != NULL) return lmo;
   675     }
   676 	
   677 	// Search myself
   678     if (inBox (p) && (this != excludeLMO) && isVisibleObj() ) 
   679 		return this;
   680 
   681 	// Search float images
   682     for (int i=0; i<floatimage.size(); ++i )
   683 		if (floatimage.at(i)->inBox(p) && 
   684 			(floatimage.at(i) != excludeLMO) && 
   685 			floatimage.at(i)->getParObj()!= excludeLMO &&
   686 			floatimage.at(i)->isVisibleObj() 
   687 		) return floatimage.at(i);
   688 
   689     return NULL;
   690 }
   691 
   692 void BranchObj::setHeading(QString s)
   693 {
   694     heading->setText(s);	// set new heading
   695 	calcBBoxSize();			// recalculate bbox
   696     positionBBox();			// rearrange contents
   697 	requestReposition();
   698 }
   699 
   700 void BranchObj::setHideTmp (HideTmpMode mode)
   701 {
   702 	if (mode==HideExport && hasHiddenExportParent(this))
   703 	{
   704 		setVisibility (false);
   705 		hidden=true;
   706 	}else
   707 	{
   708 		if (hasScrolledParent(this))
   709 			setVisibility (false);
   710 		else
   711 			setVisibility (true);
   712 		hidden=false;
   713 	}	
   714 
   715 	for (int i=0; i<branch.size(); ++i)
   716 		branch.at(i)->setHideTmp (mode);
   717 }
   718 
   719 bool BranchObj::hasHiddenExportParent(BranchObj *start)
   720 {
   721 	// Calls parents recursivly to
   722 	// find out, if we are temp. hidden
   723 
   724 	if (hideExport) return true;
   725 
   726 	BranchObj* bo=(BranchObj*)(parObj);
   727 	if (bo) 
   728 		return bo->hasHiddenExportParent(start);
   729 	else
   730 		return false;
   731 }
   732 
   733 QString BranchObj::saveToDir (const QString &tmpdir,const QString &prefix, const QPointF& offset)
   734 {
   735 	if (hidden) return "";
   736 
   737     QString s,a;
   738 	QString scrolledAttr;
   739 	if (scrolled) 
   740 		scrolledAttr=attribut ("scrolled","yes");
   741 	else
   742 		scrolledAttr="";
   743 
   744 	QString frameAttr;
   745 	if (frame->getFrameType()!=NoFrame)
   746 		frameAttr=attribut ("frameType",frame->getFrameTypeName());
   747 	else
   748 		frameAttr="";
   749 
   750 	// save area, if not scrolled
   751 	QString areaAttr;
   752 	if (!((BranchObj*)(parObj))->isScrolled() )
   753 	{
   754 		areaAttr=
   755 			attribut("x1",QString().setNum(absPos.x()-offset.x())) +
   756 			attribut("y1",QString().setNum(absPos.y()-offset.y())) +
   757 			attribut("x2",QString().setNum(absPos.x()+width()-offset.x())) +
   758 			attribut("y2",QString().setNum(absPos.y()+height()-offset.y()));
   759 
   760 	} else
   761 		areaAttr="";
   762 	
   763 	// Providing an ID for a branch makes export to XHTML easier
   764 	QString idAttr;
   765 	if (countXLinks()>0)
   766 		idAttr=attribut ("id",getSelectString());
   767 	else
   768 		idAttr="";
   769 
   770     s=beginElement ("branch" 
   771 		+getOrnAttr() 
   772 		+scrolledAttr 
   773 		+frameAttr 
   774 		+areaAttr 
   775 		+idAttr 
   776 		+getIncludeImageAttr() );
   777     incIndent();
   778 
   779 	/* Testing
   780 	for (int i=1; i<depth;i++) cout << "  ";
   781 	cout <<getHeading().ascii()<<endl;
   782 	*/
   783 
   784 	// save heading
   785     s+=valueElement("heading", getHeading(),
   786 		attribut ("textColor",QColor(heading->getColor()).name()));
   787 
   788 	// save names of flags set
   789 	s+=standardFlags->saveToDir(tmpdir,prefix,0);
   790 	
   791 	// Save FloatImages
   792 	for (int i=0; i<floatimage.size(); ++i)
   793 		s+=floatimage.at(i)->saveToDir (tmpdir,prefix);
   794 
   795 	// save note
   796 	if (!note.isEmpty() )
   797 		s+=note.saveToDir();
   798 	
   799 	// Save branches
   800 	for (int i=0; i<branch.size(); ++i)
   801 		s+=branch.at(i)->saveToDir(tmpdir,prefix,offset);
   802 
   803 	// Save XLinks
   804 	QString ol;	// old link
   805 	QString cl;	// current link
   806 	for (int i=0; i<xlink.size(); ++i)
   807 	{
   808 		cl=xlink.at(i)->saveToDir();
   809 		if (cl!=ol)
   810 		{
   811 			s+=cl;
   812 			ol=cl;
   813 		} else
   814 		{
   815 			qWarning (QString("Ignoring of duplicate xLink in %1").arg(getHeading()));
   816 		}
   817 	}	
   818 
   819     decIndent();
   820     s+=endElement   ("branch");
   821     return s;
   822 }
   823 
   824 void BranchObj::addXLink (XLinkObj *xlo)
   825 {
   826 	xlink.append (xlo);
   827 	
   828 }
   829 
   830 void BranchObj::removeXLinkRef (XLinkObj *xlo)
   831 {
   832 	xlink.removeAt (xlink.indexOf(xlo));
   833 }
   834 
   835 void BranchObj::deleteXLink(XLinkObj *xlo)
   836 {
   837 	xlo->deactivate();
   838 	if (!xlo->isUsed()) delete (xlo);
   839 }
   840 
   841 void BranchObj::deleteXLinkAt (int i)
   842 {
   843 	XLinkObj *xlo=xlink.at(i);
   844 	xlo->deactivate();
   845 	if (!xlo->isUsed()) delete(xlo);
   846 }
   847 
   848 XLinkObj* BranchObj::XLinkAt (int i)
   849 {
   850 	return xlink.at(i);
   851 }
   852 
   853 int BranchObj::countXLink()
   854 {
   855 	return xlink.count();
   856 }
   857 
   858 
   859 BranchObj* BranchObj::XLinkTargetAt (int i)
   860 {
   861 	if (i>=0 && i<xlink.size())
   862 	{
   863 		if (xlink.at(i))
   864 			return xlink.at(i)->otherBranch (this);
   865 	}
   866 	return NULL;
   867 }
   868 
   869 void BranchObj::setIncludeImagesVer(bool b)
   870 {
   871 	includeImagesVer=b;
   872 	calcBBoxSize();
   873 	positionBBox();
   874 	requestReposition();
   875 }
   876 
   877 bool BranchObj::getIncludeImagesVer()
   878 {
   879 	return includeImagesVer;
   880 }
   881 
   882 void BranchObj::setIncludeImagesHor(bool b)
   883 {
   884 	includeImagesHor=b;
   885 	calcBBoxSize();
   886 	positionBBox();
   887 	requestReposition();
   888 }
   889 
   890 bool BranchObj::getIncludeImagesHor()
   891 {
   892 	return includeImagesHor;
   893 }
   894 
   895 QString BranchObj::getIncludeImageAttr()
   896 {
   897 	QString a;
   898 	if (includeImagesVer)
   899 		a=attribut ("incImgV","true");
   900 	else
   901 		a=attribut ("incImgV","false");
   902 	if (includeImagesHor)
   903 		a+=attribut ("incImgH","true");
   904 	else
   905 		a+=attribut ("incImgH","false");
   906 	return a;	
   907 }
   908 
   909 FloatImageObj* BranchObj::addFloatImage ()
   910 {
   911 	FloatImageObj *newfi=new FloatImageObj (scene,this);
   912 	floatimage.append (newfi);
   913 	if (hasScrolledParent(this) )
   914 		newfi->setVisibility (false);
   915 	else	
   916 		newfi->setVisibility(visible);
   917 		/*
   918 	calcBBoxSize();
   919 	positionBBox();
   920 	*/
   921 	requestReposition();
   922 	return newfi;
   923 }
   924 
   925 FloatImageObj* BranchObj::addFloatImage (FloatImageObj *fio)
   926 {
   927 	FloatImageObj *newfi=new FloatImageObj (scene,this);
   928 	floatimage.append (newfi);
   929 	newfi->copy (fio);
   930 	if (hasScrolledParent(this) )
   931 		newfi->setVisibility (false);
   932 	else	
   933 		newfi->setVisibility(visible);
   934 		/*
   935 	calcBBoxSize();
   936 	positionBBox();
   937 	*/
   938 	requestReposition();
   939 	return newfi;
   940 }
   941 
   942 FloatImageObj* BranchObj::getFirstFloatImage ()
   943 {
   944     return floatimage.first();
   945 }
   946 
   947 FloatImageObj* BranchObj::getLastFloatImage ()
   948 {
   949     return floatimage.last();
   950 }
   951 
   952 FloatImageObj* BranchObj::getFloatImageNum (const uint &i)
   953 {
   954     return floatimage.at(i);
   955 }
   956 
   957 void BranchObj::removeFloatImage (FloatImageObj *fio)
   958 {
   959 	int i=floatimage.indexOf (fio);
   960 	if (i>-1) delete (floatimage.takeAt (i));
   961 	calcBBoxSize();
   962 	positionBBox();
   963 	requestReposition();
   964 }
   965 
   966 void BranchObj::savePosInAngle ()
   967 {
   968 	// Save position in angle
   969 	for (int i=0; i<branch.size(); ++i)
   970 		branch.at(i)->angle=i;
   971 }
   972 
   973 void BranchObj::setDefAttr (BranchModification mod)
   974 {
   975 	int fontsize;
   976 	switch (depth)
   977 	{
   978 		case 0: fontsize=16; break;
   979 		case 1: fontsize=12; break;
   980 		default: fontsize=10; break;
   981 	}	
   982 
   983 	setLinkColor ();
   984 	setLinkStyle(getDefLinkStyle());
   985 	QFont font("Sans Serif,8,-1,5,50,0,0,0,0,0");
   986 	font.setPointSize(fontsize);
   987 	heading->setFont(font );
   988 
   989 	if (mod==NewBranch)
   990 		setColor (((BranchObj*)(parObj))->getColor());
   991 	
   992 	calcBBoxSize();
   993 }
   994 
   995 BranchObj* BranchObj::addBranch()
   996 {
   997     BranchObj* newbo=new BranchObj(scene,this);
   998     branch.append (newbo);
   999     newbo->setParObj(this);
  1000 	newbo->setDefAttr(NewBranch);
  1001     newbo->setHeading ("new");
  1002 	if (scrolled)
  1003 		newbo->setVisibility (false);
  1004 	else	
  1005 		newbo->setVisibility(visible);
  1006 	newbo->updateLink();	
  1007 	requestReposition();
  1008 	return newbo;
  1009 }
  1010 
  1011 BranchObj* BranchObj::addBranch(BranchObj* bo)
  1012 {
  1013     BranchObj* newbo=new BranchObj(scene,this);
  1014     branch.append (newbo);
  1015     newbo->copy(bo);
  1016     newbo->setParObj(this);
  1017 	newbo->setDefAttr(MovedBranch);
  1018 	if (scrolled)
  1019 		newbo->setVisibility (false);
  1020 	else	
  1021 		newbo->setVisibility(bo->visible);
  1022 	newbo->updateLink();	
  1023 	requestReposition();
  1024 	return newbo;
  1025 }
  1026 
  1027 BranchObj* BranchObj::addBranchPtr(BranchObj* bo)
  1028 {
  1029 	branch.append (bo);
  1030 	bo->setParObj (this);
  1031 	bo->depth=depth+1;
  1032 	bo->setDefAttr(MovedBranch);
  1033 	if (scrolled) tmpUnscroll();
  1034 	setLastSelectedBranch (bo);
  1035 	return bo;
  1036 }
  1037 
  1038 BranchObj* BranchObj::insertBranch(int pos)
  1039 {
  1040 	savePosInAngle();
  1041 	// Add new bo and resort branches
  1042 	BranchObj *newbo=addBranch ();
  1043 	newbo->angle=pos-0.5;
  1044 	qSort (branch.begin(),branch.end(), isAbove);
  1045 	return newbo;
  1046 }
  1047 
  1048 BranchObj* BranchObj::insertBranch(BranchObj* bo, int pos)
  1049 {
  1050 	savePosInAngle();
  1051 	// Add new bo and resort branches
  1052 	bo->angle=pos-0.5;
  1053 	BranchObj *newbo=addBranch (bo);
  1054 	qSort (branch.begin(),branch.end(), isAbove);
  1055 	return newbo;
  1056 }
  1057 
  1058 BranchObj* BranchObj::insertBranchPtr (BranchObj* bo, int pos)
  1059 {
  1060 	savePosInAngle();
  1061 	// Add new bo and resort branches
  1062 	bo->angle=pos-0.5;
  1063 	branch.append (bo);
  1064 	bo->setParObj (this);
  1065 	bo->depth=depth+1;
  1066 	bo->setDefAttr (MovedBranch);
  1067 	if (scrolled) tmpUnscroll();
  1068 	setLastSelectedBranch (bo);
  1069 	qSort (branch.begin(),branch.end(), isAbove);
  1070 	return bo;
  1071 }
  1072 
  1073 void BranchObj::removeBranchHere(BranchObj* borem)
  1074 {
  1075 	// This removes the branch bo from list, but 
  1076 	// inserts its childs at the place of bo
  1077 	BranchObj *bo;
  1078 	bo=borem->getLastBranch();
  1079 	int pos=borem->getNum();
  1080 	while (bo)
  1081 	{
  1082 		bo->moveBranchTo (this,pos+1);
  1083 		bo=borem->getLastBranch();
  1084 	}	
  1085 	removeBranch (borem);
  1086 }
  1087 
  1088 void BranchObj::removeChilds()
  1089 {
  1090 	clear();
  1091 }
  1092 
  1093 void BranchObj::removeBranch(BranchObj* bo)
  1094 {
  1095     // if bo is not in branch remove returns false, we
  1096     // don't care...
  1097 	
  1098 	int i=branch.indexOf(bo);
  1099     if (i>=0)
  1100 	{
  1101 		delete (bo);
  1102 		branch.removeAt (i);
  1103 	} else
  1104 		qWarning ("BranchObj::removeBranch tried to remove non existing branch?!\n");
  1105 	requestReposition();
  1106 }
  1107 
  1108 void BranchObj::removeBranchPtr(BranchObj* bo)
  1109 {
  1110 	int i=branch.indexOf(bo);
  1111 	
  1112 	if (i>=0)
  1113 		branch.removeAt (i);
  1114 	else	
  1115 		qWarning ("BranchObj::removeBranchPtr tried to remove non existing branch?!\n");
  1116 	requestReposition();
  1117 }
  1118 
  1119 void BranchObj::setLastSelectedBranch (BranchObj* bo)
  1120 {
  1121     lastSelectedBranch=branch.indexOf(bo);
  1122 }
  1123 
  1124 BranchObj* BranchObj::getLastSelectedBranch ()
  1125 {
  1126     if (lastSelectedBranch>=0 && branch.size()>0) 
  1127 		return branch.at(lastSelectedBranch);
  1128     return NULL;
  1129 }
  1130 
  1131 BranchObj* BranchObj::getFirstBranch ()
  1132 {
  1133 	if (branch.size()>0)
  1134 		return branch.first();
  1135 	else
  1136 		return NULL;
  1137 }
  1138 
  1139 BranchObj* BranchObj::getLastBranch ()
  1140 {
  1141 	if (branch.size()>0)
  1142 		return branch.last();
  1143 	else
  1144 		return NULL;
  1145 }
  1146 
  1147 BranchObj* BranchObj::getBranchNum (int i)
  1148 {
  1149 	if (i>=0 && i<branch.size())
  1150 		return branch.at(i);
  1151 	else	
  1152 		return	NULL;
  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.indexOf(bo1);
  1169     if (i>0) 
  1170 	{	// -1 if bo1 not found 
  1171 		branch.at(i)->angle--;
  1172 		branch.at(i-1)->angle++;
  1173 		qSort (branch.begin(),branch.end(), isAbove);
  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.indexOf(bo1);
  1193 	int j;
  1194 	if (i <branch.size())
  1195 	{
  1196 		j = i+1;
  1197 		branch.at(i)->angle++;
  1198 		branch.at(j)->angle--;
  1199 		qSort (branch.begin(),branch.end(), isAbove);
  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 (QPointF ref)
  1239 {
  1240 	qreal 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 (QPointF ((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     QPointF 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 	for (int i=0; i<branch.size(); ++i)
  1309     {	
  1310 		if (!branch.at(i)->isHidden())
  1311 		{
  1312 			branch.at(i)->alignRelativeTo (ref2);
  1313 			ref2.setY(ref2.y() + branch.at(i)->getBBoxSizeWithChilds().height() );
  1314 		}
  1315     }
  1316 }
  1317 
  1318 
  1319 void BranchObj::reposition()
  1320 {	
  1321 /* TODO testing only
  1322 	if (!getHeading().isEmpty())
  1323 		cout << "BO::reposition  "<<getHeading().ascii()<<endl;
  1324 	else	
  1325 		cout << "BO::reposition  ???"<<endl;
  1326 
  1327 	cout << "  orient="<<orientation<<endl;
  1328 */		
  1329 
  1330 	if (depth==0)
  1331 	{
  1332 		// only calculate the sizes once. If the deepest LMO 
  1333 		// changes its height,
  1334 		// all upper LMOs have to change, too.
  1335 		calcBBoxSizeWithChilds();
  1336 		updateLink();	// This update is needed if the scene is resized 
  1337 						// due to excessive moving of a FIO
  1338 						// FIXME really needed? reposition is also called from updateLink...
  1339 
  1340 	    alignRelativeTo ( QPointF (absPos.x(),
  1341 			absPos.y()-(bboxTotal.height()-bbox.height())/2) );
  1342 		qSort (branch.begin(),branch.end(), isAbove);
  1343 		positionBBox();	// Reposition bbox and contents
  1344 	} else
  1345 	{
  1346 		// This is only important for moving branches:
  1347 		// For editing a branch it isn't called...
  1348 	    alignRelativeTo ( QPointF (absPos.x(),
  1349 							absPos.y()-(bboxTotal.height()-bbox.height())/2) );
  1350 	}
  1351 }
  1352 
  1353 void BranchObj::unsetAllRepositionRequests()
  1354 {
  1355 	repositionRequest=false;
  1356 	for (int i=0; i<branch.size(); ++i)
  1357 		branch.at(i)->unsetAllRepositionRequests();
  1358 }
  1359 
  1360 
  1361 QRectF BranchObj::getTotalBBox()
  1362 {
  1363 	QRectF r=bbox;
  1364 
  1365 	if (scrolled) return r;
  1366 
  1367 	for (int i=0; i<branch.size(); ++i)
  1368 		if (!branch.at(i)->isHidden())
  1369 			r=addBBox(branch.at(i)->getTotalBBox(),r);
  1370 
  1371 	for (int i=0; i<floatimage.size(); ++i)
  1372 		if (!floatimage.at(i)->isHidden())
  1373 			r=addBBox(floatimage.at(i)->getTotalBBox(),r);
  1374 		
  1375 	return r;
  1376 }
  1377 
  1378 QRectF BranchObj::getBBoxSizeWithChilds()
  1379 {
  1380 	return bboxTotal;
  1381 }
  1382 
  1383 void BranchObj::calcBBoxSizeWithChilds()
  1384 {	
  1385 	// This is initially called only from reposition and
  1386 	// and only for mapcenter. So it won't be
  1387 	// called more than once for a single user 
  1388 	// action
  1389 	
  1390 
  1391 	// Calculate size of LMO including all childs (to align them later)
  1392 	bboxTotal.setX(bbox.x() );
  1393 	bboxTotal.setY(bbox.y() );
  1394 
  1395 	// if branch is scrolled, ignore childs, but still consider floatimages
  1396 	if (scrolled)
  1397 	{
  1398 		bboxTotal.setWidth (bbox.width());
  1399 		bboxTotal.setHeight(bbox.height());
  1400 		return;
  1401 	}
  1402 	
  1403 	if (hidden)
  1404 	{
  1405 		bboxTotal.setWidth (0);
  1406 		bboxTotal.setHeight(0);
  1407 		if (parObj)
  1408 		{
  1409 			bboxTotal.setX (parObj->x());
  1410 			bboxTotal.setY (parObj->y());
  1411 		} else
  1412 		{
  1413 			bboxTotal.setX (bbox.x());
  1414 			bboxTotal.setY (bbox.y());
  1415 		}
  1416 		return;
  1417 	}
  1418 	
  1419 	QRectF r(0,0,0,0);
  1420 	QRectF br;
  1421 	// Now calculate recursivly
  1422 	// sum of heights 
  1423 	// maximum of widths 
  1424 	// minimum of y
  1425 	for (int i=0; i<branch.size(); ++i)
  1426 	{
  1427 		if (!branch.at(i)->isHidden())
  1428 		{
  1429 			branch.at(i)->calcBBoxSizeWithChilds();
  1430 			br=branch.at(i)->getBBoxSizeWithChilds();
  1431 			r.setWidth( max (br.width(), r.width() ));
  1432 			r.setHeight(br.height() + r.height() );
  1433 			if (br.y()<bboxTotal.y()) bboxTotal.setY(br.y());
  1434 		}
  1435 	}
  1436 	// Add myself and also
  1437 	// add width of link to sum if necessary
  1438 	if (branch.isEmpty())
  1439 		bboxTotal.setWidth (bbox.width() + r.width() );
  1440 	else	
  1441 		bboxTotal.setWidth (bbox.width() + r.width() + linkwidth);
  1442 	
  1443 	bboxTotal.setHeight(max (r.height(),  bbox.height()));
  1444 }
  1445 
  1446 void BranchObj::select()
  1447 {
  1448 	// set Text in Editor	
  1449 	textEditor->setText(note.getNote() );
  1450 	QString fnh=note.getFilenameHint();
  1451 	if (fnh!="")
  1452 		textEditor->setFilenameHint(note.getFilenameHint() );
  1453 	else	
  1454 		textEditor->setFilenameHint(getHeading() );
  1455 	textEditor->setFontHint (note.getFontHint() );
  1456 
  1457     LinkableMapObj::select();
  1458 	// Tell parent that I am selected now:
  1459 	BranchObj* po=(BranchObj*)(parObj);
  1460     if (po)	// TODO	    Try to get rid of this cast...
  1461         po->setLastSelectedBranch(this);
  1462 		
  1463 	// temporary unscroll, if we have scrolled parents somewhere
  1464 	if (parObj) ((BranchObj*)(parObj))->tmpUnscroll();
  1465 
  1466 	// Show URL and link in statusbar
  1467 	QString status;
  1468 	if (!url.isEmpty()) status+="URL: "+url+"  ";
  1469 	if (!vymLink.isEmpty()) status+="Link: "+vymLink;
  1470 	if (!status.isEmpty()) mainWindow->statusMessage (status);
  1471 
  1472 	// Update Toolbar
  1473 	updateFlagsToolbar();
  1474 
  1475 	// Update actions
  1476 	mapEditor->updateActions();
  1477 }
  1478 
  1479 void BranchObj::unselect()
  1480 {
  1481 	LinkableMapObj::unselect();
  1482 	// Delete any messages like vymLink in StatusBar
  1483 	mainWindow->statusMessage ("");
  1484 
  1485 	// save note from editor and set flag
  1486 	// text is done by updateNoteFlag(), just save
  1487 	// filename here
  1488 	note.setFilenameHint (textEditor->getFilename());
  1489 
  1490 	// reset temporary unscroll, if we have scrolled parents somewhere
  1491 	if (parObj) ((BranchObj*)(parObj))->resetTmpUnscroll();
  1492 
  1493 	// Erase content of editor 
  1494 	textEditor->setInactive();
  1495 
  1496 	// unselect all buttons in toolbar
  1497 	standardFlagsDefault->updateToolbar();
  1498 }
  1499 
  1500 QString BranchObj::getSelectString()
  1501 {
  1502 	QString s;
  1503 	if (parObj)
  1504 	{
  1505 		if (depth==1)
  1506 			s= "bo:" + QString("%1").arg(getNum());
  1507 		else	
  1508 			s= ((BranchObj*)(parObj))->getSelectString() + ",bo:" + QString("%1").arg(getNum());
  1509 	} else
  1510 		s="mc:";
  1511 	return s;
  1512 }
  1513