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