mapeditor.cpp
changeset 772 e3f722759c7e
parent 769 a6931cd6309a
child 773 340bc29da9a0
     1.1 --- a/mapeditor.cpp	Mon May 18 11:22:41 2009 +0000
     1.2 +++ b/mapeditor.cpp	Wed May 20 15:40:14 2009 +0000
     1.3 @@ -118,7 +118,7 @@
     1.4  	lineEdit=new QLineEdit;
     1.5  	lineEdit->hide();
     1.6  	QGraphicsProxyWidget *pw=scene()->addWidget (lineEdit);
     1.7 -	pw->setZValue (100);
     1.8 +	pw->setZValue (Z_LINEEDIT);
     1.9  
    1.10  	a = new QAction( tr( "Edit heading","MapEditor" ), this);
    1.11  	a->setShortcut ( Qt::Key_Return );					//Edit heading
    1.12 @@ -182,6 +182,15 @@
    1.13      return mapScene;
    1.14  }
    1.15  
    1.16 +void MapEditor::scrollTo (const QModelIndex &index)
    1.17 +{
    1.18 +	if (index.isValid())
    1.19 +	{
    1.20 +		LinkableMapObj* lmo=(static_cast<TreeItem*>(index.internalPointer()))->getLMO();
    1.21 +		if (lmo) setScrollBarPosTarget (lmo->getBBox() );
    1.22 +	}
    1.23 +}
    1.24 +
    1.25  void MapEditor::setScrollBarPosTarget (const QRectF &rect)
    1.26  {
    1.27  	// Code copied from Qt sources
    1.28 @@ -838,7 +847,10 @@
    1.29  		// Check if we could link 
    1.30  		TreeItem *dsti=findMapItem (p, seli);
    1.31  		LinkableMapObj* dst=NULL;
    1.32 -		if (dsti) dst=dsti->getLMO();	//FIXME-2 get rid of lmo...
    1.33 +		if (dsti && dsti!=seli && dsti->isBranchLikeType())
    1.34 +			dst=dsti->getLMO(); //FIXME-2 get rid of lmo...
    1.35 +		else
    1.36 +			dsti=NULL;
    1.37  		
    1.38  
    1.39  		FloatObj *fio=model->getSelectedFloatImage();
    1.40 @@ -851,15 +863,10 @@
    1.41  
    1.42  			// Relink float to new mapcenter or branch, if shift is pressed	
    1.43  			// Only relink, if selection really has a new parent
    1.44 -			if ( (e->modifiers()==Qt::ShiftModifier) && dst &&
    1.45 -				( (typeid(*dst)==typeid(BranchObj)) ||
    1.46 -				  (typeid(*dst)==typeid(MapCenterObj)) ) &&
    1.47 -				( dst != fio->getParObj())  
    1.48 +			if ( (e->modifiers()==Qt::ShiftModifier) && dst && ( dst != fio->getParObj())  
    1.49  				)
    1.50  			{
    1.51 -				if (typeid(*fio) == typeid(FloatImageObj) && 
    1.52 -				( (typeid(*dst)==typeid(BranchObj) ||
    1.53 -				  typeid(*dst)==typeid(MapCenterObj)) ))  
    1.54 +				if (typeid(*fio) == typeid(FloatImageObj) )  
    1.55  				{
    1.56  
    1.57  					// Also save the move which was done so far
    1.58 @@ -911,7 +918,7 @@
    1.59  				} 
    1.60  
    1.61  				// Maybe we can relink temporary?
    1.62 -				if (dsti && (dst!=lmosel) && seli->isBranchLikeType() && dsti->isBranchLikeType() )
    1.63 +				if (dsti)
    1.64  				{
    1.65  					if (e->modifiers()==Qt::ControlModifier)
    1.66  					{
    1.67 @@ -963,9 +970,13 @@
    1.68      QPointF p = mapToScene(e->pos());
    1.69  	TreeItem *seli=model->getSelectedItem();
    1.70  
    1.71 -	TreeItem *dsti=findMapItem(p, seli);
    1.72 +	TreeItem *dsti=NULL;
    1.73 +	if (seli) dsti=findMapItem(p, seli);
    1.74  	LinkableMapObj* dst=NULL;
    1.75 -	if (dsti) dst=dsti->getLMO();	//FIXME-2 get rid of dst...
    1.76 +	if (dsti && dsti->isBranchLikeType ()) 
    1.77 +		dst=dsti->getLMO();	//FIXME-2 get rid of dst...
    1.78 +	else
    1.79 +		dsti=NULL;
    1.80  
    1.81  
    1.82  	// Have we been picking color?
    1.83 @@ -974,7 +985,7 @@
    1.84  		pickingColor=false;
    1.85  		setCursor (Qt::ArrowCursor);
    1.86  		// Check if we are over another branch
    1.87 -		if (dsti && seli) 
    1.88 +		if (dst) 
    1.89  		{	
    1.90  			if (e->state() & Qt::ShiftModifier)
    1.91  				model->colorBranch (((BranchObj*)dst)->getColor());
    1.92 @@ -989,7 +1000,7 @@
    1.93  	{
    1.94  		drawingLink=false;
    1.95  		// Check if we are over another branch
    1.96 -		if (dsti && seli && dsti->isBranchLikeType() ) 
    1.97 +		if (dsti)
    1.98  		{	
    1.99  			tmpXLink->setEnd ( ((BranchObj*)(dst)) );
   1.100  			tmpXLink->updateXLink();
   1.101 @@ -1006,11 +1017,6 @@
   1.102      // Have we been moving something?
   1.103      if ( seli && movingObj ) 
   1.104      {	
   1.105 -		if (dsti==seli) 
   1.106 -		{
   1.107 -			dsti=NULL;
   1.108 -			dst=NULL;
   1.109 -		}
   1.110  		FloatImageObj *fo=model->getSelectedFloatImage();
   1.111  		if(fo)
   1.112  		{
   1.113 @@ -1028,15 +1034,6 @@
   1.114  			model->reposition();
   1.115  		}	
   1.116  
   1.117 -		// Check if we are over another branch, but ignore 
   1.118 -		// any found LMOs, which are FloatObjs
   1.119 -
   1.120 -		if (dsti && (!dsti->isBranchLikeType() )) 
   1.121 -		{
   1.122 -			dst=NULL;
   1.123 -			dsti=NULL;
   1.124 -		}	
   1.125 -		
   1.126  		BranchItem *bi=model->getSelectedBranchItem();
   1.127  		if (bi && bi->depth()==0)
   1.128  		{	
   1.129 @@ -1069,7 +1066,7 @@
   1.130  			QString preSelStr=model->getSelectString(lmosel);
   1.131  
   1.132  			copyingObj=false;	
   1.133 -			if (dsti && dsti->isBranchLikeType() ) 
   1.134 +			if (dsti)
   1.135  			{
   1.136  				// We have a destination, relink to that
   1.137