changed MapEditor::undo and saveState so that selection is saved, too (bgugfix)
authorinsilmaril
Mon, 25 Jul 2005 20:07:18 +0000
changeset 136b0d8b00fb937
parent 135 e7f59f62bbe3
child 137 88d2a027ef14
changed MapEditor::undo and saveState so that selection is saved, too (bgugfix)
mapeditor.cpp
mapeditor.h
     1.1 --- a/mapeditor.cpp	Sat Jul 23 15:13:34 2005 +0000
     1.2 +++ b/mapeditor.cpp	Mon Jul 25 20:07:18 2005 +0000
     1.3 @@ -587,12 +587,25 @@
     1.4  
     1.5  void MapEditor::saveState(const QString & c)
     1.6  {
     1.7 -	saveState (UndoCommand,NULL,c);
     1.8 +	LinkableMapObj *undoSel;
     1.9 +	if (selection)
    1.10 +		undoSel=selection;
    1.11 +	else
    1.12 +		undoSel=NULL;
    1.13 +	saveState (UndoCommand,undoSel,c);
    1.14  }
    1.15  
    1.16  void MapEditor::saveState(const SaveMode &savemode, LinkableMapObj *undoSel, const QString &undoCom)
    1.17  {
    1.18  	setChanged();
    1.19 +
    1.20 +	// Save what is selected now
    1.21 +	if (undoSel)
    1.22 +		undoSelection=undoSel->getSelectString();
    1.23 +	else
    1.24 +		undoSelection="";
    1.25 +		
    1.26 +	// Save depending on how much needs to be saved	
    1.27  	if (savemode==UndoCommand)
    1.28  	{
    1.29  		undoCommand=undoCom;
    1.30 @@ -600,7 +613,7 @@
    1.31  	}	
    1.32  	else if (savemode==PartOfMap && undoSel)
    1.33  	{
    1.34 -		undoCommand="undoPart (\""+undoSel->getSelectString()+"\")";
    1.35 +		undoCommand="undoPart (\""+undoSelection+"\")";
    1.36  		backupXML=saveToDir (bakMapDir,mapName+"-",false, QPoint (),undoSel);
    1.37  	} else
    1.38  	{
    1.39 @@ -1284,6 +1297,10 @@
    1.40  	// Finish open lineEdits
    1.41  	if (lineedit) finishedLineEditNoSave();
    1.42  
    1.43 +	// select  object before undo
    1.44 +	if (!undoSelection.isEmpty())
    1.45 +		select (undoSelection);
    1.46 +
    1.47  	parseAtom (undoCommand);
    1.48  	mapCenter->reposition();
    1.49  
     2.1 --- a/mapeditor.h	Sat Jul 23 15:13:34 2005 +0000
     2.2 +++ b/mapeditor.h	Mon Jul 25 20:07:18 2005 +0000
     2.3 @@ -189,6 +189,7 @@
     2.4  	
     2.5      LinkableMapObj* selection;		// select a LinkableMapObj
     2.6      LinkableMapObj* selectionLast;	// last selection 
     2.7 +	QString undoSelection;			// selection for undo
     2.8      MapObj* movingObj;				// moving a MapObj
     2.9  	MapObj* linkingObj_src;			// part of a link
    2.10      QPoint movingObj_orgPos;		// org. pos of mouse before move