mapeditor.cpp
changeset 294 3492af261af2
parent 269 4c3e9fa0093b
child 301 4258723b534c
     1.1 --- a/mapeditor.cpp	Tue Apr 11 14:34:14 2006 +0000
     1.2 +++ b/mapeditor.cpp	Tue Apr 11 14:34:14 2006 +0000
     1.3 @@ -159,7 +159,7 @@
     1.4      printer=NULL;
     1.5  
     1.6      lineedit = new QLineEdit(this, "lineedit"  );
     1.7 -    connect( lineedit, SIGNAL( returnPressed() ), SLOT( finishedLineEditNoSave() ) );
     1.8 +    connect( lineedit, SIGNAL( returnPressed() ), SLOT( finishedLineEdit() ) );
     1.9      lineedit->hide();
    1.10  
    1.11      actColor=black; setColor (actColor);
    1.12 @@ -197,7 +197,7 @@
    1.13  	
    1.14  	zipped=true;
    1.15  	filePath="";
    1.16 -	fileName="unnamed";
    1.17 +	fileName=tr("unnamed");
    1.18  	mapName="";
    1.19  
    1.20  	undosTotal=settings.readNumEntry("/vym/mapeditor/undoLevels",50);
    1.21 @@ -224,6 +224,10 @@
    1.22  	// Initially set movingCentre
    1.23  	updateViewCenter();
    1.24  
    1.25 +	// For testing purposes create history window
    1.26 +	historyWindow = new ShowTextDialog (this);
    1.27 +	historyWindow->setCaption (fileName);
    1.28 +
    1.29  	mapCenter->reposition();	//	for positioning heading
    1.30  }
    1.31  
    1.32 @@ -327,6 +331,18 @@
    1.33  	return blockReposition;
    1.34  }
    1.35  
    1.36 +QString MapEditor::getName (LinkableMapObj *lmo)
    1.37 +{
    1.38 +	if (!lmo) return QString("NULL has no name!");
    1.39 +
    1.40 +	if ((typeid(*lmo) == typeid(BranchObj) ||
    1.41 +				      typeid(*lmo) == typeid(MapCenterObj))) 
    1.42 +		return QString("branch (%1)").arg(((BranchObj*)lmo)->getHeading());
    1.43 +	if ((typeid(*lmo) == typeid(FloatImageObj) ))
    1.44 +		return QString ("floatimage [%1]").arg(((FloatImageObj*)lmo)->getOriginalFilename());
    1.45 +	return QString("Unknown type has no name!");
    1.46 +}
    1.47 +
    1.48  void MapEditor::makeTmpDirs()
    1.49  {
    1.50  	// Create unique temporary directories
    1.51 @@ -416,19 +432,19 @@
    1.52  	return s;
    1.53  }
    1.54  
    1.55 -void MapEditor::saveState()
    1.56 +void MapEditor::saveState(const QString &comment)
    1.57  {
    1.58  	// Save complete map
    1.59 -	saveState (CompleteMap,"",NULL,"",NULL);
    1.60 +	saveState (CompleteMap,"",NULL,"",NULL, comment);
    1.61  }
    1.62  
    1.63 -void MapEditor::saveState(LinkableMapObj *undoSel)
    1.64 +void MapEditor::saveState(LinkableMapObj *undoSel, const QString &comment)
    1.65  {
    1.66  	// save the given part of the map 
    1.67 -	saveState (PartOfMap,"",undoSel,"",NULL);
    1.68 +	saveState (PartOfMap,"",undoSel,"",NULL, comment);
    1.69  }
    1.70  
    1.71 -void MapEditor::saveState(const QString &uc, const QString &rc)
    1.72 +void MapEditor::saveState(const QString &uc, const QString &rc, const QString &comment)
    1.73  {
    1.74  	// selection does not change during action,
    1.75  	// so just save commands for undo and redo
    1.76 @@ -437,15 +453,15 @@
    1.77  		unsel=selection;
    1.78  	else
    1.79  		unsel=NULL;
    1.80 -	saveState (UndoCommand,uc,unsel,rc,unsel);
    1.81 +	saveState (UndoCommand,uc,unsel,rc,unsel, comment);
    1.82  }
    1.83  
    1.84 -void MapEditor::saveState(const QString & uncom, LinkableMapObj *unsel) 
    1.85 +void MapEditor::saveState(const QString & uncom, LinkableMapObj *unsel, const QString &comment) 
    1.86  {
    1.87 -	saveState (UndoCommand,uncom,unsel,"FIXME-redoCom",NULL);
    1.88 +	saveState (UndoCommand,uncom,unsel,"FIXME-redoCom",NULL, comment);
    1.89  }
    1.90  
    1.91 -void MapEditor::saveState(const SaveMode &savemode, const QString &undoCom, LinkableMapObj *undoSel, const QString &redoCom, LinkableMapObj *redoSel)
    1.92 +void MapEditor::saveState(const SaveMode &savemode, const QString &undoCom, LinkableMapObj *undoSel, const QString &redoCom, LinkableMapObj *redoSel, const QString &comment)
    1.93  {
    1.94  	// Main saveState
    1.95  
    1.96 @@ -458,6 +474,9 @@
    1.97  	cout << "       undoNum="<<undoNum<<endl;
    1.98  	cout << "    ---------------------------"<<endl;
    1.99  	*/
   1.100 +
   1.101 +	historyWindow->append (comment);
   1.102 +	
   1.103  	setChanged();
   1.104  
   1.105  	// Find out current undo directory
   1.106 @@ -510,6 +529,7 @@
   1.107  	set.setEntry (QString("undoSelection"),undoSelection);
   1.108  	set.setEntry (QString("redoCommand"),redoCom);
   1.109  	set.setEntry (QString("redoSelection"),redoSelection);
   1.110 +	set.setEntry (QString("comment"),comment);
   1.111  	set.writeSettings(QString(bakMapDir+"/commands"));
   1.112  
   1.113  	/* TODO remove after testing
   1.114 @@ -517,6 +537,8 @@
   1.115  	cout << "    undosAvail="<<undosAvail<<endl;
   1.116  	cout << "       undoNum="<<undoNum<<endl;
   1.117  	cout << "    ---------------------------"<<endl;
   1.118 +	cout << "    comment="<<comment<<endl;
   1.119 +	cout << "    ---------------------------"<<endl;
   1.120  	cout << "    undoCom="<<undoCommand<<endl;
   1.121  	cout << "    undoSel="<<undoSelection<<endl;
   1.122  	cout << "    ---------------------------"<<endl;
   1.123 @@ -640,7 +662,7 @@
   1.124  }
   1.125  
   1.126  
   1.127 -void MapEditor::finishedLineEditNoSave()
   1.128 +void MapEditor::finishedLineEdit()
   1.129  {
   1.130  	// This is called by finishedLineEdit or any MapEditor method,
   1.131  	// which wants to assure, that lineedits finish, before e.g. a branch is 
   1.132 @@ -652,6 +674,7 @@
   1.133  
   1.134      if (editingBO!=NULL) 
   1.135  	{
   1.136 +		saveState("setHeading (\""+editingBO->getHeading()+"\")",editingBO, QString("Set heading of %1 to \"%2\"").arg(getName(editingBO)).arg(lineedit->text()) );
   1.137  		editingBO->setHeading(lineedit->text() );
   1.138  		editingBO=NULL;
   1.139  		lineedit->releaseKeyboard();
   1.140 @@ -663,6 +686,14 @@
   1.141      }		
   1.142  }
   1.143  
   1.144 +void MapEditor::toggleHistoryWindow()
   1.145 +{
   1.146 +	if (historyWindow->isVisible())
   1.147 +		historyWindow->hide();
   1.148 +	else	
   1.149 +		historyWindow->show();
   1.150 +}
   1.151 +
   1.152  
   1.153  bool MapEditor::isDefault()
   1.154  {
   1.155 @@ -692,7 +723,7 @@
   1.156  void MapEditor::closeMap()
   1.157  {
   1.158  	// Finish open lineEdits
   1.159 -	if (lineedit) finishedLineEditNoSave();
   1.160 +	if (lineedit) finishedLineEdit();
   1.161  
   1.162  	// Unselect before disabling the toolbar actions
   1.163  	if (selection) selection->unselect();
   1.164 @@ -731,6 +762,9 @@
   1.165  
   1.166  		// Forget the .vym (or .xml) for name of map
   1.167  		mapName=fileName.left(fileName.findRev(".",-1,true) );
   1.168 +
   1.169 +		// Adjust history window
   1.170 +		historyWindow->setCaption (fileName);
   1.171  	}
   1.172  }
   1.173  
   1.174 @@ -757,7 +791,7 @@
   1.175  ErrorCode MapEditor::load (QString fname, LoadMode lmode)
   1.176  {
   1.177  	// Finish open lineEdits
   1.178 -	if (lineedit) finishedLineEditNoSave();
   1.179 +	if (lineedit) finishedLineEdit();
   1.180  
   1.181  	ErrorCode err=success;
   1.182  
   1.183 @@ -770,7 +804,7 @@
   1.184  		// (map state is set later at end of load...)
   1.185  	} else
   1.186  	{
   1.187 -		saveState(selection);
   1.188 +		saveState(selection,"Load map");
   1.189  	}	
   1.190  	
   1.191      
   1.192 @@ -826,7 +860,7 @@
   1.193  int MapEditor::save (const SaveMode &savemode)
   1.194  {
   1.195  	// Finish open lineEdits
   1.196 -	if (lineedit) finishedLineEditNoSave();
   1.197 +	if (lineedit) finishedLineEdit();
   1.198  
   1.199  	int returnCode=0;
   1.200  
   1.201 @@ -876,7 +910,7 @@
   1.202  void MapEditor::print()
   1.203  {
   1.204  	// Finish open lineEdits
   1.205 -	if (lineedit) finishedLineEditNoSave();
   1.206 +	if (lineedit) finishedLineEdit();
   1.207  
   1.208  	if ( !printer ) 
   1.209  	{
   1.210 @@ -1052,7 +1086,7 @@
   1.211  void MapEditor::exportImage(QString fn)
   1.212  {
   1.213  	// Finish open lineEdits
   1.214 -	if (lineedit) finishedLineEditNoSave();
   1.215 +	if (lineedit) finishedLineEdit();
   1.216  
   1.217  	setExportMode (true);
   1.218  	QPixmap pix (getPixmap());
   1.219 @@ -1073,7 +1107,7 @@
   1.220  void MapEditor::exportImage(QString fn, int item)
   1.221  {
   1.222  	// Finish open lineEdits
   1.223 -	if (lineedit) finishedLineEditNoSave();
   1.224 +	if (lineedit) finishedLineEdit();
   1.225  
   1.226  	setExportMode (true);
   1.227  	QPixmap pix (getPixmap());
   1.228 @@ -1142,7 +1176,7 @@
   1.229  void MapEditor::copy()
   1.230  {
   1.231  	// Finish open lineEdits
   1.232 -	if (lineedit) finishedLineEditNoSave();
   1.233 +	if (lineedit) finishedLineEdit();
   1.234  
   1.235  	if (selection) 
   1.236  	{
   1.237 @@ -1173,7 +1207,7 @@
   1.238  void MapEditor::redo()
   1.239  {
   1.240  	// Finish open lineEdits
   1.241 -	if (lineedit) finishedLineEditNoSave();
   1.242 +	if (lineedit) finishedLineEdit();
   1.243  
   1.244  	blockSaveState=true;
   1.245  	
   1.246 @@ -1234,7 +1268,7 @@
   1.247  void MapEditor::undo()
   1.248  {
   1.249  	// Finish open lineEdits
   1.250 -	if (lineedit) finishedLineEditNoSave();
   1.251 +	if (lineedit) finishedLineEdit();
   1.252  
   1.253  	blockSaveState=true;
   1.254  	
   1.255 @@ -1341,7 +1375,7 @@
   1.256  void MapEditor::pasteNoSave()
   1.257  {
   1.258  	// Finish open lineEdits
   1.259 -	if (lineedit) finishedLineEditNoSave();
   1.260 +	if (lineedit) finishedLineEdit();
   1.261  
   1.262  	load (clipboardDir+"/part.xml",ImportAdd);
   1.263  }
   1.264 @@ -1357,7 +1391,7 @@
   1.265  	if (selection && (typeid(*selection) == typeid(BranchObj) ||
   1.266  				      typeid(*selection) == typeid(MapCenterObj))) 
   1.267  	{
   1.268 -		saveState(selection);
   1.269 +		saveState(selection,QString("Paste to %1").arg( getName(selection)));
   1.270  		pasteNoSave();
   1.271  		mapCenter->reposition();
   1.272  		adjustCanvasSize();
   1.273 @@ -1366,7 +1400,7 @@
   1.274  
   1.275  void MapEditor::cut()
   1.276  {
   1.277 -	saveState(selection->getParObj());
   1.278 +	saveState(selection->getParObj(),QString("Cut %1").arg(getName(selection)));
   1.279  	copy();
   1.280  	cutNoSave();
   1.281  	mapCenter->reposition();
   1.282 @@ -1384,7 +1418,7 @@
   1.283  void MapEditor::moveBranchUp()
   1.284  {
   1.285  	// Finish open lineEdits
   1.286 -	if (lineedit) finishedLineEditNoSave();
   1.287 +	if (lineedit) finishedLineEdit();
   1.288  
   1.289  	BranchObj* bo;
   1.290  	BranchObj* par;
   1.291 @@ -1395,7 +1429,7 @@
   1.292  		selection->unselect();
   1.293  		selection=par->moveBranchUp (bo);
   1.294  		selection->select();
   1.295 -		saveState("moveBranchDown ()",bo);
   1.296 +		saveState("moveBranchDown ()",bo,QString("Move up %1").arg(getName(bo)));
   1.297  		mapCenter->reposition();
   1.298  		ensureSelectionVisible();
   1.299  	}
   1.300 @@ -1404,7 +1438,7 @@
   1.301  void MapEditor::moveBranchDown()
   1.302  {
   1.303  	// Finish open lineEdits
   1.304 -	if (lineedit) finishedLineEditNoSave();
   1.305 +	if (lineedit) finishedLineEdit();
   1.306  
   1.307  	BranchObj* bo;
   1.308  	BranchObj* par;
   1.309 @@ -1415,7 +1449,7 @@
   1.310  		selection->unselect(); 
   1.311  		selection=par->moveBranchDown(bo);
   1.312  		selection->select();
   1.313 -		saveState("moveBranchUp ()",bo);
   1.314 +		saveState("moveBranchUp ()",bo,QString("Move down %1").arg(getName(bo)));
   1.315  		mapCenter->reposition();
   1.316  		ensureSelectionVisible();
   1.317  	}	
   1.318 @@ -1424,14 +1458,13 @@
   1.319  void MapEditor::editHeading()
   1.320  {
   1.321  	// Finish open lineEdits
   1.322 -	if (lineedit) finishedLineEditNoSave();
   1.323 +	if (lineedit) finishedLineEdit();
   1.324  
   1.325  	if (selection  &&  
   1.326  		 (typeid(*selection) == typeid(BranchObj) || 
   1.327  		  typeid(*selection) == typeid(MapCenterObj) ) ) 
   1.328  	{
   1.329  		editingBO=(BranchObj*)selection;
   1.330 -		saveState("setHeading (\""+((BranchObj*)selection)->getHeading()+"\")",editingBO );
   1.331  
   1.332  		ensureSelectionVisible();
   1.333  		QPoint p = worldMatrix().map(QPoint (editingBO->x(),editingBO->y()));
   1.334 @@ -1492,15 +1525,15 @@
   1.335  void MapEditor::addNewBranch(int pos)
   1.336  {
   1.337  	// Finish open lineEdits
   1.338 -	if (lineedit) finishedLineEditNoSave();
   1.339 +	if (lineedit) finishedLineEdit();
   1.340  
   1.341  	if (selection  &&  
   1.342  		 (typeid(*selection) == typeid(BranchObj) || 
   1.343  		  typeid(*selection) == typeid(MapCenterObj) ) ) 
   1.344  	{
   1.345 -		saveState(selection);	//TODO undoCommand
   1.346 -
   1.347  		BranchObj* bo1 = (BranchObj*) selection;
   1.348 +		saveState(selection, QString("Add new branch to %1").arg(getName(bo1)));	//TODO undoCommand
   1.349 +
   1.350  		bool wasScrolled=false;
   1.351  		BranchObj *newbo=NULL;
   1.352  		if (pos==0)
   1.353 @@ -1558,14 +1591,14 @@
   1.354  void MapEditor::addNewBranchHere()
   1.355  {
   1.356  	// Finish open lineEdits
   1.357 -	if (lineedit) finishedLineEditNoSave();
   1.358 +	if (lineedit) finishedLineEdit();
   1.359  
   1.360  	if (selection  &&  
   1.361  		 (typeid(*selection) == typeid(BranchObj) ) )
   1.362  	{
   1.363 -		saveState(selection);
   1.364 -
   1.365  		BranchObj* bo1 = (BranchObj*) selection;
   1.366 +		saveState(selection, QString("Add new branch here").arg(getName(bo1)));
   1.367 +
   1.368  		bool wasScrolled=false;
   1.369  		BranchObj *newbo=NULL;
   1.370  		BranchObj *parbo=(BranchObj*)(selection->getParObj());
   1.371 @@ -1607,21 +1640,21 @@
   1.372  void MapEditor::deleteSelection()
   1.373  {
   1.374  	// Finish open lineEdits
   1.375 -	if (lineedit) finishedLineEditNoSave();
   1.376 +	if (lineedit) finishedLineEdit();
   1.377  
   1.378  	if (selection  && typeid(*selection) ==typeid(BranchObj) ) 
   1.379  	{
   1.380 +		BranchObj* bo=dynamic_cast <BranchObj*> (selection);
   1.381 +		BranchObj* par=(BranchObj*)(bo->getParObj());
   1.382 +		bo->unselect();
   1.383  		if (selection->getDepth()>1)
   1.384  			// Normal branch, save parent with childs
   1.385 -			saveState(selection->getParObj());
   1.386 +			saveState(par,QString("Delete %1").arg(getName(bo)));
   1.387  		else
   1.388  			// Mainbranch, save whole map
   1.389  			// TODO Better would be to insert mainbranch again at pos
   1.390  			// But undoCommand is missing right now
   1.391 -			saveState();
   1.392 -		BranchObj* bo=dynamic_cast <BranchObj*> (selection);
   1.393 -		BranchObj* par=(BranchObj*)(bo->getParObj());
   1.394 -		bo->unselect();
   1.395 +			saveState(QString("Delete %1").arg(getName(bo)));
   1.396  		selection=NULL;
   1.397  		par->removeBranch(bo);
   1.398  		selection=par;
   1.399 @@ -1632,9 +1665,9 @@
   1.400  	}
   1.401  	if (selection  && typeid(*selection) ==typeid(FloatImageObj) ) 
   1.402  	{
   1.403 -		saveState(selection->getParObj());
   1.404  		FloatImageObj* fio=dynamic_cast <FloatImageObj*> (selection);
   1.405  		BranchObj* par=(BranchObj*)(fio->getParObj());
   1.406 +		saveState(par, QString("Delete %1").arg(getName(fio)));
   1.407  		fio->unselect();
   1.408  		selection=NULL;
   1.409  		par->removeFloatImage(fio);
   1.410 @@ -1864,7 +1897,7 @@
   1.411  void MapEditor::selectUpperBranch()
   1.412  {
   1.413  	// Finish open lineEdits
   1.414 -	if (lineedit) finishedLineEditNoSave();
   1.415 +	if (lineedit) finishedLineEdit();
   1.416  
   1.417  	if (selection) 
   1.418  	{
   1.419 @@ -1884,7 +1917,7 @@
   1.420  void MapEditor::selectLowerBranch()
   1.421  {
   1.422  	// Finish open lineEdits
   1.423 -	if (lineedit) finishedLineEditNoSave();
   1.424 +	if (lineedit) finishedLineEdit();
   1.425  
   1.426  	if (selection) 
   1.427  	{
   1.428 @@ -1905,7 +1938,7 @@
   1.429  void MapEditor::selectLeftBranch()
   1.430  {
   1.431  	// Finish open lineEdits
   1.432 -	if (lineedit) finishedLineEditNoSave();
   1.433 +	if (lineedit) finishedLineEdit();
   1.434  
   1.435  	BranchObj* bo;
   1.436  	BranchObj* par;
   1.437 @@ -1967,7 +2000,7 @@
   1.438  void MapEditor::selectRightBranch()
   1.439  {
   1.440  	// Finish open lineEdits
   1.441 -	if (lineedit) finishedLineEditNoSave();
   1.442 +	if (lineedit) finishedLineEdit();
   1.443  
   1.444  	BranchObj* bo;
   1.445  	BranchObj* par;
   1.446 @@ -2027,7 +2060,7 @@
   1.447  void MapEditor::selectFirstBranch()
   1.448  {
   1.449  	// Finish open lineEdits
   1.450 -	if (lineedit) finishedLineEditNoSave();
   1.451 +	if (lineedit) finishedLineEdit();
   1.452  
   1.453  	BranchObj *bo1;
   1.454  	BranchObj *bo2;
   1.455 @@ -2052,7 +2085,7 @@
   1.456  void MapEditor::selectLastBranch()
   1.457  {
   1.458  	// Finish open lineEdits
   1.459 -	if (lineedit) finishedLineEditNoSave();
   1.460 +	if (lineedit) finishedLineEdit();
   1.461  
   1.462  	BranchObj *bo1;
   1.463  	BranchObj *bo2;
   1.464 @@ -2082,12 +2115,12 @@
   1.465  void MapEditor::selectBackgroundColor()
   1.466  {
   1.467  	// Finish open lineEdits
   1.468 -	if (lineedit) finishedLineEditNoSave();
   1.469 +	if (lineedit) finishedLineEdit();
   1.470  
   1.471  	QColor col = QColorDialog::getColor( mapCanvas->backgroundColor(), this );
   1.472  	if ( !col.isValid() ) return;
   1.473  	setBackgroundColor( col );
   1.474 -	saveState();
   1.475 +	saveState(QString("Set background color of map to %1").arg(col.name()));
   1.476  }
   1.477  
   1.478  void MapEditor::setBackgroundColor(QColor c)
   1.479 @@ -2116,8 +2149,8 @@
   1.480  		if (typeid(*selection) == typeid(BranchObj) ||
   1.481  			typeid(*selection) == typeid(MapCenterObj))
   1.482  		{
   1.483 -			saveState(selection);	//TODO undoCommand
   1.484  			BranchObj *bo=(BranchObj*)selection;
   1.485 +			saveState(selection, QString("Set color of %1 to %2").arg(getName(bo)).arg(actColor.name()));	//TODO undoCommand
   1.486  			bo->setColor(actColor); // color branch
   1.487  		}    
   1.488  	}
   1.489 @@ -2130,8 +2163,8 @@
   1.490  		if (typeid(*selection) == typeid(BranchObj) ||
   1.491  			typeid(*selection) == typeid(MapCenterObj))
   1.492  		{
   1.493 -			saveState(selection);	//TODO undoCommand
   1.494  			BranchObj *bo=(BranchObj*)selection;
   1.495 +			saveState(selection, QString ("Set color of %1 and childs to %2").arg(getName(bo)).arg(actColor.name()));	//TODO undoCommand
   1.496  			bo->setColorChilds(actColor); // color links, color childs
   1.497  		}    
   1.498  	}
   1.499 @@ -2142,8 +2175,14 @@
   1.500  {
   1.501  	if (selection)
   1.502  	{
   1.503 -		saveState(selection);// TODO undoCommand	
   1.504 -		((BranchObj*)selection)->toggleStandardFlag (f,actionSettingsUseFlagGroups);
   1.505 +		BranchObj *bo=(BranchObj*)selection;
   1.506 +		QString s;
   1.507 +		if (bo->isSetStandardFlag(f))
   1.508 +			s="Unset";
   1.509 +		else
   1.510 +			s="Set";
   1.511 +		saveState(selection, QString("%1 standard flag \"%2\" of %3").arg(s).arg(f).arg(getName(bo)));// TODO undoCommand	
   1.512 +		bo->toggleStandardFlag (f,actionSettingsUseFlagGroups);
   1.513  		adjustCanvasSize();
   1.514  	}	
   1.515  }
   1.516 @@ -2232,7 +2271,7 @@
   1.517  		if ( ok) 
   1.518  		{
   1.519  			// user entered something and pressed OK
   1.520 -			saveState("setURL (\""+bo->getURL()+"\")","setURL (\""+text+"\")");	
   1.521 +			saveState("setURL (\""+bo->getURL()+"\")","setURL (\""+text+"\")", QString("Set URL of %1 to %21").arg(getName(bo)).arg(text));	
   1.522  			bo->setURL (text);
   1.523  			updateActions();
   1.524  		}	
   1.525 @@ -2254,7 +2293,7 @@
   1.526  			typeid(*selection) == typeid(MapCenterObj)) )
   1.527  	{		
   1.528  		BranchObj *bo=(BranchObj*)selection;
   1.529 -		saveState("setURL (\""+bo->getURL()+"\")","setURL (\""+bo->getHeading()+"\")");	
   1.530 +		saveState("setURL (\""+bo->getURL()+"\")","setURL (\""+bo->getHeading()+"\")",QString("Copy heading of %1 to URL").arg(getName(bo)));	
   1.531  		bo->setURL (bo->getHeading());
   1.532  		updateActions();
   1.533  	}
   1.534 @@ -2267,7 +2306,7 @@
   1.535  	{		
   1.536  		BranchObj *bo=(BranchObj*)selection;
   1.537  		QString url= "https://bugzilla.novell.com/show_bug.cgi?id="+bo->getHeading();
   1.538 -		saveState("setURL (\""+bo->getURL()+"\")","setURL (\""+url+"\")");	
   1.539 +		saveState("setURL (\""+bo->getURL()+"\")","setURL (\""+url+"\")",QString("Use heading of %1 as link to Bugzilla").arg(getName(bo)));	
   1.540  		bo->setURL (url);
   1.541  		updateActions();
   1.542  	}
   1.543 @@ -2280,7 +2319,7 @@
   1.544  	{		
   1.545  		BranchObj *bo=(BranchObj*)selection;
   1.546  		QString url= "http://keeper.suse.de:8080/webfate/match/id?value=ID"+bo->getHeading();
   1.547 -		saveState("setURL (\""+bo->getURL()+"\")","setURL (\""+url+"\")");	
   1.548 +		saveState("setURL (\""+bo->getURL()+"\")","setURL (\""+url+"\")",QString("Use heading of %1 as link to FATE").arg(getName(bo)));	
   1.549  		bo->setURL (url);
   1.550  		updateActions();
   1.551  	}
   1.552 @@ -2302,7 +2341,7 @@
   1.553  		QString fn;
   1.554  		if ( fd->exec() == QDialog::Accepted )
   1.555  		{
   1.556 -			saveState("setVymLink (\""+bo->getVymLink()+"\")","setVymLink (\""+fd->selectedFile()+"\")");	
   1.557 +			saveState("setVymLink (\""+bo->getVymLink()+"\")","setVymLink (\""+fd->selectedFile()+"\")",QString("Set vymlink of %1 to %2").arg(getName(bo)).arg(fd->selectedFile()));	
   1.558  			bo->setVymLink (fd->selectedFile() );
   1.559  			updateActions();
   1.560  			mapCenter->reposition();
   1.561 @@ -2318,7 +2357,7 @@
   1.562  			typeid(*selection) == typeid(MapCenterObj)) )
   1.563  	{		
   1.564  		BranchObj *bo=(BranchObj*)selection;
   1.565 -		saveState("setVymLink (\""+bo->getVymLink()+"\")","setVymLink (\"\")");	
   1.566 +		saveState("setVymLink (\""+bo->getVymLink()+"\")","setVymLink (\"\")",QString("Unset vymlink of %1").arg(getName(bo)));	
   1.567  		bo->setVymLink ("" );
   1.568  		updateActions();
   1.569  		mapCenter->reposition();
   1.570 @@ -2327,23 +2366,6 @@
   1.571  	}
   1.572  }
   1.573  
   1.574 -void MapEditor::setHideExport()
   1.575 -{
   1.576 -	if (selection && (typeid(*selection) == typeid(BranchObj) ||
   1.577 -			typeid(*selection) == typeid(MapCenterObj)) ||
   1.578 -			(typeid(*selection)==typeid(FloatImageObj))
   1.579 -			)
   1.580 -	{		
   1.581 -		saveState();	//TODO undoCommand
   1.582 -		OrnamentedObj *oo=(OrnamentedObj*)selection;
   1.583 -		oo->setHideInExport(actionEditToggleHideExport->isOn());
   1.584 -		updateActions();
   1.585 -		mapCenter->reposition();
   1.586 -		adjustCanvasSize();
   1.587 -		canvas()->update();
   1.588 -	}
   1.589 -}
   1.590 -
   1.591  void MapEditor::toggleHideExport()
   1.592  {
   1.593  	if (selection && (typeid(*selection) == typeid(BranchObj) ||
   1.594 @@ -2351,12 +2373,19 @@
   1.595  			(typeid(*selection)==typeid(FloatImageObj))
   1.596  			)
   1.597  	{		
   1.598 -		saveState();	//TODO undoCommand
   1.599  		OrnamentedObj *oo=(OrnamentedObj*)selection;
   1.600 +		QString s;
   1.601  		if (oo->hideInExport())
   1.602 +		{
   1.603  			oo->setHideInExport(false);
   1.604 +			s="Unset";
   1.605 +		}	
   1.606  		else	
   1.607 +		{
   1.608  			oo->setHideInExport(true);
   1.609 +			s="Set";
   1.610 +		}	
   1.611 +		saveState(QString ("%1 hide export flag of %2").arg(s).arg(getName(selection)));	//TODO undoCommand
   1.612  		actionEditToggleHideExport->setOn (oo->hideInExport());	
   1.613  		updateActions();
   1.614  		mapCenter->reposition();
   1.615 @@ -2376,16 +2405,17 @@
   1.616  	
   1.617  }
   1.618  
   1.619 -void MapEditor::removeBranchHere()
   1.620 +void MapEditor::removeBranchKeepChilds()
   1.621  {
   1.622  	if (selection && (typeid(*selection) == typeid(BranchObj) ))
   1.623  	{		
   1.624  		BranchObj* bo=(BranchObj*)selection;
   1.625  		BranchObj* par=(BranchObj*)(bo->getParObj());
   1.626 +		QString s=QString("Remove %1 and keep its childs").arg(getName(bo));
   1.627  		if (bo->getDepth()==1)
   1.628 -			saveState();
   1.629 +			saveState(s);
   1.630  		else	
   1.631 -			saveState(selection->getParObj());	// TODO undoCommand
   1.632 +			saveState(selection->getParObj(),s);	// TODO undoCommand
   1.633  		QString sel=selection->getSelectString();
   1.634  		unselect();
   1.635  		par->removeBranchHere(bo);
   1.636 @@ -2398,7 +2428,7 @@
   1.637  {
   1.638  	if (selection && (typeid(*selection) == typeid(BranchObj) ))
   1.639  	{		
   1.640 -		saveState(selection->getParObj());
   1.641 +		saveState(selection->getParObj(), QString("Remove childs of branch").arg(getName(selection)));
   1.642  		((BranchObj*)selection)->removeChilds();
   1.643  		mapCenter->reposition();
   1.644  	}	
   1.645 @@ -2442,7 +2472,7 @@
   1.646  	// Finally show dialog
   1.647  	if (dia.exec() == QDialog::Accepted)
   1.648  	{
   1.649 -		saveState();	//TODO undoCommand
   1.650 +		saveState("Edit info about map");	//TODO undoCommand
   1.651  		mapCenter->setAuthor (dia.getAuthor() );
   1.652  		mapCenter->setComment (dia.getComment() );
   1.653  	}
   1.654 @@ -2627,7 +2657,7 @@
   1.655  {
   1.656  	linkstyle=ls;
   1.657  
   1.658 -	saveState();	// TODO undoCommand
   1.659 +	saveState("Set link style");	// TODO undoCommand
   1.660  	BranchObj *bo;
   1.661  	bo=mapCenter->first();
   1.662  	bo=bo->next();
   1.663 @@ -2716,12 +2746,12 @@
   1.664  void MapEditor::selectLinkColor()
   1.665  {
   1.666  	// Finish open lineEdits
   1.667 -	if (lineedit) finishedLineEditNoSave();
   1.668 +	if (lineedit) finishedLineEdit();
   1.669  
   1.670  	QColor col = QColorDialog::getColor( defLinkColor, this );
   1.671  	if ( !col.isValid() ) return;
   1.672  	setLinkColor( col );
   1.673 -	saveState();	//TODO undoCommand
   1.674 +	saveState(QString("Set link color to %1").arg(col.name()));	//TODO undoCommand
   1.675  
   1.676  }
   1.677  
   1.678 @@ -2732,7 +2762,12 @@
   1.679  		BranchObj *bo=((BranchObj*)selection);
   1.680  		if (bo->countBranches()==0) return;
   1.681  		if (bo->getDepth()==0) return;
   1.682 -		saveState(selection);
   1.683 +		QString s;
   1.684 +		if (bo->isScrolled())
   1.685 +			s="Unscroll";
   1.686 +		else	
   1.687 +			s="Scroll";
   1.688 +		saveState(selection, QString ("%1 %2").arg(s).arg(getName(bo)));
   1.689  		bo->toggleScroll();
   1.690  		adjustCanvasSize();
   1.691  		canvas()->update();
   1.692 @@ -2772,7 +2807,7 @@
   1.693  		QString fn;
   1.694  		if ( fd->exec() == QDialog::Accepted )
   1.695  		{
   1.696 -			saveState(selection);
   1.697 +			saveState(selection, QString("Add floatimage to %1").arg(getName(selection)));
   1.698  			lastImageDir=fn.left(fn.findRev ("/"));
   1.699  			QStringList flist = fd->selectedFiles();
   1.700  			QStringList::Iterator it = flist.begin();
   1.701 @@ -3002,7 +3037,7 @@
   1.702  				}
   1.703  				if (dia.deleteXLink())
   1.704  					((BranchObj*)selection)->deleteXLinkAt(i);
   1.705 -				saveState();	//TODO undoCommand
   1.706 +				saveState("Edit xLink");	//TODO undoCommand
   1.707  			}
   1.708  		}	
   1.709  	}
   1.710 @@ -3108,7 +3143,7 @@
   1.711  void MapEditor::contentsMousePressEvent(QMouseEvent* e)
   1.712  {
   1.713  	// Finish open lineEdits
   1.714 -	if (lineedit) finishedLineEditNoSave();
   1.715 +	if (lineedit) finishedLineEdit();
   1.716  	
   1.717      QPoint p = inverseWorldMatrix().map(e->pos());
   1.718      LinkableMapObj* lmo=mapCenter->findMapObj(p, NULL);
   1.719 @@ -3253,7 +3288,9 @@
   1.720  		if (typeid(*selection) == typeid(FloatImageObj))
   1.721  		{
   1.722  			FloatObj *fo=(FloatObj*)selection;
   1.723 -			saveState("move "+qpointToString(movingObj_orgPos),fo->getSelectString() );
   1.724 +			saveState(
   1.725 +				"move "+qpointToString(movingObj_orgPos),fo->getSelectString() ,
   1.726 +				QString("Move %1").arg(getName(selection)));
   1.727  			fo->move   (p.x() -movingObj_start.x(), p.y()-movingObj_start.y() );		
   1.728  			fo->setRelPos();
   1.729  			fo->reposition();
   1.730 @@ -3268,7 +3305,7 @@
   1.731  			{
   1.732  				if (typeid(*fo) == typeid(FloatImageObj)) 
   1.733  				{
   1.734 -					saveState();
   1.735 +					saveState(QString("Relink %1 to %2").arg(getName(fo)).arg(getName(lmo) ) );
   1.736  					FloatImageObj *fio=(FloatImageObj*)(fo);
   1.737  					((BranchObj*)(lmo))->addFloatImage (fio);
   1.738  					fio->unselect();
   1.739 @@ -3402,7 +3439,7 @@
   1.740  			tmpXLink->setEnd ( ((BranchObj*)(dst)) );
   1.741  			tmpXLink->updateXLink();
   1.742  			tmpXLink->activate();
   1.743 -			saveState();	//TODO undoCommand
   1.744 +			saveState(QString("Activate xLink from %1 to %2").arg(getName(tmpXLink->getBegin())).arg(getName(tmpXLink->getEnd())) );	//TODO undoCommand
   1.745  		} else
   1.746  		{
   1.747  			delete(tmpXLink);
   1.748 @@ -3468,11 +3505,11 @@
   1.749  					if (dst->getDepth()==0) 
   1.750  						bs->move (savePos);
   1.751  				} 
   1.752 -				saveState (undoCom,bs->getSelectString() );
   1.753 +				saveState (undoCom,bs->getSelectString(),QString("Relink %1 to %2").arg(getName(bs)).arg(getName(dst)) );
   1.754  			} else
   1.755  				if (selection->getDepth()==1)
   1.756  					// If we have moved mainbranch only save endposition
   1.757 -					saveState("move "+qpointToString(movingObj_orgPos), selection->getSelectString() );
   1.758 +					saveState("move "+qpointToString(movingObj_orgPos), selection->getSelectString(), QString("Move %1 to %2").arg(getName(selection)).arg(qpointToString(movingObj_orgPos)));
   1.759  			
   1.760  			// Draw the original link, before selection was moved around
   1.761  			mapCenter->reposition();
   1.762 @@ -3490,7 +3527,7 @@
   1.763  void MapEditor::contentsMouseDoubleClickEvent(QMouseEvent* e)
   1.764  {
   1.765  	// Finish open lineEdits
   1.766 -	if (lineedit) finishedLineEditNoSave();
   1.767 +	if (lineedit) finishedLineEdit();
   1.768  	
   1.769  	if (e->button() == QMouseEvent::LeftButton )
   1.770  	{
   1.771 @@ -3501,7 +3538,6 @@
   1.772  			if (selection) selection->unselect();
   1.773  			selection=lmo;
   1.774  			selection->select();
   1.775 -			saveState(selection);
   1.776  			editHeading();
   1.777  		}
   1.778  	}
   1.779 @@ -3670,7 +3706,8 @@
   1.780  
   1.781  		if (update) 
   1.782  		{
   1.783 -			saveState();	//TODO undo Command
   1.784 +			//FIXME saveState has to be called earlier for each of the drops...
   1.785 +			saveState("Drop Event");	//TODO undo Command
   1.786  			mapCenter->reposition();
   1.787  			adjustCanvasSize();
   1.788  			canvas()->update();
   1.789 @@ -3685,7 +3722,7 @@
   1.790        (typeid(*selection) == typeid(MapCenterObj))  )
   1.791    {
   1.792      BranchObj *bo=((BranchObj*)selection);
   1.793 -    saveState(selection);
   1.794 +    saveState(selection,QString("Add floatimage to %1").arg(getName(bo)));
   1.795      //QString fn=fd->selectedFile();
   1.796      //lastImageDir=fn.left(fn.findRev ("/"));
   1.797      bo->addFloatImage();