mapeditor.cpp
changeset 491 c58b3973337c
parent 486 9c86935835a4
child 494 eea7fa702968
     1.1 --- a/mapeditor.cpp	Thu May 17 20:19:03 2007 +0000
     1.2 +++ b/mapeditor.cpp	Thu May 17 20:19:03 2007 +0000
     1.3 @@ -26,6 +26,7 @@
     1.4  extern Main *mainWindow;
     1.5  extern QString tmpVymDir;
     1.6  extern QString clipboardDir;
     1.7 +extern QString clipboardFile;
     1.8  extern bool clipboardEmpty;
     1.9  extern bool debug;
    1.10  extern FlagRowObj *standardFlagsDefault;
    1.11 @@ -115,6 +116,7 @@
    1.12  
    1.13  	stepsTotal=settings.readNumEntry("/mapeditor/stepsTotal",100);
    1.14  	undoSet.setEntry ("/history/stepsTotal",QString::number(stepsTotal));
    1.15 +	mainWindow->updateHistory (undoSet);
    1.16  	
    1.17  	// Initialize find routine
    1.18  	itFind=NULL;				
    1.19 @@ -160,6 +162,21 @@
    1.20      return mapScene;
    1.21  }
    1.22  
    1.23 +MapEditor::State MapEditor::getState()
    1.24 +{
    1.25 +    return state;
    1.26 +}
    1.27 +
    1.28 +void MapEditor::setStateEditHeading(bool s)
    1.29 +{
    1.30 +	if (s)
    1.31 +	{
    1.32 +		if (state==Idle) state=EditHeading;
    1.33 +	}
    1.34 +	else	
    1.35 +		state=Idle;
    1.36 +}
    1.37 +
    1.38  bool MapEditor::isRepositionBlocked()
    1.39  {
    1.40  	return blockReposition;
    1.41 @@ -170,6 +187,14 @@
    1.42  	blockSaveState=b;
    1.43  }
    1.44  
    1.45 +bool MapEditor::isSelectBlocked()
    1.46 +{
    1.47 +	if (state==EditHeading)
    1.48 +		return true;
    1.49 +	else
    1.50 +		return false; 
    1.51 +}
    1.52 +
    1.53  QString MapEditor::getName (const LinkableMapObj *lmo)
    1.54  {
    1.55  	QString s;
    1.56 @@ -287,8 +312,6 @@
    1.57  
    1.58  	if (blockSaveState) return;
    1.59  
    1.60 -	/* TODO remove after testing
    1.61 -	*/
    1.62  	if (debug) cout << "ME::saveState() for  "<<mapName.ascii()<<endl;
    1.63  	
    1.64  	int undosAvail=undoSet.readNumEntry ("/history/undosAvail",0);
    1.65 @@ -569,9 +592,9 @@
    1.66  		if (xelection.isEmpty())
    1.67  		{
    1.68  			parser.setError (Aborted,"Nothing selected");
    1.69 -		} else if ( xelection.type()!=Branch  && 
    1.70 -					xelection.type()!=MapCenter  &&
    1.71 -					xelection.type()!=FloatImage )
    1.72 +		} else if ( xelection.type()!=Selection::Branch  && 
    1.73 +					xelection.type()!=Selection::MapCenter  &&
    1.74 +					xelection.type()!=Selection::FloatImage )
    1.75  		{				  
    1.76  			parser.setError (Aborted,"Type of selection is not a branch or floatimage");
    1.77  		} else if (parser.checkParamCount(0))
    1.78 @@ -583,7 +606,7 @@
    1.79  		if (xelection.isEmpty())
    1.80  		{
    1.81  			parser.setError (Aborted,"Nothing selected");
    1.82 -		} else if (xelection.type() != Branch && xelection.type() != FloatImage )
    1.83 +		} else if (xelection.type() != Selection::Branch && xelection.type() != Selection::FloatImage )
    1.84  		{
    1.85  			parser.setError (Aborted,"Type of selection is wrong.");
    1.86  		} else if (parser.checkParamCount(0))
    1.87 @@ -614,6 +637,19 @@
    1.88  		{	
    1.89  			deleteChilds();
    1.90  		}	
    1.91 +	} else if (com=="importDir")
    1.92 +	{
    1.93 +		if (xelection.isEmpty())
    1.94 +		{
    1.95 +			parser.setError (Aborted,"Nothing selected");
    1.96 +		} else if (! selb )
    1.97 +		{				  
    1.98 +			parser.setError (Aborted,"Type of selection is not a branch");
    1.99 +		} else if (parser.checkParamCount(1))
   1.100 +		{
   1.101 +			s=parser.parString(ok,0);
   1.102 +			if (ok) importDirInt(s);
   1.103 +		}	
   1.104  	} else if (com=="linkTo")
   1.105  	{
   1.106  		if (xelection.isEmpty())
   1.107 @@ -649,7 +685,7 @@
   1.108  					}	
   1.109  				}	
   1.110  			}	
   1.111 -		} else if ( xelection.type() == FloatImage) 
   1.112 +		} else if ( xelection.type() == Selection::FloatImage) 
   1.113  		{
   1.114  			if (parser.checkParamCount(1))
   1.115  			{
   1.116 @@ -708,9 +744,9 @@
   1.117  		if (xelection.isEmpty() )
   1.118  		{
   1.119  			parser.setError (Aborted,"Nothing selected");
   1.120 -		} else if ( xelection.type()!=Branch  && 
   1.121 -					xelection.type()!=MapCenter  &&
   1.122 -					xelection.type()!=FloatImage )
   1.123 +		} else if ( xelection.type()!=Selection::Branch  && 
   1.124 +					xelection.type()!=Selection::MapCenter  &&
   1.125 +					xelection.type()!=Selection::FloatImage )
   1.126  		{				  
   1.127  			parser.setError (Aborted,"Type of selection is not a branch or floatimage");
   1.128  		} else if (parser.checkParamCount(2))
   1.129 @@ -727,9 +763,9 @@
   1.130  		if (xelection.isEmpty() )
   1.131  		{
   1.132  			parser.setError (Aborted,"Nothing selected");
   1.133 -		} else if ( xelection.type()!=Branch  && 
   1.134 -					xelection.type()!=MapCenter  &&
   1.135 -					xelection.type()!=FloatImage )
   1.136 +		} else if ( xelection.type()!=Selection::Selection::Branch  && 
   1.137 +					xelection.type()!=Selection::Selection::MapCenter  &&
   1.138 +					xelection.type()!=Selection::Selection::FloatImage )
   1.139  		{				  
   1.140  			parser.setError (Aborted,"Type of selection is not a branch or floatimage");
   1.141  		} else if (parser.checkParamCount(2))
   1.142 @@ -822,7 +858,7 @@
   1.143  		}	
   1.144  	} else if (com=="setFrameType")
   1.145  	{
   1.146 -		if ( xelection.type()!=Branch && xelection.type()!= MapCenter && xelection.type()!=FloatImage)
   1.147 +		if ( xelection.type()!=Selection::Branch && xelection.type()!= Selection::MapCenter && xelection.type()!=Selection::FloatImage)
   1.148  		{
   1.149  			parser.setError (Aborted,"Type of selection does not allow setting frame type");
   1.150  		}
   1.151 @@ -833,7 +869,7 @@
   1.152  		}	
   1.153  	} else if (com=="setFramePenColor")
   1.154  	{
   1.155 -		if ( xelection.type()!=Branch && xelection.type()!= MapCenter && xelection.type()!=FloatImage)
   1.156 +		if ( xelection.type()!=Selection::Branch && xelection.type()!= Selection::MapCenter && xelection.type()!=Selection::FloatImage)
   1.157  		{
   1.158  			parser.setError (Aborted,"Type of selection does not allow setting of pen color");
   1.159  		}
   1.160 @@ -844,7 +880,7 @@
   1.161  		}	
   1.162  	} else if (com=="setFrameBrushColor")
   1.163  	{
   1.164 -		if ( xelection.type()!=Branch && xelection.type()!= MapCenter && xelection.type()!=FloatImage)
   1.165 +		if ( xelection.type()!=Selection::Branch && xelection.type()!= Selection::MapCenter && xelection.type()!=Selection::FloatImage)
   1.166  		{
   1.167  			parser.setError (Aborted,"Type of selection does not allow setting brush color");
   1.168  		}
   1.169 @@ -855,7 +891,7 @@
   1.170  		}	
   1.171  	} else if (com=="setFramePadding")
   1.172  	{
   1.173 -		if ( xelection.type()!=Branch && xelection.type()!= MapCenter && xelection.type()!=FloatImage)
   1.174 +		if ( xelection.type()!=Selection::Branch && xelection.type()!= Selection::MapCenter && xelection.type()!=Selection::FloatImage)
   1.175  		{
   1.176  			parser.setError (Aborted,"Type of selection does not allow setting frame padding");
   1.177  		}
   1.178 @@ -866,7 +902,7 @@
   1.179  		}	
   1.180  	} else if (com=="setFrameBorderWidth")
   1.181  	{
   1.182 -		if ( xelection.type()!=Branch && xelection.type()!= MapCenter && xelection.type()!=FloatImage)
   1.183 +		if ( xelection.type()!=Selection::Branch && xelection.type()!= Selection::MapCenter && xelection.type()!=Selection::FloatImage)
   1.184  		{
   1.185  			parser.setError (Aborted,"Type of selection does not allow setting frame border width");
   1.186  		}
   1.187 @@ -941,7 +977,7 @@
   1.188  		if (xelection.isEmpty() )
   1.189  		{
   1.190  			parser.setError (Aborted,"Nothing selected");
   1.191 -		} else if (xelection.type()!=Branch && xelection.type() != MapCenter &&xelection.type()!=FloatImage)
   1.192 +		} else if (xelection.type()!=Selection::Branch && xelection.type() != Selection::MapCenter &&xelection.type()!=Selection::FloatImage)
   1.193  		{				  
   1.194  			parser.setError (Aborted,"Type of selection is not a branch or floatimage");
   1.195  		} else if (parser.checkParamCount(1))
   1.196 @@ -975,6 +1011,19 @@
   1.197  			b=parser.parBool(ok,0);
   1.198  			if (ok) setIncludeImagesVer(b);
   1.199  		}
   1.200 +	} else if (com=="setHideLinkUnselected")
   1.201 +	{
   1.202 +		if (xelection.isEmpty() )
   1.203 +		{
   1.204 +			parser.setError (Aborted,"Nothing selected");
   1.205 +		} else if ( xelection.type()!=Selection::Branch && xelection.type()!= Selection::MapCenter && xelection.type()!=Selection::FloatImage)
   1.206 +		{				  
   1.207 +			parser.setError (Aborted,"Type of selection does not allow hiding the link");
   1.208 +		} else if (parser.checkParamCount(1))
   1.209 +		{
   1.210 +			b=parser.parBool(ok,0);
   1.211 +			if (ok) setHideLinkUnselected(b);
   1.212 +		}
   1.213  	} else if (com=="setSelectionColor")
   1.214  	{
   1.215  		if (parser.checkParamCount(1))
   1.216 @@ -993,7 +1042,7 @@
   1.217  		} else if (parser.checkParamCount(1))
   1.218  		{
   1.219  			s=parser.parString (ok,0);
   1.220 -			if (ok) setURLInt(s);
   1.221 +			if (ok) setURL(s);
   1.222  		}	
   1.223  	} else if (com=="setVymLink")
   1.224  	{
   1.225 @@ -1307,8 +1356,13 @@
   1.226  	if (savemode==CompleteMap || xelection.isEmpty())
   1.227  		saveFile=saveToDir (fileDir,mapName+"-",true,QPointF(),NULL);
   1.228  	else	
   1.229 -		//save () FIXME check FIO
   1.230 -		saveFile=saveToDir (fileDir,mapName+"-",true,QPointF(),xelection.getBranch());	
   1.231 +	{
   1.232 +		// TODO take care of multiselections
   1.233 +		if (xelection.type()==Selection::FloatImage)
   1.234 +			saveFloatImage();
   1.235 +		else	
   1.236 +			saveFile=saveToDir (fileDir,mapName+"-",true,QPointF(),xelection.getBranch());	
   1.237 +	}	
   1.238  
   1.239  	if (!saveStringToDisk(fileDir+fname,saveFile))
   1.240  		return 1;
   1.241 @@ -1556,11 +1610,10 @@
   1.242  	if (sel)
   1.243  	{
   1.244  		// write to directory
   1.245 -		QString clipfile="part";
   1.246 -		QString saveFile=saveToDir (fileDir,clipfile+"-",true,QPointF(),sel ); // FIXME check FIO
   1.247 +		QString saveFile=saveToDir (fileDir,clipboardFile+"-",true,QPointF(),sel ); // FIXME check FIO
   1.248  		QFile file;
   1.249  
   1.250 -		file.setName ( clipboardDir + "/"+clipfile+".xml");
   1.251 +		file.setName ( clipboardDir + "/"+clipboardFile);
   1.252  		if ( !file.open( QIODevice::WriteOnly ) )
   1.253  		{
   1.254  			// This should neverever happen
   1.255 @@ -1761,7 +1814,11 @@
   1.256  	}	
   1.257  	// Clicking below current step makes us redo things
   1.258  	if (i>undosAvail) 
   1.259 -		for (int j=undosAvail; j<i; j++) redo();
   1.260 +		for (int j=undosAvail; j<i; j++) 
   1.261 +		{
   1.262 +		cout << "redo "<<j<<"/"<<undosAvail<<" i="<<i<<endl;
   1.263 +		redo();
   1.264 +		}
   1.265  
   1.266  	// And ignore clicking the current row ;-)	
   1.267  }
   1.268 @@ -1843,13 +1900,10 @@
   1.269  
   1.270  void MapEditor::pasteNoSave()
   1.271  {
   1.272 -	load (clipboardDir+"/part.xml",ImportAdd);
   1.273 -}
   1.274 -
   1.275 -void MapEditor::cutNoSave()
   1.276 -{
   1.277 -	copy();
   1.278 -	deleteSelection();
   1.279 +	bool old=blockSaveState;
   1.280 +	blockSaveState=true;
   1.281 +	load (clipboardDir+"/"+clipboardFile,ImportAdd);
   1.282 +	blockSaveState=old;
   1.283  }
   1.284  
   1.285  void MapEditor::paste()		// FIXME no pasting of FIO ???
   1.286 @@ -1857,13 +1911,13 @@
   1.287  	BranchObj *sel=xelection.getBranch();
   1.288  	if (sel)
   1.289  	{
   1.290 -		pasteNoSave();
   1.291  		saveStateChangingPart(
   1.292  			sel,
   1.293  			sel,
   1.294  			"paste ()",
   1.295  			QString("Paste to %1").arg( getName(sel))
   1.296  		);
   1.297 +		pasteNoSave();
   1.298  		mapCenter->reposition();
   1.299  	}
   1.300  }
   1.301 @@ -1871,18 +1925,20 @@
   1.302  void MapEditor::cut()
   1.303  {
   1.304  	LinkableMapObj *sel=xelection.single();
   1.305 -	if ( sel && (xelection.type() == Branch ||
   1.306 -		xelection.type()==MapCenter ||
   1.307 -		xelection.type()==FloatImage))
   1.308 +	if ( sel && (xelection.type() == Selection::Branch ||
   1.309 +		xelection.type()==Selection::MapCenter ||
   1.310 +		xelection.type()==Selection::FloatImage))
   1.311  	{
   1.312 +	/* No savestate! savestate is called in cutNoSave
   1.313  		saveStateChangingPart(
   1.314  			sel->getParObj(),
   1.315  			sel,
   1.316  			"cut ()",
   1.317  			QString("Cut %1").arg(getName(sel ))
   1.318  		);
   1.319 +	*/	
   1.320  		copy();
   1.321 -		cutNoSave();
   1.322 +		deleteSelection();
   1.323  		mapCenter->reposition();
   1.324  	}
   1.325  }
   1.326 @@ -1957,7 +2013,7 @@
   1.327  	}	
   1.328  }
   1.329  
   1.330 -void MapEditor::linkTo(const QString &dstString)	// FIXME needed? only for FIO ??
   1.331 +void MapEditor::linkTo(const QString &dstString)	
   1.332  {
   1.333  	FloatImageObj *fio=xelection.getFloatImage();
   1.334  	if (fio)
   1.335 @@ -2018,19 +2074,6 @@
   1.336  	}
   1.337  }
   1.338  
   1.339 -void MapEditor::setURLInt (const QString &s)
   1.340 -{
   1.341 -	// Internal function, no saveState needed
   1.342 -	BranchObj *bo=xelection.getBranch();
   1.343 -	if (bo)
   1.344 -	{
   1.345 -		bo->setURL(s);
   1.346 -		mapCenter->reposition();
   1.347 -		xelection.update();
   1.348 -		ensureSelectionVisible();
   1.349 -	}
   1.350 -}
   1.351 -
   1.352  void MapEditor::setHeadingInt(const QString &s)
   1.353  {
   1.354  	BranchObj *bo=xelection.getBranch();
   1.355 @@ -2051,6 +2094,7 @@
   1.356  	{
   1.357  		bo->setVymLink(s);
   1.358  		mapCenter->reposition();
   1.359 +		updateActions();
   1.360  		xelection.update();
   1.361  		ensureSelectionVisible();
   1.362  	}
   1.363 @@ -2124,7 +2168,7 @@
   1.364  {
   1.365  	BranchObj *newbo=NULL;
   1.366  	BranchObj *bo = xelection.getBranch();
   1.367 -	if (bo && xelection.type()==Branch)
   1.368 +	if (bo && xelection.type()==Selection::Branch)
   1.369  		 // We accept no MapCenterObj here, so we _have_ a parent
   1.370  	{
   1.371  		QPointF p=bo->getRelPos();
   1.372 @@ -2154,7 +2198,7 @@
   1.373  void MapEditor::deleteSelection()
   1.374  {
   1.375  	BranchObj *bo = xelection.getBranch();
   1.376 -	if (bo && xelection.type()==Branch)
   1.377 +	if (bo && xelection.type()==Selection::Branch)
   1.378  	{
   1.379  		BranchObj* par=(BranchObj*)(bo->getParObj());
   1.380  		xelection.unselect();
   1.381 @@ -2235,7 +2279,7 @@
   1.382  
   1.383  void MapEditor::selectInt (LinkableMapObj *lmo)
   1.384  {
   1.385 -	if (lmo && xelection.single()!= lmo)
   1.386 +	if (lmo && xelection.single()!= lmo && isSelectBlocked()==false )
   1.387  	{
   1.388  		xelection.select(lmo);
   1.389  		xelection.update();
   1.390 @@ -2406,8 +2450,10 @@
   1.391  
   1.392  void MapEditor::selectUpperBranch()
   1.393  {
   1.394 +	if (isSelectBlocked() ) return;
   1.395 +
   1.396  	BranchObj *bo=xelection.getBranch();
   1.397 -	if (bo && xelection.type()==Branch)
   1.398 +	if (bo && xelection.type()==Selection::Branch)
   1.399  	{
   1.400  		if (bo->getOrientation()==LinkableMapObj::RightOfCenter)
   1.401  			selectPrevBranchInt();
   1.402 @@ -2421,8 +2467,10 @@
   1.403  
   1.404  void MapEditor::selectLowerBranch()
   1.405  {
   1.406 +	if (isSelectBlocked() ) return;
   1.407 +
   1.408  	BranchObj *bo=xelection.getBranch();
   1.409 -	if (bo && xelection.type()==Branch)
   1.410 +	if (bo && xelection.type()==Selection::Branch)
   1.411  		if (bo->getOrientation()==LinkableMapObj::RightOfCenter)
   1.412  			selectNextBranchInt();
   1.413  		else
   1.414 @@ -2435,12 +2483,14 @@
   1.415  
   1.416  void MapEditor::selectLeftBranch()
   1.417  {
   1.418 +	if (isSelectBlocked() ) return;
   1.419 +
   1.420  	BranchObj* bo;
   1.421  	BranchObj* par;
   1.422  	LinkableMapObj *sel=xelection.single();
   1.423  	if (sel)
   1.424  	{
   1.425 -		if (xelection.type()== MapCenter)
   1.426 +		if (xelection.type()== Selection::MapCenter)
   1.427  		{
   1.428  			par=xelection.getBranch();
   1.429  			bo=par->getLastSelectedBranch();
   1.430 @@ -2462,8 +2512,8 @@
   1.431  			par=(BranchObj*)(sel->getParObj());
   1.432  			if (sel->getOrientation()==LinkableMapObj::RightOfCenter)
   1.433  			{
   1.434 -				if (xelection.type() == Branch ||
   1.435 -					xelection.type() == FloatImage)
   1.436 +				if (xelection.type() == Selection::Branch ||
   1.437 +					xelection.type() == Selection::FloatImage)
   1.438  				{
   1.439  					xelection.select(par);
   1.440  					xelection.update();
   1.441 @@ -2471,7 +2521,7 @@
   1.442  				}
   1.443  			} else
   1.444  			{
   1.445 -				if (xelection.type() == Branch )
   1.446 +				if (xelection.type() == Selection::Branch )
   1.447  				{
   1.448  					bo=xelection.getBranch()->getLastSelectedBranch();
   1.449  					if (bo) 
   1.450 @@ -2488,12 +2538,14 @@
   1.451  
   1.452  void MapEditor::selectRightBranch()
   1.453  {
   1.454 +	if (isSelectBlocked() ) return;
   1.455 +
   1.456  	BranchObj* bo;
   1.457  	BranchObj* par;
   1.458  	LinkableMapObj *sel=xelection.single();
   1.459  	if (sel)
   1.460  	{
   1.461 -		if (xelection.type()==MapCenter) 
   1.462 +		if (xelection.type()==Selection::MapCenter) 
   1.463  		{
   1.464  			par=xelection.getBranch();
   1.465  			bo=par->getLastSelectedBranch();
   1.466 @@ -2514,8 +2566,8 @@
   1.467  			par=(BranchObj*)(xelection.single()->getParObj());
   1.468  			if (xelection.single()->getOrientation()==LinkableMapObj::LeftOfCenter)
   1.469  			{
   1.470 -				if (xelection.type() == Branch ||
   1.471 -					xelection.type() == FloatImage)
   1.472 +				if (xelection.type() == Selection::Branch ||
   1.473 +					xelection.type() == Selection::FloatImage)
   1.474  				{
   1.475  					xelection.select(par);
   1.476  					xelection.update();
   1.477 @@ -2523,7 +2575,7 @@
   1.478  				}
   1.479  			} else
   1.480  			{
   1.481 -				if (xelection.type()  == Branch) 
   1.482 +				if (xelection.type()  == Selection::Branch) 
   1.483  				{
   1.484  					bo=xelection.getBranch()->getLastSelectedBranch();
   1.485  					if (bo) 
   1.486 @@ -2776,6 +2828,9 @@
   1.487  			QString ("set URL of %1 to %2").arg(getName(bo)).arg(url)
   1.488  		);
   1.489  		updateActions();
   1.490 +		mapCenter->reposition();
   1.491 +		xelection.update();
   1.492 +		ensureSelectionVisible();
   1.493  	}
   1.494  }	
   1.495  
   1.496 @@ -2881,10 +2936,7 @@
   1.497  				"setVymLink (\""+fd->selectedFile()+"\")",
   1.498  				QString("Set vymlink of %1 to %2").arg(getName(bo)).arg(fd->selectedFile())
   1.499  			);	
   1.500 -			bo->setVymLink (fd->selectedFile() );
   1.501 -			updateActions();
   1.502 -			mapCenter->reposition();
   1.503 -			scene()->update();
   1.504 +			setVymLinkInt (fd->selectedFile() );
   1.505  		}
   1.506  	}
   1.507  }
   1.508 @@ -2926,6 +2978,7 @@
   1.509  		);	
   1.510  		updateActions();
   1.511  		mapCenter->reposition();
   1.512 +		xelection.update();
   1.513  		scene()->update();
   1.514  	}
   1.515  }
   1.516 @@ -2995,7 +3048,7 @@
   1.517  	if (bo)
   1.518  	{		
   1.519  		saveStateChangingPart(
   1.520 -			bo->getParObj(), 
   1.521 +			bo, 
   1.522  			bo,
   1.523  			"deleteChilds ()",
   1.524  			QString( "Remove childs of branch %1").arg(getName(bo))
   1.525 @@ -3264,6 +3317,7 @@
   1.526  			QString ("%1 %2").arg(r).arg(getName(bo))
   1.527  		);
   1.528  		bo->toggleScroll();
   1.529 +		xelection.update();
   1.530  		scene()->update();
   1.531  		return true;
   1.532  	}	
   1.533 @@ -3288,6 +3342,7 @@
   1.534  			QString ("%1 %2").arg(r).arg(getName(bo))
   1.535  		);
   1.536  		bo->toggleScroll();
   1.537 +		xelection.update();
   1.538  		scene()->update();
   1.539  		return true;
   1.540  	}	
   1.541 @@ -3297,7 +3352,7 @@
   1.542  void MapEditor::toggleScroll()
   1.543  {
   1.544  	BranchObj *bo=xelection.getBranch();
   1.545 -	if (xelection.type()==Branch )
   1.546 +	if (xelection.type()==Selection::Branch )
   1.547  	{
   1.548  		if (bo->isScrolled())
   1.549  			unscrollBranch (bo);
   1.550 @@ -3355,7 +3410,7 @@
   1.551  
   1.552  		if ( fd->exec() == QDialog::Accepted )
   1.553  		{
   1.554 -			// FIXME loadFIO in QT4 use:	lastImageDir=fd->directory();
   1.555 +			// TODO loadFIO in QT4 use:	lastImageDir=fd->directory();
   1.556  			lastImageDir=QDir (fd->dirPath());
   1.557  			QString s;
   1.558  			FloatImageObj *fio;
   1.559 @@ -3372,7 +3427,7 @@
   1.560  						QString("Add image %1 to %2").arg(s).arg(getName(bo))
   1.561  					);
   1.562  				else
   1.563 -					// FIXME loadFIO error handling
   1.564 +					// TODO loadFIO error handling
   1.565  					qWarning ("Failed to load "+s);
   1.566  			}
   1.567  		}
   1.568 @@ -3548,17 +3603,29 @@
   1.569  	}	
   1.570  }
   1.571  
   1.572 -void MapEditor::setHideLinkUnselected (bool b)	// FIXME missing saveState
   1.573 +void MapEditor::setHideLinkUnselected (bool b)
   1.574  {
   1.575  	LinkableMapObj *sel=xelection.single();
   1.576  	if (sel &&
   1.577 -		(xelection.type() == Branch || 
   1.578 -		xelection.type() == MapCenter  ||
   1.579 -		xelection.type() == FloatImage ))
   1.580 +		(xelection.type() == Selection::Branch || 
   1.581 +		xelection.type() == Selection::MapCenter  ||
   1.582 +		xelection.type() == Selection::FloatImage ))
   1.583 +	{
   1.584 +		QString u= b ? "false" : "true";
   1.585 +		QString r=!b ? "false" : "true";
   1.586 +		
   1.587 +		saveState(
   1.588 +			sel,
   1.589 +			QString("setHideLinkUnselected (%1)").arg(u),
   1.590 +			sel, 
   1.591 +			QString("setHideLinkUnselected (%1)").arg(r),
   1.592 +			QString("Hide link of %1 if unselected").arg(getName(sel))
   1.593 +		);	
   1.594  		sel->setHideLinkUnselected(b);
   1.595 +	}
   1.596  }
   1.597  
   1.598 -void MapEditor::importDirInt(BranchObj *dst, QDir d)	// FIXME missing saveState
   1.599 +void MapEditor::importDirInt(BranchObj *dst, QDir d)
   1.600  {
   1.601  	BranchObj *bo=xelection.getBranch();
   1.602  	if (bo)
   1.603 @@ -3605,6 +3672,18 @@
   1.604  	}		
   1.605  }
   1.606  
   1.607 +void MapEditor::importDirInt (const QString &s)
   1.608 +{
   1.609 +	BranchObj *bo=xelection.getBranch();
   1.610 +	if (bo)
   1.611 +	{
   1.612 +		saveStateChangingPart (bo,bo,QString ("importDir (\"%1\")").arg(s),QString("Import directory structure from %1").arg(s));
   1.613 +
   1.614 +		QDir d(s);
   1.615 +		importDirInt (bo,d);
   1.616 +	}
   1.617 +}	
   1.618 +
   1.619  void MapEditor::importDir()
   1.620  {
   1.621  	BranchObj *bo=xelection.getBranch();
   1.622 @@ -3621,7 +3700,7 @@
   1.623  		QString fn;
   1.624  		if ( fd->exec() == QDialog::Accepted )
   1.625  		{
   1.626 -			importDirInt (bo,QDir(fd->selectedFile()) );
   1.627 +			importDirInt (fd->selectedFile() );
   1.628  			mapCenter->reposition();
   1.629  			scene()->update();
   1.630  		}
   1.631 @@ -3790,6 +3869,13 @@
   1.632  		return;
   1.633  	}
   1.634  
   1.635 +	//Ignore clicks while editing heading
   1.636 +	if (isSelectBlocked() ) 
   1.637 +	{
   1.638 +		e->ignore();
   1.639 +		return;
   1.640 +	}
   1.641 +
   1.642      QPointF p = mapToScene(e->pos());
   1.643      LinkableMapObj* lmo=mapCenter->findMapObj(p, NULL);
   1.644  	
   1.645 @@ -3880,7 +3966,7 @@
   1.646  			if (mainWindow->getModMode()==Main::ModModeCopy &&
   1.647  				e->state() & Qt::ControlModifier)
   1.648  			{
   1.649 -				if (xelection.type()==Branch)
   1.650 +				if (xelection.type()==Selection::Branch)
   1.651  				{
   1.652  					copyingObj=true;
   1.653  					mapCenter->addBranch ((BranchObj*)xelection.single());
   1.654 @@ -4081,7 +4167,7 @@
   1.655  	}
   1.656  
   1.657  	// Have we been drawing a link?
   1.658 -	if (drawingLink)	//FIXME savestate missing
   1.659 +	if (drawingLink)	
   1.660  	{
   1.661  		drawingLink=false;
   1.662  		// Check if we are over another branch
   1.663 @@ -4090,7 +4176,7 @@
   1.664  		{	
   1.665  			tmpXLink->setEnd ( ((BranchObj*)(dst)) );
   1.666  			tmpXLink->updateXLink();
   1.667 -			tmpXLink->activate();
   1.668 +			tmpXLink->activate(); //FIXME savestate missing
   1.669  			//saveStateComplete(QString("Activate xLink from %1 to %2").arg(getName(tmpXLink->getBegin())).arg(getName(tmpXLink->getEnd())) );	
   1.670  		} else
   1.671  		{
   1.672 @@ -4127,11 +4213,11 @@
   1.673  		if (dst && (typeid(*dst)!=typeid(BranchObj) && typeid(*dst)!=typeid(MapCenterObj))) 
   1.674  			dst=NULL;
   1.675  		
   1.676 -		if (xelection.type() == MapCenter )
   1.677 +		if (xelection.type() == Selection::MapCenter )
   1.678  		{	// FIXME The MapCenter was moved, no savestate yet
   1.679  		}
   1.680  		
   1.681 -		if (xelection.type() == Branch )
   1.682 +		if (xelection.type() == Selection::Branch )
   1.683  		{	// A branch was moved
   1.684  			
   1.685  			// save the position in case we link to mapcenter
   1.686 @@ -4216,6 +4302,12 @@
   1.687  
   1.688  void MapEditor::mouseDoubleClickEvent(QMouseEvent* e)
   1.689  {
   1.690 +	if (isSelectBlocked() ) 
   1.691 +	{
   1.692 +		e->ignore();
   1.693 +		return;
   1.694 +	}
   1.695 +
   1.696  	if (e->button() == Qt::LeftButton )
   1.697  	{
   1.698  		QPointF p = mapToScene(e->pos());
   1.699 @@ -4310,7 +4402,7 @@
   1.700  	event->acceptProposedAction();
   1.701  }
   1.702  
   1.703 -void MapEditor::timerEvent(QTimerEvent *event)  //FIXME testing
   1.704 +void MapEditor::timerEvent(QTimerEvent *event)  //TODO animation
   1.705  {
   1.706      Q_UNUSED(event);
   1.707  
   1.708 @@ -4326,12 +4418,12 @@
   1.709  
   1.710  void MapEditor::autosave()
   1.711  {
   1.712 -	if (mapUnsaved &&mapChanged && settings.value ("/mapeditor/autosave/used",true).toBool() )
   1.713 +	if (mapUnsaved &&mapChanged && settings.value ("/mapeditor/autosave/use",true).toBool() )
   1.714  		mainWindow->fileSave (this);
   1.715  }
   1.716  
   1.717  
   1.718 -/*FIXME not needed? void MapEditor::contentsDropEvent(QDropEvent *event) 
   1.719 +/*TODO not needed? void MapEditor::contentsDropEvent(QDropEvent *event) 
   1.720  {
   1.721  
   1.722  		} else if (event->provides("application/x-moz-file-promise-url") && 
   1.723 @@ -4401,7 +4493,7 @@
   1.724    {
   1.725  	FloatImageObj *fio=bo->addFloatImage();
   1.726      fio->load(img);
   1.727 -    fio->setOriginalFilename("Image added by Drag and Drop");	// FIXME savestate
   1.728 +    fio->setOriginalFilename("Image added by Drag and Drop");	// FIXME savestate missing
   1.729      mapCenter->reposition();
   1.730      scene()->update();
   1.731    }