mapeditor.cpp
changeset 432 f867269ab8a1
parent 431 c2ffbc9b832d
child 434 c585be63ec69
     1.1 --- a/mapeditor.cpp	Sat Feb 24 12:32:53 2007 +0000
     1.2 +++ b/mapeditor.cpp	Mon Mar 05 23:22:51 2007 +0000
     1.3 @@ -8,7 +8,7 @@
     1.4  
     1.5  #include "version.h"
     1.6  
     1.7 -#include "api.h"
     1.8 +#include "parser.h"
     1.9  #include "editxlinkdialog.h"
    1.10  #include "exports.h"
    1.11  #include "extrainfodialog.h"
    1.12 @@ -427,35 +427,34 @@
    1.13  void MapEditor::parseAtom(const QString &atom)
    1.14  {
    1.15  	BranchObj *selb=xelection.getBranch();
    1.16 -	API api;
    1.17  	QString s,t;
    1.18  	int x,y;
    1.19  	bool b,ok;
    1.20  
    1.21  	// Split string s into command and parameters
    1.22 -	api.parseInput (atom);
    1.23 -	QString com=api.command();
    1.24 +	parser.parseAtom (atom);
    1.25 +	QString com=parser.command();
    1.26  	
    1.27  	// External commands
    1.28  	if (com=="addBranch")
    1.29  	{
    1.30  		if (xelection.isEmpty())
    1.31  		{
    1.32 -			api.setError (Aborted,"Nothing selected");
    1.33 +			parser.setError (Aborted,"Nothing selected");
    1.34  		} else if (! selb )
    1.35  		{				  
    1.36 -			api.setError (Aborted,"Type of selection is not a branch");
    1.37 +			parser.setError (Aborted,"Type of selection is not a branch");
    1.38  		} else 
    1.39  		{	
    1.40  			QList <int> pl;
    1.41  			pl << 0 <<1;
    1.42 -			if (api.checkParamCount(pl))
    1.43 +			if (parser.checkParamCount(pl))
    1.44  			{
    1.45 -				if (api.paramCount()==0)
    1.46 +				if (parser.paramCount()==0)
    1.47  					addNewBranchInt (-2);
    1.48  				else
    1.49  				{
    1.50 -					y=api.parInt (ok,0);
    1.51 +					y=parser.parInt (ok,0);
    1.52  					if (ok ) addNewBranchInt (y);
    1.53  				}
    1.54  			}
    1.55 @@ -464,13 +463,13 @@
    1.56  	{
    1.57  		if (xelection.isEmpty())
    1.58  		{
    1.59 -			api.setError (Aborted,"Nothing selected");
    1.60 +			parser.setError (Aborted,"Nothing selected");
    1.61  		} else if (! selb )
    1.62  		{				  
    1.63 -			api.setError (Aborted,"Type of selection is not a branch");
    1.64 +			parser.setError (Aborted,"Type of selection is not a branch");
    1.65  		} else 
    1.66  		{	
    1.67 -			if (api.paramCount()==0)
    1.68 +			if (parser.paramCount()==0)
    1.69  			{
    1.70  				addNewBranchBefore ();
    1.71  			}	
    1.72 @@ -479,31 +478,31 @@
    1.73  	{
    1.74  		if (xelection.isEmpty())
    1.75  		{
    1.76 -			api.setError (Aborted,"Nothing selected");
    1.77 +			parser.setError (Aborted,"Nothing selected");
    1.78  		} else if (! selb )
    1.79  		{				  
    1.80 -			api.setError (Aborted,"Type of selection is not a branch");
    1.81 -		} else if (api.checkParamCount(1))
    1.82 +			parser.setError (Aborted,"Type of selection is not a branch");
    1.83 +		} else if (parser.checkParamCount(1))
    1.84  		{
    1.85 -			//s=api.parString (ok,0);	// selection
    1.86 -			t=api.parString (ok,0);	// path to map
    1.87 +			//s=parser.parString (ok,0);	// selection
    1.88 +			t=parser.parString (ok,0);	// path to map
    1.89  			if (QDir::isRelativePath(t)) t=QDir::convertSeparators (tmpMapDir + "/"+t);
    1.90  			addMapReplaceInt(selb->getSelectString(),t);	
    1.91  		}
    1.92 -	} else if (com==QString("addMapInsert"))
    1.93 +	} else if (com==QString("addMparsernsert"))
    1.94  	{
    1.95  		if (xelection.isEmpty())
    1.96  		{
    1.97 -			api.setError (Aborted,"Nothing selected");
    1.98 +			parser.setError (Aborted,"Nothing selected");
    1.99  		} else if (! selb )
   1.100  		{				  
   1.101 -			api.setError (Aborted,"Type of selection is not a branch");
   1.102 +			parser.setError (Aborted,"Type of selection is not a branch");
   1.103  		} else 
   1.104  		{	
   1.105 -			if (api.checkParamCount(2))
   1.106 +			if (parser.checkParamCount(2))
   1.107  			{
   1.108 -				t=api.parString (ok,0);	// path to map
   1.109 -				y=api.parInt(ok,1);		// position
   1.110 +				t=parser.parString (ok,0);	// path to map
   1.111 +				y=parser.parInt(ok,1);		// position
   1.112  				if (QDir::isRelativePath(t)) t=QDir::convertSeparators (tmpMapDir + "/"+t);
   1.113  				addMapInsertInt(t,y);	
   1.114  			}
   1.115 @@ -512,39 +511,39 @@
   1.116  	{
   1.117  		if (xelection.isEmpty())
   1.118  		{
   1.119 -			api.setError (Aborted,"Nothing selected");
   1.120 +			parser.setError (Aborted,"Nothing selected");
   1.121  		} else if (! selb )
   1.122  		{				  
   1.123 -			api.setError (Aborted,"Type of selection is not a branch");
   1.124 -		} else if (api.checkParamCount(1))
   1.125 +			parser.setError (Aborted,"Type of selection is not a branch");
   1.126 +		} else if (parser.checkParamCount(1))
   1.127  		{	
   1.128 -			QColor c=api.parColor (ok,0);
   1.129 +			QColor c=parser.parColor (ok,0);
   1.130  			if (ok) colorBranch (c);
   1.131  		}	
   1.132  	} else if (com=="colorSubtree")
   1.133  	{
   1.134  		if (xelection.isEmpty())
   1.135  		{
   1.136 -			api.setError (Aborted,"Nothing selected");
   1.137 +			parser.setError (Aborted,"Nothing selected");
   1.138  		} else if (! selb )
   1.139  		{				  
   1.140 -			api.setError (Aborted,"Type of selection is not a branch");
   1.141 -		} else if (api.checkParamCount(1))
   1.142 +			parser.setError (Aborted,"Type of selection is not a branch");
   1.143 +		} else if (parser.checkParamCount(1))
   1.144  		{	
   1.145 -			QColor c=api.parColor (ok,0);
   1.146 +			QColor c=parser.parColor (ok,0);
   1.147  			if (ok) colorSubtree (c);
   1.148  		}	
   1.149  	} else if (com=="cut")
   1.150  	{
   1.151  		if (xelection.isEmpty())
   1.152  		{
   1.153 -			api.setError (Aborted,"Nothing selected");
   1.154 +			parser.setError (Aborted,"Nothing selected");
   1.155  		} else if ( xelection.type()!=Branch  && 
   1.156  					xelection.type()!=MapCenter  &&
   1.157  					xelection.type()!=FloatImage )
   1.158  		{				  
   1.159 -			api.setError (Aborted,"Type of selection is not a branch or floatimage");
   1.160 -		} else if (api.checkParamCount(0))
   1.161 +			parser.setError (Aborted,"Type of selection is not a branch or floatimage");
   1.162 +		} else if (parser.checkParamCount(0))
   1.163  		{	
   1.164  			cut();
   1.165  		}	
   1.166 @@ -552,11 +551,11 @@
   1.167  	{
   1.168  		if (xelection.isEmpty())
   1.169  		{
   1.170 -			api.setError (Aborted,"Nothing selected");
   1.171 +			parser.setError (Aborted,"Nothing selected");
   1.172  		} else if (! selb )
   1.173  		{
   1.174 -			api.setError (Aborted,"Type of selection is not a branch");
   1.175 -		} else if (api.checkParamCount(0))
   1.176 +			parser.setError (Aborted,"Type of selection is not a branch");
   1.177 +		} else if (parser.checkParamCount(0))
   1.178  		{	
   1.179  			deleteSelection();
   1.180  		}	
   1.181 @@ -564,11 +563,11 @@
   1.182  	{
   1.183  		if (xelection.isEmpty())
   1.184  		{
   1.185 -			api.setError (Aborted,"Nothing selected");
   1.186 +			parser.setError (Aborted,"Nothing selected");
   1.187  		} else if (! selb )
   1.188  		{
   1.189 -			api.setError (Aborted,"Type of selection is not a branch");
   1.190 -		} else if (api.checkParamCount(0))
   1.191 +			parser.setError (Aborted,"Type of selection is not a branch");
   1.192 +		} else if (parser.checkParamCount(0))
   1.193  		{	
   1.194  			deleteKeepChilds();
   1.195  		}	
   1.196 @@ -576,11 +575,11 @@
   1.197  	{
   1.198  		if (xelection.isEmpty())
   1.199  		{
   1.200 -			api.setError (Aborted,"Nothing selected");
   1.201 +			parser.setError (Aborted,"Nothing selected");
   1.202  		} else if (! selb)
   1.203  		{
   1.204 -			api.setError (Aborted,"Type of selection is not a branch");
   1.205 -		} else if (api.checkParamCount(0))
   1.206 +			parser.setError (Aborted,"Type of selection is not a branch");
   1.207 +		} else if (parser.checkParamCount(0))
   1.208  		{	
   1.209  			deleteChilds();
   1.210  		}	
   1.211 @@ -588,32 +587,32 @@
   1.212  	{
   1.213  		if (xelection.isEmpty())
   1.214  		{
   1.215 -			api.setError (Aborted,"Nothing selected");
   1.216 +			parser.setError (Aborted,"Nothing selected");
   1.217  		} else if ( selb)
   1.218  		{
   1.219 -			if (api.checkParamCount(4))
   1.220 +			if (parser.checkParamCount(4))
   1.221  			{
   1.222  				// 0	selectstring of parent
   1.223  				// 1	num in parent (for branches)
   1.224  				// 2,3	x,y of mainbranch or mapcenter
   1.225 -				s=api.parString(ok,0);
   1.226 +				s=parser.parString(ok,0);
   1.227  				LinkableMapObj *dst=mapCenter->findObjBySelect (s);
   1.228  				if (dst)
   1.229  				{	
   1.230  					if (typeid(*dst) == typeid(BranchObj) ) 
   1.231  					{
   1.232  						// Get number in parent
   1.233 -						x=api.parInt (ok,1);
   1.234 +						x=parser.parInt (ok,1);
   1.235  						if (ok)
   1.236  							selb->linkTo ((BranchObj*)(dst),x);
   1.237  					} else if (typeid(*dst) == typeid(MapCenterObj) ) 
   1.238  					{
   1.239  						selb->linkTo ((BranchObj*)(dst),-1);
   1.240  						// Get coordinates of mainbranch
   1.241 -						x=api.parInt (ok,2);
   1.242 +						x=parser.parInt (ok,2);
   1.243  						if (ok)
   1.244  						{
   1.245 -							y=api.parInt (ok,3);
   1.246 +							y=parser.parInt (ok,3);
   1.247  							if (ok) selb->move (x,y);
   1.248  						}
   1.249  					}	
   1.250 @@ -621,10 +620,10 @@
   1.251  			}	
   1.252  		} else if ( xelection.type() == FloatImage) 
   1.253  		{
   1.254 -			if (api.checkParamCount(1))
   1.255 +			if (parser.checkParamCount(1))
   1.256  			{
   1.257  				// 0	selectstring of parent
   1.258 -				s=api.parString(ok,0);
   1.259 +				s=parser.parString(ok,0);
   1.260  				LinkableMapObj *dst=mapCenter->findObjBySelect (s);
   1.261  				if (dst)
   1.262  				{	
   1.263 @@ -632,19 +631,32 @@
   1.264  						typeid(*dst) == typeid(MapCenterObj)) 
   1.265  						linkTo (dst->getSelectString());
   1.266  				} else	
   1.267 -					api.setError (Aborted,"Destination is not a branch");
   1.268 +					parser.setError (Aborted,"Destination is not a branch");
   1.269  			}		
   1.270  		} else
   1.271 -			api.setError (Aborted,"Type of selection is not a floatimage or branch");
   1.272 +			parser.setError (Aborted,"Type of selection is not a floatimage or branch");
   1.273 +	} else if (com=="loadImage")
   1.274 +	{
   1.275 +		if (xelection.isEmpty())
   1.276 +		{
   1.277 +			parser.setError (Aborted,"Nothing selected");
   1.278 +		} else if (! selb )
   1.279 +		{				  
   1.280 +			parser.setError (Aborted,"Type of selection is not a branch");
   1.281 +		} else if (parser.checkParamCount(1))
   1.282 +		{
   1.283 +			s=parser.parString(ok,0);
   1.284 +			if (ok) loadFloatImageInt (s);
   1.285 +		}	
   1.286  	} else if (com=="moveBranchUp")
   1.287  	{
   1.288  		if (xelection.isEmpty() )
   1.289  		{
   1.290 -			api.setError (Aborted,"Nothing selected");
   1.291 +			parser.setError (Aborted,"Nothing selected");
   1.292  		} else if (! selb )
   1.293  		{				  
   1.294 -			api.setError (Aborted,"Type of selection is not a branch");
   1.295 -		} else if (api.checkParamCount(0))
   1.296 +			parser.setError (Aborted,"Type of selection is not a branch");
   1.297 +		} else if (parser.checkParamCount(0))
   1.298  		{
   1.299  			moveBranchUp();
   1.300  		}	
   1.301 @@ -652,11 +664,11 @@
   1.302  	{
   1.303  		if (xelection.isEmpty() )
   1.304  		{
   1.305 -			api.setError (Aborted,"Nothing selected");
   1.306 +			parser.setError (Aborted,"Nothing selected");
   1.307  		} else if (! selb )
   1.308  		{				  
   1.309 -			api.setError (Aborted,"Type of selection is not a branch");
   1.310 -		} else if (api.checkParamCount(0))
   1.311 +			parser.setError (Aborted,"Type of selection is not a branch");
   1.312 +		} else if (parser.checkParamCount(0))
   1.313  		{
   1.314  			moveBranchDown();
   1.315  		}	
   1.316 @@ -664,18 +676,18 @@
   1.317  	{
   1.318  		if (xelection.isEmpty() )
   1.319  		{
   1.320 -			api.setError (Aborted,"Nothing selected");
   1.321 +			parser.setError (Aborted,"Nothing selected");
   1.322  		} else if ( xelection.type()!=Branch  && 
   1.323  					xelection.type()!=MapCenter  &&
   1.324  					xelection.type()!=FloatImage )
   1.325  		{				  
   1.326 -			api.setError (Aborted,"Type of selection is not a branch or floatimage");
   1.327 -		} else if (api.checkParamCount(2))
   1.328 +			parser.setError (Aborted,"Type of selection is not a branch or floatimage");
   1.329 +		} else if (parser.checkParamCount(2))
   1.330  		{	
   1.331 -			x=api.parInt (ok,0);
   1.332 +			x=parser.parInt (ok,0);
   1.333  			if (ok)
   1.334  			{
   1.335 -				y=api.parInt (ok,1);
   1.336 +				y=parser.parInt (ok,1);
   1.337  				if (ok) move (x,y);
   1.338  			}
   1.339  		}	
   1.340 @@ -683,18 +695,18 @@
   1.341  	{
   1.342  		if (xelection.isEmpty() )
   1.343  		{
   1.344 -			api.setError (Aborted,"Nothing selected");
   1.345 +			parser.setError (Aborted,"Nothing selected");
   1.346  		} else if ( xelection.type()!=Branch  && 
   1.347  					xelection.type()!=MapCenter  &&
   1.348  					xelection.type()!=FloatImage )
   1.349  		{				  
   1.350 -			api.setError (Aborted,"Type of selection is not a branch or floatimage");
   1.351 -		} else if (api.checkParamCount(2))
   1.352 +			parser.setError (Aborted,"Type of selection is not a branch or floatimage");
   1.353 +		} else if (parser.checkParamCount(2))
   1.354  		{	
   1.355 -			x=api.parInt (ok,0);
   1.356 +			x=parser.parInt (ok,0);
   1.357  			if (ok)
   1.358  			{
   1.359 -				y=api.parInt (ok,1);
   1.360 +				y=parser.parInt (ok,1);
   1.361  				if (ok) moveRel (x,y);
   1.362  			}
   1.363  		}	
   1.364 @@ -702,11 +714,11 @@
   1.365  	{
   1.366  		if (xelection.isEmpty() )
   1.367  		{
   1.368 -			api.setError (Aborted,"Nothing selected");
   1.369 +			parser.setError (Aborted,"Nothing selected");
   1.370  		} else if (! selb )
   1.371  		{				  
   1.372 -			api.setError (Aborted,"Type of selection is not a branch");
   1.373 -		} else if (api.checkParamCount(0))
   1.374 +			parser.setError (Aborted,"Type of selection is not a branch");
   1.375 +		} else if (parser.checkParamCount(0))
   1.376  		{	
   1.377  			paste();
   1.378  		}	
   1.379 @@ -714,80 +726,96 @@
   1.380  	{
   1.381  		if (xelection.isEmpty() )
   1.382  		{
   1.383 -			api.setError (Aborted,"Nothing selected");
   1.384 +			parser.setError (Aborted,"Nothing selected");
   1.385  		} else if (! selb )
   1.386  		{				  
   1.387 -			api.setError (Aborted,"Type of selection is not a branch");
   1.388 -		} else if (api.checkParamCount(0))
   1.389 +			parser.setError (Aborted,"Type of selection is not a branch");
   1.390 +		} else if (parser.checkParamCount(0))
   1.391  		{	
   1.392  			if (!scrollBranch ())	
   1.393 -				api.setError (Aborted,"Could not scroll branch");
   1.394 +				parser.setError (Aborted,"Could not scroll branch");
   1.395  		}	
   1.396  	} else if (com=="select")
   1.397  	{
   1.398 -		if (api.checkParamCount(1))
   1.399 +		if (parser.checkParamCount(1))
   1.400  		{
   1.401 -			s=api.parString(ok,0);
   1.402 +			s=parser.parString(ok,0);
   1.403  			if (ok) select (s);
   1.404  		}	
   1.405 +	} else if (com=="selectLastBranch")
   1.406 +	{
   1.407 +		if (xelection.isEmpty() )
   1.408 +		{
   1.409 +			parser.setError (Aborted,"Nothing selected");
   1.410 +		} else if (! selb )
   1.411 +		{				  
   1.412 +			parser.setError (Aborted,"Type of selection is not a branch");
   1.413 +		} else if (parser.checkParamCount(0))
   1.414 +		{	
   1.415 +			BranchObj *bo=selb->getLastBranch();
   1.416 +			if (!bo)
   1.417 +				parser.setError (Aborted,"Could not select last branch");
   1.418 +			selectInt (bo);	
   1.419 +				
   1.420 +		}	
   1.421  	} else if (com=="setMapAuthor")
   1.422  	{
   1.423 -		if (api.checkParamCount(1))
   1.424 +		if (parser.checkParamCount(1))
   1.425  		{
   1.426 -			s=api.parString(ok,0);
   1.427 +			s=parser.parString(ok,0);
   1.428  			if (ok) setMapAuthor (s);
   1.429  		}	
   1.430  	} else if (com=="setMapComment")
   1.431  	{
   1.432 -		if (api.checkParamCount(1))
   1.433 +		if (parser.checkParamCount(1))
   1.434  		{
   1.435 -			s=api.parString(ok,0);
   1.436 +			s=parser.parString(ok,0);
   1.437  			if (ok) setMapComment(s);
   1.438  		}	
   1.439  	} else if (com=="setMapBackgroundColor")
   1.440  	{
   1.441  		if (xelection.isEmpty() )
   1.442  		{
   1.443 -			api.setError (Aborted,"Nothing selected");
   1.444 +			parser.setError (Aborted,"Nothing selected");
   1.445  		} else if (! xelection.getBranch() )
   1.446  		{				  
   1.447 -			api.setError (Aborted,"Type of selection is not a branch");
   1.448 -		} else if (api.checkParamCount(1))
   1.449 +			parser.setError (Aborted,"Type of selection is not a branch");
   1.450 +		} else if (parser.checkParamCount(1))
   1.451  		{
   1.452 -			QColor c=api.parColor (ok,0);
   1.453 +			QColor c=parser.parColor (ok,0);
   1.454  			if (ok) setMapBackgroundColor (c);
   1.455  		}	
   1.456  	} else if (com=="setMapDefLinkColor")
   1.457  	{
   1.458  		if (xelection.isEmpty() )
   1.459  		{
   1.460 -			api.setError (Aborted,"Nothing selected");
   1.461 +			parser.setError (Aborted,"Nothing selected");
   1.462  		} else if (! selb )
   1.463  		{				  
   1.464 -			api.setError (Aborted,"Type of selection is not a branch");
   1.465 -		} else if (api.checkParamCount(1))
   1.466 +			parser.setError (Aborted,"Type of selection is not a branch");
   1.467 +		} else if (parser.checkParamCount(1))
   1.468  		{
   1.469 -			QColor c=api.parColor (ok,0);
   1.470 +			QColor c=parser.parColor (ok,0);
   1.471  			if (ok) setMapDefLinkColor (c);
   1.472  		}	
   1.473  	} else if (com=="setMapLinkStyle")
   1.474  	{
   1.475 -		if (api.checkParamCount(1))
   1.476 +		if (parser.checkParamCount(1))
   1.477  		{
   1.478 -			s=api.parString (ok,0);
   1.479 +			s=parser.parString (ok,0);
   1.480  			if (ok) setMapLinkStyle(s);
   1.481  		}	
   1.482  	} else if (com=="setHeading")
   1.483  	{
   1.484  		if (xelection.isEmpty() )
   1.485  		{
   1.486 -			api.setError (Aborted,"Nothing selected");
   1.487 +			parser.setError (Aborted,"Nothing selected");
   1.488  		} else if (! selb )
   1.489  		{				  
   1.490 -			api.setError (Aborted,"Type of selection is not a branch");
   1.491 -		} else if (api.checkParamCount(1))
   1.492 +			parser.setError (Aborted,"Type of selection is not a branch");
   1.493 +		} else if (parser.checkParamCount(1))
   1.494  		{
   1.495 -			s=api.parString (ok,0);
   1.496 +			s=parser.parString (ok,0);
   1.497  			if (ok) 
   1.498  				setHeading (s);
   1.499  		}	
   1.500 @@ -795,39 +823,39 @@
   1.501  	{
   1.502  		if (xelection.isEmpty() )
   1.503  		{
   1.504 -			api.setError (Aborted,"Nothing selected");
   1.505 +			parser.setError (Aborted,"Nothing selected");
   1.506  		} else if (! selb)
   1.507  		{				  
   1.508 -			api.setError (Aborted,"Type of selection is not a branch or floatimage");
   1.509 -		} else if (api.checkParamCount(1))
   1.510 +			parser.setError (Aborted,"Type of selection is not a branch or floatimage");
   1.511 +		} else if (parser.checkParamCount(1))
   1.512  		{
   1.513 -			b=api.parBool(ok,0);
   1.514 +			b=parser.parBool(ok,0);
   1.515  			if (ok) setHideExport (b);
   1.516  		}
   1.517  	} else if (com=="setURL")
   1.518  	{
   1.519  		if (xelection.isEmpty() )
   1.520  		{
   1.521 -			api.setError (Aborted,"Nothing selected");
   1.522 +			parser.setError (Aborted,"Nothing selected");
   1.523  		} else if (! selb )
   1.524  		{				  
   1.525 -			api.setError (Aborted,"Type of selection is not a branch");
   1.526 -		} else if (api.checkParamCount(1))
   1.527 +			parser.setError (Aborted,"Type of selection is not a branch");
   1.528 +		} else if (parser.checkParamCount(1))
   1.529  		{
   1.530 -			s=api.parString (ok,0);
   1.531 +			s=parser.parString (ok,0);
   1.532  			if (ok) setURLInt(s);
   1.533  		}	
   1.534  	} else if (com=="setVymLink")
   1.535  	{
   1.536  		if (xelection.isEmpty() )
   1.537  		{
   1.538 -			api.setError (Aborted,"Nothing selected");
   1.539 +			parser.setError (Aborted,"Nothing selected");
   1.540  		} else if (! selb )
   1.541  		{				  
   1.542 -			api.setError (Aborted,"Type of selection is not a branch");
   1.543 -		} else if (api.checkParamCount(1))
   1.544 +			parser.setError (Aborted,"Type of selection is not a branch");
   1.545 +		} else if (parser.checkParamCount(1))
   1.546  		{
   1.547 -			s=api.parString (ok,0);
   1.548 +			s=parser.parString (ok,0);
   1.549  			if (ok) setVymLinkInt(s);
   1.550  		}	
   1.551  	}
   1.552 @@ -835,13 +863,13 @@
   1.553  	{
   1.554  		if (xelection.isEmpty() )
   1.555  		{
   1.556 -			api.setError (Aborted,"Nothing selected");
   1.557 +			parser.setError (Aborted,"Nothing selected");
   1.558  		} else if (! selb )
   1.559  		{				  
   1.560 -			api.setError (Aborted,"Type of selection is not a branch");
   1.561 -		} else if (api.checkParamCount(1))
   1.562 +			parser.setError (Aborted,"Type of selection is not a branch");
   1.563 +		} else if (parser.checkParamCount(1))
   1.564  		{
   1.565 -			s=api.parString(ok,0);
   1.566 +			s=parser.parString(ok,0);
   1.567  			if (ok) 
   1.568  			{
   1.569  				selb->activateStandardFlag(s);
   1.570 @@ -852,26 +880,26 @@
   1.571  	{
   1.572  		if (xelection.isEmpty() )
   1.573  		{
   1.574 -			api.setError (Aborted,"Nothing selected");
   1.575 +			parser.setError (Aborted,"Nothing selected");
   1.576  		} else if (! selb )
   1.577  		{				  
   1.578 -			api.setError (Aborted,"Type of selection is not a branch");
   1.579 -		} else if (api.checkParamCount(0))
   1.580 +			parser.setError (Aborted,"Type of selection is not a branch");
   1.581 +		} else if (parser.checkParamCount(0))
   1.582  		{	
   1.583  			if (!unscrollBranch ())	
   1.584 -				api.setError (Aborted,"Could not unscroll branch");
   1.585 +				parser.setError (Aborted,"Could not unscroll branch");
   1.586  		}	
   1.587  	} else if (com=="unsetFlag")
   1.588  	{
   1.589  		if (xelection.isEmpty() )
   1.590  		{
   1.591 -			api.setError (Aborted,"Nothing selected");
   1.592 +			parser.setError (Aborted,"Nothing selected");
   1.593  		} else if (! selb )
   1.594  		{				  
   1.595 -			api.setError (Aborted,"Type of selection is not a branch");
   1.596 -		} else if (api.checkParamCount(1))
   1.597 +			parser.setError (Aborted,"Type of selection is not a branch");
   1.598 +		} else if (parser.checkParamCount(1))
   1.599  		{
   1.600 -			s=api.parString(ok,0);
   1.601 +			s=parser.parString(ok,0);
   1.602  			if (ok) 
   1.603  			{
   1.604  				selb->deactivateStandardFlag(s);
   1.605 @@ -879,19 +907,43 @@
   1.606  			}	
   1.607  		}
   1.608  	} else
   1.609 -		api.setError (Aborted,"Unknown command");
   1.610 +		parser.setError (Aborted,"Unknown command");
   1.611  
   1.612  	// Any errors?
   1.613 -	if (api.errorLevel()==NoError)
   1.614 +	if (parser.errorLevel()==NoError)
   1.615 +	{
   1.616  		setChanged();
   1.617 +		mapCenter->reposition();
   1.618 +	}	
   1.619  	else	
   1.620  	{
   1.621  		// TODO Error handling
   1.622  		qWarning("MapEditor::parseAtom: Error!");
   1.623 -		qWarning(api.errorMessage());
   1.624 +		qWarning(parser.errorMessage());
   1.625  	} 
   1.626  }
   1.627  
   1.628 +void MapEditor::runScript (QString script)
   1.629 +{
   1.630 +	// TODO "atomize" script, currently each line holds one atom
   1.631 +
   1.632 +	QStringList list=script.split("\n");
   1.633 +	QString l;
   1.634 +	int pos;
   1.635 +	for (int i=0; i<list.size(); i++)
   1.636 +	{
   1.637 +		l=list.at(i);
   1.638 +
   1.639 +		// Ignore comments
   1.640 +		pos=l.indexOf ("#");
   1.641 +		if (pos>=0) l.truncate (pos);
   1.642 +
   1.643 +		// Try to ignore empty lines
   1.644 +		if (l.contains (QRegExp ("\\w")))
   1.645 +			parseAtom (l);
   1.646 +	}
   1.647 +
   1.648 +}
   1.649  
   1.650  bool MapEditor::isDefault()
   1.651  {
   1.652 @@ -3017,6 +3069,21 @@
   1.653  	}	
   1.654  }
   1.655  
   1.656 +FloatImageObj* MapEditor::loadFloatImageInt (QString fn)
   1.657 +{
   1.658 +	BranchObj *bo=xelection.getBranch();
   1.659 +	if (bo)
   1.660 +	{
   1.661 +		FloatImageObj *fio;
   1.662 +		bo->addFloatImage();
   1.663 +		fio=bo->getLastFloatImage();
   1.664 +		fio->load(fn);
   1.665 +		mapCenter->reposition();
   1.666 +		scene()->update();
   1.667 +		return fio;
   1.668 +	}
   1.669 +	return NULL;
   1.670 +}	
   1.671  
   1.672  void MapEditor::loadFloatImage ()
   1.673  {
   1.674 @@ -3035,34 +3102,28 @@
   1.675  		fd->setDir (lastImageDir);
   1.676  		fd->show();
   1.677  
   1.678 -		QString fn;
   1.679  		if ( fd->exec() == QDialog::Accepted )
   1.680  		{
   1.681  			// FIXME loadFIO in QT4 use:	lastImageDir=fd->directory();
   1.682  			lastImageDir=QDir (fd->dirPath());
   1.683 -			QStringList flist = fd->selectedFiles();
   1.684 -			QStringList::Iterator it = flist.begin();
   1.685 +			QString s;
   1.686  			FloatImageObj *fio;
   1.687 -			while( it != flist.end() ) 
   1.688 +			for (int j=0; j<fd->selectedFiles().count(); j++)
   1.689  			{
   1.690 -				fn = *it;
   1.691 -				bo->addFloatImage();
   1.692 -				fio=bo->getLastFloatImage();
   1.693 -				fio->load(*it);
   1.694 -				// FIXME loadFIO check if load of fio was successful
   1.695 -				saveState(
   1.696 -					(LinkableMapObj*)fio,
   1.697 -					"delete ()",
   1.698 -					bo, 
   1.699 -					QString ("loadFloatImage (%1)").arg(*it),
   1.700 -					QString("Add floatimage %1 to %2").arg(*it).arg(getName(bo))
   1.701 -				);
   1.702 -				bo->getLastFloatImage()->setOriginalFilename(fn);
   1.703 -				++it;
   1.704 +				s=fd->selectedFiles().at(j);
   1.705 +				fio=loadFloatImageInt (s);
   1.706 +				if (fio)
   1.707 +					saveState(
   1.708 +						(LinkableMapObj*)fio,
   1.709 +						"delete ()",
   1.710 +						bo, 
   1.711 +						QString ("loadImage (%1)").arg(s ),
   1.712 +						QString("Add image %1 to %2").arg(s).arg(getName(bo))
   1.713 +					);
   1.714 +				else
   1.715 +					// FIXME loadFIO error handling
   1.716 +					qWarning ("Failed to load "+s);
   1.717  			}
   1.718 -
   1.719 -			mapCenter->reposition();
   1.720 -			scene()->update();
   1.721  		}
   1.722  		delete (p);
   1.723  		delete (fd);
   1.724 @@ -3269,16 +3330,19 @@
   1.725  {
   1.726  	// This is the playground
   1.727  
   1.728 +	
   1.729 +/*
   1.730  	WarningDialog dia;
   1.731  	dia.showCancelButton (true);
   1.732  	dia.setText("This is a longer \nWarning");
   1.733  	dia.setCaption("Warning: Flux problem");
   1.734 -	dia.setShowAgainName("/warnings/mapeditor");
   1.735 +	dia.setShowAgainName("mapeditor/testDialog");
   1.736  	if (dia.exec()==QDialog::Accepted)
   1.737  		cout << "accepted!\n";
   1.738  	else	
   1.739  		cout << "canceled!\n";
   1.740  	return;
   1.741 +*/
   1.742  
   1.743  /* TODO Hide hidden stuff temporary, maybe add this as regular function somewhere
   1.744  	if (hidemode==HideNone)