# HG changeset patch
# User insilmaril
# Date 1144766054 0
# Node ID 3492af261af2668ecdf3e27b66696617438879a2
# Parent  68495946fe334b384349640fe4e2b36873bfc7ba
added basic history window

diff -r 68495946fe33 -r 3492af261af2 main.cpp
--- a/main.cpp	Tue Apr 11 14:34:14 2006 +0000
+++ b/main.cpp	Tue Apr 11 14:34:14 2006 +0000
@@ -59,7 +59,7 @@
 QAction *actionEditAddBranchHere;
 QAction *actionEditAddBranchAbove;
 QAction *actionEditAddBranchBelow;
-QAction *actionEditRemoveBranchHere;
+QAction *actionEditRemoveBranchKeepChilds;
 QAction *actionEditRemoveChilds;
 QAction *actionEditImportAdd;
 QAction *actionEditImportReplace;
@@ -95,6 +95,7 @@
 QAction *actionFormatLinkStylePolyParabel;
 
 QAction *actionViewToggleNoteEditor;
+QAction *actionViewToggleHistoryWindow;
 
 QAction *actionSettingsAutoselectHeading;
 QAction *actionSettingsAutoselectText;
diff -r 68495946fe33 -r 3492af261af2 mainwindow.cpp
--- a/mainwindow.cpp	Tue Apr 11 14:34:14 2006 +0000
+++ b/mainwindow.cpp	Tue Apr 11 14:34:14 2006 +0000
@@ -73,7 +73,7 @@
 extern QAction *actionEditAddBranchHere;
 extern QAction *actionEditAddBranchAbove;
 extern QAction *actionEditAddBranchBelow;
-extern QAction *actionEditRemoveBranchHere;
+extern QAction *actionEditRemoveBranchKeepChilds;
 extern QAction *actionEditRemoveChilds;
 extern QAction *actionEditImportAdd;
 extern QAction *actionEditImportReplace;
@@ -109,6 +109,7 @@
 extern QAction *actionFormatHideLinkUnselected;
 
 extern QAction *actionViewToggleNoteEditor;
+extern QAction *actionViewToggleHistoryWindow;
 
 extern QAction* actionSettingsAutoedit;
 extern QAction* actionSettingsAutoselectHeading;
@@ -628,10 +629,10 @@
 
 	// Only remove branch, not its childs
     a = new QAction( tr( "Remove only branch and keep its childs" ),tr( "Remove only branch " ), ALT + Key_Delete, this, "removeBranchHere" );
-    connect( a, SIGNAL( activated() ), this, SLOT( editRemoveBranchHere() ) );
+    connect( a, SIGNAL( activated() ), this, SLOT( editRemoveBranchKeepChilds() ) );
 	a->setEnabled (false);
 	actionListBranches.append(a);
-	actionEditRemoveBranchHere=a;
+	actionEditRemoveBranchKeepChilds=a;
 
 	// Only remove childs of a branch
     a = new QAction( tr( "Remove childs of branch" ),tr( "Remove childs" ), SHIFT + Key_Delete, this, "removeBranchChilds" );
@@ -787,6 +788,8 @@
     connect( a, SIGNAL( activated() ), this, SLOT( viewZoomOut() ) );
     a->addTo( tb );
     a->addTo( menu );
+
+
     a = new QAction( tr( "Toggle Note Editor" ), QPixmap(flagsPath+"flag-note.png"), tr( "Toggle Note Editor" ), CTRL + Key_E , this, "noteEditor" );
     connect( a, SIGNAL( activated() ), this, SLOT(windowToggleNoteEditor() ) );
 	a->setToggleAction(true);
@@ -797,6 +800,13 @@
     a->addTo( tb );
     a->addTo( menu );
 	actionViewToggleNoteEditor=a;
+
+    a = new QAction( tr( "Toggle history window" ), QPixmap(), tr( "Toggle history window" ), CTRL + Key_H , this, "historyWindow" );
+    connect( a, SIGNAL( activated() ), this, SLOT(windowToggleHistory() ) );
+	a->setToggleAction(false);
+    a->addTo( menu );
+	actionViewToggleHistoryWindow=a;
+
     a = new QAction( tr( "&Next Window" ), QPixmap(), tr( "Next Window" ), ALT + Key_N , this, "nextWindow" );
     connect( a, SIGNAL( activated() ), this, SLOT(windowNextEditor() ) );
     a->addTo( menu );
@@ -1132,7 +1142,7 @@
 		branchRemoveContextMenu =new QPopupMenu (this);
 		actionEditCut->addTo ( branchRemoveContextMenu );
 		actionEditDelete->addTo ( branchRemoveContextMenu );
