# HG changeset patch
# User insilmaril
# Date 1122322038 0
# Node ID b0d8b00fb9370bcc035e6d2a4c2bc4f6e60a4fb7
# Parent  e7f59f62bbe3ba4c7cceed04032e5a5f32b2a261
changed MapEditor::undo and saveState so that  selection is saved, too (bgugfix)

diff -r e7f59f62bbe3 -r b0d8b00fb937 mapeditor.cpp
--- a/mapeditor.cpp	Sat Jul 23 15:13:34 2005 +0000
+++ b/mapeditor.cpp	Mon Jul 25 20:07:18 2005 +0000
@@ -587,12 +587,25 @@
 
 void MapEditor::saveState(const QString & c)
 {
-	saveState (UndoCommand,NULL,c);
+	LinkableMapObj *undoSel;
+	if (selection)
+		undoSel=selection;
+	else
+		undoSel=NULL;
+	saveState (UndoCommand,undoSel,c);
 }
 
 void MapEditor::saveState(const SaveMode &savemode, LinkableMapObj *undoSel, const QString &undoCom)
 {
 	setChanged();
+
+	// Save what is selected now
+	if (undoSel)
+		undoSelection=undoSel->getSelectString();
+	else
+		undoSelection="";
+		
+	// Save depending on how much needs to be saved	
 	if (savemode==UndoCommand)
 	{
 		undoCommand=undoCom;
@@ -600,7 +613,7 @@
 	}	
 	else if (savemode==PartOfMap && undoSel)
 	{
-		undoCommand="undoPart (\""+undoSel->getSelectString()+"\")";
+		undoCommand="undoPart (\""+undoSelection+"\")";
 		backupXML=saveToDir (bakMapDir,mapName+"-",false, QPoint (),undoSel);
 	} else
 	{
@@ -1284,6 +1297,10 @@
 	// Finish open lineEdits
 	if (lineedit) finishedLineEditNoSave();
 
+	// select  object before undo
+	if (!undoSelection.isEmpty())
+		select (undoSelection);
+
 	parseAtom (undoCommand);
 	mapCenter->reposition();
 
diff -r e7f59f62bbe3 -r b0d8b00fb937 mapeditor.h
--- a/mapeditor.h	Sat Jul 23 15:13:34 2005 +0000
+++ b/mapeditor.h	Mon Jul 25 20:07:18 2005 +0000
@@ -189,6 +189,7 @@
 	
     LinkableMapObj* selection;		// select a LinkableMapObj
     LinkableMapObj* selectionLast;	// last selection 
+	QString undoSelection;			// selection for undo
     MapObj* movingObj;				// moving a MapObj
 	MapObj* linkingObj_src;			// part of a link
     QPoint movingObj_orgPos;		// org. pos of mouse before move