branchobj.cpp
changeset 721 12958f987bcf
parent 688 d0086df58648
child 722 462d39502273
     1.1 --- a/branchobj.cpp	Wed Jul 16 10:44:44 2008 +0000
     1.2 +++ b/branchobj.cpp	Wed Jul 16 10:46:14 2008 +0000
     1.3 @@ -21,7 +21,7 @@
     1.4  BranchObj* BranchObj::itFirst=NULL;
     1.5  
     1.6  
     1.7 -BranchObj::BranchObj () :OrnamentedObj()
     1.8 +BranchObj::BranchObj () :OrnamentedObj()	// FIXME needed at all?
     1.9  {
    1.10  //    cout << "Const BranchObj ()\n";
    1.11      setParObj (this);	
    1.12 @@ -103,7 +103,7 @@
    1.13  	branch.clear();
    1.14  	for (int i=0; i<other->branch.size(); ++i)
    1.15  		// Make deep copy of b
    1.16 -		// Because addBranch again calls copy for the childs,
    1.17 +		// Because addBranch again calls copy for the children,
    1.18  		// Those will get a deep copy, too
    1.19  		addBranch(other->branch.at(i) );	
    1.20  
    1.21 @@ -214,7 +214,7 @@
    1.22  		if (off==0)
    1.23  		{
    1.24  			// new parent is just a branch, link to it
    1.25 -			QRectF t=o->getBBoxSizeWithChilds();
    1.26 +			QRectF t=o->getBBoxSizeWithChildren();
    1.27  			if (o->getLastBranch())
    1.28  				y=t.y() + t.height() ;
    1.29  			else
    1.30 @@ -343,10 +343,10 @@
    1.31  		standardFlags->setVisibility(v);
    1.32  		LinkableMapObj::setVisibility (v);
    1.33  		
    1.34 -		// Only change childs, if I am not scrolled
    1.35 +		// Only change children, if I am not scrolled
    1.36  		if (!scrolled && (depth < toDepth))
    1.37  		{
    1.38 -			// Now go recursivly through all childs
    1.39 +			// Now go recursivly through all children
    1.40  			int i;
    1.41  			for (i=0; i<branch.size(); ++i)
    1.42  				branch.at(i)->setVisibility (v,toDepth);	
    1.43 @@ -370,9 +370,9 @@
    1.44  	// Overloaded from LinkableMapObj
    1.45  	// BranchObj can use color of heading
    1.46  
    1.47 -	if (mapEditor)
    1.48 +	if (model)
    1.49  	{
    1.50 -		if (mapEditor->getMapLinkColorHint()==HeadingColor)
    1.51 +		if (model->getMapLinkColorHint()==HeadingColor)
    1.52  			LinkableMapObj::setLinkColor (heading->getColor() );
    1.53  		else	
    1.54  			LinkableMapObj::setLinkColor ();
    1.55 @@ -409,13 +409,13 @@
    1.56  		// no itLast, we are just beginning
    1.57  		if (bo) 
    1.58  		{
    1.59 -			// we have childs, return first one
    1.60 +			// we have children, return first one
    1.61  			itLast=this;
    1.62  			return bo;
    1.63  		}	
    1.64  		else
    1.65  		{
    1.66 -			// No childs, so there is no next
    1.67 +			// No children, so there is no next
    1.68  			itLast=this;
    1.69  			return NULL;
    1.70  		}	
    1.71 @@ -426,12 +426,12 @@
    1.72  	{	// We come from parent
    1.73  		if (bo)
    1.74  		{
    1.75 -			// there are childs, go there
    1.76 +			// there are children, go there
    1.77  			itLast=this;
    1.78  			return bo;
    1.79  		}	
    1.80  		else
    1.81 -		{	// no childs, try to go up again
    1.82 +		{	// no children, try to go up again
    1.83  			if (po)
    1.84  			{
    1.85  				// go back to parent and try to find next there
    1.86 @@ -450,17 +450,17 @@
    1.87  		}
    1.88  	}
    1.89  
    1.90 -	// We don't come from parent, but from brother or childs
    1.91 +	// We don't come from parent, but from brother or children
    1.92  
    1.93 -	// Try to find last child, where we came from, in my own childs
    1.94 +	// Try to find last child, where we came from, in my own children
    1.95  	bool searching=true;
    1.96  	int i=0;
    1.97  	while (i<branch.size())
    1.98  	{
    1.99 -		// Try to find itLast in my own childs
   1.100 +		// Try to find itLast in my own children
   1.101  		if (itLast==branch.at(i))
   1.102  		{
   1.103 -			// ok, we come from my own childs
   1.104 +			// ok, we come from my own children
   1.105  			if (i<branch.size()-1)
   1.106  				bo=branch.at(i+1);
   1.107  			 else
   1.108 @@ -471,7 +471,7 @@
   1.109  		++i;	
   1.110  	}
   1.111  	if (!searching)
   1.112 -	{	// found itLast in my childs
   1.113 +	{	// found itLast in my children
   1.114  		if (bo)
   1.115  		{
   1.116  			// found a brother of lastLMO 
   1.117 @@ -756,7 +756,7 @@
   1.118  		hidden=false;
   1.119  	}	
   1.120  
   1.121 -	// And take care of my childs
   1.122 +	// And take care of my children
   1.123  	for (int i=0; i<branch.size(); ++i)
   1.124  		branch.at(i)->setHideTmp (mode);
   1.125  }
   1.126 @@ -1114,7 +1114,7 @@
   1.127  void BranchObj::removeBranchHere(BranchObj* borem)
   1.128  {
   1.129  	// This removes the branch bo from list, but 
   1.130 -	// inserts its childs at the place of bo
   1.131 +	// inserts its children at the place of bo
   1.132  	BranchObj *bo;
   1.133  	bo=borem->getLastBranch();
   1.134  	int pos=borem->getNum();
   1.135 @@ -1126,7 +1126,7 @@
   1.136  	removeBranch (borem);
   1.137  }
   1.138  
   1.139 -void BranchObj::removeChilds()
   1.140 +void BranchObj::removeChildren()
   1.141  {
   1.142  	clear();
   1.143  }
   1.144 @@ -1302,7 +1302,7 @@
   1.145  	}	
   1.146  }
   1.147  
   1.148 -void BranchObj::alignRelativeTo (QPointF ref)
   1.149 +void BranchObj::alignRelativeTo (QPointF ref,bool alignSelf)
   1.150  {
   1.151  	qreal th = bboxTotal.height();	
   1.152  // TODO testing
   1.153 @@ -1313,9 +1313,11 @@
   1.154  		"  ref="<<ref<<
   1.155  //		"  bbox.topLeft="<<bboxTotal.topLeft()<<
   1.156  		"  absPos="<<absPos<<
   1.157 -		"  relPos="<<relPos<<
   1.158 -		"  parPos="<<pp<<
   1.159 +//		"  relPos="<<relPos<<
   1.160 +//		"  parPos="<<pp<<
   1.161 +		"  width="<<bbox.width()<<
   1.162  		"  orient="<<orientation<<
   1.163 +		"  alignSelf="<<alignSelf<<
   1.164  //		"  pad="<<topPad<<","<<botPad<<","<<leftPad<<","<<rightPad<<
   1.165  //		"  hidden="<<hidden<<
   1.166  //		"  th="<<th<<
   1.167 @@ -1351,24 +1353,26 @@
   1.168  		{
   1.169  			LinkableMapObj::Orientation o;
   1.170  			o=parObj->getOrientation();
   1.171 -			switch (orientation) 
   1.172 -			{
   1.173 -				case LinkableMapObj::LeftOfCenter:
   1.174 -					move (ref.x() - bbox.width(), ref.y() + (th-bbox.height())/2 );
   1.175 -				break;
   1.176 -				case LinkableMapObj::RightOfCenter:	
   1.177 -					move (ref.x() , ref.y() + (th-bbox.height())/2  );
   1.178 -				break;
   1.179 -				default:
   1.180 -					qWarning ("LMO::alignRelativeTo: oops, no orientation given...");
   1.181 -				break;
   1.182 -			}	
   1.183 +			if (alignSelf)
   1.184 +				switch (orientation) 
   1.185 +				{
   1.186 +					case LinkableMapObj::LeftOfCenter:
   1.187 +						move (ref.x() - bbox.width(), ref.y() + (th-bbox.height())/2 );
   1.188 +						//move (ref.x() , ref.y() + (th-bbox.height())/2 );
   1.189 +					break;
   1.190 +					case LinkableMapObj::RightOfCenter:	
   1.191 +						move (ref.x() , ref.y() + (th-bbox.height())/2  );
   1.192 +					break;
   1.193 +					default:
   1.194 +						qWarning ("LMO::alignRelativeTo: oops, no orientation given...");
   1.195 +					break;
   1.196 +				}
   1.197  		}
   1.198      }		
   1.199  
   1.200  	if (scrolled) return;
   1.201  
   1.202 -    // Set reference point for alignment of childs
   1.203 +    // Set reference point for alignment of children
   1.204      QPointF ref2;
   1.205      if (orientation==LinkableMapObj::LeftOfCenter)
   1.206  		ref2.setX(bbox.topLeft().x() - linkwidth);
   1.207 @@ -1380,13 +1384,15 @@
   1.208  	else	
   1.209  		ref2.setY(ref.y() );	
   1.210  
   1.211 -    // Align the childs depending on reference point 
   1.212 +    // Align the children depending on reference point 
   1.213  	for (int i=0; i<branch.size(); ++i)
   1.214      {	
   1.215  		if (!branch.at(i)->isHidden())
   1.216  		{
   1.217 -			branch.at(i)->alignRelativeTo (ref2);
   1.218 -			ref2.setY(ref2.y() + branch.at(i)->getBBoxSizeWithChilds().height() );
   1.219 +			branch.at(i)->alignRelativeTo (ref2,true);
   1.220 +
   1.221 +			// append next branch below current one
   1.222 +			ref2.setY(ref2.y() + branch.at(i)->getBBoxSizeWithChildren().height() );
   1.223  		}
   1.224      }
   1.225  }
   1.226 @@ -1408,7 +1414,7 @@
   1.227  		// only calculate the sizes once. If the deepest LMO 
   1.228  		// changes its height,
   1.229  		// all upper LMOs have to change, too.
   1.230 -		calcBBoxSizeWithChilds();
   1.231 +		calcBBoxSizeWithChildren();
   1.232  		updateLink();	// This update is needed if the scene is resized 
   1.233  						// due to excessive moving of a FIO
   1.234  
   1.235 @@ -1472,12 +1478,12 @@
   1.236  	return r;
   1.237  }
   1.238  
   1.239 -QRectF BranchObj::getBBoxSizeWithChilds()
   1.240 +QRectF BranchObj::getBBoxSizeWithChildren()
   1.241  {
   1.242  	return bboxTotal;
   1.243  }
   1.244  
   1.245 -void BranchObj::calcBBoxSizeWithChilds()
   1.246 +void BranchObj::calcBBoxSizeWithChildren()
   1.247  {	
   1.248  	// This is initially called only from reposition and
   1.249  	// and only for mapcenter. So it won't be
   1.250 @@ -1485,11 +1491,11 @@
   1.251  	// action
   1.252  	
   1.253  
   1.254 -	// Calculate size of LMO including all childs (to align them later)
   1.255 +	// Calculate size of LMO including all children (to align them later)
   1.256  	bboxTotal.setX(bbox.x() );
   1.257  	bboxTotal.setY(bbox.y() );
   1.258  
   1.259 -	// if branch is scrolled, ignore childs, but still consider floatimages
   1.260 +	// if branch is scrolled, ignore children, but still consider floatimages
   1.261  	if (scrolled)
   1.262  	{
   1.263  		bboxTotal.setWidth (bbox.width());
   1.264 @@ -1523,8 +1529,8 @@
   1.265  	{
   1.266  		if (!branch.at(i)->isHidden())
   1.267  		{
   1.268 -			branch.at(i)->calcBBoxSizeWithChilds();
   1.269 -			br=branch.at(i)->getBBoxSizeWithChilds();
   1.270 +			branch.at(i)->calcBBoxSizeWithChildren();
   1.271 +			br=branch.at(i)->getBBoxSizeWithChildren();
   1.272  			r.setWidth( max (br.width(), r.width() ));
   1.273  			r.setHeight(br.height() + r.height() );
   1.274  			if (br.y()<bboxTotal.y()) bboxTotal.setY(br.y());
   1.275 @@ -1573,14 +1579,14 @@
   1.276  	updateFlagsToolbar();
   1.277  
   1.278  	// Update actions
   1.279 -	mapEditor->updateActions();
   1.280 +	model->updateActions();
   1.281  }
   1.282  
   1.283  void BranchObj::unselect()
   1.284  {
   1.285  	LinkableMapObj::unselect();
   1.286  	// Delete any messages like vymLink in StatusBar
   1.287 -	mainWindow->statusMessage ("");
   1.288 +	mainWindow->statusMessage ("");		//FIXME this causes segfault, when MainWindow is already gone in global destructor on quitting vym
   1.289  
   1.290  	// Save current note
   1.291  	if (isNoteInEditor) getNoteFromTextEditor();
   1.292 @@ -1609,7 +1615,11 @@
   1.293  bool BranchObj::animate()
   1.294  {
   1.295  	anim.animate ();
   1.296 -	setRelPos (anim);
   1.297 -	return anim.isAnimated();
   1.298 +	if ( anim.isAnimated() )
   1.299 +	{
   1.300 +		setRelPos (anim);
   1.301 +		return true;
   1.302 +	}
   1.303 +	return false;
   1.304  }
   1.305