mapeditor.cpp
changeset 755 ed5b407975b3
parent 754 db0ec4bcf416
child 756 a8a5c7288f57
     1.1 --- a/mapeditor.cpp	Mon Apr 20 10:42:05 2009 +0000
     1.2 +++ b/mapeditor.cpp	Thu Apr 23 12:15:31 2009 +0000
     1.3 @@ -719,7 +719,7 @@
     1.4  			}
     1.5  		} else	
     1.6  		{	// selection != a FloatObj
     1.7 -			if (lmosel->getDepth()==0)		//FIXME-1 also moved mapcenters could be linked, but not working here...
     1.8 +			if (seli->depth()==0)		//FIXME-1 also moved mapcenters could be linked, but not working here...
     1.9  			{
    1.10  				// Move MapCenter
    1.11  				if (e->buttons()== Qt::LeftButton && e->modifiers()==Qt::ShiftModifier) 
    1.12 @@ -729,7 +729,7 @@
    1.13  				model->updateRelPositions();
    1.14  			} else
    1.15  			{	
    1.16 -				if (lmosel->getDepth()==1)
    1.17 +				if (seli->depth()==1)
    1.18  				{
    1.19  					// Move mainbranch
    1.20  					lmosel->move(p.x() -movingObj_start.x(), p.y()-movingObj_start.y() );		
    1.21 @@ -797,13 +797,12 @@
    1.22  void MapEditor::mouseReleaseEvent(QMouseEvent* e)
    1.23  {
    1.24      QPointF p = mapToScene(e->pos());
    1.25 -	TreeItem *dsti=findMapItem(p, NULL);
    1.26 -	LinkableMapObj* dst=NULL;
    1.27 -	if (dsti) dst=dsti->getLMO();	//FIXME-2 get rid of dst...
    1.28 -
    1.29  	TreeItem *seli=model->getSelectedItem();
    1.30  	LinkableMapObj *lmosel=seli->getLMO();	// FIXME-2 get rid of lmosel
    1.31  
    1.32 +	TreeItem *dsti=findMapItem(p, seli);
    1.33 +	LinkableMapObj* dst=NULL;
    1.34 +	if (dsti) dst=dsti->getLMO();	//FIXME-2 get rid of dst...
    1.35  
    1.36  
    1.37  	// Have we been picking color?
    1.38 @@ -905,37 +904,36 @@
    1.39  			QString preSelStr=model->getSelectString(lmosel);
    1.40  
    1.41  			copyingObj=false;	
    1.42 -			if (dsti ) 
    1.43 +			if (dsti && dsti->isBranchLikeType() ) 
    1.44  			{
    1.45  				// We have a destination, relink to that
    1.46  
    1.47  				BranchObj* bsel=model->getSelectedBranchObj();
    1.48 -				TreeItem * tisel=model->getSelectedItem();
    1.49  				BranchObj* bdst=(BranchObj*)dst;
    1.50 -				TreeItem* tidst=dst->getTreeItem();
    1.51  
    1.52  				QString preParStr=model->getSelectString (bsel->getParObj());
    1.53 -				QString preNum=QString::number (tisel->num(),10);
    1.54 +				QString preNum=QString::number (seli->num(),10);
    1.55  				QString preDstParStr;
    1.56  
    1.57  				if (e->state() & Qt::ShiftModifier && dst->getParObj())
    1.58  				{	// Link above dst
    1.59  					preDstParStr=model->getSelectString (dst->getParObj());
    1.60 -					bsel->linkTo ( (BranchObj*)(bdst->getParObj()), tidst->num());
    1.61 +					bsel->linkTo ( (BranchObj*)(bdst->getParObj()), seli->num());
    1.62  				} else 
    1.63  				if (e->state() & Qt::ControlModifier && dst->getParObj())
    1.64  				{
    1.65  					// Link below dst
    1.66  					preDstParStr=model->getSelectString (dst->getParObj());
    1.67 -					bsel->linkTo ( (BranchObj*)(bdst->getParObj()), tidst->num()+1);
    1.68 +					bsel->linkTo ( (BranchObj*)(bdst->getParObj()), seli->num()+1);
    1.69  				} else	
    1.70  				{	// Append to dst
    1.71  					preDstParStr=model->getSelectString(dst);
    1.72  					bsel->linkTo (bdst,-1);
    1.73 -					if (dst->getDepth()==0) bsel->move (savePos);
    1.74 +					model->relinkBranch ((BranchItem*)seli,(BranchItem*)dsti);
    1.75 +					if (dsti->depth()==0) bsel->move (savePos);
    1.76  				} 
    1.77  				QString postSelStr=model->getSelectString(lmosel);
    1.78 -				QString postNum=QString::number (tisel->num(),10);
    1.79 +				QString postNum=QString::number (seli->num(),10);
    1.80  
    1.81  				QString undoCom="linkTo (\""+ 
    1.82  					preParStr+ "\"," + preNum  +"," + 
    1.83 @@ -955,7 +953,7 @@
    1.84  			{
    1.85  				// No destination, undo  temporary move
    1.86  
    1.87 -				if (lmosel->getDepth()==1)
    1.88 +				if (seli->depth()==1)
    1.89  				{
    1.90  					cout << "ME::releaseMouse d=1\n"; // FIXME_1    better use depth
    1.91  					// The select string might be different _after_ moving around.
    1.92 @@ -974,7 +972,7 @@
    1.93  				}
    1.94  
    1.95  				// Draw the original link, before selection was moved around
    1.96 -				if (settings.value("/animation/use",false).toBool() && lmosel->getDepth()>1) 
    1.97 +				if (settings.value("/animation/use",false).toBool() && seli->depth()>1) 
    1.98  				{
    1.99  					lmosel->setRelPos();	// calc relPos first for starting point
   1.100  					QPointF dst=bi->getBranchObj()->getParObj()->getChildPos();		// FIXME-3 check getBO here...