-		actionEditRemoveBranchHere->addTo( branchRemoveContextMenu );
+		actionEditRemoveBranchKeepChilds->addTo( branchRemoveContextMenu );
 		actionEditRemoveChilds->addTo( branchRemoveContextMenu );
 		
 	branchContextMenu->insertItem (tr("Add"),branchAddContextMenu);	
@@ -2283,7 +2293,7 @@
 void Main::editToggleHideExport()
 {
 	if (currentMapEditor())
-		currentMapEditor()->setHideExport();	
+		currentMapEditor()->toggleHideExport();	
 }
 
 void Main::editMapInfo()
@@ -2365,10 +2375,10 @@
 	fileSaveAs (PartOfMap);
 }
 
-void Main::editRemoveBranchHere()
+void Main::editRemoveBranchKeepChilds()
 {
 	if (currentMapEditor())
-		currentMapEditor()->removeBranchHere();
+		currentMapEditor()->removeBranchKeepChilds();
 }
 
 void Main::editRemoveChilds()
@@ -2628,6 +2638,12 @@
 		windowShowNoteEditor();
 }
 
+void Main::windowToggleHistory()
+{
+	if (currentMapEditor())
+		currentMapEditor()->toggleHistoryWindow();
+}
+
 void Main::updateNoteFlag()
 {
 	if (currentMapEditor())
diff -r 68495946fe33 -r 3492af261af2 mainwindow.h
--- a/mainwindow.h	Tue Apr 11 14:34:14 2006 +0000
+++ b/mainwindow.h	Tue Apr 11 14:34:14 2006 +0000
@@ -115,7 +115,7 @@
     void editImportAdd();
     void editImportReplace();
     void editSaveBranch();
-    void editRemoveBranchHere();
+    void editRemoveBranchKeepChilds();
     void editRemoveChilds();
     void editDeleteSelection();
     void editUpperBranch();
@@ -159,6 +159,7 @@
 	bool settingsURL();
 
 	void windowToggleNoteEditor();
+	void windowToggleHistory();
 	void updateNoteFlag();
 
 private slots:
diff -r 68495946fe33 -r 3492af261af2 mapeditor.cpp
--- a/mapeditor.cpp	Tue Apr 11 14:34:14 2006 +0000
+++ b/mapeditor.cpp	Tue Apr 11 14:34:14 2006 +0000
@@ -159,7 +159,7 @@
     printer=NULL;
 
     lineedit = new QLineEdit(this, "lineedit"  );
-    connect( lineedit, SIGNAL( returnPressed() ), SLOT( finishedLineEditNoSave() ) );
+    connect( lineedit, SIGNAL( returnPressed() ), SLOT( finishedLineEdit() ) );
     lineedit->hide();
 
     actColor=black; setColor (actColor);
@@ -197,7 +197,7 @@
 	
 	zipped=true;
 	filePath="";
-	fileName="unnamed";
+	fileName=tr("unnamed");
 	mapName="";
 
 	undosTotal=settings.readNumEntry("/vym/mapeditor/undoLevels",50);
@@ -224,6 +224,10 @@
 	// Initially set movingCentre
 	updateViewCenter();
 
+	// For testing purposes create history window
+	historyWindow = new ShowTextDialog (this);
+	historyWindow->setCaption (fileName);
+
 	mapCenter->reposition();	//	for positioning heading
 }
 
@@ -327,6 +331,18 @@
 	return blockReposition;
 }
 
+QString MapEditor::getName (LinkableMapObj *lmo)
+{
+	if (!lmo) return QString("NULL has no name!");
+
+	if ((typeid(*lmo) == typeid(BranchObj) ||
+				      typeid(*lmo) == typeid(MapCenterObj))) 
+		return QString("branch (%1)").arg(((BranchObj*)lmo)->getHeading());
+	if ((typeid(*lmo) == typeid(FloatImageObj) ))
+		return QString ("floatimage [%1]").arg(((FloatImageObj*)lmo)->getOriginalFilename());
+	return QString("Unknown type has no name!");
+}
+
 void MapEditor::makeTmpDirs()
 {
 	// Create unique temporary directories
@@ -416,19 +432,19 @@
 	return s;
 }
 
-void MapEditor::saveState()
+void MapEditor::saveState(const QString &comment)
 {
 	// Save complete map
-	saveState (CompleteMap,"",NULL,"",NULL);
+	saveState (CompleteMap,"",NULL,"",NULL, comment);
 }
 
-void MapEditor::saveState(LinkableMapObj *undoSel)
+void MapEditor::saveState(LinkableMapObj *undoSel, const QString &comment)
 {
 	// save the given part of the map 
-	saveState (PartOfMap,"",undoSel,"",NULL);
+	saveState (PartOfMap,"",undoSel,"",NULL, comment);
 }
 
