mapeditor.cpp
changeset 473 8b9cfc26638c
parent 450 beb875135811
child 486 9c86935835a4
     1.1 --- a/mapeditor.cpp	Wed Apr 25 16:02:54 2007 +0000
     1.2 +++ b/mapeditor.cpp	Wed Apr 25 16:02:54 2007 +0000
     1.3 @@ -27,6 +27,7 @@
     1.4  extern QString tmpVymDir;
     1.5  extern QString clipboardDir;
     1.6  extern bool clipboardEmpty;
     1.7 +extern bool debug;
     1.8  extern FlagRowObj *standardFlagsDefault;
     1.9  
    1.10  extern QMenu* branchContextMenu;
    1.11 @@ -55,7 +56,7 @@
    1.12  ///////////////////////////////////////////////////////////////////////
    1.13  ///////////////////////////////////////////////////////////////////////
    1.14  MapEditor::MapEditor( QWidget* parent) :
    1.15 -  QGraphicsView(parent)
    1.16 +  QGraphicsView(parent)  
    1.17  {
    1.18  	//cout << "Constructor ME "<<this<<endl;
    1.19  	mapNum++;
    1.20 @@ -79,8 +80,8 @@
    1.21  
    1.22  	defLinkColor=QColor (0,0,255);
    1.23  	defXLinkColor=QColor (180,180,180);
    1.24 -	linkcolorhint=DefaultColor;
    1.25 -	linkstyle=StylePolyParabel;
    1.26 +	linkcolorhint=LinkableMapObj::DefaultColor;
    1.27 +	linkstyle=LinkableMapObj::PolyParabel;
    1.28  
    1.29  	// Create bitmap cursors, platform dependant
    1.30  	HandOpenCursor=QCursor (QPixmap(iconPath+"cursorhandopen.png"),1,1);		
    1.31 @@ -125,7 +126,7 @@
    1.32  	blockReposition=false;
    1.33  	blockSaveState=false;
    1.34  
    1.35 -	hidemode=HideNone;
    1.36 +	hidemode=BranchObj::HideNone;
    1.37  
    1.38  	// Create temporary files
    1.39  	makeTmpDirs();
    1.40 @@ -134,11 +135,19 @@
    1.41  
    1.42  	mapCenter->reposition();	//	for positioning heading
    1.43  
    1.44 +	// TODO animations
    1.45 +	animObjList.clear();
    1.46 +	//timerId = startTimer(100);  
    1.47 +
    1.48 +	// autosave
    1.49 +	autosaveTimer=new QTimer (this);
    1.50 +	connect(autosaveTimer, SIGNAL(timeout()), this, SLOT(autosave()));
    1.51  }
    1.52  
    1.53  MapEditor::~MapEditor()
    1.54  {
    1.55  	//cout <<"Destructor MapEditor\n";
    1.56 +	autosaveTimer->stop();
    1.57  }
    1.58  
    1.59  MapCenterObj* MapEditor::getMapCenter()
    1.60 @@ -156,6 +165,11 @@
    1.61  	return blockReposition;
    1.62  }
    1.63  
    1.64 +void MapEditor::setSaveStateBlocked(bool b)
    1.65 +{
    1.66 +	blockSaveState=b;
    1.67 +}
    1.68 +
    1.69  QString MapEditor::getName (const LinkableMapObj *lmo)
    1.70  {
    1.71  	QString s;
    1.72 @@ -197,13 +211,13 @@
    1.73  	QString ls;
    1.74  	switch (linkstyle)
    1.75  	{
    1.76 -		case StyleLine: 
    1.77 +		case LinkableMapObj::Line: 
    1.78  			ls="StyleLine";
    1.79  			break;
    1.80 -		case StyleParabel:
    1.81 +		case LinkableMapObj::Parabel:
    1.82  			ls="StyleParabel";
    1.83  			break;
    1.84 -		case StylePolyLine:	
    1.85 +		case LinkableMapObj::PolyLine:	
    1.86  			ls="StylePolyLine";
    1.87  			break;
    1.88  		default:
    1.89 @@ -213,7 +227,7 @@
    1.90  
    1.91  	QString s="<?xml version=\"1.0\" encoding=\"utf-8\"?><!DOCTYPE vymmap>\n";
    1.92  	QString colhint="";
    1.93 -	if (linkcolorhint==HeadingColor) 
    1.94 +	if (linkcolorhint==LinkableMapObj::HeadingColor) 
    1.95  		colhint=attribut("linkColorHint","HeadingColor");
    1.96  
    1.97  	QString mapAttr=attribut("version",vymVersion);
    1.98 @@ -349,7 +363,7 @@
    1.99  
   1.100  	/* TODO remove after testing
   1.101  	*/
   1.102 -	cout << "ME::saveState()  "<<endl;
   1.103 +	if (debug) cout << "ME::saveState() for  "<<mapName.ascii()<<endl;
   1.104  	
   1.105  	int undosAvail=undoSet.readNumEntry ("/history/undosAvail",0);
   1.106  	int redosAvail=undoSet.readNumEntry ("/history/redosAvail",0);
   1.107 @@ -404,21 +418,23 @@
   1.108  	undoSet.setEntry (QString("/history/version"),vymVersion);
   1.109  	undoSet.writeSettings(histPath);
   1.110  
   1.111 -	/* TODO remove after testing
   1.112 -	*/
   1.113 -	//cout << "          into="<< histPath.toStdString()<<endl;
   1.114 -	cout << "    stepsTotal="<<stepsTotal<<
   1.115 -	", undosAvail="<<undosAvail<<
   1.116 -	", redosAvail="<<redosAvail<<
   1.117 -	", curStep="<<curStep<<endl;
   1.118 -	cout << "    ---------------------------"<<endl;
   1.119 -	cout << "    comment="<<comment.toStdString()<<endl;
   1.120 -	cout << "    undoCom="<<undoCommand.toStdString()<<endl;
   1.121 -	cout << "    undoSel="<<undoSelection.toStdString()<<endl;
   1.122 -	cout << "    redoCom="<<redoCom.toStdString()<<endl;
   1.123 -	cout << "    redoSel="<<redoSelection.toStdString()<<endl;
   1.124 -	if (saveSel) cout << "    saveSel="<<saveSel->getSelectString().ascii()<<endl;
   1.125 -	cout << "    ---------------------------"<<endl;
   1.126 +	if (debug)
   1.127 +	{
   1.128 +		// TODO remove after testing
   1.129 +		//cout << "          into="<< histPath.toStdString()<<endl;
   1.130 +		cout << "    stepsTotal="<<stepsTotal<<
   1.131 +		", undosAvail="<<undosAvail<<
   1.132 +		", redosAvail="<<redosAvail<<
   1.133 +		", curStep="<<curStep<<endl;
   1.134 +		cout << "    ---------------------------"<<endl;
   1.135 +		cout << "    comment="<<comment.toStdString()<<endl;
   1.136 +		cout << "    undoCom="<<undoCommand.toStdString()<<endl;
   1.137 +		cout << "    undoSel="<<undoSelection.toStdString()<<endl;
   1.138 +		cout << "    redoCom="<<redoCom.toStdString()<<endl;
   1.139 +		cout << "    redoSel="<<redoSelection.toStdString()<<endl;
   1.140 +		if (saveSel) cout << "    saveSel="<<saveSel->getSelectString().ascii()<<endl;
   1.141 +		cout << "    ---------------------------"<<endl;
   1.142 +	}
   1.143  
   1.144  	mainWindow->updateHistory (undoSet);
   1.145  	setChanged();
   1.146 @@ -761,7 +777,7 @@
   1.147  			parser.setError (Aborted,"Type of selection is not a branch");
   1.148  		} else if (parser.checkParamCount(0))
   1.149  		{	
   1.150 -			if (!scrollBranch ())	
   1.151 +			if (!scrollBranch (selb))	
   1.152  				parser.setError (Aborted,"Could not scroll branch");
   1.153  		}	
   1.154  	} else if (com=="select")
   1.155 @@ -803,6 +819,17 @@
   1.156  			selectInt (fio);	
   1.157  				
   1.158  		}	
   1.159 +	} else if (com=="setFrameType")
   1.160 +	{
   1.161 +		if ( xelection.type()!=Branch && xelection.type()!= MapCenter && xelection.type()!=FloatImage)
   1.162 +		{
   1.163 +			parser.setError (Aborted,"Type of selection does not allow setting frame type");
   1.164 +		}
   1.165 +		else if (parser.checkParamCount(1))
   1.166 +		{
   1.167 +			s=parser.parString(ok,0);
   1.168 +			if (ok) setFrameType (s);
   1.169 +		}	
   1.170  	} else if (com=="setMapAuthor")
   1.171  	{
   1.172  		if (parser.checkParamCount(1))
   1.173 @@ -869,17 +896,16 @@
   1.174  		if (xelection.isEmpty() )
   1.175  		{
   1.176  			parser.setError (Aborted,"Nothing selected");
   1.177 -		} else if (! selb)
   1.178 +		} else if (xelection.type()!=Branch && xelection.type() != MapCenter &&xelection.type()!=FloatImage)
   1.179  		{				  
   1.180  			parser.setError (Aborted,"Type of selection is not a branch or floatimage");
   1.181 -			//FIXME selb is never a floatimage!!
   1.182  		} else if (parser.checkParamCount(1))
   1.183  		{
   1.184  			b=parser.parBool(ok,0);
   1.185  			if (ok) setHideExport (b);
   1.186  		}
   1.187  	} else if (com=="setIncludeImagesHorizontally")
   1.188 -	{
   1.189 +	{ 
   1.190  		if (xelection.isEmpty() )
   1.191  		{
   1.192  			parser.setError (Aborted,"Nothing selected");
   1.193 @@ -996,9 +1022,21 @@
   1.194  			parser.setError (Aborted,"Type of selection is not a branch");
   1.195  		} else if (parser.checkParamCount(0))
   1.196  		{	
   1.197 -			if (!unscrollBranch ())	
   1.198 +			if (!unscrollBranch (selb))	
   1.199  				parser.setError (Aborted,"Could not unscroll branch");
   1.200  		}	
   1.201 +	} else if (com=="unscrollChilds")
   1.202 +	{
   1.203 +		if (xelection.isEmpty() )
   1.204 +		{
   1.205 +			parser.setError (Aborted,"Nothing selected");
   1.206 +		} else if (! selb )
   1.207 +		{				  
   1.208 +			parser.setError (Aborted,"Type of selection is not a branch");
   1.209 +		} else if (parser.checkParamCount(0))
   1.210 +		{	
   1.211 +			unscrollChilds ();
   1.212 +		}	
   1.213  	} else if (com=="unsetFlag")
   1.214  	{
   1.215  		if (xelection.isEmpty() )
   1.216 @@ -1058,10 +1096,13 @@
   1.217  
   1.218  void MapEditor::setChanged()
   1.219  {
   1.220 +	if (!mapChanged)
   1.221 +		autosaveTimer->start(settings.value("/mapeditor/autosave/ms/",300000).toInt());
   1.222  	mapChanged=true;
   1.223  	mapDefault=false;
   1.224  	mapUnsaved=true;
   1.225  	findReset();
   1.226 +
   1.227  }
   1.228  
   1.229  void MapEditor::closeMap()
   1.230 @@ -1168,7 +1209,9 @@
   1.231  		err=aborted;	
   1.232  	} else
   1.233  	{
   1.234 +		bool blockSaveStateOrg=blockSaveState;
   1.235  		blockReposition=true;
   1.236 +		blockSaveState=true;
   1.237  		QXmlInputSource source( file);
   1.238  		QXmlSimpleReader reader;
   1.239  		reader.setContentHandler( &handler );
   1.240 @@ -1177,10 +1220,9 @@
   1.241  		handler.setTmpDir (filePath.left(filePath.findRev("/",-1)));	// needed to load files with rel. path
   1.242  		handler.setInputFile (file.name());
   1.243  		handler.setLoadMode (lmode);
   1.244 -		blockSaveState=true;
   1.245  		bool ok = reader.parse( source );
   1.246  		blockReposition=false;
   1.247 -		blockSaveState=false;
   1.248 +		blockSaveState=blockSaveStateOrg;
   1.249  		file.close();
   1.250  		if ( ok ) 
   1.251  		{
   1.252 @@ -1191,6 +1233,7 @@
   1.253  				mapDefault=false;
   1.254  				mapChanged=false;
   1.255  				mapUnsaved=false;
   1.256 +				autosaveTimer->stop();
   1.257  			}
   1.258  		} else 
   1.259  		{
   1.260 @@ -1224,7 +1267,8 @@
   1.261  	if (savemode==CompleteMap || xelection.isEmpty())
   1.262  		saveFile=saveToDir (fileDir,mapName+"-",true,QPointF(),NULL);
   1.263  	else	
   1.264 -		saveFile=saveToDir (fileDir,mapName+"-",true,QPointF(),xelection.getBranch());	//FIXME check selected FIO
   1.265 +		//save () FIXME check FIO
   1.266 +		saveFile=saveToDir (fileDir,mapName+"-",true,QPointF(),xelection.getBranch());	
   1.267  
   1.268  	if (!saveStringToDisk(fileDir+fname,saveFile))
   1.269  		return 1;
   1.270 @@ -1233,6 +1277,7 @@
   1.271  	{
   1.272  		mapChanged=false;
   1.273  		mapUnsaved=false;
   1.274 +		autosaveTimer->stop();
   1.275  		updateActions();
   1.276  	}
   1.277  
   1.278 @@ -1373,7 +1418,7 @@
   1.279  	return pix;
   1.280  }
   1.281  
   1.282 -void MapEditor::setHideTmpMode (HideTmpMode mode)
   1.283 +void MapEditor::setHideTmpMode (BranchObj::HideTmpMode mode)
   1.284  {
   1.285  	hidemode=mode;
   1.286  	mapCenter->setHideTmp (hidemode);
   1.287 @@ -1381,7 +1426,7 @@
   1.288  	scene()->update();
   1.289  }
   1.290  
   1.291 -HideTmpMode MapEditor::getHideTmpMode()
   1.292 +BranchObj::HideTmpMode MapEditor::getHideTmpMode()
   1.293  {
   1.294  	return hidemode;
   1.295  }
   1.296 @@ -1399,9 +1444,9 @@
   1.297  	// should be called before and after exports
   1.298  	// depending on the settings
   1.299  	if (b && settings.value("/export/useHideExport","yes")=="yes")
   1.300 -		setHideTmpMode (HideExport);
   1.301 +		setHideTmpMode (BranchObj::HideExport);
   1.302  	else	
   1.303 -		setHideTmpMode (HideNone);
   1.304 +		setHideTmpMode (BranchObj::HideNone);
   1.305  }
   1.306  
   1.307  void MapEditor::exportImage(QString fn, QString format)
   1.308 @@ -1496,14 +1541,16 @@
   1.309  
   1.310  void MapEditor::redo()
   1.311  {
   1.312 -	blockSaveState=true;
   1.313 -	
   1.314  	// Restore variables
   1.315  	int curStep=undoSet.readNumEntry (QString("/history/curStep"));
   1.316  	int undosAvail=undoSet.readNumEntry (QString("/history/undosAvail"));
   1.317  	int redosAvail=undoSet.readNumEntry (QString("/history/redosAvail"));
   1.318  	// Can we undo at all?
   1.319  	if (redosAvail<1) return;
   1.320 +
   1.321 +	bool blockSaveStateOrg=blockSaveState;
   1.322 +	blockSaveState=true;
   1.323 +	
   1.324  	redosAvail--;
   1.325  
   1.326  	if (undosAvail<stepsTotal) undosAvail++;
   1.327 @@ -1524,19 +1571,20 @@
   1.328  	// Find out current undo directory
   1.329  	QString bakMapDir=QDir::convertSeparators (QString(tmpMapDir+"/undo-%1").arg(curStep));
   1.330  
   1.331 -/* TODO remove testing
   1.332 -*/
   1.333 -	cout << "ME::redo() begin\n";
   1.334 -	cout << "    undosAvail="<<undosAvail<<endl;
   1.335 -	cout << "    redosAvail="<<redosAvail<<endl;
   1.336 -	cout << "       curStep="<<curStep<<endl;
   1.337 -	cout << "    ---------------------------"<<endl;
   1.338 -	cout << "    comment="<<comment.toStdString()<<endl;
   1.339 -	cout << "    undoCom="<<undoCommand.toStdString()<<endl;
   1.340 -	cout << "    undoSel="<<undoSelection.toStdString()<<endl;
   1.341 -	cout << "    redoCom="<<redoCommand.toStdString()<<endl;
   1.342 -	cout << "    redoSel="<<redoSelection.toStdString()<<endl;
   1.343 -	cout << "    ---------------------------"<<endl<<endl;
   1.344 +	if (debug)
   1.345 +	{
   1.346 +		cout << "ME::redo() begin\n";
   1.347 +		cout << "    undosAvail="<<undosAvail<<endl;
   1.348 +		cout << "    redosAvail="<<redosAvail<<endl;
   1.349 +		cout << "       curStep="<<curStep<<endl;
   1.350 +		cout << "    ---------------------------"<<endl;
   1.351 +		cout << "    comment="<<comment.toStdString()<<endl;
   1.352 +		cout << "    undoCom="<<undoCommand.toStdString()<<endl;
   1.353 +		cout << "    undoSel="<<undoSelection.toStdString()<<endl;
   1.354 +		cout << "    redoCom="<<redoCommand.toStdString()<<endl;
   1.355 +		cout << "    redoSel="<<redoSelection.toStdString()<<endl;
   1.356 +		cout << "    ---------------------------"<<endl<<endl;
   1.357 +	}
   1.358  
   1.359  	// select  object before redo
   1.360  	if (!redoSelection.isEmpty())
   1.361 @@ -1546,7 +1594,7 @@
   1.362  	parseAtom (redoCommand);
   1.363  	mapCenter->reposition();
   1.364  
   1.365 -	blockSaveState=false;
   1.366 +	blockSaveState=blockSaveStateOrg;
   1.367  
   1.368  	undoSet.setEntry ("/history/undosAvail",QString::number(undosAvail));
   1.369  	undoSet.setEntry ("/history/redosAvail",QString::number(redosAvail));
   1.370 @@ -1577,8 +1625,6 @@
   1.371  
   1.372  void MapEditor::undo()
   1.373  {
   1.374 -	blockSaveState=true;
   1.375 -	
   1.376  	// Restore variables
   1.377  	int curStep=undoSet.readNumEntry (QString("/history/curStep"));
   1.378  	int undosAvail=undoSet.readNumEntry (QString("/history/undosAvail"));
   1.379 @@ -1587,6 +1633,9 @@
   1.380  	// Can we undo at all?
   1.381  	if (undosAvail<1) return;
   1.382  
   1.383 +	bool blockSaveStateOrg=blockSaveState;
   1.384 +	blockSaveState=true;
   1.385 +	
   1.386  	QString undoCommand=  undoSet.readEntry (QString("/history/step-%1/undoCommand").arg(curStep));
   1.387  	QString undoSelection=undoSet.readEntry (QString("/history/step-%1/undoSelection").arg(curStep));
   1.388  	QString redoCommand=  undoSet.readEntry (QString("/history/step-%1/redoCommand").arg(curStep));
   1.389 @@ -1605,19 +1654,20 @@
   1.390  	if (!undoSelection.isEmpty())
   1.391  		select (undoSelection);
   1.392  
   1.393 -/* TODO testing
   1.394 -*/	
   1.395 -	cout << "ME::undo() begin\n";
   1.396 -	cout << "    undosAvail="<<undosAvail<<endl;
   1.397 -	cout << "    redosAvail="<<redosAvail<<endl;
   1.398 -	cout << "       curStep="<<curStep<<endl;
   1.399 -	cout << "    ---------------------------"<<endl;
   1.400 -	cout << "    comment="<<comment.toStdString()<<endl;
   1.401 -	cout << "    undoCom="<<undoCommand.toStdString()<<endl;
   1.402 -	cout << "    undoSel="<<undoSelection.toStdString()<<endl;
   1.403 -	cout << "    redoCom="<<redoCommand.toStdString()<<endl;
   1.404 -	cout << "    redoSel="<<redoSelection.toStdString()<<endl;
   1.405 -	cout << "    ---------------------------"<<endl<<endl;
   1.406 +	if (debug)
   1.407 +	{
   1.408 +		cout << "ME::undo() begin\n";
   1.409 +		cout << "    undosAvail="<<undosAvail<<endl;
   1.410 +		cout << "    redosAvail="<<redosAvail<<endl;
   1.411 +		cout << "       curStep="<<curStep<<endl;
   1.412 +		cout << "    ---------------------------"<<endl;
   1.413 +		cout << "    comment="<<comment.toStdString()<<endl;
   1.414 +		cout << "    undoCom="<<undoCommand.toStdString()<<endl;
   1.415 +		cout << "    undoSel="<<undoSelection.toStdString()<<endl;
   1.416 +		cout << "    redoCom="<<redoCommand.toStdString()<<endl;
   1.417 +		cout << "    redoSel="<<redoSelection.toStdString()<<endl;
   1.418 +		cout << "    ---------------------------"<<endl<<endl;
   1.419 +	}	
   1.420  	parseAtom (undoCommand);
   1.421  	mapCenter->reposition();
   1.422  
   1.423 @@ -1627,7 +1677,7 @@
   1.424  
   1.425  	redosAvail++;
   1.426  
   1.427 -	blockSaveState=false;
   1.428 +	blockSaveState=blockSaveStateOrg;
   1.429  /* TODO remove testing
   1.430  	cout << "ME::undo() end\n";
   1.431  	cout << "    undosAvail="<<undosAvail<<endl;
   1.432 @@ -1808,7 +1858,7 @@
   1.433  			s, "move "+ps, 
   1.434  			s, "move "+qpointfToString (QPointF (x,y)), 
   1.435  			QString("Move %1 to  %2").arg(getName(sel)).arg(ps));
   1.436 -		sel->move(x,y);	// FIXME	xelection not moved automagically...
   1.437 +		sel->move(x,y);
   1.438  		mapCenter->reposition();
   1.439  		xelection.update();
   1.440  	}
   1.441 @@ -1841,11 +1891,8 @@
   1.442  	{
   1.443  		if (!bo->canMoveBranchUp()) return;
   1.444  		par=(BranchObj*)(bo->getParObj());
   1.445 -		xelection.unselect();		// FIXME needed?
   1.446 -		bo=par->moveBranchUp (bo);	// bo will be the one below selection
   1.447 -		xelection.reselect();
   1.448 -		//saveState (selection,"moveBranchDown ()",bo,"moveBranchUp ()",QString("Move up %1").arg(getName(bo)));
   1.449 -		saveState (bo,"moveBranchDown ()",bo,"moveBranchUp ()",QString("Move up %1").arg(getName(bo)));
   1.450 +		BranchObj *obo=par->moveBranchUp (bo);	// bo will be the one below selection
   1.451 +		saveState (bo->getSelectString(),"moveBranchDown ()",obo->getSelectString(),"moveBranchUp ()",QString("Move up %1").arg(getName(bo)));
   1.452  		mapCenter->reposition();
   1.453  		scene()->update();
   1.454  		xelection.update();
   1.455 @@ -1861,11 +1908,8 @@
   1.456  	{
   1.457  		if (!bo->canMoveBranchDown()) return;
   1.458  		par=(BranchObj*)(bo->getParObj());
   1.459 -		xelection.unselect();		// FIXME needed?
   1.460 -		bo=par->moveBranchDown(bo);	// bo will be the one above selection
   1.461 -		xelection.reselect();
   1.462 -		//saveState(selection,"moveBranchUp ()",bo,"moveBranchDown ()",QString("Move down %1").arg(getName(bo)));
   1.463 -		saveState(bo,"moveBranchUp ()",bo,"moveBranchDown ()",QString("Move down %1").arg(getName(bo)));
   1.464 +		BranchObj *obo=par->moveBranchDown(bo);	// bo will be the one above selection
   1.465 +		saveState(bo->getSelectString(),"moveBranchUp ()",obo->getSelectString(),"moveBranchDown ()",QString("Move down %1").arg(getName(bo)));
   1.466  		mapCenter->reposition();
   1.467  		scene()->update();
   1.468  		xelection.update();
   1.469 @@ -2209,7 +2253,7 @@
   1.470  			} else
   1.471  			{
   1.472  				// Special case, look at orientation
   1.473 -				if (xelection.single()->getOrientation()==OrientRightOfCenter)
   1.474 +				if (xelection.single()->getOrientation()==LinkableMapObj::RightOfCenter)
   1.475  					num=QString ("%1").arg(num.toUInt()+1);
   1.476  				else	
   1.477  					num=QString ("%1").arg(num.toUInt()-1);
   1.478 @@ -2291,7 +2335,7 @@
   1.479  			} else
   1.480  			{
   1.481  				// Special case, look at orientation
   1.482 -				if (xelection.single()->getOrientation()==OrientRightOfCenter)
   1.483 +				if (xelection.single()->getOrientation()==LinkableMapObj::RightOfCenter)
   1.484  					num=QString ("%1").arg(num.toInt()-1);
   1.485  				else	
   1.486  					num=QString ("%1").arg(num.toInt()+1);
   1.487 @@ -2325,7 +2369,7 @@
   1.488  	BranchObj *bo=xelection.getBranch();
   1.489  	if (bo && xelection.type()==Branch)
   1.490  	{
   1.491 -		if (bo->getOrientation()==OrientRightOfCenter)
   1.492 +		if (bo->getOrientation()==LinkableMapObj::RightOfCenter)
   1.493  			selectPrevBranchInt();
   1.494  		else
   1.495  			if (bo->getDepth()==1)
   1.496 @@ -2339,7 +2383,7 @@
   1.497  {
   1.498  	BranchObj *bo=xelection.getBranch();
   1.499  	if (bo && xelection.type()==Branch)
   1.500 -		if (bo->getOrientation()==OrientRightOfCenter)
   1.501 +		if (bo->getOrientation()==LinkableMapObj::RightOfCenter)
   1.502  			selectNextBranchInt();
   1.503  		else
   1.504  			if (bo->getDepth()==1)
   1.505 @@ -2363,7 +2407,7 @@
   1.506  			if (bo)
   1.507  			{
   1.508  				// Workaround for reselecting on left and right side
   1.509 -				if (bo->getOrientation()==OrientRightOfCenter)
   1.510 +				if (bo->getOrientation()==LinkableMapObj::RightOfCenter)
   1.511  					bo=par->getLastBranch();
   1.512  				if (bo)
   1.513  				{
   1.514 @@ -2376,7 +2420,7 @@
   1.515  		} else
   1.516  		{
   1.517  			par=(BranchObj*)(sel->getParObj());
   1.518 -			if (sel->getOrientation()==OrientRightOfCenter)
   1.519 +			if (sel->getOrientation()==LinkableMapObj::RightOfCenter)
   1.520  			{
   1.521  				if (xelection.type() == Branch ||
   1.522  					xelection.type() == FloatImage)
   1.523 @@ -2416,7 +2460,7 @@
   1.524  			if (bo)
   1.525  			{
   1.526  				// Workaround for reselecting on left and right side
   1.527 -				if (bo->getOrientation()==OrientLeftOfCenter)
   1.528 +				if (bo->getOrientation()==LinkableMapObj::LeftOfCenter)
   1.529  					bo=par->getFirstBranch();
   1.530  				if (bo)
   1.531  				{
   1.532 @@ -2428,7 +2472,7 @@
   1.533  		} else
   1.534  		{
   1.535  			par=(BranchObj*)(xelection.single()->getParObj());
   1.536 -			if (xelection.single()->getOrientation()==OrientLeftOfCenter)
   1.537 +			if (xelection.single()->getOrientation()==LinkableMapObj::LeftOfCenter)
   1.538  			{
   1.539  				if (xelection.type() == Branch ||
   1.540  					xelection.type() == FloatImage)
   1.541 @@ -3025,13 +3069,13 @@
   1.542  	);	
   1.543  
   1.544  	if (s=="StyleLine")
   1.545 -		linkstyle=StyleLine;
   1.546 +		linkstyle=LinkableMapObj::Line;
   1.547  	else if (s=="StyleParabel")
   1.548 -		linkstyle=StyleParabel;
   1.549 +		linkstyle=LinkableMapObj::Parabel;
   1.550  	else if (s=="StylePolyLine")
   1.551 -		linkstyle=StylePolyLine;
   1.552 +		linkstyle=LinkableMapObj::PolyLine;
   1.553  	else	
   1.554 -		linkstyle=StylePolyParabel;
   1.555 +		linkstyle=LinkableMapObj::PolyParabel;
   1.556  
   1.557  	BranchObj *bo;
   1.558  	bo=mapCenter->first();
   1.559 @@ -3044,7 +3088,7 @@
   1.560  	mapCenter->reposition();
   1.561  }
   1.562  
   1.563 -LinkStyle MapEditor::getMapLinkStyle ()
   1.564 +LinkableMapObj::Style MapEditor::getMapLinkStyle ()
   1.565  {
   1.566  	return linkstyle;
   1.567  }	
   1.568 @@ -3067,7 +3111,7 @@
   1.569  	}
   1.570  }
   1.571  
   1.572 -void MapEditor::setMapLinkColorHint(LinkColorHint lch)
   1.573 +void MapEditor::setMapLinkColorHint(LinkableMapObj::ColorHint lch)
   1.574  {
   1.575  	linkcolorhint=lch;
   1.576  	setMapLinkColorHintInt();
   1.577 @@ -3075,10 +3119,10 @@
   1.578  
   1.579  void MapEditor::toggleMapLinkColorHint()
   1.580  {
   1.581 -	if (linkcolorhint==HeadingColor)
   1.582 -		linkcolorhint=DefaultColor;
   1.583 +	if (linkcolorhint==LinkableMapObj::HeadingColor)
   1.584 +		linkcolorhint=LinkableMapObj::DefaultColor;
   1.585  	else	
   1.586 -		linkcolorhint=HeadingColor;
   1.587 +		linkcolorhint=LinkableMapObj::HeadingColor;
   1.588  	BranchObj *bo;
   1.589  	bo=mapCenter->first();
   1.590  	while (bo) 
   1.591 @@ -3088,7 +3132,7 @@
   1.592  	}
   1.593  }
   1.594  
   1.595 -LinkColorHint MapEditor::getMapLinkColorHint()
   1.596 +LinkableMapObj::ColorHint MapEditor::getMapLinkColorHint()
   1.597  {
   1.598  	return linkcolorhint;
   1.599  }
   1.600 @@ -3162,9 +3206,8 @@
   1.601  	return xelection.getColor();
   1.602  }
   1.603  
   1.604 -bool MapEditor::scrollBranch()
   1.605 +bool MapEditor::scrollBranch(BranchObj *bo)
   1.606  {
   1.607 -	BranchObj *bo=xelection.getBranch();
   1.608  	if (bo)
   1.609  	{
   1.610  		if (bo->isScrolled()) return false;
   1.611 @@ -3187,9 +3230,8 @@
   1.612  	return false;
   1.613  }
   1.614  
   1.615 -bool MapEditor::unscrollBranch()
   1.616 +bool MapEditor::unscrollBranch(BranchObj *bo)
   1.617  {
   1.618 -	BranchObj *bo=xelection.getBranch();
   1.619  	if (bo)
   1.620  	{
   1.621  		if (!bo->isScrolled()) return false;
   1.622 @@ -3218,13 +3260,13 @@
   1.623  	if (xelection.type()==Branch )
   1.624  	{
   1.625  		if (bo->isScrolled())
   1.626 -			unscrollBranch ();
   1.627 +			unscrollBranch (bo);
   1.628  		else
   1.629 -			scrollBranch ();
   1.630 +			scrollBranch (bo);
   1.631  	}
   1.632  }
   1.633  
   1.634 -void MapEditor::unscrollChilds() // FIXME saveState missing
   1.635 +void MapEditor::unscrollChilds() 
   1.636  {
   1.637  	BranchObj *bo=xelection.getBranch();
   1.638  	if (bo)
   1.639 @@ -3232,7 +3274,7 @@
   1.640  		bo->first();
   1.641  		while (bo) 
   1.642  		{
   1.643 -			if (bo->isScrolled()) bo->toggleScroll();
   1.644 +			if (bo->isScrolled()) unscrollBranch (bo);
   1.645  			bo=bo->next();
   1.646  		}
   1.647  	}	
   1.648 @@ -3351,40 +3393,79 @@
   1.649  	}
   1.650  }
   1.651  
   1.652 -void MapEditor::setFrameType(const FrameType &t)	// FIXME missing saveState
   1.653 +void MapEditor::setFrameType(const FrameObj::FrameType &t)
   1.654  {
   1.655  	BranchObj *bo=xelection.getBranch();
   1.656  	if (bo)
   1.657  	{
   1.658 +		QString s=bo->getFrameTypeName();
   1.659  		bo->setFrameType (t);
   1.660 +		saveState (bo, QString("setFrameType (\"%1\")").arg(s),
   1.661 +			bo, QString ("setFrameType (\"%1\")").arg(bo->getFrameTypeName()),QString ("set type of frame to %1").arg(s));
   1.662  		mapCenter->reposition();
   1.663  		bo->updateLink();
   1.664  	}
   1.665  }
   1.666  
   1.667 -void MapEditor::setFrameType(const QString &s)	// FIXME missing saveState
   1.668 +void MapEditor::setFrameType(const QString &s)	
   1.669  {
   1.670  	BranchObj *bo=xelection.getBranch();
   1.671  	if (bo)
   1.672  	{
   1.673 +		saveState (bo, QString("setFrameType (\"%1\")").arg(bo->getFrameTypeName()),
   1.674 +			bo, QString ("setFrameType (\"%1\")").arg(s),QString ("set type of frame to %1").arg(s));
   1.675  		bo->setFrameType (s);
   1.676  		mapCenter->reposition();
   1.677  		bo->updateLink();
   1.678  	}
   1.679  }
   1.680  
   1.681 -void MapEditor::setFramePenColor(const QColor &c)	// FIXME missing saveState
   1.682 +void MapEditor::setFramePenColor(const QColor &c)	
   1.683  {
   1.684  	BranchObj *bo=xelection.getBranch();
   1.685  	if (bo)
   1.686 +	{
   1.687 +		saveState (bo, QString("setFramePenColor (\"%1\")").arg(bo->getFramePenColor().name() ),
   1.688 +			bo, QString ("setFramePenColor (\"%1\")").arg(c.name() ),QString ("set pen color of frame to %1").arg(c.name() ));
   1.689  		bo->setFramePenColor (c);
   1.690 +	}	
   1.691  }
   1.692  
   1.693 -void MapEditor::setFrameBrushColor(const QColor &c)	// FIXME missing saveState
   1.694 +void MapEditor::setFrameBrushColor(const QColor &c)	
   1.695  {
   1.696  	BranchObj *bo=xelection.getBranch();
   1.697  	if (bo)
   1.698 +	{
   1.699 +		saveState (bo, QString("setFrameBrushColor (\"%1\")").arg(bo->getFrameBrushColor().name() ),
   1.700 +			bo, QString ("setFrameBrushColor (\"%1\")").arg(c.name() ),QString ("set brush color of frame to %1").arg(c.name() ));
   1.701  		bo->setFrameBrushColor (c);
   1.702 +	}	
   1.703 +}
   1.704 +
   1.705 +void MapEditor::setFramePadding (const int &)
   1.706 +{
   1.707 +	BranchObj *bo=xelection.getBranch();
   1.708 +	/*
   1.709 +	if (bo)
   1.710 +	{
   1.711 +		saveState (bo, QString("setFrameBrushColor (\"%1\")").arg(bo->getFrameBrushColor().name() ),
   1.712 +			bo, QString ("setFrameBrushColor (\"%1\")").arg(c.name() ),QString ("set brush color of frame to %1").arg(c.name() ));
   1.713 +		bo->setFrameBrushColor (c);
   1.714 +	}	
   1.715 +	*/
   1.716 +}
   1.717 +
   1.718 +void MapEditor::setFrameBorderWidth(const int &)
   1.719 +{
   1.720 +	BranchObj *bo=xelection.getBranch();
   1.721 +	/*
   1.722 +	if (bo)
   1.723 +	{
   1.724 +		saveState (bo, QString("setFrameBrushColor (\"%1\")").arg(bo->getFrameBrushColor().name() ),
   1.725 +			bo, QString ("setFrameBrushColor (\"%1\")").arg(c.name() ),QString ("set brush color of frame to %1").arg(c.name() ));
   1.726 +		bo->setFrameBrushColor (c);
   1.727 +	}	
   1.728 +	*/
   1.729  }
   1.730  
   1.731  void MapEditor::setIncludeImagesVer(bool b)	
   1.732 @@ -3550,6 +3631,8 @@
   1.733  {
   1.734  	// This is the playground
   1.735  
   1.736 +	BranchObj *bo=xelection.getBranch();
   1.737 +	if (bo) animObjList.append( bo );
   1.738  	
   1.739  /*
   1.740  	WarningDialog dia;
   1.741 @@ -3636,13 +3719,13 @@
   1.742  	{
   1.743  		switch (mainWindow->getModMode())
   1.744  		{
   1.745 -			case ModModeColor: 
   1.746 +			case Main::ModModeColor: 
   1.747  				setCursor (PickColorCursor);
   1.748  				break;
   1.749 -			case ModModeCopy: 
   1.750 +			case Main::ModModeCopy: 
   1.751  				setCursor (CopyCursor);
   1.752  				break;
   1.753 -			case ModModeXLink: 
   1.754 +			case Main::ModModeXLink: 
   1.755  				setCursor (XLinkCursor);
   1.756  				break;
   1.757  			default :
   1.758 @@ -3706,13 +3789,13 @@
   1.759  	// No system flag clicked, take care of modmodes (CTRL-Click)
   1.760  	if (e->state() & Qt::ControlModifier)
   1.761  	{
   1.762 -		if (mainWindow->getModMode()==ModModeColor)
   1.763 +		if (mainWindow->getModMode()==Main::ModModeColor)
   1.764  		{
   1.765  				pickingColor=true;
   1.766  				setCursor (PickColorCursor);
   1.767  				return;
   1.768  		} 
   1.769 -		if (mainWindow->getModMode()==ModModeXLink)
   1.770 +		if (mainWindow->getModMode()==Main::ModModeXLink)
   1.771  		{	
   1.772  			BranchObj *bo_begin=NULL;
   1.773  			if (lmo)
   1.774 @@ -3754,7 +3837,7 @@
   1.775  
   1.776  			// If modMode==copy, then we want to "move" the _new_ object around
   1.777  			// then we need the offset from p to the _old_ selection, because of tmp
   1.778 -			if (mainWindow->getModMode()==ModModeCopy &&
   1.779 +			if (mainWindow->getModMode()==Main::ModModeCopy &&
   1.780  				e->state() & Qt::ControlModifier)
   1.781  			{
   1.782  				if (xelection.type()==Branch)
   1.783 @@ -3801,7 +3884,7 @@
   1.784      if ( lmosel && movingObj) 
   1.785      {	
   1.786  		// reset cursor if we are moving and don't copy
   1.787 -		if (mainWindow->getModMode()!=ModModeCopy)
   1.788 +		if (mainWindow->getModMode()!=Main::ModModeCopy)
   1.789  			setCursor (Qt::ArrowCursor);
   1.790  
   1.791  		// To avoid jumping of the sceneView, only 
   1.792 @@ -3878,7 +3961,7 @@
   1.793  				} else
   1.794  				{
   1.795  					// Move ordinary branch
   1.796 -					if (lmosel->getOrientation() == OrientLeftOfCenter)
   1.797 +					if (lmosel->getOrientation() == LinkableMapObj::LeftOfCenter)
   1.798  						// Add width of bbox here, otherwise alignRelTo will cause jumping around
   1.799  						lmosel->move(p.x() -movingObj_start.x()+lmosel->getBBox().width(), 
   1.800  							p.y()-movingObj_start.y() +lmosel->getTopPad() );		
   1.801 @@ -3958,7 +4041,7 @@
   1.802  	}
   1.803  
   1.804  	// Have we been drawing a link?
   1.805 -	if (drawingLink)
   1.806 +	if (drawingLink)	//FIXME savestate missing
   1.807  	{
   1.808  		drawingLink=false;
   1.809  		// Check if we are over another branch
   1.810 @@ -3968,7 +4051,7 @@
   1.811  			tmpXLink->setEnd ( ((BranchObj*)(dst)) );
   1.812  			tmpXLink->updateXLink();
   1.813  			tmpXLink->activate();
   1.814 -			//saveStateComplete(QString("Activate xLink from %1 to %2").arg(getName(tmpXLink->getBegin())).arg(getName(tmpXLink->getEnd())) );	//FIXME undoCommand
   1.815 +			//saveStateComplete(QString("Activate xLink from %1 to %2").arg(getName(tmpXLink->getBegin())).arg(getName(tmpXLink->getEnd())) );	
   1.816  		} else
   1.817  		{
   1.818  			delete(tmpXLink);
   1.819 @@ -4187,8 +4270,28 @@
   1.820  	event->acceptProposedAction();
   1.821  }
   1.822  
   1.823 -/*
   1.824 -void MapEditor::contentsDropEvent(QDropEvent *event) 
   1.825 +void MapEditor::timerEvent(QTimerEvent *event)  //FIXME testing
   1.826 +{
   1.827 +    Q_UNUSED(event);
   1.828 +
   1.829 +	cout << "ME::timerEvent\n";
   1.830 +
   1.831 +	for (int i=0; i<animObjList.size(); ++i)
   1.832 +	{
   1.833 +		animObjList.at(i)->animate();
   1.834 +		((BranchObj*)animObjList.at(i))->move2RelPos (((BranchObj*)animObjList.at(i))->getRelPos() );
   1.835 +	}
   1.836 +	mapCenter->reposition();
   1.837 +}
   1.838 +
   1.839 +void MapEditor::autosave()
   1.840 +{
   1.841 +	if (mapUnsaved &&mapChanged && settings.value ("/mapeditor/autosave/used",true).toBool() )
   1.842 +		mainWindow->fileSave (this);
   1.843 +}
   1.844 +
   1.845 +
   1.846 +/*FIXME not needed? void MapEditor::contentsDropEvent(QDropEvent *event) 
   1.847  {
   1.848  
   1.849  		} else if (event->provides("application/x-moz-file-promise-url") && 
   1.850 @@ -4256,12 +4359,9 @@
   1.851  	BranchObj *bo=xelection.getBranch();
   1.852  	if (bo)
   1.853    {
   1.854 -    //FIXME XXX saveStateChangingPart(selection,QString("Add floatimage to %1").arg(getName(bo)));
   1.855 -    //QString fn=fd->selectedFile();
   1.856 -    //lastImageDir=fn.left(fn.findRev ("/"));
   1.857  	FloatImageObj *fio=bo->addFloatImage();
   1.858      fio->load(img);
   1.859 -    fio->setOriginalFilename("Image added by Drag and Drop");
   1.860 +    fio->setOriginalFilename("Image added by Drag and Drop");	// FIXME savestate
   1.861      mapCenter->reposition();
   1.862      scene()->update();
   1.863    }