Some code cleanup and experimental stuff to support animations later
authorinsilmaril
Mon, 05 May 2008 13:46:42 +0000
changeset 691058b0e70f5ec
parent 690 3bb6b1548c53
child 692 c5e3cb54b9db
Some code cleanup and experimental stuff to support animations later
mapeditor.cpp
     1.1 --- a/mapeditor.cpp	Mon May 05 13:46:42 2008 +0000
     1.2 +++ b/mapeditor.cpp	Mon May 05 13:46:42 2008 +0000
     1.3 @@ -137,10 +137,6 @@
     1.4  
     1.5  	model->reposition();
     1.6  
     1.7 -	// TODO animations
     1.8 -	animObjList.clear();
     1.9 -	//timerId = startTimer(100);  
    1.10 -
    1.11  	// autosave
    1.12  	autosaveTimer=new QTimer (this);
    1.13  	connect(autosaveTimer, SIGNAL(timeout()), this, SLOT(autosave()));
    1.14 @@ -941,9 +937,9 @@
    1.15  		if (xelection.isEmpty() )
    1.16  		{
    1.17  			parser.setError (Aborted,"Nothing selected");
    1.18 -		} else if ( xelection.type()!=Selection::Selection::Branch  && 
    1.19 -					xelection.type()!=Selection::Selection::MapCenter  &&
    1.20 -					xelection.type()!=Selection::Selection::FloatImage )
    1.21 +		} else if ( xelection.type()!=Selection::Branch  && 
    1.22 +					xelection.type()!=Selection::MapCenter  &&
    1.23 +					xelection.type()!=Selection::FloatImage )
    1.24  		{				  
    1.25  			parser.setError (Aborted,"Type of selection is not a branch or floatimage");
    1.26  		} else if (parser.checkParCount(2))
    1.27 @@ -2355,8 +2351,8 @@
    1.28  	if (i>undosAvail) 
    1.29  		for (int j=undosAvail; j<i; j++) 
    1.30  		{
    1.31 -		cout << "redo "<<j<<"/"<<undosAvail<<" i="<<i<<endl;
    1.32 -		redo();
    1.33 +			if (debug) cout << "ME::gotoHistoryStep redo "<<j<<"/"<<undosAvail<<" i="<<i<<endl;
    1.34 +			redo();
    1.35  		}
    1.36  
    1.37  	// And ignore clicking the current row ;-)	
    1.38 @@ -2816,21 +2812,21 @@
    1.39  	}
    1.40  	if (bo && xelection.type()==Selection::Branch)
    1.41  	{
    1.42 -		BranchObj* par=(BranchObj*)(bo->getParObj());
    1.43 +		BranchObj* par=(BranchObj*)bo->getParObj();
    1.44  		xelection.unselect();
    1.45  		saveStateRemovingPart (bo, QString ("Delete %1").arg(getName(bo)));
    1.46  		par->removeBranch(bo);
    1.47  		xelection.select (par);
    1.48  		ensureSelectionVisible();
    1.49  		model->reposition();
    1.50 -		xelection.update();
    1.51 +//		xelection.update();
    1.52  		xelection.update();
    1.53  		return;
    1.54  	}
    1.55  	FloatImageObj *fio=xelection.getFloatImage();
    1.56  	if (fio)
    1.57  	{
    1.58 -		BranchObj* par=(BranchObj*)(fio->getParObj());
    1.59 +		BranchObj* par=(BranchObj*)fio->getParObj();
    1.60  		saveStateChangingPart(
    1.61  			par, 
    1.62  			fio,
    1.63 @@ -4135,7 +4131,7 @@
    1.64  				QMessageBox::Warning,
    1.65  				QMessageBox::Yes | QMessageBox::Default,
    1.66  				QMessageBox::Cancel | QMessageBox::Escape,
    1.67 -				QMessageBox::QMessageBox::NoButton );
    1.68 +				QMessageBox::NoButton );
    1.69  
    1.70  				mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
    1.71  				mb.setButtonText( QMessageBox::No, tr("Cancel"));
    1.72 @@ -4424,12 +4420,6 @@
    1.73  {
    1.74  	BranchObj *bo=xelection.getBranch();
    1.75  	if (bo) model->moveAway (bo);
    1.76 -
    1.77 -
    1.78 -/*
    1.79 -	BranchObj *bo=xelection.getBranch();
    1.80 -	if (bo) animObjList.append( bo );
    1.81 -*/	
    1.82  	
    1.83  /* TODO Hide hidden stuff temporary, maybe add this as regular function somewhere
    1.84  	if (hidemode==HideNone)
    1.85 @@ -4461,11 +4451,13 @@
    1.86  void MapEditor::testFunction2()
    1.87  {
    1.88  
    1.89 +/*
    1.90  	// Toggle hidemode
    1.91  	if (hidemode==HideExport)
    1.92  		setHideTmpMode (HideNone);
    1.93  	else	
    1.94  		setHideTmpMode (HideExport);
    1.95 +*/		
    1.96  }
    1.97  
    1.98  void MapEditor::contextMenuEvent ( QContextMenuEvent * e )
    1.99 @@ -4921,6 +4913,8 @@
   1.100  			copyingObj=false;	
   1.101  			if (dst ) 
   1.102  			{
   1.103 +				// We have a destination, relink to that
   1.104 +
   1.105  				BranchObj* bsel=xelection.getBranch();
   1.106  				BranchObj* bdst=(BranchObj*)dst;
   1.107  
   1.108 @@ -4959,7 +4953,12 @@
   1.109  					postSelStr,undoCom,
   1.110  					preSelStr, redoCom,
   1.111  					QString("Relink %1 to %2").arg(getName(bsel)).arg(getName(dst)) );
   1.112 +
   1.113 +				model->reposition();	// not necessary if we undo temporary move  below
   1.114  			} else
   1.115 +			{
   1.116 +				// No destination, undo  temporary move
   1.117 +
   1.118  				if (lmosel->getDepth()==1)
   1.119  				{
   1.120  					// The select string might be different _after_ moving around.
   1.121 @@ -4976,10 +4975,21 @@
   1.122                              QString("Move %1 to relative position %2").arg(getName(lmosel)).arg(ps));
   1.123                      }
   1.124  				}
   1.125 -			// Draw the original link, before selection was moved around
   1.126 -			model->reposition();
   1.127 +
   1.128 +				// Draw the original link, before selection was moved around
   1.129 +				if (settings.value("/animation/use",false).toBool() && lmosel->getDepth()>1) 
   1.130 +				{
   1.131 +					QPointF p=bo->getParObj()->getChildPos();
   1.132 +					lmosel->setRelPos();	// calc relPos first
   1.133 +					model->startAnimation(
   1.134 +						lmosel->getRelPos(),
   1.135 +						QPointF (movingObj_orgPos.x() - p.x(), movingObj_orgPos.y() - p.y() )
   1.136 +					);	
   1.137 +				} else	
   1.138 +					model->reposition();
   1.139 +			}
   1.140  		}
   1.141 -		xelection.update();
   1.142 +		 xelection.update();
   1.143  		// Finally resize scene, if needed
   1.144  		scene()->update();
   1.145  		movingObj=NULL;		
   1.146 @@ -5099,20 +5109,6 @@
   1.147  	event->acceptProposedAction();
   1.148  }
   1.149  
   1.150 -void MapEditor::timerEvent(QTimerEvent *event)  //TODO animation
   1.151 -{
   1.152 -    Q_UNUSED(event);
   1.153 -
   1.154 -	cout << "ME::timerEvent\n";
   1.155 -
   1.156 -	for (int i=0; i<animObjList.size(); ++i)
   1.157 -	{
   1.158 -		animObjList.at(i)->animate();
   1.159 -		((BranchObj*)animObjList.at(i))->move2RelPos (((BranchObj*)animObjList.at(i))->getRelPos() );
   1.160 -	}
   1.161 -	model->reposition();
   1.162 -}
   1.163 -
   1.164  
   1.165  void MapEditor::sendSelection()
   1.166  {
   1.167 @@ -5292,7 +5288,7 @@
   1.168  			// FIXME switch to current mapeditor and finish lineedits...
   1.169  			QMessageBox mb( vymName,
   1.170  				tr("The file of the map  on disk has changed:\n\n"  
   1.171 -				   "   %1\n\nDo you want to reload this map with the new file?").arg(filePath),
   1.172 +				   "   %1\n\nDo you want to reload that map with the new file?").arg(filePath),
   1.173  				QMessageBox::Question,
   1.174  				QMessageBox::Yes ,
   1.175  				QMessageBox::Cancel | QMessageBox::Default,