mapeditor.cpp
changeset 648 e4435f252e44
parent 638 3436b8eb3d9b
child 650 65c5a0c28d20
     1.1 --- a/mapeditor.cpp	Mon Jan 07 14:52:49 2008 +0000
     1.2 +++ b/mapeditor.cpp	Mon Jan 14 16:27:00 2008 +0000
     1.3 @@ -6,8 +6,6 @@
     1.4  #include <cstdlib>
     1.5  #include <typeinfo>
     1.6  
     1.7 -#include "version.h"
     1.8 -
     1.9  #include "parser.h"
    1.10  #include "editxlinkdialog.h"
    1.11  #include "exports.h"
    1.12 @@ -69,15 +67,11 @@
    1.13  	//mapScene= new QGraphicsScene(QRectF(0,0,width(),height()), parent);
    1.14  	mapScene->setBackgroundBrush (QBrush(Qt::white, Qt::SolidPattern));
    1.15  
    1.16 +	model=new VymModel();
    1.17 +	model->setScene (mapScene);
    1.18 +	model->setMapEditor (this);
    1.19  
    1.20      setScene (mapScene);
    1.21 -	
    1.22 -    mapCenter = new MapCenterObj(mapScene);
    1.23 -    mapCenter->setVisibility (true);
    1.24 -	mapCenter->setMapEditor (this);
    1.25 -	mapCenter->setHeading (tr("New Map","Heading of mapcenter in new map"));
    1.26 -	//mapCenter->move(mapScene->width()/2-mapCenter->width()/2,mapScene->height()/2-mapCenter->height()/2);
    1.27 -	mapCenter->move(0,0);
    1.28  
    1.29      printer=NULL;
    1.30  
    1.31 @@ -101,7 +95,7 @@
    1.32      editingBO=NULL;
    1.33      movingObj=NULL;
    1.34  
    1.35 -	xelection.setMapEditor (this);
    1.36 +	xelection.setModel (model);
    1.37  	xelection.unselect();
    1.38  
    1.39  	defXLinkWidth=1;
    1.40 @@ -141,7 +135,7 @@
    1.41  
    1.42  	setAcceptDrops (true);	
    1.43  
    1.44 -	mapCenter->reposition();	//	for positioning heading
    1.45 +	model->reposition();
    1.46  
    1.47  	// TODO animations
    1.48  	animObjList.clear();
    1.49 @@ -195,11 +189,12 @@
    1.50  	// tmpMapDir is in tmpVymDir, so it gets removed automagically when vym closes
    1.51  	
    1.52  	//removeDir(QDir(tmpMapDir));
    1.53 +	delete (model);
    1.54  }
    1.55  
    1.56 -MapCenterObj* MapEditor::getMapCenter()
    1.57 +VymModel* MapEditor::getModel()
    1.58  {
    1.59 -    return mapCenter;
    1.60 +    return model;
    1.61  }
    1.62  
    1.63  QGraphicsScene * MapEditor::getScene()
    1.64 @@ -299,10 +294,10 @@
    1.65  		colhint=attribut("linkColorHint","HeadingColor");
    1.66  
    1.67  	QString mapAttr=attribut("version",vymVersion);
    1.68 -	if (!saveSel || saveSel==mapCenter)
    1.69 -		mapAttr+= attribut("author",mapCenter->getAuthor()) +
    1.70 -				  attribut("comment",mapCenter->getComment()) +
    1.71 -			      attribut("date",mapCenter->getDate()) +
    1.72 +	if (!saveSel)
    1.73 +		mapAttr+= attribut("author",model->getAuthor()) +
    1.74 +				  attribut("comment",model->getComment()) +
    1.75 +			      attribut("date",model->getDate()) +
    1.76  		          attribut("backgroundColor", mapScene->backgroundBrush().color().name() ) +
    1.77  		          attribut("selectionColor", xelection.getColor().name() ) +
    1.78  		          attribut("linkStyle", ls ) +
    1.79 @@ -323,7 +318,7 @@
    1.80  	// Build xml recursivly
    1.81  	if (!saveSel || typeid (*saveSel) == typeid (MapCenterObj))
    1.82  		// Save complete map, if saveSel not set
    1.83 -		s+=mapCenter->saveToDir(tmpdir,prefix,writeflags,offset);
    1.84 +		s+=model->saveToDir(tmpdir,prefix,writeflags,offset);
    1.85  	else
    1.86  	{
    1.87  		if ( typeid(*saveSel) == typeid(BranchObj) )
    1.88 @@ -512,6 +507,17 @@
    1.89  		NULL);
    1.90  }
    1.91  
    1.92 +void MapEditor::saveState(const QString &uc, const QString &rc, const QString &comment) 
    1.93 +{
    1.94 +	// "Normal" savestate applied to model (no selection needed): 
    1.95 +	// save commands  and comment
    1.96 +	saveState (UndoCommand,
    1.97 +		NULL, uc,
    1.98 +		NULL, rc, 
    1.99 +		comment, 
   1.100 +		NULL);
   1.101 +}
   1.102 +
   1.103  		
   1.104  void MapEditor::parseAtom(const QString &atom)
   1.105  {
   1.106 @@ -803,7 +809,7 @@
   1.107  				// 1	num in parent (for branches)
   1.108  				// 2,3	x,y of mainbranch or mapcenter
   1.109  				s=parser.parString(ok,0);
   1.110 -				LinkableMapObj *dst=mapCenter->findObjBySelect (s);
   1.111 +				LinkableMapObj *dst=model->findObjBySelect (s);
   1.112  				if (dst)
   1.113  				{	
   1.114  					if (typeid(*dst) == typeid(BranchObj) ) 
   1.115 @@ -838,7 +844,7 @@
   1.116  			{
   1.117  				// 0	selectstring of parent
   1.118  				s=parser.parString(ok,0);
   1.119 -				LinkableMapObj *dst=mapCenter->findObjBySelect (s);
   1.120 +				LinkableMapObj *dst=model->findObjBySelect (s);
   1.121  				if (dst)
   1.122  				{	
   1.123  					if (typeid(*dst) == typeid(BranchObj) ||
   1.124 @@ -1431,7 +1437,7 @@
   1.125  	if (parser.errorLevel()==NoError)
   1.126  	{
   1.127  		// setChanged();  FIXME should not be called e.g. for export?!
   1.128 -		mapCenter->reposition();
   1.129 +		model->reposition();
   1.130  	}	
   1.131  	else	
   1.132  	{
   1.133 @@ -1550,8 +1556,8 @@
   1.134  	{
   1.135  		if (xelection.isEmpty() ) xelection.unselect();
   1.136  		xelection.clear();
   1.137 -		mapCenter->clear();
   1.138 -		mapCenter->setMapEditor(this);
   1.139 +		model->clear();
   1.140 +		model->setMapEditor(this);
   1.141  		// (map state is set later at end of load...)
   1.142  	} else
   1.143  	{
   1.144 @@ -1589,7 +1595,7 @@
   1.145  		QXmlSimpleReader reader;
   1.146  		reader.setContentHandler( handler );
   1.147  		reader.setErrorHandler( handler );
   1.148 -		handler->setMapEditor( this );
   1.149 +		handler->setModel ( model);
   1.150  
   1.151  
   1.152  		// We need to set the tmpDir in order  to load files with rel. path
   1.153 @@ -1603,7 +1609,7 @@
   1.154  		file.close();
   1.155  		if ( ok ) 
   1.156  		{
   1.157 -			mapCenter->reposition();
   1.158 +			model->reposition();
   1.159  			xelection.update();
   1.160  			if (lmode==NewMap)
   1.161  			{
   1.162 @@ -1685,7 +1691,7 @@
   1.163  		printer->setOutputFileName(settings.value("/mainwindow/printerFileName",printer->outputFileName()).toString());
   1.164  	}
   1.165  
   1.166 -	QRectF totalBBox=mapCenter->getTotalBBox();
   1.167 +	QRectF totalBBox=model->getTotalBBox();
   1.168  
   1.169  	// Try to set orientation automagically
   1.170  	// Note: Interpretation of generated postscript is amibiguous, if 
   1.171 @@ -1779,7 +1785,7 @@
   1.172  
   1.173  QPixmap MapEditor::getPixmap()
   1.174  {
   1.175 -	QRectF mapRect=mapCenter->getTotalBBox();
   1.176 +	QRectF mapRect=model->getTotalBBox();
   1.177  	QPixmap pix((int)mapRect.width()+2,(int)mapRect.height()+1);
   1.178  	QPainter pp (&pix);
   1.179  	
   1.180 @@ -1801,8 +1807,8 @@
   1.181  void MapEditor::setHideTmpMode (HideTmpMode mode)
   1.182  {
   1.183  	hidemode=mode;
   1.184 -	mapCenter->setHideTmp (hidemode);
   1.185 -	mapCenter->reposition();
   1.186 +	model->setHideTmp (hidemode);
   1.187 +	model->reposition();
   1.188  	scene()->update();
   1.189  }
   1.190  
   1.191 @@ -1824,7 +1830,7 @@
   1.192  void MapEditor::exportASCII(QString fname,bool askName)
   1.193  {
   1.194  	ExportASCII ex;
   1.195 -	ex.setMapCenter(mapCenter);
   1.196 +	ex.setModel (model);
   1.197  	if (fname=="") 
   1.198  		ex.setFile (mapName+".txt");	
   1.199  	else
   1.200 @@ -1879,7 +1885,7 @@
   1.201  {
   1.202  	ExportOO ex;
   1.203  	ex.setFile (fn);
   1.204 -	ex.setMapCenter(mapCenter);
   1.205 +	ex.setModel (model);
   1.206  	if (ex.setConfigFile(cf)) 
   1.207  	{
   1.208  		setExportMode (true);
   1.209 @@ -1946,7 +1952,7 @@
   1.210  	makeSubDirs (dir);
   1.211  
   1.212  	// write to directory
   1.213 -	QString saveFile=saveToDir (dir,mapName+"-",true,mapCenter->getTotalBBox().topLeft() ,NULL);
   1.214 +	QString saveFile=saveToDir (dir,mapName+"-",true,model->getTotalBBox().topLeft() ,NULL);
   1.215  	QFile file;
   1.216  
   1.217  	file.setName ( dir + "/"+mapName+".xml");
   1.218 @@ -1972,7 +1978,7 @@
   1.219  void MapEditor::clear()
   1.220  {
   1.221  	xelection.unselect();
   1.222 -	mapCenter->clear();
   1.223 +	model->clear();
   1.224  }
   1.225  
   1.226  void MapEditor::copy()
   1.227 @@ -2018,10 +2024,11 @@
   1.228  	QString comment=undoSet.readEntry (QString("/history/step-%1/comment").arg(curStep));
   1.229  	QString version=undoSet.readEntry ("/history/version");
   1.230  
   1.231 +	/* TODO Maybe check for version, if we save the history
   1.232  	if (!checkVersion(version))
   1.233  		QMessageBox::warning(0,tr("Warning"),
   1.234  			tr("Version %1 of saved undo/redo data\ndoes not match current vym version %2.").arg(version).arg(vymVersion));
   1.235 -
   1.236 +	*/ 
   1.237  
   1.238  	// Find out current undo directory
   1.239  	QString bakMapDir(QString(tmpMapDir+"/undo-%1").arg(curStep));
   1.240 @@ -2047,7 +2054,7 @@
   1.241  
   1.242  
   1.243  	parseAtom (redoCommand);
   1.244 -	mapCenter->reposition();
   1.245 +	model->reposition();
   1.246  
   1.247  	blockSaveState=blockSaveStateOrg;
   1.248  
   1.249 @@ -2095,9 +2102,11 @@
   1.250  	QString comment=undoSet.readEntry (QString("/history/step-%1/comment").arg(curStep));
   1.251  	QString version=undoSet.readEntry ("/history/version");
   1.252  
   1.253 +	/* TODO Maybe check for version, if we save the history
   1.254  	if (!checkVersion(version))
   1.255  		QMessageBox::warning(0,tr("Warning"),
   1.256  			tr("Version %1 of saved undo/redo data\ndoes not match current vym version %2.").arg(version).arg(vymVersion));
   1.257 +	*/
   1.258  
   1.259  	// Find out current undo directory
   1.260  	QString bakMapDir(QString(tmpMapDir+"/undo-%1").arg(curStep));
   1.261 @@ -2121,7 +2130,7 @@
   1.262  		cout << "    ---------------------------"<<endl<<endl;
   1.263  	}	
   1.264  	parseAtom (undoCommand);
   1.265 -	mapCenter->reposition();
   1.266 +	model->reposition();
   1.267  
   1.268  	undosAvail--;
   1.269  	curStep--; 
   1.270 @@ -2196,12 +2205,12 @@
   1.271  		QXmlSimpleReader reader;
   1.272  		reader.setContentHandler( &handler );
   1.273  		reader.setErrorHandler( &handler );
   1.274 -		handler.setMapEditor( this );
   1.275 +		handler.setModel ( model);
   1.276  		handler.setTmpDir ( pathDir );	// needed to load files with rel. path
   1.277  		if (undoSel.isEmpty())
   1.278  		{
   1.279  			unselect();
   1.280 -			mapCenter->clear();
   1.281 +			model->clear();
   1.282  			handler.setLoadMode (NewMap);
   1.283  		} else	
   1.284  		{
   1.285 @@ -2238,7 +2247,7 @@
   1.286  			QXmlSimpleReader reader;
   1.287  			reader.setContentHandler( &handler );
   1.288  			reader.setErrorHandler( &handler );
   1.289 -			handler.setMapEditor( this );
   1.290 +			handler.setModel (model);
   1.291  			handler.setTmpDir ( pathDir );	// needed to load files with rel. path
   1.292  			handler.setLoadMode (ImportAdd);
   1.293  			blockReposition=true;
   1.294 @@ -2250,7 +2259,7 @@
   1.295  				QMessageBox::critical( 0, tr( "Critical Parse Error while reading %1").arg(path),
   1.296  										handler.errorProtocol());
   1.297  			}
   1.298 -			if (sel!=mapCenter)
   1.299 +			if (sel->getDepth()>0)
   1.300  				sel->getLastBranch()->linkTo (sel,pos);
   1.301  		} else	
   1.302  			QMessageBox::critical( 0, tr( "Critical Error" ), tr("Could not read %1").arg(path));
   1.303 @@ -2285,7 +2294,7 @@
   1.304  			QString("Paste to %1").arg( getName(sel))
   1.305  		);
   1.306  		pasteNoSave(0);
   1.307 -		mapCenter->reposition();
   1.308 +		model->reposition();
   1.309  	}
   1.310  }
   1.311  
   1.312 @@ -2306,7 +2315,7 @@
   1.313  	*/	
   1.314  		copy();
   1.315  		deleteSelection();
   1.316 -		mapCenter->reposition();
   1.317 +		model->reposition();
   1.318  	}
   1.319  }
   1.320  
   1.321 @@ -2326,7 +2335,7 @@
   1.322                  s, "move "+qpointfToString(to), 
   1.323                  QString("Move %1 to %2").arg(getName(sel)).arg(ps));
   1.324              sel->move(x,y);
   1.325 -            mapCenter->reposition();
   1.326 +            model->reposition();
   1.327              xelection.update();
   1.328          }
   1.329  	}
   1.330 @@ -2348,7 +2357,7 @@
   1.331                  s, "moveRel "+qpointfToString(to), 
   1.332                  QString("Move %1 to relative position %2").arg(getName(sel)).arg(ps));
   1.333              ((OrnamentedObj*)sel)->move2RelPos (x,y);
   1.334 -            mapCenter->reposition();
   1.335 +            model->reposition();
   1.336              sel->updateLink();
   1.337              xelection.update();
   1.338          }
   1.339 @@ -2365,7 +2374,7 @@
   1.340  		par=(BranchObj*)(bo->getParObj());
   1.341  		BranchObj *obo=par->moveBranchUp (bo);	// bo will be the one below selection
   1.342  		saveState (bo->getSelectString(),"moveBranchDown ()",obo->getSelectString(),"moveBranchUp ()",QString("Move up %1").arg(getName(bo)));
   1.343 -		mapCenter->reposition();
   1.344 +		model->reposition();
   1.345  		scene()->update();
   1.346  		xelection.update();
   1.347  		ensureSelectionVisible();
   1.348 @@ -2382,7 +2391,7 @@
   1.349  		par=(BranchObj*)(bo->getParObj());
   1.350  		BranchObj *obo=par->moveBranchDown(bo);	// bo will be the one above selection
   1.351  		saveState(bo->getSelectString(),"moveBranchUp ()",obo->getSelectString(),"moveBranchDown ()",QString("Move down %1").arg(getName(bo)));
   1.352 -		mapCenter->reposition();
   1.353 +		model->reposition();
   1.354  		scene()->update();
   1.355  		xelection.update();
   1.356  		ensureSelectionVisible();
   1.357 @@ -2398,7 +2407,7 @@
   1.358  		{
   1.359  			saveStateChangingPart(bo,bo, "sortChildren ()",QString("Sort children of %1").arg(getName(bo)));
   1.360  			bo->sortChildren();
   1.361 -			mapCenter->reposition();
   1.362 +			model->reposition();
   1.363  			ensureSelectionVisible();
   1.364  		}
   1.365  	}
   1.366 @@ -2409,7 +2418,7 @@
   1.367  	FloatImageObj *fio=xelection.getFloatImage();
   1.368  	if (fio)
   1.369  	{
   1.370 -		BranchObj *dst=(BranchObj*)(mapCenter->findObjBySelect(dstString));
   1.371 +		BranchObj *dst=(BranchObj*)(model->findObjBySelect(dstString));
   1.372  		if (dst && (typeid(*dst)==typeid (BranchObj) || 
   1.373  					typeid(*dst)==typeid (MapCenterObj)))
   1.374  		{			
   1.375 @@ -2459,7 +2468,7 @@
   1.376  			"setHeading (\""+s+"\")", 
   1.377  			QString("Set heading of %1 to \"%2\"").arg(getName(sel)).arg(s) );
   1.378  		sel->setHeading(s );
   1.379 -		mapCenter->reposition();
   1.380 +		model->reposition();
   1.381  		xelection.update();
   1.382  		ensureSelectionVisible();
   1.383  	}
   1.384 @@ -2471,7 +2480,7 @@
   1.385  	if (bo)
   1.386  	{
   1.387  		bo->setHeading(s);
   1.388 -		mapCenter->reposition();
   1.389 +		model->reposition();
   1.390  		xelection.update();
   1.391  		ensureSelectionVisible();
   1.392  	}
   1.393 @@ -2484,7 +2493,7 @@
   1.394  	if (bo)
   1.395  	{
   1.396  		bo->setVymLink(s);
   1.397 -		mapCenter->reposition();
   1.398 +		model->reposition();
   1.399  		updateActions();
   1.400  		xelection.update();
   1.401  		ensureSelectionVisible();
   1.402 @@ -2548,7 +2557,7 @@
   1.403  				QString ("addBranch (%1)").arg(pos),
   1.404  				QString ("Add new branch to %1").arg(getName(bo)));	
   1.405  
   1.406 -			mapCenter->reposition();
   1.407 +			model->reposition();
   1.408  			xelection.update();
   1.409  			latestSelection=newbo->getSelectString();
   1.410  			// In Network mode, the client needs to know where the new branch is,
   1.411 @@ -2588,7 +2597,7 @@
   1.412  			saveState (newbo, "deleteKeepChilds ()", newbo, "addBranchBefore ()", 
   1.413  				QString ("Add branch before %1").arg(getName(bo)));
   1.414  
   1.415 -			mapCenter->reposition();
   1.416 +			model->reposition();
   1.417  			xelection.update();
   1.418  		}
   1.419  	}	
   1.420 @@ -2599,6 +2608,23 @@
   1.421  void MapEditor::deleteSelection()
   1.422  {
   1.423  	BranchObj *bo = xelection.getBranch();
   1.424 +	if (bo && xelection.type()==Selection::MapCenter)
   1.425 +	{
   1.426 +	//	BranchObj* par=(BranchObj*)(bo->getParObj());
   1.427 +		xelection.unselect();
   1.428 +	/* FIXME Note:  does saveStateRemovingPart work for MCO? (No parent!)
   1.429 +		saveStateRemovingPart (bo, QString ("Delete %1").arg(getName(bo)));
   1.430 +		*/
   1.431 +		bo=model->removeMapCenter ((MapCenterObj*)bo);
   1.432 +		if (bo) 
   1.433 +		{
   1.434 +			xelection.select (bo);
   1.435 +			ensureSelectionVisible();
   1.436 +			xelection.update();
   1.437 +		}	
   1.438 +		model->reposition();
   1.439 +		return;
   1.440 +	}
   1.441  	if (bo && xelection.type()==Selection::Branch)
   1.442  	{
   1.443  		BranchObj* par=(BranchObj*)(bo->getParObj());
   1.444 @@ -2607,7 +2633,7 @@
   1.445  		par->removeBranch(bo);
   1.446  		xelection.select (par);
   1.447  		ensureSelectionVisible();
   1.448 -		mapCenter->reposition();
   1.449 +		model->reposition();
   1.450  		xelection.update();
   1.451  		xelection.update();
   1.452  		return;
   1.453 @@ -2625,7 +2651,7 @@
   1.454  		xelection.unselect();
   1.455  		par->removeFloatImage(fio);
   1.456  		xelection.select (par);
   1.457 -		mapCenter->reposition();
   1.458 +		model->reposition();
   1.459  		xelection.update();
   1.460  		ensureSelectionVisible();
   1.461  		return;
   1.462 @@ -2659,7 +2685,7 @@
   1.463  
   1.464  bool MapEditor::select (const QString &s)
   1.465  {
   1.466 -	LinkableMapObj *lmo=mapCenter->findObjBySelect(s);
   1.467 +	LinkableMapObj *lmo=model->findObjBySelect(s);
   1.468  
   1.469  	// Finally select the found object
   1.470  	if (lmo)
   1.471 @@ -3085,9 +3111,7 @@
   1.472  {
   1.473  	QColor oldcol=mapScene->backgroundBrush().color();
   1.474  	saveState(
   1.475 -		mapCenter,
   1.476  		QString ("setMapBackgroundColor (\"%1\")").arg(oldcol.name()),
   1.477 -		mapCenter,
   1.478  		QString ("setMapBackgroundColor (\"%1\")").arg(col.name()),
   1.479  		QString("Set background color of map to %1").arg(col.name()));
   1.480  	mapScene->setBackgroundBrush(col);
   1.481 @@ -3177,7 +3201,7 @@
   1.482  		if (EOFind)
   1.483  			// nothing found, start again
   1.484  			EOFind=false;
   1.485 -		itFind=mapCenter->first();
   1.486 +		itFind=model->first();
   1.487  	}	
   1.488  	bool searching=true;
   1.489  	bool foundNote=false;
   1.490 @@ -3209,7 +3233,7 @@
   1.491  		}	
   1.492  		if (!foundNote)
   1.493  		{
   1.494 -			itFind=itFind->next();
   1.495 +			itFind=model->next(itFind);
   1.496  			if (!itFind) EOFind=true;
   1.497  		}
   1.498  	}	
   1.499 @@ -3239,7 +3263,7 @@
   1.500  			QString ("set URL of %1 to %2").arg(getName(bo)).arg(url)
   1.501  		);
   1.502  		updateActions();
   1.503 -		mapCenter->reposition();
   1.504 +		model->reposition();
   1.505  		xelection.update();
   1.506  		ensureSelectionVisible();
   1.507  	}
   1.508 @@ -3393,7 +3417,7 @@
   1.509  		);	
   1.510  		bo->setVymLink ("" );
   1.511  		updateActions();
   1.512 -		mapCenter->reposition();
   1.513 +		model->reposition();
   1.514  		scene()->update();
   1.515  	}
   1.516  }
   1.517 @@ -3415,7 +3439,7 @@
   1.518  			QString ("Set HideExport flag of %1 to %2").arg(getName(bo)).arg (r)
   1.519  		);	
   1.520  		updateActions();
   1.521 -		mapCenter->reposition();
   1.522 +		model->reposition();
   1.523  		xelection.update();
   1.524  		scene()->update();
   1.525  	}
   1.526 @@ -3473,10 +3497,10 @@
   1.527  		QString sel=bo->getSelectString();
   1.528  		unselect();
   1.529  		par->removeBranchHere(bo);
   1.530 -		mapCenter->reposition();
   1.531 +		model->reposition();
   1.532  		select (sel);
   1.533  		xelection.getBranch()->move2RelPos (p);
   1.534 -		mapCenter->reposition();
   1.535 +		model->reposition();
   1.536  	}	
   1.537  }
   1.538  
   1.539 @@ -3492,7 +3516,7 @@
   1.540  			QString( "Remove childs of branch %1").arg(getName(bo))
   1.541  		);
   1.542  		bo->removeChilds();
   1.543 -		mapCenter->reposition();
   1.544 +		model->reposition();
   1.545  	}	
   1.546  }
   1.547  
   1.548 @@ -3500,8 +3524,8 @@
   1.549  {
   1.550  	ExtraInfoDialog dia;
   1.551  	dia.setMapName (getFileName() );
   1.552 -	dia.setAuthor (mapCenter->getAuthor() );
   1.553 -	dia.setComment(mapCenter->getComment() );
   1.554 +	dia.setAuthor (model->getAuthor() );
   1.555 +	dia.setComment(model->getComment() );
   1.556  
   1.557  	// Calc some stats
   1.558  	QString stats;
   1.559 @@ -3512,14 +3536,14 @@
   1.560  	uint n=0;
   1.561  	uint xl=0;
   1.562  	BranchObj *bo;
   1.563 -	bo=mapCenter->first();
   1.564 +	bo=model->first();
   1.565  	while (bo) 
   1.566  	{
   1.567  		if (!bo->getNote().isEmpty() ) n++;
   1.568  		f+= bo->countFloatImages();
   1.569  		b++;
   1.570  		xl+=bo->countXLinks();
   1.571 -		bo=bo->next();
   1.572 +		bo=model->next(bo);
   1.573  	}
   1.574      stats+=QString ("%1 branches\n").arg (b-1,6);
   1.575      stats+=QString ("%1 xLinks \n").arg (xl,6);
   1.576 @@ -3569,33 +3593,38 @@
   1.577  void MapEditor::setMapAuthor (const QString &s)
   1.578  {
   1.579  	saveState (
   1.580 -		mapCenter,
   1.581 -		QString ("setMapAuthor (\"%1\")").arg(mapCenter->getAuthor()),
   1.582 -		mapCenter,
   1.583 +		QString ("setMapAuthor (\"%1\")").arg(model->getAuthor()),
   1.584  		QString ("setMapAuthor (\"%1\")").arg(s),
   1.585  		QString ("Set author of map to \"%1\"").arg(s)
   1.586  	);
   1.587 -	mapCenter->setAuthor (s);
   1.588 +	model->setAuthor (s);
   1.589  }
   1.590  
   1.591  void MapEditor::setMapComment (const QString &s)
   1.592  {
   1.593  	saveState (
   1.594 -		mapCenter,
   1.595 -		QString ("setMapComment (\"%1\")").arg(mapCenter->getComment()),
   1.596 -		mapCenter,
   1.597 +		QString ("setMapComment (\"%1\")").arg(model->getComment()),
   1.598  		QString ("setMapComment (\"%1\")").arg(s),
   1.599  		QString ("Set comment of map")
   1.600  	);
   1.601 -	mapCenter->setComment (s);
   1.602 +	model->setComment (s);
   1.603  }
   1.604  
   1.605  void MapEditor::setMapLinkStyle (const QString & s)
   1.606  {
   1.607 -	saveStateChangingPart (
   1.608 -		mapCenter,
   1.609 -		mapCenter,
   1.610 +	QString snow;
   1.611 +	if (linkstyle==LinkableMapObj::Line)
   1.612 +		snow="StyleLine";
   1.613 +	else if (linkstyle==LinkableMapObj::Parabel)
   1.614 +		snow="StyleParabel";
   1.615 +	else if (linkstyle==LinkableMapObj::PolyLine)
   1.616 +		snow="StylePolyLine";
   1.617 +	else if (linkstyle==LinkableMapObj::PolyParabel)
   1.618 +		snow="StyleParabel";
   1.619 +
   1.620 +	saveState (
   1.621  		QString("setMapLinkStyle (\"%1\")").arg(s),
   1.622 +		QString("setMapLinkStyle (\"%1\")").arg(snow),
   1.623  		QString("Set map link style (\"%1\")").arg(s)
   1.624  	);	
   1.625  
   1.626 @@ -3609,14 +3638,14 @@
   1.627  		linkstyle=LinkableMapObj::PolyParabel;
   1.628  
   1.629  	BranchObj *bo;
   1.630 -	bo=mapCenter->first();
   1.631 -	bo=bo->next();
   1.632 +	bo=model->first();
   1.633 +	bo=model->next(bo);
   1.634  	while (bo) 
   1.635  	{
   1.636  		bo->setLinkStyle(bo->getDefLinkStyle());
   1.637 -		bo=bo->next();
   1.638 +		bo=model->next(bo);
   1.639  	}
   1.640 -	mapCenter->reposition();
   1.641 +	model->reposition();
   1.642  }
   1.643  
   1.644  LinkableMapObj::Style MapEditor::getMapLinkStyle ()
   1.645 @@ -3628,11 +3657,11 @@
   1.646  {
   1.647  	defLinkColor=c;
   1.648  	BranchObj *bo;
   1.649 -	bo=mapCenter->first();
   1.650 +	bo=model->first();
   1.651  	while (bo) 
   1.652  	{
   1.653  		bo->setLinkColor();
   1.654 -		bo=bo->next();
   1.655 +		bo=model->next(bo);
   1.656  	}
   1.657  	updateActions();
   1.658  }
   1.659 @@ -3641,11 +3670,11 @@
   1.660  {
   1.661  	// called from setMapLinkColorHint(lch) or at end of parse
   1.662  	BranchObj *bo;
   1.663 -	bo=mapCenter->first();
   1.664 +	bo=model->first();
   1.665  	while (bo) 
   1.666  	{
   1.667  		bo->setLinkColor();
   1.668 -		bo=bo->next();
   1.669 +		bo=model->next(bo);
   1.670  	}
   1.671  }
   1.672  
   1.673 @@ -3662,11 +3691,11 @@
   1.674  	else	
   1.675  		linkcolorhint=LinkableMapObj::HeadingColor;
   1.676  	BranchObj *bo;
   1.677 -	bo=mapCenter->first();
   1.678 +	bo=model->first();
   1.679  	while (bo) 
   1.680  	{
   1.681  		bo->setLinkColor();
   1.682 -		bo=bo->next();
   1.683 +		bo=model->next(bo);
   1.684  	}
   1.685  }
   1.686  
   1.687 @@ -3705,9 +3734,7 @@
   1.688  	QColor col = QColorDialog::getColor( defLinkColor, this );
   1.689  	if ( !col.isValid() ) return;
   1.690  	saveState (
   1.691 -		mapCenter,
   1.692  		QString("setMapDefLinkColor (\"%1\")").arg(getMapDefLinkColor().name()),
   1.693 -		mapCenter,
   1.694  		QString("setMapDefLinkColor (\"%1\")").arg(col.name()),
   1.695  		QString("Set map link color to %1").arg(col.name())
   1.696  	);
   1.697 @@ -3730,9 +3757,7 @@
   1.698  {
   1.699  	if ( !col.isValid() ) return;
   1.700  	saveState (
   1.701 -		mapCenter,
   1.702  		QString("setSelectionColor (%1)").arg(xelection.getColor().name()),
   1.703 -		mapCenter,
   1.704  		QString("setSelectionColor (%1)").arg(col.name()),
   1.705  		QString("Set color of selection box to %1").arg(col.name())
   1.706  	);
   1.707 @@ -3829,7 +3854,7 @@
   1.708  		bo->addFloatImage();
   1.709  		fio=bo->getLastFloatImage();
   1.710  		fio->load(fn);
   1.711 -		mapCenter->reposition();
   1.712 +		model->reposition();
   1.713  		scene()->update();
   1.714  		return fio;
   1.715  	}
   1.716 @@ -3942,7 +3967,7 @@
   1.717  		bo->setFrameType (t);
   1.718  		saveState (bo, QString("setFrameType (\"%1\")").arg(s),
   1.719  			bo, QString ("setFrameType (\"%1\")").arg(bo->getFrameTypeName()),QString ("set type of frame to %1").arg(s));
   1.720 -		mapCenter->reposition();
   1.721 +		model->reposition();
   1.722  		bo->updateLink();
   1.723  	}
   1.724  }
   1.725 @@ -3955,7 +3980,7 @@
   1.726  		saveState (bo, QString("setFrameType (\"%1\")").arg(bo->getFrameTypeName()),
   1.727  			bo, QString ("setFrameType (\"%1\")").arg(s),QString ("set type of frame to %1").arg(s));
   1.728  		bo->setFrameType (s);
   1.729 -		mapCenter->reposition();
   1.730 +		model->reposition();
   1.731  		bo->updateLink();
   1.732  	}
   1.733  }
   1.734 @@ -3990,7 +4015,7 @@
   1.735  		saveState (bo, QString("setFramePadding (\"%1\")").arg(bo->getFramePadding() ),
   1.736  			bo, QString ("setFramePadding (\"%1\")").arg(i),QString ("set brush color of frame to %1").arg(i));
   1.737  		bo->setFramePadding (i);
   1.738 -		mapCenter->reposition();
   1.739 +		model->reposition();
   1.740  		bo->updateLink();
   1.741  	}	
   1.742  }
   1.743 @@ -4003,7 +4028,7 @@
   1.744  		saveState (bo, QString("setFrameBorderWidth (\"%1\")").arg(bo->getFrameBorderWidth() ),
   1.745  			bo, QString ("setFrameBorderWidth (\"%1\")").arg(i),QString ("set border width of frame to %1").arg(i));
   1.746  		bo->setFrameBorderWidth (i);
   1.747 -		mapCenter->reposition();
   1.748 +		model->reposition();
   1.749  		bo->updateLink();
   1.750  	}	
   1.751  }
   1.752 @@ -4024,7 +4049,7 @@
   1.753  			QString("Include images vertically in %1").arg(getName(bo))
   1.754  		);	
   1.755  		bo->setIncludeImagesVer(b);
   1.756 -		mapCenter->reposition();
   1.757 +		model->reposition();
   1.758  	}	
   1.759  }
   1.760  
   1.761 @@ -4044,7 +4069,7 @@
   1.762  			QString("Include images horizontally in %1").arg(getName(bo))
   1.763  		);	
   1.764  		bo->setIncludeImagesHor(b);
   1.765 -		mapCenter->reposition();
   1.766 +		model->reposition();
   1.767  	}	
   1.768  }
   1.769  
   1.770 @@ -4146,7 +4171,7 @@
   1.771  		if ( fd->exec() == QDialog::Accepted )
   1.772  		{
   1.773  			importDirInt (fd->selectedFile() );
   1.774 -			mapCenter->reposition();
   1.775 +			model->reposition();
   1.776  			scene()->update();
   1.777  		}
   1.778  	}	
   1.779 @@ -4232,8 +4257,9 @@
   1.780  	
   1.781  void MapEditor::testFunction2()
   1.782  {
   1.783 -	mapCenter->reposition();
   1.784 -	scene()->update();
   1.785 +
   1.786 +	cout << "Selection: "<<xelection.getSelectString().ascii()<<endl;
   1.787 +//	model->addMapCenter();
   1.788  
   1.789  /*
   1.790  	// Toggle hidemode
   1.791 @@ -4258,7 +4284,7 @@
   1.792  	// mouseEvent, we don't need to close here.
   1.793  
   1.794      QPointF p = mapToScene(e->pos());
   1.795 -    LinkableMapObj* lmo=mapCenter->findMapObj(p, NULL);
   1.796 +    LinkableMapObj* lmo=model->findMapObj(p, NULL);
   1.797  	
   1.798      if (lmo) 
   1.799  	{	// MapObj was found
   1.800 @@ -4336,7 +4362,7 @@
   1.801  	}
   1.802  
   1.803      QPointF p = mapToScene(e->pos());
   1.804 -    LinkableMapObj* lmo=mapCenter->findMapObj(p, NULL);
   1.805 +    LinkableMapObj* lmo=model->findMapObj(p, NULL);
   1.806  	
   1.807  	e->accept();
   1.808  
   1.809 @@ -4425,13 +4451,14 @@
   1.810  			if (mainWindow->getModMode()==Main::ModModeCopy &&
   1.811  				e->state() & Qt::ControlModifier)
   1.812  			{
   1.813 -				if (xelection.type()==Selection::Branch)
   1.814 +				BranchObj *bo=xelection.getBranch();
   1.815 +				if (bo)
   1.816  				{
   1.817  					copyingObj=true;
   1.818 -					mapCenter->addBranch ((BranchObj*)xelection.single());
   1.819 +					bo->addBranch ((BranchObj*)xelection.single());
   1.820  					unselect();
   1.821 -					xelection.select(mapCenter->getLastBranch());
   1.822 -					mapCenter->reposition();
   1.823 +					xelection.select(bo->getLastBranch());
   1.824 +					model->reposition();
   1.825  				}
   1.826  			} 
   1.827  
   1.828 @@ -4483,7 +4510,7 @@
   1.829  		// of selection back to absPos)
   1.830  		
   1.831  		// Check if we could link 
   1.832 -		LinkableMapObj* lmo=mapCenter->findMapObj(p, lmosel);
   1.833 +		LinkableMapObj* lmo=model->findMapObj(p, lmosel);
   1.834  		
   1.835  
   1.836  		FloatObj *fio=xelection.getFloatImage();
   1.837 @@ -4517,13 +4544,13 @@
   1.838  						"moveRel "+pnow,
   1.839  						QString("Move %1 to relative position %2").arg(getName(fio)).arg(pnow));
   1.840  					fio->getParObj()->requestReposition();
   1.841 -					mapCenter->reposition();
   1.842 +					model->reposition();
   1.843  
   1.844  					linkTo (lmo->getSelectString());
   1.845  					//movingObj=lmosel;
   1.846  					//movingObj_orgRelPos=lmosel->getRelPos();	
   1.847  
   1.848 -					mapCenter->reposition();
   1.849 +					model->reposition();
   1.850  				}	
   1.851  			}
   1.852  		} else	
   1.853 @@ -4532,10 +4559,10 @@
   1.854  			{
   1.855  				// Move MapCenter
   1.856  				if (e->buttons()== Qt::LeftButton && e->modifiers()==Qt::ShiftModifier) 
   1.857 -					mapCenter->moveAll(p.x() -movingObj_start.x(), p.y()-movingObj_start.y() );		
   1.858 +					((MapCenterObj*)lmosel)->moveAll(p.x() -movingObj_start.x(), p.y()-movingObj_start.y() );		
   1.859  				else	
   1.860 -					mapCenter->move   (p.x() -movingObj_start.x(), p.y()-movingObj_start.y() );		
   1.861 -				mapCenter->updateRelPositions();	
   1.862 +					lmosel->move   (p.x() -movingObj_start.x(), p.y()-movingObj_start.y() );		
   1.863 +				model->updateRelPositions();
   1.864  			} else
   1.865  			{	
   1.866  				if (lmosel->getDepth()==1)
   1.867 @@ -4614,7 +4641,7 @@
   1.868  		pickingColor=false;
   1.869  		setCursor (Qt::ArrowCursor);
   1.870  		// Check if we are over another branch
   1.871 -		dst=mapCenter->findMapObj(p, NULL);
   1.872 +		dst=model->findMapObj(p, NULL);
   1.873  		if (dst && lmosel) 
   1.874  		{	
   1.875  			if (e->state() & Qt::ShiftModifier)
   1.876 @@ -4630,7 +4657,7 @@
   1.877  	{
   1.878  		drawingLink=false;
   1.879  		// Check if we are over another branch
   1.880 -		dst=mapCenter->findMapObj(p, NULL);
   1.881 +		dst=model->findMapObj(p, NULL);
   1.882  		if (dst && lmosel) 
   1.883  		{	
   1.884  			tmpXLink->setEnd ( ((BranchObj*)(dst)) );
   1.885 @@ -4662,33 +4689,32 @@
   1.886  				QString("Move %1 to relative position %2").arg(getName(fo)).arg(pnow));
   1.887  
   1.888  			fo->getParObj()->requestReposition();
   1.889 -			mapCenter->reposition();
   1.890 +			model->reposition();
   1.891  		}	
   1.892  
   1.893  		// Check if we are over another branch, but ignore 
   1.894  		// any found LMOs, which are FloatObjs
   1.895 -		dst=mapCenter->findMapObj(mapToScene(e->pos() ), lmosel);
   1.896 +		dst=model->findMapObj(mapToScene(e->pos() ), lmosel);
   1.897  
   1.898  		if (dst && (typeid(*dst)!=typeid(BranchObj) && typeid(*dst)!=typeid(MapCenterObj))) 
   1.899  			dst=NULL;
   1.900  		
   1.901 -		if (xelection.type() == Selection::MapCenter )
   1.902 +		BranchObj *bo=xelection.getBranch();
   1.903 +		if (bo && bo->getDepth()==0)
   1.904  		{	
   1.905 -			// TODO: Check for problems if graphicsview is resized for 
   1.906 -			// undo/redo...
   1.907 -            if (movingObj_orgPos != mapCenter->getAbsPos())
   1.908 +            if (movingObj_orgPos != bo->getAbsPos())
   1.909              {
   1.910                  QString pold=qpointfToString(movingObj_orgPos);
   1.911 -                QString pnow=qpointfToString(mapCenter->getAbsPos());
   1.912 +                QString pnow=qpointfToString(bo->getAbsPos());
   1.913                  saveState(
   1.914                      fo,
   1.915                      "move "+pold,
   1.916                      fo,
   1.917                      "move "+pnow,
   1.918 -                    QString("Move mapcenter %1 to position %2").arg(getName(mapCenter)).arg(pnow));
   1.919 +                    QString("Move mapcenter %1 to position %2").arg(getName(bo)).arg(pnow));
   1.920              }
   1.921  		}
   1.922 -
   1.923 +	
   1.924  		if (xelection.type() == Selection::Branch )
   1.925  		{	// A branch was moved
   1.926  			
   1.927 @@ -4747,7 +4773,7 @@
   1.928  				{
   1.929  					// The select string might be different _after_ moving around.
   1.930  					// Therefor reposition and then use string of old selection, too
   1.931 -					mapCenter->reposition();
   1.932 +					model->reposition();
   1.933  
   1.934                      QPointF rp(lmosel->getRelPos());
   1.935                      if (rp != movingObj_orgRelPos)
   1.936 @@ -4760,7 +4786,7 @@
   1.937                      }
   1.938  				}
   1.939  			// Draw the original link, before selection was moved around
   1.940 -			mapCenter->reposition();
   1.941 +			model->reposition();
   1.942  		}
   1.943  		xelection.update();
   1.944  		// Finally resize scene, if needed
   1.945 @@ -4786,7 +4812,7 @@
   1.946  	if (e->button() == Qt::LeftButton )
   1.947  	{
   1.948  		QPointF p = mapToScene(e->pos());
   1.949 -		LinkableMapObj *lmo=mapCenter->findMapObj(p, NULL);
   1.950 +		LinkableMapObj *lmo=model->findMapObj(p, NULL);
   1.951  		if (lmo) {	// MapObj was found
   1.952  			// First select the MapObj than edit heading
   1.953  			xelection.select(lmo);
   1.954 @@ -4876,7 +4902,7 @@
   1.955  					}
   1.956  				}
   1.957  			}
   1.958 -			mapCenter->reposition();
   1.959 +			model->reposition();
   1.960  		}
   1.961  	}	
   1.962  	event->acceptProposedAction();
   1.963 @@ -4893,7 +4919,7 @@
   1.964  		animObjList.at(i)->animate();
   1.965  		((BranchObj*)animObjList.at(i))->move2RelPos (((BranchObj*)animObjList.at(i))->getRelPos() );
   1.966  	}
   1.967 -	mapCenter->reposition();
   1.968 +	model->reposition();
   1.969  }
   1.970  
   1.971  
   1.972 @@ -5011,19 +5037,19 @@
   1.973      case QAbstractSocket::RemoteHostClosedError:
   1.974          break;
   1.975      case QAbstractSocket::HostNotFoundError:
   1.976 -        QMessageBox::information(this, __VYM_NAME " Network client",
   1.977 +        QMessageBox::information(this, vymName +" Network client",
   1.978                                   "The host was not found. Please check the "
   1.979                                      "host name and port settings.");
   1.980          break;
   1.981      case QAbstractSocket::ConnectionRefusedError:
   1.982 -        QMessageBox::information(this, __VYM_NAME " Network client",
   1.983 +        QMessageBox::information(this, vymName + " Network client",
   1.984                                   "The connection was refused by the peer. "
   1.985                                      "Make sure the fortune server is running, "
   1.986                                      "and check that the host name and port "
   1.987                                      "settings are correct.");
   1.988          break;
   1.989      default:
   1.990 -        QMessageBox::information(this, __VYM_NAME " Network client",
   1.991 +        QMessageBox::information(this, vymName + " Network client",
   1.992                                   QString("The following error occurred: %1.")
   1.993                                   .arg(clientSocket->errorString()));
   1.994      }
   1.995 @@ -5115,7 +5141,7 @@
   1.996  	QString s=bo->getSelectString();
   1.997  	saveState (PartOfMap, s, "nop ()", s, "copy ()","Copy dropped image to clipboard",fio  );
   1.998  	saveState (fio,"delete ()", bo,QString("paste(%1)").arg(curStep),"Pasting dropped image");
   1.999 -    mapCenter->reposition();
  1.1000 +    model->reposition();
  1.1001      scene()->update();
  1.1002    }
  1.1003  }