mapeditor.cpp
changeset 112 276468359068
parent 105 67a91e28b30f
child 119 0f183befd9af
     1.1 --- a/mapeditor.cpp	Mon Jun 06 20:27:42 2005 +0000
     1.2 +++ b/mapeditor.cpp	Fri Jul 08 07:24:42 2005 +0000
     1.3 @@ -341,7 +341,6 @@
     1.4      mapChanged=false;
     1.5  	mapDefault=true;
     1.6  	mapUnsaved=false;
     1.7 -	undoSelection=NULL;
     1.8  	
     1.9  	zipped=true;
    1.10  	filePath="";
    1.11 @@ -468,8 +467,7 @@
    1.12  	char tmpdir[]="/tmp/vym-XXXXXX";	
    1.13  	bakMapDir=mkdtemp(tmpdir);
    1.14  	makeSubDirs(bakMapDir);
    1.15 -	// FIXME set permissions
    1.16 -	// and maybe use QT method for portability
    1.17 +	// FIXME set permissions and maybe use QT method for portability
    1.18  }
    1.19  
    1.20  void MapEditor::delTmpDirs()
    1.21 @@ -487,7 +485,7 @@
    1.22  }
    1.23  
    1.24  
    1.25 -QString MapEditor::saveToDir(const QString &tmpdir, const QString &prefix, bool writeflags, const QPoint &offset, SaveMode savemode)
    1.26 +QString MapEditor::saveToDir(const QString &tmpdir, const QString &prefix, bool writeflags, const QPoint &offset, LinkableMapObj *saveSelection)
    1.27  {
    1.28  	// tmpdir		temporary directory to which data will be writte
    1.29  	// prefix		mapname, which will be appended to images etc.
    1.30 @@ -521,7 +519,7 @@
    1.31  		colhint=attribut("linkColorHint","HeadingColor");
    1.32  
    1.33  	QString mapAttr=attribut("version",__VYM_VERSION__);
    1.34 -	if (savemode==CompleteMap)
    1.35 +	if (!saveSelection)
    1.36  		mapAttr+= attribut("author",mapCenter->getAuthor()) +
    1.37  				  attribut("comment",mapCenter->getComment()) +
    1.38  			      attribut("date",mapCenter->getDate()) +
    1.39 @@ -538,15 +536,15 @@
    1.40  	standardFlagsDefault->resetUsedCounter();
    1.41  	
    1.42  	// Build xml recursivly
    1.43 -	if (savemode==CompleteMap)
    1.44 +	if (!saveSelection)
    1.45  		s+=mapCenter->saveToDir(tmpdir,prefix,writeflags,offset);
    1.46  	else
    1.47  	{
    1.48 -		if ( undoSelection &&
    1.49 -			typeid(*undoSelection) == typeid(BranchObj) )
    1.50 -			s+=((BranchObj*)(undoSelection))->saveToDir(tmpdir,prefix,offset);
    1.51 +		if ( typeid(*saveSelection) == typeid(BranchObj) )
    1.52 +			s+=((BranchObj*)(saveSelection))->saveToDir(tmpdir,prefix,offset);
    1.53  		else	
    1.54  			if (selection && typeid(*selection)==typeid(BranchObj))
    1.55 +				// This is used if selected branch is saved from mainwindow
    1.56  				s+=((BranchObj*)(selection))->saveToDir(tmpdir,prefix,offset);
    1.57  	}
    1.58  
    1.59 @@ -554,7 +552,7 @@
    1.60  	s+=settings.getXMLData (destPath);
    1.61  
    1.62  	// Save selection
    1.63 -	if (selection) 
    1.64 +	if (selection && !saveSelection) 
    1.65  		s+=valueElement("select",selection->getSelectString());
    1.66  
    1.67  	decIndent();
    1.68 @@ -567,44 +565,76 @@
    1.69  
    1.70  void MapEditor::saveState()
    1.71  {
    1.72 -	saveState (CompleteMap,NULL);
    1.73 +	saveState (CompleteMap,NULL,"");
    1.74  }
    1.75  
    1.76 -void MapEditor::saveState(const SaveMode &mode, LinkableMapObj *part)
    1.77 +void MapEditor::saveState(LinkableMapObj *undoSel)
    1.78  {
    1.79 -	saveState (mode,part,"");
    1.80 +	saveState (PartOfMap,undoSel,"");
    1.81  }
    1.82  
    1.83 -void MapEditor::saveState(const SaveMode &mode, LinkableMapObj *part, const QString &undoCom)
    1.84 +void MapEditor::saveState(const QString & c)
    1.85  {
    1.86 -	// all binary data is saved in bakMapDir (created in Constructor)
    1.87 -	// the xml data itself is kept in memory in backupXML
    1.88 -	// 
    1.89 -	// For faster write/read of data, a part of the map can be
    1.90 -	// written. Then the undoSelection will mark the part of the
    1.91 -	// map which should be replaced if an undo is wanted later.
    1.92 -
    1.93 -	if (mode==PartOfMap && part && (typeid(*part) == typeid (BranchObj) ) ) 
    1.94 +	saveState (UndoCommand,NULL,c);
    1.95 +}
    1.96 +
    1.97 +void MapEditor::saveState(const SaveMode &savemode, LinkableMapObj *undoSel, const QString &undoCom)
    1.98 +{
    1.99 +	if (savemode==UndoCommand)
   1.100  	{
   1.101 -		// So far we only test undoCommands for BranchObjs
   1.102  		undoCommand=undoCom;
   1.103 -		if (undoCommand!="")
   1.104 -		{
   1.105 -			undoSelection=part;
   1.106 -		} else
   1.107 -		{
   1.108 -			// Writing a vympart only is useful for BranchObj
   1.109 -			undoSelection=part;
   1.110 -			backupXML=saveToDir (bakMapDir,mapName+"-",false, QPoint (),PartOfMap);
   1.111 -		}
   1.112 -	} else	
   1.113 +		backupXML="";
   1.114 +	}	
   1.115 +	else if (savemode==PartOfMap && undoSel)
   1.116  	{
   1.117 -		undoCommand="";
   1.118 -		undoSelection=NULL;
   1.119 -		backupXML=saveToDir (bakMapDir,mapName+"-",false, QPoint (),CompleteMap);
   1.120 +		undoCommand="undoPart (\""+undoSel->getSelectString()+"\")";
   1.121 +		backupXML=saveToDir (bakMapDir,mapName+"-",false, QPoint (),undoSel);
   1.122 +	} else
   1.123 +	{
   1.124 +		undoCommand="undoMap ()";
   1.125 +		backupXML=saveToDir (bakMapDir,mapName+"-",false, QPoint (),NULL);
   1.126 +	}
   1.127 +	/* FIXME testing
   1.128 +	cout << "ME::saveState()\n";
   1.129 +	cout << "  undoCom="<<undoCommand<<endl;
   1.130 +	*/
   1.131 +}
   1.132 +
   1.133 +void MapEditor::parseAtom(const QString &s)
   1.134 +{
   1.135 +	API api;
   1.136 +	QString c,p,p0;
   1.137 +	api.parseCommand (s,c,p);
   1.138 +	api.getString(p,p0);
   1.139 +	/* FIXME testing
   1.140 +	cout <<"ME::parseAtom  s="<<s<<endl;
   1.141 +	cout <<"ME::parseAtom  c="<<c<<endl;
   1.142 +	cout <<"ME::parseAtom  p="<<p<<endl;
   1.143 +	*/
   1.144 +
   1.145 +	// External commands
   1.146 +	if (c==QString("moveBranchUp"))
   1.147 +		moveBranchUp();
   1.148 +	else if (c=="moveBranchDown")
   1.149 +		moveBranchDown();
   1.150 +	else if (c=="setHeading")
   1.151 +		setHeading (p0);
   1.152 +	// Internal commands, used for undo etc.	
   1.153 +	else if (c==QString("undoMap"))
   1.154 +		undoXML("");
   1.155 +	else if (c==QString("undoPart"))
   1.156 +		undoXML(p0);
   1.157 +	else if (c=="select")
   1.158 +		select (p0);
   1.159 +	else
   1.160 +	{
   1.161 +		cout << "MapEditor::parseAtom: Error!\n";
   1.162 +		cout << "  Command unknown: \""<<c<<"\""<<endl;
   1.163 +		cout << "     Used in atom: \""<<s<<"\""<<endl;
   1.164  	}	
   1.165  }
   1.166  
   1.167 +
   1.168  void MapEditor::finishedLineEditNoSave()
   1.169  {
   1.170  	// This is called by finishedLineEdit or any MapEditor method,
   1.171 @@ -675,20 +705,28 @@
   1.172  
   1.173  void MapEditor::setFilePath(QString fname, QString destname)
   1.174  {
   1.175 -	filePath=fname;
   1.176 -	fileName=fname;
   1.177 -	destPath=destname;
   1.178 -
   1.179 -	// If fname is not an absolute path, complete it
   1.180 -	filePath=QDir(fname).absPath();
   1.181 -	fileDir=filePath.left (1+filePath.findRev ("/"));
   1.182 -
   1.183 -	// Set short name, too. Search from behind:
   1.184 -	int i=fileName.findRev("/");
   1.185 -	if (i>=0) fileName=fileName.remove (0,i+1);
   1.186 -
   1.187 -	// Forget the .vym (or .xml) for name of map
   1.188 -	mapName=fileName.left(fileName.findRev(".",-1,true) );
   1.189 +	if (fname.isEmpty())
   1.190 +	{
   1.191 +		filePath="";
   1.192 +		fileName="";
   1.193 +		destPath="";
   1.194 +	} else
   1.195 +	{
   1.196 +		filePath=fname;		// becomes absolute path
   1.197 +		fileName=fname;		// gets stripped of path
   1.198 +		destPath=destname;	// needed for vymlinks
   1.199 +
   1.200 +		// If fname is not an absolute path, complete it
   1.201 +		filePath=QDir(fname).absPath();
   1.202 +		fileDir=filePath.left (1+filePath.findRev ("/"));
   1.203 +
   1.204 +		// Set short name, too. Search from behind:
   1.205 +		int i=fileName.findRev("/");
   1.206 +		if (i>=0) fileName=fileName.remove (0,i+1);
   1.207 +
   1.208 +		// Forget the .vym (or .xml) for name of map
   1.209 +		mapName=fileName.left(fileName.findRev(".",-1,true) );
   1.210 +	}
   1.211  }
   1.212  
   1.213  QString MapEditor::getFilePath()
   1.214 @@ -728,7 +766,7 @@
   1.215  	} else
   1.216  	{
   1.217  		setChanged();
   1.218 -		saveState(PartOfMap,selection);
   1.219 +		saveState(selection);
   1.220  	}	
   1.221  	
   1.222      
   1.223 @@ -785,6 +823,9 @@
   1.224  
   1.225  	int returnCode=0;
   1.226  
   1.227 +	// The SaveMode UndoCommand is not supported here
   1.228 +	if (savemode==UndoCommand) return 1;
   1.229 +
   1.230  	// Create mapName and fileDir
   1.231  	makeSubDirs (fileDir);
   1.232  	QString fname;
   1.233 @@ -807,7 +848,10 @@
   1.234  	file.close();
   1.235  
   1.236  	QString saveFile;
   1.237 -	saveFile=saveToDir (fileDir,mapName+"-",true,QPoint(),savemode);
   1.238 +	if (savemode==CompleteMap || selection==NULL)
   1.239 +		saveFile=saveToDir (fileDir,mapName+"-",true,QPoint(),NULL);
   1.240 +	else	
   1.241 +		saveFile=saveToDir (fileDir,mapName+"-",true,QPoint(),selection);
   1.242  
   1.243  	file.setName ( fileDir  + fname);
   1.244  	if ( !file.open( IO_WriteOnly ) )
   1.245 @@ -1073,7 +1117,7 @@
   1.246  	makeSubDirs (dir);
   1.247  
   1.248  	// write to directory
   1.249 -	QString saveFile=saveToDir (dir,mapName+"-",true,mapCenter->getTotalBBox().topLeft() ,CompleteMap);
   1.250 +	QString saveFile=saveToDir (dir,mapName+"-",true,mapCenter->getTotalBBox().topLeft() ,NULL);
   1.251  	QFile file;
   1.252  
   1.253  	file.setName ( dir + "/"+mapName+".xml");
   1.254 @@ -1105,82 +1149,6 @@
   1.255  	mapCenter->clear();
   1.256  }
   1.257  
   1.258 -void MapEditor::undo()
   1.259 -{
   1.260 -	QDir d;
   1.261 -	d.setPath(bakMapDir);
   1.262 -	if (d.exists() )
   1.263 -	{
   1.264 -		// Finish open lineEdits
   1.265 -		if (lineedit) finishedLineEditNoSave();
   1.266 -
   1.267 -		if (selection) 
   1.268 -		{
   1.269 -			selection->unselect();
   1.270 -			selection=NULL;
   1.271 -		}	
   1.272 -		
   1.273 -		if (undoCommand!="" && undoSelection)
   1.274 -		{
   1.275 -			// We don't need to parse XML backup, but
   1.276 -			// do the undoCommand
   1.277 -			selection=undoSelection;
   1.278 -			selection->select();
   1.279 -			parseTest (undoCommand);
   1.280 -
   1.281 -		} else
   1.282 -		{
   1.283 -			// We need to parse saved XML data
   1.284 -			mapBuilderHandler handler;
   1.285 -			QXmlInputSource source;
   1.286 -			source.setData(backupXML);
   1.287 -			QXmlSimpleReader reader;
   1.288 -			reader.setContentHandler( &handler );
   1.289 -			reader.setErrorHandler( &handler );
   1.290 -			handler.setMapEditor( this );
   1.291 -			handler.setTmpDir ( bakMapDir );	// needed to load files with rel. path
   1.292 -			if (undoSelection)
   1.293 -			{
   1.294 -				selection=undoSelection;
   1.295 -				selection->select();
   1.296 -				handler.setLoadMode (ImportReplace);
   1.297 -
   1.298 -			} else	
   1.299 -			{
   1.300 -				mapCenter->clear();
   1.301 -				handler.setLoadMode (NewMap);
   1.302 -			}	
   1.303 -			blockreposition=true;
   1.304 -			bool ok = reader.parse( source );
   1.305 -			blockreposition=false;
   1.306 -			if ( ok ) 
   1.307 -				mapCenter->reposition();
   1.308 -				
   1.309 -			else 
   1.310 -			{	
   1.311 -				// This should never ever happen
   1.312 -				QMessageBox::critical( 0, tr( "Critical Parse Error by reading backupFile" ),
   1.313 -									   tr( handler.errorProtocol() )+" in "+backupXML );
   1.314 -			}
   1.315 -		} // restoring saved version	
   1.316 -
   1.317 -		// Undo not longer available now
   1.318 -		actionEditUndo->setEnabled (false);
   1.319 -		undoSelection=false;
   1.320 -		mapChanged=false;
   1.321 -		return;
   1.322 -	} else	
   1.323 -	{
   1.324 -		QMessageBox::critical( 0, tr( "Critical Error" ),
   1.325 -			"Temporary directory " +bakMapDir + 
   1.326 -			tr (" used for undo is gone. \n"
   1.327 -			"I will create a new one, but at the moment no undo is available.\n"
   1.328 -			"Maybe you want to reload your original data.\n\n"
   1.329 -			"Sorry for any inconveniences.") );
   1.330 -		makeTmpDirs();	
   1.331 -	}							
   1.332 -}
   1.333 -
   1.334  void MapEditor::copy()
   1.335  {
   1.336  	// Finish open lineEdits
   1.337 @@ -1244,6 +1212,72 @@
   1.338  	}	    
   1.339  }
   1.340  
   1.341 +void MapEditor::undo()
   1.342 +{
   1.343 +	// Finish open lineEdits
   1.344 +	if (lineedit) finishedLineEditNoSave();
   1.345 +
   1.346 +	// Unselect
   1.347 +	if (selection) 
   1.348 +	{
   1.349 +		selection->unselect();
   1.350 +		selection=NULL;
   1.351 +	}	
   1.352 +		
   1.353 +	parseAtom (undoCommand);
   1.354 +	mapCenter->reposition();
   1.355 +
   1.356 +	// Undo not longer available now
   1.357 +	actionEditUndo->setEnabled (false);
   1.358 +	mapChanged=false;
   1.359 +
   1.360 +}
   1.361 +
   1.362 +void MapEditor::undoXML(const QString &undoSel)
   1.363 +{
   1.364 +	QDir d;
   1.365 +	d.setPath(bakMapDir);
   1.366 +	if (d.exists() )
   1.367 +	{
   1.368 +		// We need to parse saved XML data
   1.369 +		mapBuilderHandler handler;
   1.370 +		QXmlInputSource source;
   1.371 +		source.setData(backupXML);
   1.372 +		QXmlSimpleReader reader;
   1.373 +		reader.setContentHandler( &handler );
   1.374 +		reader.setErrorHandler( &handler );
   1.375 +		handler.setMapEditor( this );
   1.376 +		handler.setTmpDir ( bakMapDir );	// needed to load files with rel. path
   1.377 +		if (undoSel.isEmpty())
   1.378 +		{
   1.379 +			mapCenter->clear();
   1.380 +			handler.setLoadMode (NewMap);
   1.381 +		} else	
   1.382 +		{
   1.383 +			select (undoSel);
   1.384 +			handler.setLoadMode (ImportReplace);
   1.385 +		}	
   1.386 +		blockreposition=true;
   1.387 +		bool ok = reader.parse( source );
   1.388 +		blockreposition=false;
   1.389 +		if (! ok ) 
   1.390 +		{	
   1.391 +			// This should never ever happen
   1.392 +			QMessageBox::critical( 0, tr( "Critical Parse Error by reading backupFile" ),
   1.393 +								   tr( handler.errorProtocol() )+" in "+backupXML );
   1.394 +		}
   1.395 +	} else	
   1.396 +	{
   1.397 +		QMessageBox::critical( 0, tr( "Critical Error" ),
   1.398 +			"Temporary directory " +bakMapDir + 
   1.399 +			tr (" used for undo is gone. \n"
   1.400 +			"I will create a new one, but at the moment no undo is available.\n"
   1.401 +			"Maybe you want to reload your original data.\n\n"
   1.402 +			"Sorry for any inconveniences.") );
   1.403 +		makeTmpDirs();	
   1.404 +	}							
   1.405 +}
   1.406 +
   1.407  LinkableMapObj* MapEditor::pasteNoSave()
   1.408  {
   1.409  	// Finish open lineEdits
   1.410 @@ -1309,7 +1343,7 @@
   1.411  void MapEditor::paste()
   1.412  {   
   1.413  	setChanged();
   1.414 -	saveState(PartOfMap,selection);
   1.415 +	saveState(selection);
   1.416  	pasteNoSave();
   1.417  	mapCenter->reposition();
   1.418  	adjustCanvasSize();
   1.419 @@ -1318,7 +1352,7 @@
   1.420  void MapEditor::cut()
   1.421  {
   1.422  	setChanged();
   1.423 -	saveState(PartOfMap,selection->getParObj());
   1.424 +	saveState(selection->getParObj());
   1.425  	copy();
   1.426  	cutNoSave();
   1.427  	mapCenter->reposition();
   1.428 @@ -1335,7 +1369,7 @@
   1.429  	if (typeid(*selection) == typeid(BranchObj)  ) 
   1.430  	{
   1.431  		setChanged();
   1.432 -		saveState(PartOfMap,selection,"moveBranchDown ()");
   1.433 +		saveState("moveBranchDown ()");
   1.434  		bo=(BranchObj*)(selection);
   1.435  		par=(BranchObj*)(bo->getParObj());
   1.436  		selection->unselect();
   1.437 @@ -1356,7 +1390,7 @@
   1.438  	if (typeid(*selection) == typeid(BranchObj)  ) 
   1.439  	{
   1.440  		setChanged();
   1.441 -		saveState(PartOfMap,selection,"moveBranchUp ()");
   1.442 +		saveState("moveBranchUp ()");
   1.443  		bo=(BranchObj*)(selection);
   1.444  		par=(BranchObj*)(bo->getParObj());
   1.445  		selection->unselect(); 
   1.446 @@ -1377,7 +1411,7 @@
   1.447  		  typeid(*selection) == typeid(MapCenterObj) ) ) 
   1.448  	{
   1.449  		setChanged();
   1.450 -		saveState(PartOfMap,selection);
   1.451 +		saveState("setHeading (\""+((BranchObj*)(selection))->getHeading()+"\")");
   1.452  
   1.453  		ensureSelectionVisible();
   1.454  		editingBO=(BranchObj*)(selection);
   1.455 @@ -1395,6 +1429,20 @@
   1.456  	}				
   1.457  }
   1.458  
   1.459 +void MapEditor::setHeading(const QString &s)
   1.460 +{
   1.461 +	// Internal function, no saveState needed
   1.462 +	if (selection  &&  
   1.463 +		 (typeid(*selection) == typeid(BranchObj) || 
   1.464 +		  typeid(*selection) == typeid(MapCenterObj) ) ) 
   1.465 +	{
   1.466 +		((BranchObj*)(selection))->setHeading(s);
   1.467 +		mapCenter->reposition();
   1.468 +		adjustCanvasSize();
   1.469 +		ensureSelectionVisible();
   1.470 +	}
   1.471 +}
   1.472 +
   1.473  void MapEditor::addNewBranch(int pos)
   1.474  {
   1.475  	// Finish open lineEdits
   1.476 @@ -1405,7 +1453,7 @@
   1.477  		  typeid(*selection) == typeid(MapCenterObj) ) ) 
   1.478  	{
   1.479  		setChanged();
   1.480 -		saveState(PartOfMap,selection);
   1.481 +		saveState(selection);
   1.482  
   1.483  		BranchObj* bo1 = (BranchObj*) (selection);
   1.484  		bool wasScrolled=false;
   1.485 @@ -1471,7 +1519,7 @@
   1.486  		 (typeid(*selection) == typeid(BranchObj) ) )
   1.487  	{
   1.488  		setChanged();
   1.489 -		saveState(PartOfMap,selection);
   1.490 +		saveState(selection);
   1.491  
   1.492  		BranchObj* bo1 = (BranchObj*) (selection);
   1.493  		bool wasScrolled=false;
   1.494 @@ -1520,7 +1568,7 @@
   1.495  	if (selection  && typeid(*selection) ==typeid(BranchObj) ) 
   1.496  	{
   1.497  		setChanged();
   1.498 -		saveState(PartOfMap,selection->getParObj());
   1.499 +		saveState(selection->getParObj());
   1.500  		BranchObj* bo=dynamic_cast <BranchObj*> (selection);
   1.501  		BranchObj* par=(BranchObj*)(bo->getParObj());
   1.502  		bo->unselect();
   1.503 @@ -1535,7 +1583,7 @@
   1.504  	if (selection  && typeid(*selection) ==typeid(FloatImageObj) ) 
   1.505  	{
   1.506  		setChanged();
   1.507 -		saveState(PartOfMap,selection->getParObj());
   1.508 +		saveState(selection->getParObj());
   1.509  		FloatImageObj* fio=dynamic_cast <FloatImageObj*> (selection);
   1.510  		BranchObj* par=(BranchObj*)(fio->getParObj());
   1.511  		fio->unselect();
   1.512 @@ -1556,7 +1604,7 @@
   1.513  
   1.514  bool MapEditor::select (const QString &s)
   1.515  {
   1.516 -	LinkableMapObj *lmo=mapCenter->findObj(s);
   1.517 +	LinkableMapObj *lmo=mapCenter->findObjBySelect(s);
   1.518  
   1.519  	// Finally select the found object
   1.520  	if (lmo)
   1.521 @@ -2006,7 +2054,7 @@
   1.522  			typeid(*selection) == typeid(MapCenterObj))
   1.523  		{
   1.524  			setChanged();
   1.525 -			saveState(PartOfMap,selection);
   1.526 +			saveState(selection);
   1.527  			BranchObj *bo=(BranchObj*)(selection);
   1.528  			bo->setColor(actColor, false); // color links, color childs
   1.529  		}    
   1.530 @@ -2021,7 +2069,7 @@
   1.531  			typeid(*selection) == typeid(MapCenterObj))
   1.532  		{
   1.533  			setChanged();
   1.534 -			saveState(PartOfMap,selection);
   1.535 +			saveState(selection);
   1.536  			BranchObj *bo=(BranchObj*)(selection);
   1.537  			bo->setColor(actColor, true); // color links, color childs
   1.538  		}    
   1.539 @@ -2034,7 +2082,7 @@
   1.540  	if (selection)
   1.541  	{
   1.542  		setChanged();
   1.543 -		saveState(PartOfMap,selection);	
   1.544 +		saveState(selection);	
   1.545  		((BranchObj*)(selection))->toggleStandardFlag (f,actionSettingsUseFlagGroups);
   1.546  	}	
   1.547  }
   1.548 @@ -2234,7 +2282,7 @@
   1.549  	if (selection && (typeid(*selection) == typeid(BranchObj) ))
   1.550  	{		
   1.551  		setChanged();
   1.552 -		saveState(PartOfMap,selection->getParObj());
   1.553 +		saveState(selection->getParObj());
   1.554  		QString sel=selection->getSelectString();
   1.555  		BranchObj* bo=(BranchObj*)(selection);
   1.556  		BranchObj* par=(BranchObj*)(bo->getParObj());
   1.557 @@ -2250,7 +2298,7 @@
   1.558  	if (selection && (typeid(*selection) == typeid(BranchObj) ))
   1.559  	{		
   1.560  		setChanged();
   1.561 -		saveState(PartOfMap,selection->getParObj());
   1.562 +		saveState(selection->getParObj());
   1.563  		((BranchObj*)(selection))->removeChilds();
   1.564  		mapCenter->reposition();
   1.565  	}	
   1.566 @@ -2555,7 +2603,7 @@
   1.567  		if (bo->countBranches()==0) return;
   1.568  		if (bo->getDepth()==0) return;
   1.569  		setChanged();
   1.570 -		saveState(PartOfMap,selection);
   1.571 +		saveState(selection);
   1.572  		bo->toggleScroll();
   1.573  		adjustCanvasSize();
   1.574  		canvas()->update();
   1.575 @@ -2595,7 +2643,7 @@
   1.576  		if ( fd->exec() == QDialog::Accepted )
   1.577  		{
   1.578  			setChanged();
   1.579 -			saveState(PartOfMap,selection);
   1.580 +			saveState(selection);
   1.581  			QString fn=fd->selectedFile();
   1.582  			lastImageDir=fn.left(fn.findRev ("/"));
   1.583  			bo->addFloatImage();
   1.584 @@ -2816,25 +2864,10 @@
   1.585  		(typeid(*selection) == typeid(BranchObj)) )
   1.586  	{
   1.587  		QString s=((BranchObj*)(selection))->getHeading();
   1.588 -		parseTest (s);
   1.589 +		parseAtom(s);
   1.590  	}
   1.591  }
   1.592  
   1.593 -void MapEditor::parseTest(const QString &s)
   1.594 -{
   1.595 -	API api;
   1.596 -	QString c,p,p0;
   1.597 -	api.parseCommand (s,c,p);
   1.598 -	if (c==QString("moveBranchUp"))
   1.599 -		moveBranchUp();
   1.600 -	else if (c=="moveBranchDown")
   1.601 -		moveBranchDown();
   1.602 -	else if (c=="select")
   1.603 -		select (p);
   1.604 -	else
   1.605 -		cout << "Don't know about command \""<<s<<"\".\n";
   1.606 -}
   1.607 -
   1.608  void MapEditor::ensureSelectionVisible()
   1.609  {
   1.610  	if (selection)
   1.611 @@ -3109,7 +3142,7 @@
   1.612  				{
   1.613  					// depth==1, mainbranch
   1.614  					setChanged();
   1.615 -					saveState(PartOfMap,lmosel);
   1.616 +					saveState(lmosel);
   1.617  					lmosel->move(p.x() -movingObj_start.x(), p.y()-movingObj_start.y() );		
   1.618  				} else
   1.619  				{
   1.620 @@ -3326,7 +3359,7 @@
   1.621  			selection=lmo;
   1.622  			selection->select();
   1.623  			setChanged();
   1.624 -			saveState(PartOfMap,selection);
   1.625 +			saveState(selection);
   1.626  			editHeading();
   1.627  		}
   1.628  	}