-void MapEditor::saveState(const QString &uc, const QString &rc)
+void MapEditor::saveState(const QString &uc, const QString &rc, const QString &comment)
 {
 	// selection does not change during action,
 	// so just save commands for undo and redo
@@ -437,15 +453,15 @@
 		unsel=selection;
 	else
 		unsel=NULL;
-	saveState (UndoCommand,uc,unsel,rc,unsel);
+	saveState (UndoCommand,uc,unsel,rc,unsel, comment);
 }
 
-void MapEditor::saveState(const QString & uncom, LinkableMapObj *unsel) 
+void MapEditor::saveState(const QString & uncom, LinkableMapObj *unsel, const QString &comment) 
 {
-	saveState (UndoCommand,uncom,unsel,"FIXME-redoCom",NULL);
+	saveState (UndoCommand,uncom,unsel,"FIXME-redoCom",NULL, comment);
 }
 
-void MapEditor::saveState(const SaveMode &savemode, const QString &undoCom, LinkableMapObj *undoSel, const QString &redoCom, LinkableMapObj *redoSel)
+void MapEditor::saveState(const SaveMode &savemode, const QString &undoCom, LinkableMapObj *undoSel, const QString &redoCom, LinkableMapObj *redoSel, const QString &comment)
 {
 	// Main saveState
 
@@ -458,6 +474,9 @@
 	cout << "       undoNum="<<undoNum<<endl;
 	cout << "    ---------------------------"<<endl;
 	*/
+
+	historyWindow->append (comment);
+	
 	setChanged();
 
 	// Find out current undo directory
@@ -510,6 +529,7 @@
 	set.setEntry (QString("undoSelection"),undoSelection);
 	set.setEntry (QString("redoCommand"),redoCom);
 	set.setEntry (QString("redoSelection"),redoSelection);
+	set.setEntry (QString("comment"),comment);
 	set.writeSettings(QString(bakMapDir+"/commands"));
 
 	/* TODO remove after testing
@@ -517,6 +537,8 @@
 	cout << "    undosAvail="<<undosAvail<<endl;
 	cout << "       undoNum="<<undoNum<<endl;
 	cout << "    ---------------------------"<<endl;
+	cout << "    comment="<<comment<<endl;
+	cout << "    ---------------------------"<<endl;
 	cout << "    undoCom="<<undoCommand<<endl;
 	cout << "    undoSel="<<undoSelection<<endl;
 	cout << "    ---------------------------"<<endl;
@@ -640,7 +662,7 @@
 }
 
 
-void MapEditor::finishedLineEditNoSave()
+void MapEditor::finishedLineEdit()
 {
 	// This is called by finishedLineEdit or any MapEditor method,
 	// which wants to assure, that lineedits finish, before e.g. a branch is 
@@ -652,6 +674,7 @@
 
     if (editingBO!=NULL) 
 	{
+		saveState("setHeading (\""+editingBO->getHeading()+"\")",editingBO, QString("Set heading of %1 to \"%2\"").arg(getName(editingBO)).arg(lineedit->text()) );
 		editingBO->setHeading(lineedit->text() );
 		editingBO=NULL;
 		lineedit->releaseKeyboard();
@@ -663,6 +686,14 @@
     }		
 }
 
+void MapEditor::toggleHistoryWindow()
+{
+	if (historyWindow->isVisible())
+		historyWindow->hide();
+	else	
+		historyWindow->show();
+}
+
 
 bool MapEditor::isDefault()
 {
@@ -692,7 +723,7 @@
 void MapEditor::closeMap()
 {
 	// Finish open lineEdits
-	if (lineedit) finishedLineEditNoSave();
+	if (lineedit) finishedLineEdit();
 
 	// Unselect before disabling the toolbar actions
 	if (selection) selection->unselect();
@@ -731,6 +762,9 @@
 
 		// Forget the .vym (or .xml) for name of map
 		mapName=fileName.left(fileName.findRev(".",-1,true) );
+
+		// Adjust history window
+		historyWindow->setCaption (fileName);
 	}
 }
 
@@ -757,7 +791,7 @@
 ErrorCode MapEditor::load (QString fname, LoadMode lmode)
 {
 	// Finish open lineEdits
-	if (lineedit) finishedLineEditNoSave();
+	if (lineedit) finishedLineEdit();
 
 	ErrorCode err=success;
 
@@ -770,7 +804,7 @@
 		// (map state is set later at end of load...)
 	} else
 	{
-		saveState(selection);
+		saveState(selection,"Load map");
 	}	
 	
     
@@ -826,7 +860,7 @@
 int MapEditor::save (const SaveMode &savemode)
 {
 	// Finish open lineEdits
-	if (lineedit) finishedLineEditNoSave();
+	if (lineedit) finishedLineEdit();
 
 	int returnCode=0;
 
@@ -876,7 +910,7 @@
 void MapEditor::print()
 {
 	// Finish open lineEdits
-	if (lineedit) finishedLineEditNoSave();
+	if (lineedit) finishedLineEdit();
 
 	if ( !printer ) 
 	{
@@ -1052,7 +1086,7 @@
 void MapEditor::exportImage(QString fn)
 {
 	// Finish open lineEdits
-	if (lineedit) finishedLineEditNoSave();
+	if (lineedit) finishedLineEdit();
 
 	setExportMode (true);
 	QPixmap pix (getPixmap());
@@ -1073,7 +1107,7 @@
 void MapEditor::exportImage(QString fn, int item)
 {
 	// Finish open lineEdits
-	if (lineedit) finishedLineEditNoSave();
+	if (lineedit) finishedLineEdit();
 
 	setExportMode (true);
 	QPixmap pix (getPixmap());
@@ -1142,7 +1176,7 @@
 void MapEditor::copy()
 {
 	// Finish open lineEdits
-	if (lineedit) finishedLineEditNoSave();
+	if (lineedit) finishedLineEdit();
 
 	if (selection) 
 	{
@@ -1173,7 +1207,7 @@
 void MapEditor::redo()
 {
 	// Finish open lineEdits
-	if (lineedit) finishedLineEditNoSave();
+	if (lineedit) finishedLineEdit();
 
 	blockSaveState=true;
 	
@@ -1234,7 +1268,7 @@
 void MapEditor::undo()
 {
 	// Finish open lineEdits
-	if (lineedit) finishedLineEditNoSave();
+	if (lineedit) finishedLineEdit();
 
 	blockSaveState=true;
 	
@@ -1341,7 +1375,7 @@
 void MapEditor::pasteNoSave()
 {
 	// Finish open lineEdits
-	if (lineedit) finishedLineEditNoSave();
+	if (lineedit) finishedLineEdit();
 
 	load (clipboardDir+"/part.xml",ImportAdd);
 }
@@ -1357,7 +1391,7 @@
 	if (selection && (typeid(*selection) == typeid(BranchObj) ||
 				      typeid(*selection) == typeid(MapCenterObj))) 
 	{
-		saveState(selection);
+		saveState(selection,QString("Paste to %1").arg( getName(selection)));
 		pasteNoSave();
 		mapCenter->reposition();
 		adjustCanvasSize();
@@ -1366,7 +1400,7 @@
 
 void MapEditor::cut()
 {
-	saveState(selection->getParObj());
+	saveState(selection->getParObj(),QString("Cut %1").arg(getName(selection)));
 	copy();
 	cutNoSave();
 	mapCenter->reposition();
@@ -1384,7 +1418,7 @@
 void MapEditor::moveBranchUp()
 {
 	// Finish open lineEdits
-	if (lineedit) finishedLineEditNoSave();
+	if (lineedit) finishedLineEdit();
 
 	BranchObj* bo;
 	BranchObj* par;
@@ -1395,7 +1429,7 @@
 		selection->unselect();
 		selection=par->moveBranchUp (bo);
 		selection->select();
-		saveState("moveBranchDown ()",bo);
+		saveState("moveBranchDown ()",bo,QString("Move up %1").arg(getName(bo)));
 		mapCenter->reposition();
 		ensureSelectionVisible();
 	}
@@ -1404,7 +1438,7 @@
 void MapEditor::moveBranchDown()
 {
 	// Finish open lineEdits
-	if (lineedit) finishedLineEditNoSave();
+	if (lineedit) finishedLineEdit();
 
 	BranchObj* bo;
 	BranchObj* par;
@@ -1415,7 +1449,7 @@
 		selection->unselect(); 
 		selection=par->moveBranchDown(bo);
 		selection->select();
-		saveState("moveBranchUp ()",bo);
+		saveState("moveBranchUp ()",bo,QString("Move down %1").arg(getName(bo)));
 		mapCenter->reposition();
 		ensureSelectionVisible();
 	}	
@@ -1424,14 +1458,13 @@
 void MapEditor::editHeading()
 {
 	// Finish open lineEdits
-	if (lineedit) finishedLineEditNoSave();
+	if (lineedit) finishedLineEdit();
 
 	if (selection  &&  
 		 (typeid(*selection) == typeid(BranchObj) || 
 		  typeid(*selection) == typeid(MapCenterObj) ) ) 
 	{
 		editingBO=(BranchObj*)selection;
-		saveState("setHeading (\""+((BranchObj*)selection)->getHeading()+"\")",editingBO );
 
 		ensureSelectionVisible();
 		QPoint p = worldMatrix().map(QPoint (editingBO->x(),editingBO->y()));
@@ -1492,15 +1525,15 @@
 void MapEditor::addNewBranch(int pos)
 {
 	// Finish open lineEdits
-	if (lineedit) finishedLineEditNoSave();
+	if (lineedit) finishedLineEdit();
 
 	if (selection  &&  
 		 (typeid(*selection) == typeid(BranchObj) || 
 		  typeid(*selection) == typeid(MapCenterObj) ) ) 
 	{
-		saveState(selection);	//TODO undoCommand
-
 		BranchObj* bo1 = (BranchObj*) selection;
+		saveState(selection, QString("Add new branch to %1").arg(getName(bo1)));	//TODO undoCommand
+
 		bool wasScrolled=false;
 		BranchObj *newbo=NULL;
 		if (pos==0)
@@ -1558,14 +1591,14 @@
 void MapEditor::addNewBranchHere()
 {
 	// Finish open lineEdits
-	if (lineedit) finishedLineEditNoSave();
+	if (lineedit) finishedLineEdit();
 
 	if (selection  &&  
 		 (typeid(*selection) == typeid(BranchObj) ) )
 	{
-		saveState(selection);
-
 		BranchObj* bo1 = (BranchObj*) selection;
+		saveState(selection, QString("Add new branch here").arg(getName(bo1)));
+
 		bool wasScrolled=false;
 		BranchObj *newbo=NULL;
 		BranchObj *parbo=(BranchObj*)(selection->getParObj());
@@ -1607,21 +1640,21 @@
 void MapEditor::deleteSelection()
 {
 	// Finish open lineEdits
-	if (lineedit) finishedLineEditNoSave();
+	if (lineedit) finishedLineEdit();
 
 	if (selection  && typeid(*selection) ==typeid(BranchObj) ) 
 	{
+		BranchObj* bo=dynamic_cast <BranchObj*> (selection);
+		BranchObj* par=(BranchObj*)(bo->getParObj());
+		bo->unselect();
 		if (selection->getDepth()>1)
 			// Normal branch, save parent with childs
-			saveState(selection->getParObj());
+			saveState(par,QString("Delete %1").arg(getName(bo)));
 		else
 			// Mainbranch, save whole map
 			// TODO Better would be to insert mainbranch again at pos
 			// But undoCommand is missing right now
-			saveState();
-		BranchObj* bo=dynamic_cast <BranchObj*> (selection);
-		BranchObj* par=(BranchObj*)(bo->getParObj());
-		bo->unselect();
+			saveState(QString("Delete %1").arg(getName(bo)));
 		selection=NULL;
 		par->removeBranch(bo);
 		selection=par;
@@ -1632,9 +1665,9 @@
 	}
 	if (selection  && typeid(*selection) ==typeid(FloatImageObj) ) 
 	{
-		saveState(selection->getParObj());
 		FloatImageObj* fio=dynamic_cast <FloatImageObj*> (selection);
 		BranchObj* par=(BranchObj*)(fio->getParObj());
+		saveState(par, QString("Delete %1").arg(getName(fio)));
 		fio->unselect();
 		selection=NULL;
 		par->removeFloatImage(fio);
@@ -1864,7 +1897,7 @@
 void MapEditor::selectUpperBranch()
 {
 	// Finish open lineEdits
-	if (lineedit) finishedLineEditNoSave();
+	if (lineedit) finishedLineEdit();
 
 	if (selection) 
 	{
@@ -1884,7 +1917,7 @@
 void MapEditor::selectLowerBranch()
 {
 	// Finish open lineEdits
-	if (lineedit) finishedLineEditNoSave();
+	if (lineedit) finishedLineEdit();
 
 	if (selection) 
 	{
@@ -1905,7 +1938,7 @@
 void MapEditor::selectLeftBranch()
 {
 	// Finish open lineEdits
-	if (lineedit) finishedLineEditNoSave();
+	if (lineedit) finishedLineEdit();
 
 	BranchObj* bo;
 	BranchObj* par;
@@ -1967,7 +2000,7 @@
 void MapEditor::selectRightBranch()
 {
 	// Finish open lineEdits
-	if (lineedit) finishedLineEditNoSave();
+	if (lineedit) finishedLineEdit();
 
 	BranchObj* bo;
 	BranchObj* par;
@@ -2027,7 +2060,7 @@
 void MapEditor::selectFirstBranch()
 {
 	// Finish open lineEdits
-	if (lineedit) finishedLineEditNoSave();
+	if (lineedit) finishedLineEdit();
 
 	BranchObj *bo1;
 	BranchObj *bo2;
@@ -2052,7 +2085,7 @@
 void MapEditor::selectLastBranch()
 {
 	// Finish open lineEdits
-	if (lineedit) finishedLineEditNoSave();
+	if (lineedit) finishedLineEdit();
 
 	BranchObj *bo1;
 	BranchObj *bo2;
@@ -2082,12 +2115,12 @@
 void MapEditor::selectBackgroundColor()
 {
 	// Finish open lineEdits
-	if (lineedit) finishedLineEditNoSave();
+	if (lineedit) finishedLineEdit();
 
 	QColor col = QColorDialog::getColor( mapCanvas->backgroundColor(), this );
 	if ( !col.isValid() ) return;
 	setBackgroundColor( col );
-	saveState();
+	saveState(QString("Set background color of map to %1").arg(col.name()));
 }
 
 void MapEditor::setBackgroundColor(QColor c)
@@ -2116,8 +2149,8 @@
 		if (typeid(*selection) == typeid(BranchObj) ||
 			typeid(*selection) == typeid(MapCenterObj))
 		{
-			saveState(selection);	//TODO undoCommand
 			BranchObj *bo=(BranchObj*)selection;
+			saveState(selection, QString("Set color of %1 to %2").arg(getName(bo)).arg(actColor.name()));	//TODO undoCommand
 			bo->setColor(actColor); // color branch
 		}    
 	}
@@ -2130,8 +2163,8 @@
 		if (typeid(*selection) == typeid(BranchObj) ||
 			typeid(*selection) == typeid(MapCenterObj))
 		{
-			saveState(selection);	//TODO undoCommand
 			BranchObj *bo=(BranchObj*)selection;
+			saveState(selection, QString ("Set color of %1 and childs to %2").arg(getName(bo)).arg(actColor.name()));	//TODO undoCommand
 			bo->setColorChilds(actColor); // color links, color childs
 		}    
 	}
@@ -2142,8 +2175,14 @@
 {
 	if (selection)
 	{
-		saveState(selection);// TODO undoCommand	
-		((BranchObj*)selection)->toggleStandardFlag (f,actionSettingsUseFlagGroups);
+		BranchObj *bo=(BranchObj*)selection;
+		QString s;
+		if (bo->isSetStandardFlag(f))
+			s="Unset";
+		else
+			s="Set";
+		saveState(selection, QString("%1 standard flag \"%2\" of %3").arg(s).arg(f).arg(getName(bo)));// TODO undoCommand	
+		bo->toggleStandardFlag (f,actionSettingsUseFlagGroups);
 		adjustCanvasSize();
 	}	
 }
@@ -2232,7 +2271,7 @@
 		if ( ok) 
 		{
 			// user entered something and pressed OK
-			saveState("setURL (\""+bo->getURL()+"\")","setURL (\""+text+"\")");	
+			saveState("setURL (\""+bo->getURL()+"\")","setURL (\""+text+"\")", QString("Set URL of %1 to %21").arg(getName(bo)).arg(text));	
 			bo->setURL (text);
 			updateActions();
 		}	
@@ -2254,7 +2293,7 @@
 			typeid(*selection) == typeid(MapCenterObj)) )
 	{		
 		BranchObj *bo=(BranchObj*)selection;
-		saveState("setURL (\""+bo->getURL()+"\")","setURL (\""+bo->getHeading()+"\")");	
+		saveState("setURL (\""+bo->getURL()+"\")","setURL (\""+bo->getHeading()+"\")",QString("Copy heading of %1 to URL").arg(getName(bo)));	
 		bo->setURL (bo->getHeading());
 		updateActions();
 	}
@@ -2267,7 +2306,7 @@
 	{		
 		BranchObj *bo=(BranchObj*)selection;
 		QString url= "https://bugzilla.novell.com/show_bug.cgi?id="+bo->getHeading();
-		saveState("setURL (\""+bo->getURL()+"\")","setURL (\""+url+"\")");	
+		saveState("setURL (\""+bo->getURL()+"\")","setURL (\""+url+"\")",QString("Use heading of %1 as link to Bugzilla").arg(getName(bo)));	
 		bo->setURL (url);
 		updateActions();
 	}
@@ -2280,7 +2319,7 @@
 	{		
 		BranchObj *bo=(BranchObj*)selection;
 		QString url= "http://keeper.suse.de:8080/webfate/match/id?value=ID"+bo->getHeading();
-		saveState("setURL (\""+bo->getURL()+"\")","setURL (\""+url+"\")");	
+		saveState("setURL (\""+bo->getURL()+"\")","setURL (\""+url+"\")",QString("Use heading of %1 as link to FATE").arg(getName(bo)));	
 		bo->setURL (url);
 		updateActions();
 	}
@@ -2302,7 +2341,7 @@
 		QString fn;
 		if ( fd->exec() == QDialog::Accepted )
 		{
-			saveState("setVymLink (\""+bo->getVymLink()+"\")","setVymLink (\""+fd->selectedFile()+"\")");	
+			saveState("setVymLink (\""+bo->getVymLink()+"\")","setVymLink (\""+fd->selectedFile()+"\")",QString("Set vymlink of %1 to %2").arg(getName(bo)).arg(fd->selectedFile()));	
 			bo->setVymLink (fd->selectedFile() );
 			updateActions();
 			mapCenter->reposition();
@@ -2318,7 +2357,7 @@
 			typeid(*selection) == typeid(MapCenterObj)) )
 	{		
 		BranchObj *bo=(BranchObj*)selection;
-		saveState("setVymLink (\""+bo->getVymLink()+"\")","setVymLink (\"\")");	
+		saveState("setVymLink (\""+bo->getVymLink()+"\")","setVymLink (\"\")",QString("Unset vymlink of %1").arg(getName(bo)));	
 		bo->setVymLink ("" );
 		updateActions();
 		mapCenter->reposition();
@@ -2327,23 +2366,6 @@
 	}
 }
 
-void MapEditor::setHideExport()
-{
-	if (selection && (typeid(*selection) == typeid(BranchObj) ||
-			typeid(*selection) == typeid(MapCenterObj)) ||
-			(typeid(*selection)==typeid(FloatImageObj))
-			)
-	{		
-		saveState();	//TODO undoCommand
-		OrnamentedObj *oo=(OrnamentedObj*)selection;
-		oo->setHideInExport(actionEditToggleHideExport->isOn());
-		updateActions();
-		mapCenter->reposition();
-		adjustCanvasSize();
-		canvas()->update();
-	}
-}
-
 void MapEditor::toggleHideExport()
 {
 	if (selection && (typeid(*selection) == typeid(BranchObj) ||
@@ -2351,12 +2373,19 @@
 			(typeid(*selection)==typeid(FloatImageObj))
 			)
 	{		
-		saveState();	//TODO undoCommand
 		OrnamentedObj *oo=(OrnamentedObj*)selection;
+		QString s;
 		if (oo->hideInExport())
+		{
 			oo->setHideInExport(false);
+			s="Unset";
+		}	
 		else	
+		{
 			oo->setHideInExport(true);
+			s="Set";
+		}	
+		saveState(QString ("%1 hide export flag of %2").arg(s).arg(getName(selection)));	//TODO undoCommand
 		actionEditToggleHideExport->setOn (oo->hideInExport());	
 		updateActions();
 		mapCenter->reposition();
@@ -2376,16 +2405,17 @@
 	
 }
 
-void MapEditor::removeBranchHere()
+void MapEditor::removeBranchKeepChilds()
 {
 	if (selection && (typeid(*selection) == typeid(BranchObj) ))
 	{		
 		BranchObj* bo=(BranchObj*)selection;
 		BranchObj* par=(BranchObj*)(bo->getParObj());
+		QString s=QString("Remove %1 and keep its childs").arg(getName(bo));
 		if (bo->getDepth()==1)
-			saveState();
+			saveState(s);
 		else	
-			saveState(selection->getParObj());	// TODO undoCommand
+			saveState(selection->getParObj(),s);	// TODO undoCommand
 		QString sel=selection->getSelectString();
 		unselect();
 		par->removeBranchHere(bo);
@@ -2398,7 +2428,7 @@
 {
 	if (selection && (typeid(*selection) == typeid(BranchObj) ))
 	{		
-		saveState(selection->getParObj());
+		saveState(selection->getParObj(), QString("Remove childs of branch").arg(getName(selection)));
 		((BranchObj*)selection)->removeChilds();
 		mapCenter->reposition();
 	}	
@@ -2442,7 +2472,7 @@
 	// Finally show dialog
 	if (dia.exec() == QDialog::Accepted)
 	{
-		saveState();	//TODO undoCommand
+		saveState("Edit info about map");	//TODO undoCommand
 		mapCenter->setAuthor (dia.getAuthor() );
 		mapCenter->setComment (dia.getComment() );
 	}
@@ -2627,7 +2657,7 @@
 {
 	linkstyle=ls;
 
-	saveState();	// TODO undoCommand
+	saveState("Set link style");	// TODO undoCommand
 	BranchObj *bo;
 	bo=mapCenter->first();
 	bo=bo->next();
@@ -2716,12 +2746,12 @@
 void MapEditor::selectLinkColor()
 {
 	// Finish open lineEdits
-	if (lineedit) finishedLineEditNoSave();
+	if (lineedit) finishedLineEdit();
 
 	QColor col = QColorDialog::getColor( defLinkColor, this );
 	if ( !col.isValid() ) return;
 	setLinkColor( col );
-	saveState();	//TODO undoCommand
+	saveState(QString("Set link color to %1").arg(col.name()));	//TODO undoCommand
 
 }
 
@@ -2732,7 +2762,12 @@
 		BranchObj *bo=((BranchObj*)selection);
 		if (bo->countBranches()==0) return;
 		if (bo->getDepth()==0) return;
-		saveState(selection);
+		QString s;
+		if (bo->isScrolled())
+			s="Unscroll";
+		else	
+			s="Scroll";
+		saveState(selection, QString ("%1 %2").arg(s).arg(getName(bo)));
 		bo->toggleScroll();
 		adjustCanvasSize();
 		canvas()->update();
@@ -2772,7 +2807,7 @@
 		QString fn;
 		if ( fd->exec() == QDialog::Accepted )
 		{
-			saveState(selection);
+			saveState(selection, QString("Add floatimage to %1").arg(getName(selection)));
 			lastImageDir=fn.left(fn.findRev ("/"));
 			QStringList flist = fd->selectedFiles();
 			QStringList::Iterator it = flist.begin();
@@ -3002,7 +3037,7 @@
 				}
 				if (dia.deleteXLink())
 					((BranchObj*)selection)->deleteXLinkAt(i);
-				saveState();	//TODO undoCommand
+				saveState("Edit xLink");	//TODO undoCommand
 			}
 		}	
 	}
@@ -3108,7 +3143,7 @@
 void MapEditor::contentsMousePressEvent(QMouseEvent* e)
 {
 	// Finish open lineEdits
-	if (lineedit) finishedLineEditNoSave();
+	if (lineedit) finishedLineEdit();
 	
     QPoint p = inverseWorldMatrix().map(e->pos());
     LinkableMapObj* lmo=mapCenter->findMapObj(p, NULL);
@@ -3253,7 +3288,9 @@
 		if (typeid(*selection) == typeid(FloatImageObj))
 		{
 			FloatObj *fo=(FloatObj*)selection;
-			saveState("move "+qpointToString(movingObj_orgPos),fo->getSelectString() );
+			saveState(
+				"move "+qpointToString(movingObj_orgPos),fo->getSelectString() ,
+				QString("Move %1").arg(getName(selection)));
 			fo->move   (p.x() -movingObj_start.x(), p.y()-movingObj_start.y() );		
 			fo->setRelPos();
 			fo->reposition();
@@ -3268,7 +3305,7 @@
 			{
 				if (typeid(*fo) == typeid(FloatImageObj)) 
 				{
-					saveState();
+					saveState(QString("Relink %1 to %2").arg(getName(fo)).arg(getName(lmo) ) );
 					FloatImageObj *fio=(FloatImageObj*)(fo);
 					((BranchObj*)(lmo))->addFloatImage (fio);
 					fio->unselect();
@@ -3402,7 +3439,7 @@
 			tmpXLink->setEnd ( ((BranchObj*)(dst)) );
 			tmpXLink->updateXLink();
 			tmpXLink->activate();
-			saveState();	//TODO undoCommand
+			saveState(QString("Activate xLink from %1 to %2").arg(getName(tmpXLink->getBegin())).arg(getName(tmpXLink->getEnd())) );	//TODO undoCommand
 		} else
 		{
 			delete(tmpXLink);
@@ -3468,11 +3505,11 @@
 					if (dst->getDepth()==0) 
 						bs->move (savePos);
 				} 
-				saveState (undoCom,bs->getSelectString() );
+				saveState (undoCom,bs->getSelectString(),QString("Relink %1 to %2").arg(getName(bs)).arg(getName(dst)) );
 			} else
 				if (selection->getDepth()==1)
 					// If we have moved mainbranch only save endposition
-					saveState("move "+qpointToString(movingObj_orgPos), selection->getSelectString() );
+					saveState("move "+qpointToString(movingObj_orgPos), selection->getSelectString(), QString("Move %1 to %2").arg(getName(selection)).arg(qpointToString(movingObj_orgPos)));
 			
 			// Draw the original link, before selection was moved around
 			mapCenter->reposition();
@@ -3490,7 +3527,7 @@
 void MapEditor::contentsMouseDoubleClickEvent(QMouseEvent* e)
 {
 	// Finish open lineEdits
-	if (lineedit) finishedLineEditNoSave();
+	if (lineedit) finishedLineEdit();
 	
 	if (e->button() == QMouseEvent::LeftButton )
 	{
@@ -3501,7 +3538,6 @@
 			if (selection) selection->unselect();
 			selection=lmo;
 			selection->select();
-			saveState(selection);
 			editHeading();
 		}
 	}
@@ -3670,7 +3706,8 @@
 
 		if (update) 
 		{
-			saveState();	//TODO undo Command
+			//FIXME saveState has to be called earlier for each of the drops...
+			saveState("Drop Event");	//TODO undo Command
 			mapCenter->reposition();
 			adjustCanvasSize();
 			canvas()->update();
@@ -3685,7 +3722,7 @@
       (typeid(*selection) == typeid(MapCenterObj))  )
   {
     BranchObj *bo=((BranchObj*)selection);
-    saveState(selection);
+    saveState(selection,QString("Add floatimage to %1").arg(getName(bo)));
     //QString fn=fd->selectedFile();
     //lastImageDir=fn.left(fn.findRev ("/"));
     bo->addFloatImage();