Started to restructure for later use of Model/View
authorinsilmaril
Wed, 16 Jul 2008 10:44:44 +0000
changeset 720192e1392ba6a
parent 719 3f90aab4794d
child 721 12958f987bcf
Started to restructure for later use of Model/View
mapeditor.cpp
mapeditor.h
     1.1 --- a/mapeditor.cpp	Mon Jul 14 11:25:09 2008 +0000
     1.2 +++ b/mapeditor.cpp	Wed Jul 16 10:44:44 2008 +0000
     1.3 @@ -1,27 +1,16 @@
     1.4  #include "mapeditor.h"
     1.5  
     1.6 -#include <q3filedialog.h>
     1.7 -
     1.8  #include <iostream>
     1.9  #include <cstdlib>
    1.10  #include <typeinfo>
    1.11  
    1.12 -#include "parser.h"
    1.13 -#include "editxlinkdialog.h"
    1.14 -#include "exports.h"
    1.15 -#include "exportxhtmldialog.h"
    1.16 -#include "extrainfodialog.h"
    1.17 -#include "file.h"
    1.18 -#include "linkablemapobj.h"
    1.19 +#include <QObject>
    1.20 +
    1.21  #include "mainwindow.h"
    1.22  #include "misc.h"
    1.23 -#include "texteditor.h"
    1.24  #include "warningdialog.h"
    1.25 -#include "xml-freemind.h"
    1.26 -#include "xml-vym.h"
    1.27  
    1.28  
    1.29 -extern TextEditor *textEditor;
    1.30  extern int statusbarTime;
    1.31  extern Main *mainWindow;
    1.32  extern QString tmpVymDir;
    1.33 @@ -40,48 +29,28 @@
    1.34  extern QMenu* floatimageContextMenu;
    1.35  extern QMenu* canvasContextMenu;
    1.36  
    1.37 -
    1.38  extern Settings settings;
    1.39 -extern ImageIO imageIO;
    1.40 -
    1.41 -extern QString vymName;
    1.42 -extern QString vymVersion;
    1.43 -
    1.44  extern QString iconPath;
    1.45 -extern QDir vymBaseDir;
    1.46 -extern QDir lastImageDir;
    1.47 -extern QDir lastFileDir;
    1.48 -
    1.49 -int MapEditor::mapNum=0;	// make instance
    1.50  
    1.51  ///////////////////////////////////////////////////////////////////////
    1.52  ///////////////////////////////////////////////////////////////////////
    1.53 -MapEditor::MapEditor( QWidget* parent) :
    1.54 -  QGraphicsView(parent)  
    1.55 +MapEditor::MapEditor( VymModel *vm) 
    1.56  {
    1.57 -	setObjectName ("MapEditor");
    1.58 -
    1.59  	//cout << "Constructor ME "<<this<<endl;
    1.60 -	mapNum++;
    1.61 -
    1.62 -
    1.63 -	mapScene= new QGraphicsScene(parent);
    1.64 -	//mapScene= new QGraphicsScene(QRectF(0,0,width(),height()), parent);
    1.65 +	mapScene= new QGraphicsScene(NULL);
    1.66  	mapScene->setBackgroundBrush (QBrush(Qt::white, Qt::SolidPattern));
    1.67  
    1.68 -	model=new VymModel();
    1.69 +	model=vm;
    1.70  	model->setScene (mapScene);
    1.71  	model->setMapEditor (this);
    1.72 +	model->registerEditor(this);
    1.73 +	model->addMapCenter();	//  FIXME create this in MapEditor until BO and MCO are independent of scene
    1.74 +	model->makeDefault();
    1.75  
    1.76      setScene (mapScene);
    1.77  
    1.78      printer=NULL;
    1.79  
    1.80 -	defLinkColor=QColor (0,0,255);
    1.81 -	defXLinkColor=QColor (180,180,180);
    1.82 -	linkcolorhint=LinkableMapObj::DefaultColor;
    1.83 -	linkstyle=LinkableMapObj::PolyParabel;
    1.84 -
    1.85  	// Create bitmap cursors, platform dependant
    1.86  	HandOpenCursor=QCursor (QPixmap(iconPath+"cursorhandopen.png"),1,1);		
    1.87  	PickColorCursor=QCursor ( QPixmap(iconPath+"cursorcolorpicker.png"), 5,27 ); 
    1.88 @@ -97,58 +66,31 @@
    1.89      editingBO=NULL;
    1.90      movingObj=NULL;
    1.91  
    1.92 -	xelection.setModel (model);
    1.93 -	xelection.unselect();
    1.94 -
    1.95 -	defXLinkWidth=1;
    1.96 -	defXLinkColor=QColor (230,230,230);
    1.97 -
    1.98 -    mapChanged=false;
    1.99 -	mapDefault=true;
   1.100 -	mapUnsaved=false;
   1.101 -	
   1.102 -	zipped=true;
   1.103 -	filePath="";
   1.104 -	fileName=tr("unnamed");
   1.105 -	mapName="";
   1.106 -
   1.107 -	stepsTotal=settings.readNumEntry("/mapeditor/stepsTotal",100);
   1.108 -	undoSet.setEntry ("/history/stepsTotal",QString::number(stepsTotal));
   1.109 -	mainWindow->updateHistory (undoSet);
   1.110 -	
   1.111 -	// Initialize find routine
   1.112 -	itFind=NULL;				
   1.113 -	EOFind=false;
   1.114 -
   1.115  	printFrame=true;
   1.116  	printFooter=true;
   1.117  
   1.118 -	blockReposition=false;
   1.119 -	blockSaveState=false;
   1.120 -
   1.121 -	hidemode=HideNone;
   1.122 -
   1.123 -	// Create temporary files
   1.124 -	makeTmpDirs();
   1.125 -
   1.126 -	curStep=0;
   1.127 -	redosAvail=0;
   1.128 -	undosAvail=0;
   1.129 -
   1.130  	setAcceptDrops (true);	
   1.131  
   1.132 -	model->reposition();
   1.133 +	model->reposition();	//FIXME really still needed?
   1.134  
   1.135 -	// autosave
   1.136 -	autosaveTimer=new QTimer (this);
   1.137 -	connect(autosaveTimer, SIGNAL(timeout()), this, SLOT(autosave()));
   1.138  
   1.139 -	fileChangedTimer=new QTimer (this);
   1.140 -	fileChangedTimer->start(3000);
   1.141 -	connect(fileChangedTimer, SIGNAL(timeout()), this, SLOT(fileChanged()));
   1.142 +	// Action to embed LineEdit for heading in Scene
   1.143 +	editingHeading=false;
   1.144 +	lineEdit=new QLineEdit;
   1.145 +	lineEdit->hide();
   1.146 +	QGraphicsProxyWidget *pw=scene()->addWidget (lineEdit);
   1.147 +	pw->setZValue (100);
   1.148  
   1.149 -	// Network
   1.150 -	netstate=Offline;
   1.151 +	QAction *a = new QAction( tr( "Edit heading","MapEditor" ), this);
   1.152 +	a->setShortcut ( Qt::Key_Return );					//Edit heading
   1.153 +	//a->setShortcutContext (Qt::WindowShortcut);
   1.154 +	addAction (a);
   1.155 +    connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
   1.156 +	a = new QAction( tr( "Edit heading","MapEditor" ), this);
   1.157 +	a->setShortcut ( Qt::Key_Enter);					//Edit heading
   1.158 +	//a->setShortcutContext (Qt::WindowShortcut);
   1.159 +	addAction (a);
   1.160 +    connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
   1.161  
   1.162  	// Attributes	//FIXME testing only...
   1.163  	QString k;
   1.164 @@ -186,13 +128,10 @@
   1.165  MapEditor::~MapEditor()
   1.166  {
   1.167  	//cout <<"Destructor MapEditor\n";
   1.168 -	autosaveTimer->stop();
   1.169 -	fileChangedTimer->stop();
   1.170 -
   1.171  	// tmpMapDir is in tmpVymDir, so it gets removed automagically when vym closes
   1.172  	
   1.173 -	//removeDir(QDir(tmpMapDir));
   1.174 -	delete (model);
   1.175 +	//removeDir(QDir(tmpMapDir));	// FIXME check?!?
   1.176 +	model->unregisterEditor(this);
   1.177  }
   1.178  
   1.179  VymModel* MapEditor::getModel()
   1.180 @@ -205,1650 +144,6 @@
   1.181      return mapScene;
   1.182  }
   1.183  
   1.184 -MapEditor::State MapEditor::getState()
   1.185 -{
   1.186 -    return state;
   1.187 -}
   1.188 -
   1.189 -void MapEditor::setStateEditHeading(bool s)
   1.190 -{
   1.191 -	if (s)
   1.192 -	{
   1.193 -		if (state==Idle) state=EditHeading;
   1.194 -	}
   1.195 -	else	
   1.196 -		state=Idle;
   1.197 -}
   1.198 -
   1.199 -bool MapEditor::isRepositionBlocked()
   1.200 -{
   1.201 -	return blockReposition;
   1.202 -}
   1.203 -
   1.204 -void MapEditor::setSaveStateBlocked(bool b)
   1.205 -{
   1.206 -	blockSaveState=b;
   1.207 -}
   1.208 -
   1.209 -bool MapEditor::isSelectBlocked()
   1.210 -{
   1.211 -	if (state==EditHeading)
   1.212 -		return true;
   1.213 -	else
   1.214 -		return false; 
   1.215 -}
   1.216 -
   1.217 -QString MapEditor::getName (const LinkableMapObj *lmo)
   1.218 -{
   1.219 -	QString s;
   1.220 -	if (!lmo) return QString("Error: NULL has no name!");
   1.221 -
   1.222 -	if ((typeid(*lmo) == typeid(BranchObj) ||
   1.223 -				      typeid(*lmo) == typeid(MapCenterObj))) 
   1.224 -	{
   1.225 -		
   1.226 -		s=(((BranchObj*)lmo)->getHeading());
   1.227 -		if (s=="") s="unnamed";
   1.228 -		return QString("branch (%1)").arg(s);
   1.229 -	}	
   1.230 -	if ((typeid(*lmo) == typeid(FloatImageObj) ))
   1.231 -		return QString ("floatimage [%1]").arg(((FloatImageObj*)lmo)->getOriginalFilename());
   1.232 -	return QString("Unknown type has no name!");
   1.233 -}
   1.234 -
   1.235 -void MapEditor::makeTmpDirs()
   1.236 -{
   1.237 -	// Create unique temporary directories
   1.238 -	tmpMapDir = tmpVymDir+QString("/mapeditor-%1").arg(mapNum);
   1.239 -	histPath = tmpMapDir+"/history";
   1.240 -	QDir d;
   1.241 -	d.mkdir (tmpMapDir);
   1.242 -}
   1.243 -
   1.244 -QString MapEditor::saveToDir(const QString &tmpdir, const QString &prefix, bool writeflags, const QPointF &offset, LinkableMapObj *saveSel)
   1.245 -{
   1.246 -	// tmpdir		temporary directory to which data will be written
   1.247 -	// prefix		mapname, which will be appended to images etc.
   1.248 -	// writeflags	Only write flags for "real" save of map, not undo
   1.249 -	// offset		offset of bbox of whole map in scene. 
   1.250 -	//				Needed for XML export
   1.251 -	
   1.252 -	// Save Header
   1.253 -	QString ls;
   1.254 -	switch (linkstyle)
   1.255 -	{
   1.256 -		case LinkableMapObj::Line: 
   1.257 -			ls="StyleLine";
   1.258 -			break;
   1.259 -		case LinkableMapObj::Parabel:
   1.260 -			ls="StyleParabel";
   1.261 -			break;
   1.262 -		case LinkableMapObj::PolyLine:	
   1.263 -			ls="StylePolyLine";
   1.264 -			break;
   1.265 -		default:
   1.266 -			ls="StylePolyParabel";
   1.267 -			break;
   1.268 -	}	
   1.269 -
   1.270 -	QString s="<?xml version=\"1.0\" encoding=\"utf-8\"?><!DOCTYPE vymmap>\n";
   1.271 -	QString colhint="";
   1.272 -	if (linkcolorhint==LinkableMapObj::HeadingColor) 
   1.273 -		colhint=attribut("linkColorHint","HeadingColor");
   1.274 -
   1.275 -	QString mapAttr=attribut("version",vymVersion);
   1.276 -	if (!saveSel)
   1.277 -		mapAttr+= attribut("author",model->getAuthor()) +
   1.278 -				  attribut("comment",model->getComment()) +
   1.279 -			      attribut("date",model->getDate()) +
   1.280 -		          attribut("backgroundColor", mapScene->backgroundBrush().color().name() ) +
   1.281 -		          attribut("selectionColor", xelection.getColor().name() ) +
   1.282 -		          attribut("linkStyle", ls ) +
   1.283 -		          attribut("linkColor", defLinkColor.name() ) +
   1.284 -		          attribut("defXLinkColor", defXLinkColor.name() ) +
   1.285 -		          attribut("defXLinkWidth", QString().setNum(defXLinkWidth,10) ) +
   1.286 -		          colhint; 
   1.287 -	s+=beginElement("vymmap",mapAttr);
   1.288 -	incIndent();
   1.289 -
   1.290 -	// Find the used flags while traversing the tree
   1.291 -	standardFlagsDefault->resetUsedCounter();
   1.292 -	
   1.293 -	// Reset the counters before saving
   1.294 -	// TODO constr. of FIO creates lots of objects, better do this in some other way...
   1.295 -	FloatImageObj (mapScene).resetSaveCounter();
   1.296 -
   1.297 -	// Build xml recursivly
   1.298 -	if (!saveSel || typeid (*saveSel) == typeid (MapCenterObj))
   1.299 -		// Save complete map, if saveSel not set
   1.300 -		s+=model->saveToDir(tmpdir,prefix,writeflags,offset);
   1.301 -	else
   1.302 -	{
   1.303 -		if ( typeid(*saveSel) == typeid(BranchObj) )
   1.304 -			// Save Subtree
   1.305 -			s+=((BranchObj*)(saveSel))->saveToDir(tmpdir,prefix,offset);
   1.306 -		else if ( typeid(*saveSel) == typeid(FloatImageObj) )
   1.307 -			// Save image
   1.308 -			s+=((FloatImageObj*)(saveSel))->saveToDir(tmpdir,prefix);
   1.309 -	}
   1.310 -
   1.311 -	// Save local settings
   1.312 -	s+=settings.getDataXML (destPath);
   1.313 -
   1.314 -	// Save selection
   1.315 -	if (!xelection.isEmpty() && !saveSel ) 
   1.316 -		s+=valueElement("select",xelection.getSelectString());
   1.317 -
   1.318 -	decIndent();
   1.319 -	s+=endElement("vymmap");
   1.320 -
   1.321 -	if (writeflags)
   1.322 -		standardFlagsDefault->saveToDir (tmpdir+"/flags/","",writeflags);
   1.323 -	return s;
   1.324 -}
   1.325 -
   1.326 -QString MapEditor::getHistoryDir()
   1.327 -{
   1.328 -	QString histName(QString("history-%1").arg(curStep));
   1.329 -	return (tmpMapDir+"/"+histName);
   1.330 -}
   1.331 -
   1.332 -void MapEditor::saveState(const SaveMode &savemode, const QString &undoSelection, const QString &undoCom, const QString &redoSelection, const QString &redoCom, const QString &comment, LinkableMapObj *saveSel)
   1.333 -{
   1.334 -	sendData(redoCom);	//FIXME testing
   1.335 -
   1.336 -	// Main saveState
   1.337 -
   1.338 -
   1.339 -	if (blockSaveState) return;
   1.340 -
   1.341 -	if (debug) cout << "ME::saveState() for  "<<qPrintable (mapName)<<endl;
   1.342 -	
   1.343 -	// Find out current undo directory
   1.344 -	if (undosAvail<stepsTotal) undosAvail++;
   1.345 -	curStep++;
   1.346 -	if (curStep>stepsTotal) curStep=1;
   1.347 -	
   1.348 -	QString backupXML="";
   1.349 -	QString histDir=getHistoryDir();
   1.350 -	QString bakMapPath=histDir+"/map.xml";
   1.351 -
   1.352 -	// Create histDir if not available
   1.353 -	QDir d(histDir);
   1.354 -	if (!d.exists()) 
   1.355 -		makeSubDirs (histDir);
   1.356 -
   1.357 -	// Save depending on how much needs to be saved	
   1.358 -	if (saveSel)
   1.359 -		backupXML=saveToDir (histDir,mapName+"-",false, QPointF (),saveSel);
   1.360 -		
   1.361 -	QString undoCommand="";
   1.362 -	if (savemode==UndoCommand)
   1.363 -	{
   1.364 -		undoCommand=undoCom;
   1.365 -	}	
   1.366 -	else if (savemode==PartOfMap )
   1.367 -	{
   1.368 -		undoCommand=undoCom;
   1.369 -		undoCommand.replace ("PATH",bakMapPath);
   1.370 -	}
   1.371 -
   1.372 -	if (!backupXML.isEmpty())
   1.373 -		// Write XML Data to disk
   1.374 -		saveStringToDisk (bakMapPath,backupXML);
   1.375 -
   1.376 -	// We would have to save all actions in a tree, to keep track of 
   1.377 -	// possible redos after a action. Possible, but we are too lazy: forget about redos.
   1.378 -	redosAvail=0;
   1.379 -
   1.380 -	// Write the current state to disk
   1.381 -	undoSet.setEntry ("/history/undosAvail",QString::number(undosAvail));
   1.382 -	undoSet.setEntry ("/history/redosAvail",QString::number(redosAvail));
   1.383 -	undoSet.setEntry ("/history/curStep",QString::number(curStep));
   1.384 -	undoSet.setEntry (QString("/history/step-%1/undoCommand").arg(curStep),undoCommand);
   1.385 -	undoSet.setEntry (QString("/history/step-%1/undoSelection").arg(curStep),undoSelection);
   1.386 -	undoSet.setEntry (QString("/history/step-%1/redoCommand").arg(curStep),redoCom);
   1.387 -	undoSet.setEntry (QString("/history/step-%1/redoSelection").arg(curStep),redoSelection);
   1.388 -	undoSet.setEntry (QString("/history/step-%1/comment").arg(curStep),comment);
   1.389 -	undoSet.setEntry (QString("/history/version"),vymVersion);
   1.390 -	undoSet.writeSettings(histPath);
   1.391 -
   1.392 -	if (debug)
   1.393 -	{
   1.394 -		// TODO remove after testing
   1.395 -		//cout << "          into="<< histPath.toStdString()<<endl;
   1.396 -		cout << "    stepsTotal="<<stepsTotal<<
   1.397 -		", undosAvail="<<undosAvail<<
   1.398 -		", redosAvail="<<redosAvail<<
   1.399 -		", curStep="<<curStep<<endl;
   1.400 -		cout << "    ---------------------------"<<endl;
   1.401 -		cout << "    comment="<<comment.toStdString()<<endl;
   1.402 -		cout << "    undoCom="<<undoCommand.toStdString()<<endl;
   1.403 -		cout << "    undoSel="<<undoSelection.toStdString()<<endl;
   1.404 -		cout << "    redoCom="<<redoCom.toStdString()<<endl;
   1.405 -		cout << "    redoSel="<<redoSelection.toStdString()<<endl;
   1.406 -		if (saveSel) cout << "    saveSel="<<qPrintable (model->getSelectString(saveSel))<<endl;
   1.407 -		cout << "    ---------------------------"<<endl;
   1.408 -	}
   1.409 -
   1.410 -	mainWindow->updateHistory (undoSet);
   1.411 -	setChanged();
   1.412 -	updateActions();
   1.413 -}
   1.414 -
   1.415 -
   1.416 -void MapEditor::saveStateChangingPart(LinkableMapObj *undoSel, LinkableMapObj* redoSel, const QString &rc, const QString &comment)
   1.417 -{
   1.418 -	// save the selected part of the map, Undo will replace part of map 
   1.419 -	QString undoSelection="";
   1.420 -	if (undoSel)
   1.421 -		undoSelection=model->getSelectString(undoSel);
   1.422 -	else
   1.423 -		qWarning ("MapEditor::saveStateChangingPart  no undoSel given!");
   1.424 -	QString redoSelection="";
   1.425 -	if (redoSel)
   1.426 -		redoSelection=model->getSelectString(undoSel);
   1.427 -	else
   1.428 -		qWarning ("MapEditor::saveStateChangingPart  no redoSel given!");
   1.429 -		
   1.430 -
   1.431 -	saveState (PartOfMap,
   1.432 -		undoSelection, "addMapReplace (\"PATH\")",
   1.433 -		redoSelection, rc, 
   1.434 -		comment, 
   1.435 -		undoSel);
   1.436 -}
   1.437 -
   1.438 -void MapEditor::saveStateRemovingPart(LinkableMapObj *redoSel, const QString &comment)
   1.439 -{
   1.440 -	if (!redoSel)
   1.441 -	{
   1.442 -		qWarning ("MapEditor::saveStateRemovingPart  no redoSel given!");
   1.443 -		return;
   1.444 -	}
   1.445 -	QString undoSelection=model->getSelectString (redoSel->getParObj());
   1.446 -	QString redoSelection=model->getSelectString(redoSel);
   1.447 -	if (typeid(*redoSel) == typeid(BranchObj)  ) 
   1.448 -	{
   1.449 -		// save the selected branch of the map, Undo will insert part of map 
   1.450 -		saveState (PartOfMap,
   1.451 -			undoSelection, QString("addMapInsert (\"PATH\",%1)").arg(((BranchObj*)redoSel)->getNum()),
   1.452 -			redoSelection, "delete ()", 
   1.453 -			comment, 
   1.454 -			redoSel);
   1.455 -	}
   1.456 -}
   1.457 -
   1.458 -
   1.459 -void MapEditor::saveState(LinkableMapObj *undoSel, const QString &uc, LinkableMapObj *redoSel, const QString &rc, const QString &comment) 
   1.460 -{
   1.461 -	// "Normal" savestate: save commands, selections and comment
   1.462 -	// so just save commands for undo and redo
   1.463 -	// and use current selection
   1.464 -
   1.465 -	QString redoSelection="";
   1.466 -	if (redoSel) redoSelection=model->getSelectString(redoSel);
   1.467 -	QString undoSelection="";
   1.468 -	if (undoSel) undoSelection=model->getSelectString(undoSel);
   1.469 -
   1.470 -	saveState (UndoCommand,
   1.471 -		undoSelection, uc,
   1.472 -		redoSelection, rc, 
   1.473 -		comment, 
   1.474 -		NULL);
   1.475 -}
   1.476 -
   1.477 -void MapEditor::saveState(const QString &undoSel, const QString &uc, const QString &redoSel, const QString &rc, const QString &comment) 
   1.478 -{
   1.479 -	// "Normal" savestate: save commands, selections and comment
   1.480 -	// so just save commands for undo and redo
   1.481 -	// and use current selection
   1.482 -	saveState (UndoCommand,
   1.483 -		undoSel, uc,
   1.484 -		redoSel, rc, 
   1.485 -		comment, 
   1.486 -		NULL);
   1.487 -}
   1.488 -
   1.489 -void MapEditor::saveState(const QString &uc, const QString &rc, const QString &comment) 
   1.490 -{
   1.491 -	// "Normal" savestate applied to model (no selection needed): 
   1.492 -	// save commands  and comment
   1.493 -	saveState (UndoCommand,
   1.494 -		NULL, uc,
   1.495 -		NULL, rc, 
   1.496 -		comment, 
   1.497 -		NULL);
   1.498 -}
   1.499 -
   1.500 -		
   1.501 -void MapEditor::parseAtom(const QString &atom)
   1.502 -{
   1.503 -	BranchObj *selb=xelection.getBranch();
   1.504 -	QString s,t;
   1.505 -	double x,y;
   1.506 -	int n;
   1.507 -	bool b,ok;
   1.508 -
   1.509 -	// Split string s into command and parameters
   1.510 -	parser.parseAtom (atom);
   1.511 -	QString com=parser.getCommand();
   1.512 -	
   1.513 -	// External commands
   1.514 -	/////////////////////////////////////////////////////////////////////
   1.515 -	if (com=="addBranch")
   1.516 -	{
   1.517 -		if (xelection.isEmpty())
   1.518 -		{
   1.519 -			parser.setError (Aborted,"Nothing selected");
   1.520 -		} else if (! selb )
   1.521 -		{				  
   1.522 -			parser.setError (Aborted,"Type of selection is not a branch");
   1.523 -		} else 
   1.524 -		{	
   1.525 -			QList <int> pl;
   1.526 -			pl << 0 <<1;
   1.527 -			if (parser.checkParCount(pl))
   1.528 -			{
   1.529 -				if (parser.parCount()==0)
   1.530 -					addNewBranch (0);
   1.531 -				else
   1.532 -				{
   1.533 -					n=parser.parInt (ok,0);
   1.534 -					if (ok ) addNewBranch (n);
   1.535 -				}
   1.536 -			}
   1.537 -		}
   1.538 -	/////////////////////////////////////////////////////////////////////
   1.539 -	} else if (com=="addBranchBefore")
   1.540 -	{
   1.541 -		if (xelection.isEmpty())
   1.542 -		{
   1.543 -			parser.setError (Aborted,"Nothing selected");
   1.544 -		} else if (! selb )
   1.545 -		{				  
   1.546 -			parser.setError (Aborted,"Type of selection is not a branch");
   1.547 -		} else 
   1.548 -		{	
   1.549 -			if (parser.parCount()==0)
   1.550 -			{
   1.551 -				addNewBranchBefore ();
   1.552 -			}	
   1.553 -		}
   1.554 -	/////////////////////////////////////////////////////////////////////
   1.555 -	} else if (com==QString("addMapCenter"))
   1.556 -	{
   1.557 -		if (parser.checkParCount(2))
   1.558 -		{
   1.559 -			x=parser.parDouble (ok,0);
   1.560 -			if (ok)
   1.561 -			{
   1.562 -				y=parser.parDouble (ok,1);
   1.563 -				if (ok) model->addMapCenter (QPointF(x,y));
   1.564 -			}
   1.565 -		}	
   1.566 -	/////////////////////////////////////////////////////////////////////
   1.567 -	} else if (com==QString("addMapReplace"))
   1.568 -	{
   1.569 -		if (xelection.isEmpty())
   1.570 -		{
   1.571 -			parser.setError (Aborted,"Nothing selected");
   1.572 -		} else if (! selb )
   1.573 -		{				  
   1.574 -			parser.setError (Aborted,"Type of selection is not a branch");
   1.575 -		} else if (parser.checkParCount(1))
   1.576 -		{
   1.577 -			//s=parser.parString (ok,0);	// selection
   1.578 -			t=parser.parString (ok,0);	// path to map
   1.579 -			if (QDir::isRelativePath(t)) t=(tmpMapDir + "/"+t);
   1.580 -			addMapReplaceInt(model->getSelectString(selb),t);	
   1.581 -		}
   1.582 -	/////////////////////////////////////////////////////////////////////
   1.583 -	} else if (com==QString("addMapInsert"))
   1.584 -	{
   1.585 -		if (xelection.isEmpty())
   1.586 -		{
   1.587 -			parser.setError (Aborted,"Nothing selected");
   1.588 -		} else if (! selb )
   1.589 -		{				  
   1.590 -			parser.setError (Aborted,"Type of selection is not a branch");
   1.591 -		} else 
   1.592 -		{	
   1.593 -			if (parser.checkParCount(2))
   1.594 -			{
   1.595 -				t=parser.parString (ok,0);	// path to map
   1.596 -				n=parser.parInt(ok,1);		// position
   1.597 -				if (QDir::isRelativePath(t)) t=(tmpMapDir + "/"+t);
   1.598 -				addMapInsertInt(t,n);	
   1.599 -			}
   1.600 -		}
   1.601 -	/////////////////////////////////////////////////////////////////////
   1.602 -	} else if (com=="clearFlags")
   1.603 -	{
   1.604 -		if (xelection.isEmpty() )
   1.605 -		{
   1.606 -			parser.setError (Aborted,"Nothing selected");
   1.607 -		} else if (! selb )
   1.608 -		{				  
   1.609 -			parser.setError (Aborted,"Type of selection is not a branch");
   1.610 -		} else if (parser.checkParCount(0))
   1.611 -		{
   1.612 -			selb->clearStandardFlags();	
   1.613 -			selb->updateFlagsToolbar();
   1.614 -		}
   1.615 -	/////////////////////////////////////////////////////////////////////
   1.616 -	} else if (com=="colorBranch")
   1.617 -	{
   1.618 -		if (xelection.isEmpty())
   1.619 -		{
   1.620 -			parser.setError (Aborted,"Nothing selected");
   1.621 -		} else if (! selb )
   1.622 -		{				  
   1.623 -			parser.setError (Aborted,"Type of selection is not a branch");
   1.624 -		} else if (parser.checkParCount(1))
   1.625 -		{	
   1.626 -			QColor c=parser.parColor (ok,0);
   1.627 -			if (ok) colorBranch (c);
   1.628 -		}	
   1.629 -	/////////////////////////////////////////////////////////////////////
   1.630 -	} else if (com=="colorSubtree")
   1.631 -	{
   1.632 -		if (xelection.isEmpty())
   1.633 -		{
   1.634 -			parser.setError (Aborted,"Nothing selected");
   1.635 -		} else if (! selb )
   1.636 -		{				  
   1.637 -			parser.setError (Aborted,"Type of selection is not a branch");
   1.638 -		} else if (parser.checkParCount(1))
   1.639 -		{	
   1.640 -			QColor c=parser.parColor (ok,0);
   1.641 -			if (ok) colorSubtree (c);
   1.642 -		}	
   1.643 -	/////////////////////////////////////////////////////////////////////
   1.644 -	} else if (com=="copy")
   1.645 -	{
   1.646 -		if (xelection.isEmpty())
   1.647 -		{
   1.648 -			parser.setError (Aborted,"Nothing selected");
   1.649 -		} else if (! selb )
   1.650 -		{				  
   1.651 -			parser.setError (Aborted,"Type of selection is not a branch");
   1.652 -		} else if (parser.checkParCount(0))
   1.653 -		{	
   1.654 -			//FIXME missing action for copy
   1.655 -		}	
   1.656 -	/////////////////////////////////////////////////////////////////////
   1.657 -	} else if (com=="cut")
   1.658 -	{
   1.659 -		if (xelection.isEmpty())
   1.660 -		{
   1.661 -			parser.setError (Aborted,"Nothing selected");
   1.662 -		} else if ( xelection.type()!=Selection::Branch  && 
   1.663 -					xelection.type()!=Selection::MapCenter  &&
   1.664 -					xelection.type()!=Selection::FloatImage )
   1.665 -		{				  
   1.666 -			parser.setError (Aborted,"Type of selection is not a branch or floatimage");
   1.667 -		} else if (parser.checkParCount(0))
   1.668 -		{	
   1.669 -			cut();
   1.670 -		}	
   1.671 -	/////////////////////////////////////////////////////////////////////
   1.672 -	} else if (com=="delete")
   1.673 -	{
   1.674 -		if (xelection.isEmpty())
   1.675 -		{
   1.676 -			parser.setError (Aborted,"Nothing selected");
   1.677 -		} 
   1.678 -		/*else if (xelection.type() != Selection::Branch && xelection.type() != Selection::FloatImage )
   1.679 -		{
   1.680 -			parser.setError (Aborted,"Type of selection is wrong.");
   1.681 -		} 
   1.682 -		*/
   1.683 -		else if (parser.checkParCount(0))
   1.684 -		{	
   1.685 -			deleteSelection();
   1.686 -		}	
   1.687 -	/////////////////////////////////////////////////////////////////////
   1.688 -	} else if (com=="deleteKeepChilds")
   1.689 -	{
   1.690 -		if (xelection.isEmpty())
   1.691 -		{
   1.692 -			parser.setError (Aborted,"Nothing selected");
   1.693 -		} else if (! selb )
   1.694 -		{
   1.695 -			parser.setError (Aborted,"Type of selection is not a branch");
   1.696 -		} else if (parser.checkParCount(0))
   1.697 -		{	
   1.698 -			deleteKeepChilds();
   1.699 -		}	
   1.700 -	/////////////////////////////////////////////////////////////////////
   1.701 -	} else if (com=="deleteChilds")
   1.702 -	{
   1.703 -		if (xelection.isEmpty())
   1.704 -		{
   1.705 -			parser.setError (Aborted,"Nothing selected");
   1.706 -		} else if (! selb)
   1.707 -		{
   1.708 -			parser.setError (Aborted,"Type of selection is not a branch");
   1.709 -		} else if (parser.checkParCount(0))
   1.710 -		{	
   1.711 -			deleteChilds();
   1.712 -		}	
   1.713 -	/////////////////////////////////////////////////////////////////////
   1.714 -	} else if (com=="exportASCII")
   1.715 -	{
   1.716 -		QString fname="";
   1.717 -		ok=true;
   1.718 -		if (parser.parCount()>=1)
   1.719 -			// Hey, we even have a filename
   1.720 -			fname=parser.parString(ok,0); 
   1.721 -		if (!ok)
   1.722 -		{
   1.723 -			parser.setError (Aborted,"Could not read filename");
   1.724 -		} else
   1.725 -		{
   1.726 -				exportASCII (fname,false);
   1.727 -		}
   1.728 -	/////////////////////////////////////////////////////////////////////
   1.729 -	} else if (com=="exportImage")
   1.730 -	{
   1.731 -		QString fname="";
   1.732 -		ok=true;
   1.733 -		if (parser.parCount()>=2)
   1.734 -			// Hey, we even have a filename
   1.735 -			fname=parser.parString(ok,0); 
   1.736 -		if (!ok)
   1.737 -		{
   1.738 -			parser.setError (Aborted,"Could not read filename");
   1.739 -		} else
   1.740 -		{
   1.741 -			QString format="PNG";
   1.742 -			if (parser.parCount()>=2)
   1.743 -			{
   1.744 -				format=parser.parString(ok,1);
   1.745 -			}
   1.746 -			exportImage (fname,false,format);
   1.747 -		}
   1.748 -	/////////////////////////////////////////////////////////////////////
   1.749 -	} else if (com=="exportXHTML")
   1.750 -	{
   1.751 -		QString fname="";
   1.752 -		ok=true;
   1.753 -		if (parser.parCount()>=2)
   1.754 -			// Hey, we even have a filename
   1.755 -			fname=parser.parString(ok,1); 
   1.756 -		if (!ok)
   1.757 -		{
   1.758 -			parser.setError (Aborted,"Could not read filename");
   1.759 -		} else
   1.760 -		{
   1.761 -			exportXHTML (fname,false);
   1.762 -		}
   1.763 -	/////////////////////////////////////////////////////////////////////
   1.764 -	} else if (com=="exportXML")
   1.765 -	{
   1.766 -		QString fname="";
   1.767 -		ok=true;
   1.768 -		if (parser.parCount()>=2)
   1.769 -			// Hey, we even have a filename
   1.770 -			fname=parser.parString(ok,1); 
   1.771 -		if (!ok)
   1.772 -		{
   1.773 -			parser.setError (Aborted,"Could not read filename");
   1.774 -		} else
   1.775 -		{
   1.776 -			exportXML (fname,false);
   1.777 -		}
   1.778 -	/////////////////////////////////////////////////////////////////////
   1.779 -	} else if (com=="importDir")
   1.780 -	{
   1.781 -		if (xelection.isEmpty())
   1.782 -		{
   1.783 -			parser.setError (Aborted,"Nothing selected");
   1.784 -		} else if (! selb )
   1.785 -		{				  
   1.786 -			parser.setError (Aborted,"Type of selection is not a branch");
   1.787 -		} else if (parser.checkParCount(1))
   1.788 -		{
   1.789 -			s=parser.parString(ok,0);
   1.790 -			if (ok) importDirInt(s);
   1.791 -		}	
   1.792 -	/////////////////////////////////////////////////////////////////////
   1.793 -	} else if (com=="linkTo")
   1.794 -	{
   1.795 -		if (xelection.isEmpty())
   1.796 -		{
   1.797 -			parser.setError (Aborted,"Nothing selected");
   1.798 -		} else if ( selb)
   1.799 -		{
   1.800 -			if (parser.checkParCount(4))
   1.801 -			{
   1.802 -				// 0	selectstring of parent
   1.803 -				// 1	num in parent (for branches)
   1.804 -				// 2,3	x,y of mainbranch or mapcenter
   1.805 -				s=parser.parString(ok,0);
   1.806 -				LinkableMapObj *dst=model->findObjBySelect (s);
   1.807 -				if (dst)
   1.808 -				{	
   1.809 -					if (typeid(*dst) == typeid(BranchObj) ) 
   1.810 -					{
   1.811 -						// Get number in parent
   1.812 -						n=parser.parInt (ok,1);
   1.813 -						if (ok)
   1.814 -						{
   1.815 -							selb->linkTo ((BranchObj*)(dst),n);
   1.816 -							xelection.update();
   1.817 -						}	
   1.818 -					} else if (typeid(*dst) == typeid(MapCenterObj) ) 
   1.819 -					{
   1.820 -						selb->linkTo ((BranchObj*)(dst),-1);
   1.821 -						// Get coordinates of mainbranch
   1.822 -						x=parser.parDouble(ok,2);
   1.823 -						if (ok)
   1.824 -						{
   1.825 -							y=parser.parDouble(ok,3);
   1.826 -							if (ok) 
   1.827 -							{
   1.828 -								selb->move (x,y);
   1.829 -								xelection.update();
   1.830 -							}
   1.831 -						}
   1.832 -					}	
   1.833 -				}	
   1.834 -			}	
   1.835 -		} else if ( xelection.type() == Selection::FloatImage) 
   1.836 -		{
   1.837 -			if (parser.checkParCount(1))
   1.838 -			{
   1.839 -				// 0	selectstring of parent
   1.840 -				s=parser.parString(ok,0);
   1.841 -				LinkableMapObj *dst=model->findObjBySelect (s);
   1.842 -				if (dst)
   1.843 -				{	
   1.844 -					if (typeid(*dst) == typeid(BranchObj) ||
   1.845 -						typeid(*dst) == typeid(MapCenterObj)) 
   1.846 -						linkTo (model->getSelectString(dst));
   1.847 -				} else	
   1.848 -					parser.setError (Aborted,"Destination is not a branch");
   1.849 -			}		
   1.850 -		} else
   1.851 -			parser.setError (Aborted,"Type of selection is not a floatimage or branch");
   1.852 -	/////////////////////////////////////////////////////////////////////
   1.853 -	} else if (com=="loadImage")
   1.854 -	{
   1.855 -		if (xelection.isEmpty())
   1.856 -		{
   1.857 -			parser.setError (Aborted,"Nothing selected");
   1.858 -		} else if (! selb )
   1.859 -		{				  
   1.860 -			parser.setError (Aborted,"Type of selection is not a branch");
   1.861 -		} else if (parser.checkParCount(1))
   1.862 -		{
   1.863 -			s=parser.parString(ok,0);
   1.864 -			if (ok) loadFloatImageInt (s);
   1.865 -		}	
   1.866 -	/////////////////////////////////////////////////////////////////////
   1.867 -	} else if (com=="moveBranchUp")
   1.868 -	{
   1.869 -		if (xelection.isEmpty() )
   1.870 -		{
   1.871 -			parser.setError (Aborted,"Nothing selected");
   1.872 -		} else if (! selb )
   1.873 -		{				  
   1.874 -			parser.setError (Aborted,"Type of selection is not a branch");
   1.875 -		} else if (parser.checkParCount(0))
   1.876 -		{
   1.877 -			moveBranchUp();
   1.878 -		}	
   1.879 -	/////////////////////////////////////////////////////////////////////
   1.880 -	} else if (com=="moveBranchDown")
   1.881 -	{
   1.882 -		if (xelection.isEmpty() )
   1.883 -		{
   1.884 -			parser.setError (Aborted,"Nothing selected");
   1.885 -		} else if (! selb )
   1.886 -		{				  
   1.887 -			parser.setError (Aborted,"Type of selection is not a branch");
   1.888 -		} else if (parser.checkParCount(0))
   1.889 -		{
   1.890 -			moveBranchDown();
   1.891 -		}	
   1.892 -	/////////////////////////////////////////////////////////////////////
   1.893 -	} else if (com=="move")
   1.894 -	{
   1.895 -		if (xelection.isEmpty() )
   1.896 -		{
   1.897 -			parser.setError (Aborted,"Nothing selected");
   1.898 -		} else if ( xelection.type()!=Selection::Branch  && 
   1.899 -					xelection.type()!=Selection::MapCenter  &&
   1.900 -					xelection.type()!=Selection::FloatImage )
   1.901 -		{				  
   1.902 -			parser.setError (Aborted,"Type of selection is not a branch or floatimage");
   1.903 -		} else if (parser.checkParCount(2))
   1.904 -		{	
   1.905 -			x=parser.parDouble (ok,0);
   1.906 -			if (ok)
   1.907 -			{
   1.908 -				y=parser.parDouble (ok,1);
   1.909 -				if (ok) move (x,y);
   1.910 -			}
   1.911 -		}	
   1.912 -	/////////////////////////////////////////////////////////////////////
   1.913 -	} else if (com=="moveRel")
   1.914 -	{
   1.915 -		if (xelection.isEmpty() )
   1.916 -		{
   1.917 -			parser.setError (Aborted,"Nothing selected");
   1.918 -		} else if ( xelection.type()!=Selection::Branch  && 
   1.919 -					xelection.type()!=Selection::MapCenter  &&
   1.920 -					xelection.type()!=Selection::FloatImage )
   1.921 -		{				  
   1.922 -			parser.setError (Aborted,"Type of selection is not a branch or floatimage");
   1.923 -		} else if (parser.checkParCount(2))
   1.924 -		{	
   1.925 -			x=parser.parDouble (ok,0);
   1.926 -			if (ok)
   1.927 -			{
   1.928 -				y=parser.parDouble (ok,1);
   1.929 -				if (ok) moveRel (x,y);
   1.930 -			}
   1.931 -		}	
   1.932 -	/////////////////////////////////////////////////////////////////////
   1.933 -	} else if (com=="nop")
   1.934 -	{
   1.935 -	/////////////////////////////////////////////////////////////////////
   1.936 -	} else if (com=="paste")
   1.937 -	{
   1.938 -		if (xelection.isEmpty() )
   1.939 -		{
   1.940 -			parser.setError (Aborted,"Nothing selected");
   1.941 -		} else if (! selb )
   1.942 -		{				  
   1.943 -			parser.setError (Aborted,"Type of selection is not a branch");
   1.944 -		} else if (parser.checkParCount(1))
   1.945 -		{	
   1.946 -			n=parser.parInt (ok,0);
   1.947 -			if (ok) pasteNoSave(n);
   1.948 -		}	
   1.949 -	/////////////////////////////////////////////////////////////////////
   1.950 -	} else if (com=="qa")
   1.951 -	{
   1.952 -		if (xelection.isEmpty() )
   1.953 -		{
   1.954 -			parser.setError (Aborted,"Nothing selected");
   1.955 -		} else if (! selb )
   1.956 -		{				  
   1.957 -			parser.setError (Aborted,"Type of selection is not a branch");
   1.958 -		} else if (parser.checkParCount(4))
   1.959 -		{	
   1.960 -			QString c,u;
   1.961 -			c=parser.parString (ok,0);
   1.962 -			if (!ok)
   1.963 -			{
   1.964 -				parser.setError (Aborted,"No comment given");
   1.965 -			} else
   1.966 -			{
   1.967 -				s=parser.parString (ok,1);
   1.968 -				if (!ok)
   1.969 -				{
   1.970 -					parser.setError (Aborted,"First parameter is not a string");
   1.971 -				} else
   1.972 -				{
   1.973 -					t=parser.parString (ok,2);
   1.974 -					if (!ok)
   1.975 -					{
   1.976 -						parser.setError (Aborted,"Condition is not a string");
   1.977 -					} else
   1.978 -					{
   1.979 -						u=parser.parString (ok,3);
   1.980 -						if (!ok)
   1.981 -						{
   1.982 -							parser.setError (Aborted,"Third parameter is not a string");
   1.983 -						} else
   1.984 -						{
   1.985 -							if (s!="heading")
   1.986 -							{
   1.987 -								parser.setError (Aborted,"Unknown type: "+s);
   1.988 -							} else
   1.989 -							{
   1.990 -								if (! (t=="eq") ) 
   1.991 -								{
   1.992 -									parser.setError (Aborted,"Unknown operator: "+t);
   1.993 -								} else
   1.994 -								{
   1.995 -									if (! selb    )
   1.996 -									{
   1.997 -										parser.setError (Aborted,"Type of selection is not a branch");
   1.998 -									} else
   1.999 -									{
  1.1000 -										if (selb->getHeading() == u)
  1.1001 -										{
  1.1002 -											cout << "PASSED: " << qPrintable (c)  << endl;
  1.1003 -										} else
  1.1004 -										{
  1.1005 -											cout << "FAILED: " << qPrintable (c)  << endl;
  1.1006 -										}
  1.1007 -									}
  1.1008 -								}
  1.1009 -							}
  1.1010 -						} 
  1.1011 -					} 
  1.1012 -				} 
  1.1013 -			}
  1.1014 -		}	
  1.1015 -	/////////////////////////////////////////////////////////////////////
  1.1016 -	} else if (com=="saveImage")
  1.1017 -	{
  1.1018 -		FloatImageObj *fio=xelection.getFloatImage();
  1.1019 -		if (!fio)
  1.1020 -		{
  1.1021 -			parser.setError (Aborted,"Type of selection is not an image");
  1.1022 -		} else if (parser.checkParCount(2))
  1.1023 -		{
  1.1024 -			s=parser.parString(ok,0);
  1.1025 -			if (ok)
  1.1026 -			{
  1.1027 -				t=parser.parString(ok,1);
  1.1028 -				if (ok) saveFloatImageInt (fio,t,s);
  1.1029 -			}
  1.1030 -		}	
  1.1031 -	/////////////////////////////////////////////////////////////////////
  1.1032 -	} else if (com=="scroll")
  1.1033 -	{
  1.1034 -		if (xelection.isEmpty() )
  1.1035 -		{
  1.1036 -			parser.setError (Aborted,"Nothing selected");
  1.1037 -		} else if (! selb )
  1.1038 -		{				  
  1.1039 -			parser.setError (Aborted,"Type of selection is not a branch");
  1.1040 -		} else if (parser.checkParCount(0))
  1.1041 -		{	
  1.1042 -			if (!scrollBranch (selb))	
  1.1043 -				parser.setError (Aborted,"Could not scroll branch");
  1.1044 -		}	
  1.1045 -	/////////////////////////////////////////////////////////////////////
  1.1046 -	} else if (com=="select")
  1.1047 -	{
  1.1048 -		if (parser.checkParCount(1))
  1.1049 -		{
  1.1050 -			s=parser.parString(ok,0);
  1.1051 -			if (ok) select (s);
  1.1052 -		}	
  1.1053 -	/////////////////////////////////////////////////////////////////////
  1.1054 -	} else if (com=="selectLastBranch")
  1.1055 -	{
  1.1056 -		if (xelection.isEmpty() )
  1.1057 -		{
  1.1058 -			parser.setError (Aborted,"Nothing selected");
  1.1059 -		} else if (! selb )
  1.1060 -		{				  
  1.1061 -			parser.setError (Aborted,"Type of selection is not a branch");
  1.1062 -		} else if (parser.checkParCount(0))
  1.1063 -		{	
  1.1064 -			BranchObj *bo=selb->getLastBranch();
  1.1065 -			if (!bo)
  1.1066 -				parser.setError (Aborted,"Could not select last branch");
  1.1067 -			selectInt (bo);	
  1.1068 -				
  1.1069 -		}	
  1.1070 -	/////////////////////////////////////////////////////////////////////
  1.1071 -	} else if (com=="selectLastImage")
  1.1072 -	{
  1.1073 -		if (xelection.isEmpty() )
  1.1074 -		{
  1.1075 -			parser.setError (Aborted,"Nothing selected");
  1.1076 -		} else if (! selb )
  1.1077 -		{				  
  1.1078 -			parser.setError (Aborted,"Type of selection is not a branch");
  1.1079 -		} else if (parser.checkParCount(0))
  1.1080 -		{	
  1.1081 -			FloatImageObj *fio=selb->getLastFloatImage();
  1.1082 -			if (!fio)
  1.1083 -				parser.setError (Aborted,"Could not select last image");
  1.1084 -			selectInt (fio);	
  1.1085 -				
  1.1086 -		}	
  1.1087 -	/////////////////////////////////////////////////////////////////////
  1.1088 -	} else if (com=="selectLatestAdded")
  1.1089 -	{
  1.1090 -		if (latestSelection.isEmpty() )
  1.1091 -		{
  1.1092 -			parser.setError (Aborted,"No latest added object");
  1.1093 -		} else
  1.1094 -		{	
  1.1095 -			if (!select (latestSelection))
  1.1096 -				parser.setError (Aborted,"Could not select latest added object "+latestSelection);
  1.1097 -		}	
  1.1098 -	/////////////////////////////////////////////////////////////////////
  1.1099 -	} else if (com=="setFrameType")
  1.1100 -	{
  1.1101 -		if ( xelection.type()!=Selection::Branch && xelection.type()!= Selection::MapCenter && xelection.type()!=Selection::FloatImage)
  1.1102 -		{
  1.1103 -			parser.setError (Aborted,"Type of selection does not allow setting frame type");
  1.1104 -		}
  1.1105 -		else if (parser.checkParCount(1))
  1.1106 -		{
  1.1107 -			s=parser.parString(ok,0);
  1.1108 -			if (ok) setFrameType (s);
  1.1109 -		}	
  1.1110 -	/////////////////////////////////////////////////////////////////////
  1.1111 -	} else if (com=="setFramePenColor")
  1.1112 -	{
  1.1113 -		if ( xelection.type()!=Selection::Branch && xelection.type()!= Selection::MapCenter && xelection.type()!=Selection::FloatImage)
  1.1114 -		{
  1.1115 -			parser.setError (Aborted,"Type of selection does not allow setting of pen color");
  1.1116 -		}
  1.1117 -		else if (parser.checkParCount(1))
  1.1118 -		{
  1.1119 -			QColor c=parser.parColor(ok,0);
  1.1120 -			if (ok) setFramePenColor (c);
  1.1121 -		}	
  1.1122 -	/////////////////////////////////////////////////////////////////////
  1.1123 -	} else if (com=="setFrameBrushColor")
  1.1124 -	{
  1.1125 -		if ( xelection.type()!=Selection::Branch && xelection.type()!= Selection::MapCenter && xelection.type()!=Selection::FloatImage)
  1.1126 -		{
  1.1127 -			parser.setError (Aborted,"Type of selection does not allow setting brush color");
  1.1128 -		}
  1.1129 -		else if (parser.checkParCount(1))
  1.1130 -		{
  1.1131 -			QColor c=parser.parColor(ok,0);
  1.1132 -			if (ok) setFrameBrushColor (c);
  1.1133 -		}	
  1.1134 -	/////////////////////////////////////////////////////////////////////
  1.1135 -	} else if (com=="setFramePadding")
  1.1136 -	{
  1.1137 -		if ( xelection.type()!=Selection::Branch && xelection.type()!= Selection::MapCenter && xelection.type()!=Selection::FloatImage)
  1.1138 -		{
  1.1139 -			parser.setError (Aborted,"Type of selection does not allow setting frame padding");
  1.1140 -		}
  1.1141 -		else if (parser.checkParCount(1))
  1.1142 -		{
  1.1143 -			n=parser.parInt(ok,0);
  1.1144 -			if (ok) setFramePadding(n);
  1.1145 -		}	
  1.1146 -	/////////////////////////////////////////////////////////////////////
  1.1147 -	} else if (com=="setFrameBorderWidth")
  1.1148 -	{
  1.1149 -		if ( xelection.type()!=Selection::Branch && xelection.type()!= Selection::MapCenter && xelection.type()!=Selection::FloatImage)
  1.1150 -		{
  1.1151 -			parser.setError (Aborted,"Type of selection does not allow setting frame border width");
  1.1152 -		}
  1.1153 -		else if (parser.checkParCount(1))
  1.1154 -		{
  1.1155 -			n=parser.parInt(ok,0);
  1.1156 -			if (ok) setFrameBorderWidth (n);
  1.1157 -		}	
  1.1158 -	/////////////////////////////////////////////////////////////////////
  1.1159 -	} else if (com=="setMapAuthor")
  1.1160 -	{
  1.1161 -		if (parser.checkParCount(1))
  1.1162 -		{
  1.1163 -			s=parser.parString(ok,0);
  1.1164 -			if (ok) setMapAuthor (s);
  1.1165 -		}	
  1.1166 -	/////////////////////////////////////////////////////////////////////
  1.1167 -	} else if (com=="setMapComment")
  1.1168 -	{
  1.1169 -		if (parser.checkParCount(1))
  1.1170 -		{
  1.1171 -			s=parser.parString(ok,0);
  1.1172 -			if (ok) setMapComment(s);
  1.1173 -		}	
  1.1174 -	/////////////////////////////////////////////////////////////////////
  1.1175 -	} else if (com=="setMapBackgroundColor")
  1.1176 -	{
  1.1177 -		if (xelection.isEmpty() )
  1.1178 -		{
  1.1179 -			parser.setError (Aborted,"Nothing selected");
  1.1180 -		} else if (! xelection.getBranch() )
  1.1181 -		{				  
  1.1182 -			parser.setError (Aborted,"Type of selection is not a branch");
  1.1183 -		} else if (parser.checkParCount(1))
  1.1184 -		{
  1.1185 -			QColor c=parser.parColor (ok,0);
  1.1186 -			if (ok) setMapBackgroundColor (c);
  1.1187 -		}	
  1.1188 -	/////////////////////////////////////////////////////////////////////
  1.1189 -	} else if (com=="setMapDefLinkColor")
  1.1190 -	{
  1.1191 -		if (xelection.isEmpty() )
  1.1192 -		{
  1.1193 -			parser.setError (Aborted,"Nothing selected");
  1.1194 -		} else if (! selb )
  1.1195 -		{				  
  1.1196 -			parser.setError (Aborted,"Type of selection is not a branch");
  1.1197 -		} else if (parser.checkParCount(1))
  1.1198 -		{
  1.1199 -			QColor c=parser.parColor (ok,0);
  1.1200 -			if (ok) setMapDefLinkColor (c);
  1.1201 -		}	
  1.1202 -	/////////////////////////////////////////////////////////////////////
  1.1203 -	} else if (com=="setMapLinkStyle")
  1.1204 -	{
  1.1205 -		if (parser.checkParCount(1))
  1.1206 -		{
  1.1207 -			s=parser.parString (ok,0);
  1.1208 -			if (ok) setMapLinkStyle(s);
  1.1209 -		}	
  1.1210 -	/////////////////////////////////////////////////////////////////////
  1.1211 -	} else if (com=="setHeading")
  1.1212 -	{
  1.1213 -		if (xelection.isEmpty() )
  1.1214 -		{
  1.1215 -			parser.setError (Aborted,"Nothing selected");
  1.1216 -		} else if (! selb )
  1.1217 -		{				  
  1.1218 -			parser.setError (Aborted,"Type of selection is not a branch");
  1.1219 -		} else if (parser.checkParCount(1))
  1.1220 -		{
  1.1221 -			s=parser.parString (ok,0);
  1.1222 -			if (ok) 
  1.1223 -				setHeading (s);
  1.1224 -		}	
  1.1225 -	/////////////////////////////////////////////////////////////////////
  1.1226 -	} else if (com=="setHideExport")
  1.1227 -	{
  1.1228 -		if (xelection.isEmpty() )
  1.1229 -		{
  1.1230 -			parser.setError (Aborted,"Nothing selected");
  1.1231 -		} else if (xelection.type()!=Selection::Branch && xelection.type() != Selection::MapCenter &&xelection.type()!=Selection::FloatImage)
  1.1232 -		{				  
  1.1233 -			parser.setError (Aborted,"Type of selection is not a branch or floatimage");
  1.1234 -		} else if (parser.checkParCount(1))
  1.1235 -		{
  1.1236 -			b=parser.parBool(ok,0);
  1.1237 -			if (ok) setHideExport (b);
  1.1238 -		}
  1.1239 -	/////////////////////////////////////////////////////////////////////
  1.1240 -	} else if (com=="setIncludeImagesHorizontally")
  1.1241 -	{ 
  1.1242 -		if (xelection.isEmpty() )
  1.1243 -		{
  1.1244 -			parser.setError (Aborted,"Nothing selected");
  1.1245 -		} else if (! selb)
  1.1246 -		{				  
  1.1247 -			parser.setError (Aborted,"Type of selection is not a branch");
  1.1248 -		} else if (parser.checkParCount(1))
  1.1249 -		{
  1.1250 -			b=parser.parBool(ok,0);
  1.1251 -			if (ok) setIncludeImagesHor(b);
  1.1252 -		}
  1.1253 -	/////////////////////////////////////////////////////////////////////
  1.1254 -	} else if (com=="setIncludeImagesVertically")
  1.1255 -	{
  1.1256 -		if (xelection.isEmpty() )
  1.1257 -		{
  1.1258 -			parser.setError (Aborted,"Nothing selected");
  1.1259 -		} else if (! selb)
  1.1260 -		{				  
  1.1261 -			parser.setError (Aborted,"Type of selection is not a branch");
  1.1262 -		} else if (parser.checkParCount(1))
  1.1263 -		{
  1.1264 -			b=parser.parBool(ok,0);
  1.1265 -			if (ok) setIncludeImagesVer(b);
  1.1266 -		}
  1.1267 -	/////////////////////////////////////////////////////////////////////
  1.1268 -	} else if (com=="setHideLinkUnselected")
  1.1269 -	{
  1.1270 -		if (xelection.isEmpty() )
  1.1271 -		{
  1.1272 -			parser.setError (Aborted,"Nothing selected");
  1.1273 -		} else if ( xelection.type()!=Selection::Branch && xelection.type()!= Selection::MapCenter && xelection.type()!=Selection::FloatImage)
  1.1274 -		{				  
  1.1275 -			parser.setError (Aborted,"Type of selection does not allow hiding the link");
  1.1276 -		} else if (parser.checkParCount(1))
  1.1277 -		{
  1.1278 -			b=parser.parBool(ok,0);
  1.1279 -			if (ok) setHideLinkUnselected(b);
  1.1280 -		}
  1.1281 -	/////////////////////////////////////////////////////////////////////
  1.1282 -	} else if (com=="setSelectionColor")
  1.1283 -	{
  1.1284 -		if (parser.checkParCount(1))
  1.1285 -		{
  1.1286 -			QColor c=parser.parColor (ok,0);
  1.1287 -			if (ok) setSelectionColorInt (c);
  1.1288 -		}	
  1.1289 -	/////////////////////////////////////////////////////////////////////
  1.1290 -	} else if (com=="setURL")
  1.1291 -	{
  1.1292 -		if (xelection.isEmpty() )
  1.1293 -		{
  1.1294 -			parser.setError (Aborted,"Nothing selected");
  1.1295 -		} else if (! selb )
  1.1296 -		{				  
  1.1297 -			parser.setError (Aborted,"Type of selection is not a branch");
  1.1298 -		} else if (parser.checkParCount(1))
  1.1299 -		{
  1.1300 -			s=parser.parString (ok,0);
  1.1301 -			if (ok) setURL(s);
  1.1302 -		}	
  1.1303 -	/////////////////////////////////////////////////////////////////////
  1.1304 -	} else if (com=="setVymLink")
  1.1305 -	{
  1.1306 -		if (xelection.isEmpty() )
  1.1307 -		{
  1.1308 -			parser.setError (Aborted,"Nothing selected");
  1.1309 -		} else if (! selb )
  1.1310 -		{				  
  1.1311 -			parser.setError (Aborted,"Type of selection is not a branch");
  1.1312 -		} else if (parser.checkParCount(1))
  1.1313 -		{
  1.1314 -			s=parser.parString (ok,0);
  1.1315 -			if (ok) setVymLinkInt(s);
  1.1316 -		}	
  1.1317 -	}
  1.1318 -	/////////////////////////////////////////////////////////////////////
  1.1319 -	else if (com=="setFlag")
  1.1320 -	{
  1.1321 -		if (xelection.isEmpty() )
  1.1322 -		{
  1.1323 -			parser.setError (Aborted,"Nothing selected");
  1.1324 -		} else if (! selb )
  1.1325 -		{				  
  1.1326 -			parser.setError (Aborted,"Type of selection is not a branch");
  1.1327 -		} else if (parser.checkParCount(1))
  1.1328 -		{
  1.1329 -			s=parser.parString(ok,0);
  1.1330 -			if (ok) 
  1.1331 -			{
  1.1332 -				selb->activateStandardFlag(s);
  1.1333 -				selb->updateFlagsToolbar();
  1.1334 -			}	
  1.1335 -		}
  1.1336 -	/////////////////////////////////////////////////////////////////////
  1.1337 -	} else if (com=="setFrameType")
  1.1338 -	{
  1.1339 -		if (xelection.isEmpty() )
  1.1340 -		{
  1.1341 -			parser.setError (Aborted,"Nothing selected");
  1.1342 -		} else if (! selb )
  1.1343 -		{				  
  1.1344 -			parser.setError (Aborted,"Type of selection is not a branch");
  1.1345 -		} else if (parser.checkParCount(1))
  1.1346 -		{
  1.1347 -			s=parser.parString(ok,0);
  1.1348 -			if (ok) 
  1.1349 -				setFrameType (s);
  1.1350 -		}
  1.1351 -	/////////////////////////////////////////////////////////////////////
  1.1352 -	} else if (com=="sortChildren")
  1.1353 -	{
  1.1354 -		if (xelection.isEmpty() )
  1.1355 -		{
  1.1356 -			parser.setError (Aborted,"Nothing selected");
  1.1357 -		} else if (! selb )
  1.1358 -		{				  
  1.1359 -			parser.setError (Aborted,"Type of selection is not a branch");
  1.1360 -		} else if (parser.checkParCount(0))
  1.1361 -		{
  1.1362 -			sortChildren();
  1.1363 -		}
  1.1364 -	/////////////////////////////////////////////////////////////////////
  1.1365 -	} else if (com=="toggleFlag")
  1.1366 -	{
  1.1367 -		if (xelection.isEmpty() )
  1.1368 -		{
  1.1369 -			parser.setError (Aborted,"Nothing selected");
  1.1370 -		} else if (! selb )
  1.1371 -		{				  
  1.1372 -			parser.setError (Aborted,"Type of selection is not a branch");
  1.1373 -		} else if (parser.checkParCount(1))
  1.1374 -		{
  1.1375 -			s=parser.parString(ok,0);
  1.1376 -			if (ok) 
  1.1377 -			{
  1.1378 -				selb->toggleStandardFlag(s);	
  1.1379 -				selb->updateFlagsToolbar();
  1.1380 -			}	
  1.1381 -		}
  1.1382 -	/////////////////////////////////////////////////////////////////////
  1.1383 -	} else if (com=="unscroll")
  1.1384 -	{
  1.1385 -		if (xelection.isEmpty() )
  1.1386 -		{
  1.1387 -			parser.setError (Aborted,"Nothing selected");
  1.1388 -		} else if (! selb )
  1.1389 -		{				  
  1.1390 -			parser.setError (Aborted,"Type of selection is not a branch");
  1.1391 -		} else if (parser.checkParCount(0))
  1.1392 -		{	
  1.1393 -			if (!unscrollBranch (selb))	
  1.1394 -				parser.setError (Aborted,"Could not unscroll branch");
  1.1395 -		}	
  1.1396 -	/////////////////////////////////////////////////////////////////////
  1.1397 -	} else if (com=="unscrollChilds")
  1.1398 -	{
  1.1399 -		if (xelection.isEmpty() )
  1.1400 -		{
  1.1401 -			parser.setError (Aborted,"Nothing selected");
  1.1402 -		} else if (! selb )
  1.1403 -		{				  
  1.1404 -			parser.setError (Aborted,"Type of selection is not a branch");
  1.1405 -		} else if (parser.checkParCount(0))
  1.1406 -		{	
  1.1407 -			unscrollChilds ();
  1.1408 -		}	
  1.1409 -	/////////////////////////////////////////////////////////////////////
  1.1410 -	} else if (com=="unsetFlag")
  1.1411 -	{
  1.1412 -		if (xelection.isEmpty() )
  1.1413 -		{
  1.1414 -			parser.setError (Aborted,"Nothing selected");
  1.1415 -		} else if (! selb )
  1.1416 -		{				  
  1.1417 -			parser.setError (Aborted,"Type of selection is not a branch");
  1.1418 -		} else if (parser.checkParCount(1))
  1.1419 -		{
  1.1420 -			s=parser.parString(ok,0);
  1.1421 -			if (ok) 
  1.1422 -			{
  1.1423 -				selb->deactivateStandardFlag(s);
  1.1424 -				selb->updateFlagsToolbar();
  1.1425 -			}	
  1.1426 -		}
  1.1427 -	} else
  1.1428 -		parser.setError (Aborted,"Unknown command");
  1.1429 -
  1.1430 -	// Any errors?
  1.1431 -	if (parser.errorLevel()==NoError)
  1.1432 -	{
  1.1433 -		// setChanged();  FIXME should not be called e.g. for export?!
  1.1434 -		model->reposition();
  1.1435 -	}	
  1.1436 -	else	
  1.1437 -	{
  1.1438 -		// TODO Error handling
  1.1439 -		qWarning("MapEditor::parseAtom: Error!");
  1.1440 -		qWarning(parser.errorMessage());
  1.1441 -	} 
  1.1442 -}
  1.1443 -
  1.1444 -void MapEditor::runScript (QString script)
  1.1445 -{
  1.1446 -	parser.setScript (script);
  1.1447 -	parser.runScript();
  1.1448 -	while (parser.next() ) 
  1.1449 -		parseAtom(parser.getAtom());
  1.1450 -}
  1.1451 -
  1.1452 -bool MapEditor::isDefault()
  1.1453 -{
  1.1454 -    return mapDefault;
  1.1455 -}
  1.1456 -
  1.1457 -bool MapEditor::hasChanged()
  1.1458 -{
  1.1459 -    return mapChanged;
  1.1460 -}
  1.1461 -
  1.1462 -void MapEditor::setChanged()
  1.1463 -{
  1.1464 -	if (!mapChanged)
  1.1465 -		autosaveTimer->start(settings.value("/mapeditor/autosave/ms/",300000).toInt());
  1.1466 -	mapChanged=true;
  1.1467 -	mapDefault=false;
  1.1468 -	mapUnsaved=true;
  1.1469 -	findReset();
  1.1470 -
  1.1471 -}
  1.1472 -
  1.1473 -void MapEditor::closeMap()
  1.1474 -{
  1.1475 -	// Unselect before disabling the toolbar actions
  1.1476 -	if (!xelection.isEmpty() ) xelection.unselect();
  1.1477 -	xelection.clear();
  1.1478 -	updateActions();
  1.1479 -
  1.1480 -    clear();
  1.1481 -	// close();  FIXME needed?
  1.1482 -}
  1.1483 -
  1.1484 -void MapEditor::setFilePath(QString fpath, QString destname)
  1.1485 -{
  1.1486 -	if (fpath.isEmpty() || fpath=="")
  1.1487 -	{
  1.1488 -		filePath="";
  1.1489 -		fileName="";
  1.1490 -		destPath="";
  1.1491 -	} else
  1.1492 -	{
  1.1493 -		filePath=fpath;		// becomes absolute path
  1.1494 -		fileName=fpath;		// gets stripped of path
  1.1495 -		destPath=destname;	// needed for vymlinks and during load to reset fileChangedTime
  1.1496 -
  1.1497 -		// If fpath is not an absolute path, complete it
  1.1498 -		filePath=QDir(fpath).absPath();
  1.1499 -		fileDir=filePath.left (1+filePath.findRev ("/"));
  1.1500 -
  1.1501 -		// Set short name, too. Search from behind:
  1.1502 -		int i=fileName.findRev("/");
  1.1503 -		if (i>=0) fileName=fileName.remove (0,i+1);
  1.1504 -
  1.1505 -		// Forget the .vym (or .xml) for name of map
  1.1506 -		mapName=fileName.left(fileName.findRev(".",-1,true) );
  1.1507 -	}
  1.1508 -}
  1.1509 -
  1.1510 -void MapEditor::setFilePath(QString fpath)
  1.1511 -{
  1.1512 -	setFilePath (fpath,fpath);
  1.1513 -}
  1.1514 -
  1.1515 -QString MapEditor::getFilePath()
  1.1516 -{
  1.1517 -	return filePath;
  1.1518 -}
  1.1519 -
  1.1520 -QString MapEditor::getFileName()
  1.1521 -{
  1.1522 -	return fileName;
  1.1523 -}
  1.1524 -
  1.1525 -QString MapEditor::getMapName()
  1.1526 -{
  1.1527 -	return mapName;
  1.1528 -}
  1.1529 -
  1.1530 -QString MapEditor::getDestPath()
  1.1531 -{
  1.1532 -	return destPath;
  1.1533 -}
  1.1534 -
  1.1535 -ErrorCode MapEditor::load (QString fname, const LoadMode &lmode, const FileType &ftype)
  1.1536 -{
  1.1537 -	ErrorCode err=success;
  1.1538 -
  1.1539 -	parseBaseHandler *handler;
  1.1540 -	fileType=ftype;
  1.1541 -	switch (fileType)
  1.1542 -	{
  1.1543 -		case VymMap: handler=new parseVYMHandler; break;
  1.1544 -		case FreemindMap : handler=new parseFreemindHandler; break;
  1.1545 -		default: 
  1.1546 -			QMessageBox::critical( 0, tr( "Critical Parse Error" ),
  1.1547 -				   "Unknown FileType in MapEditor::load()");
  1.1548 -		return aborted;	
  1.1549 -	}
  1.1550 -	if (lmode==NewMap)
  1.1551 -	{
  1.1552 -		xelection.clear();
  1.1553 -		model->setMapEditor(this);
  1.1554 -		// (map state is set later at end of load...)
  1.1555 -	} else
  1.1556 -	{
  1.1557 -		BranchObj *bo=xelection.getBranch();
  1.1558 -		if (!bo) return aborted;
  1.1559 -		if (lmode==ImportAdd)
  1.1560 -			saveStateChangingPart(
  1.1561 -				bo,
  1.1562 -				bo,
  1.1563 -				QString("addMapInsert (%1)").arg(fname),
  1.1564 -				QString("Add map %1 to %2").arg(fname).arg(getName(bo)));
  1.1565 -		else	
  1.1566 -			saveStateChangingPart(
  1.1567 -				bo,
  1.1568 -				bo,
  1.1569 -				QString("addMapReplace(%1)").arg(fname),
  1.1570 -				QString("Add map %1 to %2").arg(fname).arg(getName(bo)));
  1.1571 -	}	
  1.1572 -    
  1.1573 -
  1.1574 -	// Create temporary directory for packing
  1.1575 -	bool ok;
  1.1576 -	QString tmpZipDir=makeTmpDir (ok,"vym-pack");
  1.1577 -	if (!ok)
  1.1578 -	{
  1.1579 -		QMessageBox::critical( 0, tr( "Critical Load Error" ),
  1.1580 -		   tr("Couldn't create temporary directory before load\n"));
  1.1581 -		return aborted; 
  1.1582 -	}
  1.1583 -
  1.1584 -	// Try to unzip file
  1.1585 -	err=unzipDir (tmpZipDir,fname);
  1.1586 -	QString xmlfile;
  1.1587 -	if (err==nozip)
  1.1588 -	{
  1.1589 -		xmlfile=fname;
  1.1590 -		zipped=false;
  1.1591 -	} else
  1.1592 -	{
  1.1593 -		zipped=true;
  1.1594 -		
  1.1595 -		// Look for mapname.xml
  1.1596 -		xmlfile= fname.left(fname.findRev(".",-1,true));
  1.1597 -		xmlfile=xmlfile.section( '/', -1 );
  1.1598 -		QFile mfile( tmpZipDir + "/" + xmlfile + ".xml");
  1.1599 -		if (!mfile.exists() )
  1.1600 -		{
  1.1601 -			// mapname.xml does not exist, well, 
  1.1602 -			// maybe someone renamed the mapname.vym file...
  1.1603 -			// Try to find any .xml in the toplevel 
  1.1604 -			// directory of the .vym file
  1.1605 -			QStringList flist=QDir (tmpZipDir).entryList("*.xml");
  1.1606 -			if (flist.count()==1) 
  1.1607 -			{
  1.1608 -				// Only one entry, take this one
  1.1609 -				xmlfile=tmpZipDir + "/"+flist.first();
  1.1610 -			} else
  1.1611 -			{
  1.1612 -				for ( QStringList::Iterator it = flist.begin(); it != flist.end(); ++it ) 
  1.1613 -					*it=tmpZipDir + "/" + *it;
  1.1614 -				// TODO Multiple entries, load all (but only the first one into this ME)
  1.1615 -				//mainWindow->fileLoadFromTmp (flist);
  1.1616 -				//returnCode=1;	// Silently forget this attempt to load
  1.1617 -				qWarning ("MainWindow::load (fn)  multimap found...");
  1.1618 -			}	
  1.1619 -				
  1.1620 -			if (flist.isEmpty() )
  1.1621 -			{
  1.1622 -				QMessageBox::critical( 0, tr( "Critical Load Error" ),
  1.1623 -						   tr("Couldn't find a map (*.xml) in .vym archive.\n"));
  1.1624 -				err=aborted;				   
  1.1625 -			}	
  1.1626 -		} //file doesn't exist	
  1.1627 -		else
  1.1628 -			xmlfile=mfile.name();
  1.1629 -	}
  1.1630 -
  1.1631 -	QFile file( xmlfile);
  1.1632 -
  1.1633 -	// I am paranoid: file should exist anyway
  1.1634 -	// according to check in mainwindow.
  1.1635 -	if (!file.exists() )
  1.1636 -	{
  1.1637 -		QMessageBox::critical( 0, tr( "Critical Parse Error" ),
  1.1638 -				   tr(QString("Couldn't open map %1").arg(file.name())));
  1.1639 -		err=aborted;	
  1.1640 -	} else
  1.1641 -	{
  1.1642 -		bool blockSaveStateOrg=blockSaveState;
  1.1643 -		blockReposition=true;
  1.1644 -		blockSaveState=true;
  1.1645 -		QXmlInputSource source( file);
  1.1646 -		QXmlSimpleReader reader;
  1.1647 -		reader.setContentHandler( handler );
  1.1648 -		reader.setErrorHandler( handler );
  1.1649 -		handler->setModel ( model);
  1.1650 -
  1.1651 -
  1.1652 -		// We need to set the tmpDir in order  to load files with rel. path
  1.1653 -		QString tmpdir;
  1.1654 -		if (zipped)
  1.1655 -			tmpdir=tmpZipDir;
  1.1656 -		else
  1.1657 -			tmpdir=fname.left(fname.findRev("/",-1));	
  1.1658 -		handler->setTmpDir (tmpdir);
  1.1659 -		handler->setInputFile (file.name());
  1.1660 -		handler->setLoadMode (lmode);
  1.1661 -		bool ok = reader.parse( source );
  1.1662 -		blockReposition=false;
  1.1663 -		blockSaveState=blockSaveStateOrg;
  1.1664 -		file.close();
  1.1665 -		if ( ok ) 
  1.1666 -		{
  1.1667 -			model->reposition();	// FIXME reposition the view instead...
  1.1668 -			xelection.update();
  1.1669 -			if (lmode==NewMap)
  1.1670 -			{
  1.1671 -				mapDefault=false;
  1.1672 -				mapChanged=false;
  1.1673 -				mapUnsaved=false;
  1.1674 -				autosaveTimer->stop();
  1.1675 -			}
  1.1676 -
  1.1677 -			// Reset timestamp to check for later updates of file
  1.1678 -			fileChangedTime=QFileInfo (destPath).lastModified();
  1.1679 -		} else 
  1.1680 -		{
  1.1681 -			QMessageBox::critical( 0, tr( "Critical Parse Error" ),
  1.1682 -					   tr( handler->errorProtocol() ) );
  1.1683 -			// returnCode=1;	
  1.1684 -			// Still return "success": the map maybe at least
  1.1685 -			// partially read by the parser
  1.1686 -		}	
  1.1687 -	}	
  1.1688 -
  1.1689 -	// Delete tmpZipDir
  1.1690 -	removeDir (QDir(tmpZipDir));
  1.1691 -
  1.1692 -	updateActions();
  1.1693 -
  1.1694 -	return err;
  1.1695 -}
  1.1696 -
  1.1697 -ErrorCode MapEditor::save (const SaveMode &savemode)
  1.1698 -{
  1.1699 -	QString tmpZipDir;
  1.1700 -	QString mapFileName;
  1.1701 -	QString safeFilePath;
  1.1702 -
  1.1703 -	ErrorCode err=success;
  1.1704 -
  1.1705 -	if (zipped)
  1.1706 -		// save as .xml
  1.1707 -		mapFileName=mapName+".xml";
  1.1708 -	else
  1.1709 -		// use name given by user, even if he chooses .doc
  1.1710 -		mapFileName=fileName;
  1.1711 -
  1.1712 -	// Look, if we should zip the data:
  1.1713 -	if (!zipped)
  1.1714 -	{
  1.1715 -		QMessageBox mb( vymName,
  1.1716 -			tr("The map %1\ndid not use the compressed "
  1.1717 -			"vym file format.\nWriting it uncompressed will also write images \n"
  1.1718 -			"and flags and thus may overwrite files in the "
  1.1719 -			"given directory\n\nDo you want to write the map").arg(filePath),
  1.1720 -			QMessageBox::Warning,
  1.1721 -			QMessageBox::Yes | QMessageBox::Default,
  1.1722 -			QMessageBox::No ,
  1.1723 -			QMessageBox::Cancel | QMessageBox::Escape);
  1.1724 -		mb.setButtonText( QMessageBox::Yes, tr("compressed (vym default)") );
  1.1725 -		mb.setButtonText( QMessageBox::No, tr("uncompressed") );
  1.1726 -		mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
  1.1727 -		switch( mb.exec() ) 
  1.1728 -		{
  1.1729 -			case QMessageBox::Yes:
  1.1730 -				// save compressed (default file format)
  1.1731 -				zipped=true;
  1.1732 -				break;
  1.1733 -			case QMessageBox::No:
  1.1734 -				// save uncompressed
  1.1735 -				zipped=false;
  1.1736 -				break;
  1.1737 -			case QMessageBox::Cancel:
  1.1738 -				// do nothing
  1.1739 -				return aborted;
  1.1740 -				break;
  1.1741 -		}
  1.1742 -	}
  1.1743 -
  1.1744 -	// First backup existing file, we 
  1.1745 -	// don't want to add to old zip archives
  1.1746 -	QFile f(destPath);
  1.1747 -	if (f.exists())
  1.1748 -	{
  1.1749 -		if ( settings.value ("/mapeditor/writeBackupFile").toBool())
  1.1750 -		{
  1.1751 -			QString backupFileName(destPath + "~");
  1.1752 -			QFile backupFile(backupFileName);
  1.1753 -			if (backupFile.exists() && !backupFile.remove())
  1.1754 -			{
  1.1755 -				QMessageBox::warning(0, tr("Save Error"),
  1.1756 -									 tr("%1\ncould not be removed before saving").arg(backupFileName));
  1.1757 -			}
  1.1758 -			else if (!f.rename(backupFileName))
  1.1759 -			{
  1.1760 -				QMessageBox::warning(0, tr("Save Error"),
  1.1761 -									 tr("%1\ncould not be renamed before saving").arg(destPath));
  1.1762 -			}
  1.1763 -		}
  1.1764 -	}
  1.1765 -
  1.1766 -	if (zipped)
  1.1767 -	{
  1.1768 -		// Create temporary directory for packing
  1.1769 -		bool ok;
  1.1770 -		tmpZipDir=makeTmpDir (ok,"vym-zip");
  1.1771 -		if (!ok)
  1.1772 -		{
  1.1773 -			QMessageBox::critical( 0, tr( "Critical Load Error" ),
  1.1774 -			   tr("Couldn't create temporary directory before save\n"));
  1.1775 -			return aborted; 
  1.1776 -		}
  1.1777 -
  1.1778 -		safeFilePath=filePath;
  1.1779 -		setFilePath (tmpZipDir+"/"+ mapName+ ".xml", safeFilePath);
  1.1780 -	} // zipped
  1.1781 -
  1.1782 -	// Create mapName and fileDir
  1.1783 -	makeSubDirs (fileDir);
  1.1784 -
  1.1785 -	QString saveFile;
  1.1786 -	if (savemode==CompleteMap || xelection.isEmpty())
  1.1787 -	{
  1.1788 -		// Save complete map
  1.1789 -		saveFile=saveToDir (fileDir,mapName+"-",true,QPointF(),NULL);
  1.1790 -		mapChanged=false;
  1.1791 -		mapUnsaved=false;
  1.1792 -		autosaveTimer->stop();
  1.1793 -	}
  1.1794 -	else	
  1.1795 -	{
  1.1796 -		// Save part of map
  1.1797 -		if (xelection.type()==Selection::FloatImage)
  1.1798 -			saveFloatImage();
  1.1799 -		else	
  1.1800 -			saveFile=saveToDir (fileDir,mapName+"-",true,QPointF(),xelection.getBranch());	
  1.1801 -		// TODO take care of multiselections
  1.1802 -	}	
  1.1803 -
  1.1804 -	if (!saveStringToDisk(fileDir+mapFileName,saveFile))
  1.1805 -	{
  1.1806 -		err=aborted;
  1.1807 -		qWarning ("ME::saveStringToDisk failed!");
  1.1808 -	}
  1.1809 -
  1.1810 -	if (zipped)
  1.1811 -	{
  1.1812 -		// zip
  1.1813 -		if (err==success) err=zipDir (tmpZipDir,destPath);
  1.1814 -
  1.1815 -		// Delete tmpDir
  1.1816 -		removeDir (QDir(tmpZipDir));
  1.1817 -
  1.1818 -		// Restore original filepath outside of tmp zip dir
  1.1819 -		setFilePath (safeFilePath);
  1.1820 -	}
  1.1821 -
  1.1822 -	updateActions();
  1.1823 -	fileChangedTime=QFileInfo (destPath).lastModified();
  1.1824 -	return err;
  1.1825 -}
  1.1826 -
  1.1827 -
  1.1828  void MapEditor::print()
  1.1829  {
  1.1830  	if ( !printer ) 
  1.1831 @@ -1882,7 +177,7 @@
  1.1832  		pp.setRenderHint(QPainter::Antialiasing,true);
  1.1833  
  1.1834  		// Don't print the visualisation of selection
  1.1835 -		xelection.unselect();
  1.1836 +		model->unselect();
  1.1837  
  1.1838  		QRectF mapRect=totalBBox;
  1.1839  		QGraphicsRectItem *frame=NULL;
  1.1840 @@ -1920,7 +215,7 @@
  1.1841  			font.setPointSize(10);
  1.1842  			pp.setFont (font);
  1.1843  			QRectF footerBox(0,viewBottom,printer->width(),15);
  1.1844 -			pp.drawText ( footerBox,Qt::AlignLeft,"VYM - " +fileName);
  1.1845 +			// FIXME fileName not any longer available here: pp.drawText ( footerBox,Qt::AlignLeft,"VYM - " +fileName);
  1.1846  			pp.drawText ( footerBox, Qt::AlignRight, QDate::currentDate().toString(Qt::TextDate));
  1.1847  		}
  1.1848  		mapScene->render (
  1.1849 @@ -1933,7 +228,7 @@
  1.1850  		if (frame)  delete (frame);
  1.1851  
  1.1852  		// Restore selection
  1.1853 -		xelection.reselect();
  1.1854 +		model->reselect();
  1.1855  
  1.1856  		// Save settings in vymrc
  1.1857  		settings.writeEntry("/mainwindow/printerName",printer->printerName());
  1.1858 @@ -1952,1418 +247,9 @@
  1.1859  	setRenderHint(QPainter::SmoothPixmapTransform,b);
  1.1860  }
  1.1861  
  1.1862 -QPixmap MapEditor::getPixmap()
  1.1863 -{
  1.1864 -	QRectF mapRect=model->getTotalBBox();
  1.1865 -	QPixmap pix((int)mapRect.width()+2,(int)mapRect.height()+1);
  1.1866 -	QPainter pp (&pix);
  1.1867 -	
  1.1868 -	pp.setRenderHints(renderHints());
  1.1869 -
  1.1870 -	// Don't print the visualisation of selection
  1.1871 -	xelection.unselect();
  1.1872 -
  1.1873 -	mapScene->render (	&pp, 
  1.1874 -		QRectF(0,0,mapRect.width()+2,mapRect.height()+2),
  1.1875 -		QRectF(mapRect.x(),mapRect.y(),mapRect.width(),mapRect.height() ));
  1.1876 -
  1.1877 -	// Restore selection
  1.1878 -	xelection.reselect();
  1.1879 -	
  1.1880 -	return pix;
  1.1881 -}
  1.1882 -
  1.1883 -void MapEditor::setHideTmpMode (HideTmpMode mode)
  1.1884 -{
  1.1885 -	hidemode=mode;
  1.1886 -	model->setHideTmp (hidemode);
  1.1887 -	model->reposition();
  1.1888 -	scene()->update();
  1.1889 -}
  1.1890 -
  1.1891 -HideTmpMode MapEditor::getHideTmpMode()
  1.1892 -{
  1.1893 -	return hidemode;
  1.1894 -}
  1.1895 -
  1.1896 -void MapEditor::setExportMode (bool b)
  1.1897 -{
  1.1898 -	// should be called before and after exports
  1.1899 -	// depending on the settings
  1.1900 -	if (b && settings.value("/export/useHideExport","true")=="true")
  1.1901 -		setHideTmpMode (HideExport);
  1.1902 -	else	
  1.1903 -		setHideTmpMode (HideNone);
  1.1904 -}
  1.1905 -
  1.1906 -void MapEditor::exportASCII(QString fname,bool askName)
  1.1907 -{
  1.1908 -	ExportASCII ex;
  1.1909 -	ex.setModel (model);
  1.1910 -	if (fname=="") 
  1.1911 -		ex.setFile (mapName+".txt");	
  1.1912 -	else
  1.1913 -		ex.setFile (fname);
  1.1914 -
  1.1915 -	if (askName)
  1.1916 -	{
  1.1917 -		//ex.addFilter ("TXT (*.txt)");
  1.1918 -		ex.setDir(lastImageDir);
  1.1919 -		//ex.setCaption(vymName+ " -" +tr("Export as ASCII")+" "+tr("(still experimental)"));
  1.1920 -		ex.execDialog() ; 
  1.1921 -	} 
  1.1922 -	if (!ex.canceled())
  1.1923 -	{
  1.1924 -		setExportMode(true);
  1.1925 -		ex.doExport();
  1.1926 -		setExportMode(false);
  1.1927 -	}
  1.1928 -}
  1.1929 -
  1.1930 -void MapEditor::exportImage(QString fname, bool askName, QString format)
  1.1931 -{
  1.1932 -	if (fname=="")
  1.1933 -	{
  1.1934 -		fname=mapName+".png";
  1.1935 -		format="PNG";
  1.1936 -	} 	
  1.1937 -
  1.1938 -	if (askName)
  1.1939 -	{
  1.1940 -		QStringList fl;
  1.1941 -		QFileDialog *fd=new QFileDialog (this);
  1.1942 -		fd->setCaption (tr("Export map as image"));
  1.1943 -		fd->setDirectory (lastImageDir);
  1.1944 -		fd->setFileMode(QFileDialog::AnyFile);
  1.1945 -		fd->setFilters  (imageIO.getFilters() );
  1.1946 -		if (fd->exec())
  1.1947 -		{
  1.1948 -			fl=fd->selectedFiles();
  1.1949 -			fname=fl.first();
  1.1950 -			format=imageIO.getType(fd->selectedFilter());
  1.1951 -		} 
  1.1952 -	}
  1.1953 -
  1.1954 -	setExportMode (true);
  1.1955 -	QPixmap pix (getPixmap());
  1.1956 -	pix.save(fname, format);
  1.1957 -	setExportMode (false);
  1.1958 -}
  1.1959 -
  1.1960 -void MapEditor::exportOOPresentation(const QString &fn, const QString &cf)
  1.1961 -{
  1.1962 -	ExportOO ex;
  1.1963 -	ex.setFile (fn);
  1.1964 -	ex.setModel (model);
  1.1965 -	if (ex.setConfigFile(cf)) 
  1.1966 -	{
  1.1967 -		setExportMode (true);
  1.1968 -		ex.exportPresentation();
  1.1969 -		setExportMode (false);
  1.1970 -	}
  1.1971 -}
  1.1972 -
  1.1973 -void MapEditor::exportXHTML (const QString &dir, bool askForName)
  1.1974 -{
  1.1975 -			ExportXHTMLDialog dia(this);
  1.1976 -			dia.setFilePath (filePath );
  1.1977 -			dia.setMapName (mapName );
  1.1978 -			dia.readSettings();
  1.1979 -			if (dir!="") dia.setDir (dir);
  1.1980 -
  1.1981 -			bool ok=true;
  1.1982 -			
  1.1983 -			if (askForName)
  1.1984 -			{
  1.1985 -				if (dia.exec()!=QDialog::Accepted) 
  1.1986 -					ok=false;
  1.1987 -				else	
  1.1988 -				{
  1.1989 -					QDir d (dia.getDir());
  1.1990 -					// Check, if warnings should be used before overwriting
  1.1991 -					// the output directory
  1.1992 -					if (d.exists() && d.count()>0)
  1.1993 -					{
  1.1994 -						WarningDialog warn;
  1.1995 -						warn.showCancelButton (true);
  1.1996 -						warn.setText(QString(
  1.1997 -							"The directory %1 is not empty.\n"
  1.1998 -							"Do you risk to overwrite some of its contents?").arg(d.path() ));
  1.1999 -						warn.setCaption("Warning: Directory not empty");
  1.2000 -						warn.setShowAgainName("mainwindow/overwrite-dir-xhtml");
  1.2001 -
  1.2002 -						if (warn.exec()!=QDialog::Accepted) ok=false;
  1.2003 -					}
  1.2004 -				}	
  1.2005 -			}
  1.2006 -
  1.2007 -			if (ok)
  1.2008 -			{
  1.2009 -				exportXML (dia.getDir(),false );
  1.2010 -				dia.doExport(mapName );
  1.2011 -				//if (dia.hasChanged()) setChanged();
  1.2012 -			}
  1.2013 -}
  1.2014 -
  1.2015 -void MapEditor::exportXML(QString dir, bool askForName)
  1.2016 -{
  1.2017 -	if (askForName)
  1.2018 -	{
  1.2019 -		dir=browseDirectory(this,tr("Export XML to directory"));
  1.2020 -		if (dir =="" && !reallyWriteDirectory(dir) )
  1.2021 -		return;
  1.2022 -	}
  1.2023 -
  1.2024 -	// Hide stuff during export, if settings want this
  1.2025 -	setExportMode (true);
  1.2026 -
  1.2027 -	// Create subdirectories
  1.2028 -	makeSubDirs (dir);
  1.2029 -
  1.2030 -	// write to directory
  1.2031 -	QString saveFile=saveToDir (dir,mapName+"-",true,model->getTotalBBox().topLeft() ,NULL);
  1.2032 -	QFile file;
  1.2033 -
  1.2034 -	file.setName ( dir + "/"+mapName+".xml");
  1.2035 -	if ( !file.open( QIODevice::WriteOnly ) )
  1.2036 -	{
  1.2037 -		// This should neverever happen
  1.2038 -		QMessageBox::critical (0,tr("Critical Export Error"),tr("MapEditor::exportXML couldn't open %1").arg(file.name()));
  1.2039 -		return;
  1.2040 -	}	
  1.2041 -
  1.2042 -	// Write it finally, and write in UTF8, no matter what 
  1.2043 -	QTextStream ts( &file );
  1.2044 -	ts.setEncoding (QTextStream::UnicodeUTF8);
  1.2045 -	ts << saveFile;
  1.2046 -	file.close();
  1.2047 -
  1.2048 -	// Now write image, too
  1.2049 -	exportImage (dir+"/images/"+mapName+".png",false,"PNG");
  1.2050 -
  1.2051 -	setExportMode (false);
  1.2052 -}
  1.2053 -
  1.2054 -void MapEditor::clear()
  1.2055 -{
  1.2056 -	xelection.unselect();
  1.2057 -	model->clear();
  1.2058 -}
  1.2059 -
  1.2060 -void MapEditor::copy()
  1.2061 -{
  1.2062 -	LinkableMapObj *sel=xelection.single();
  1.2063 -	if (sel)
  1.2064 -	{
  1.2065 -		if (redosAvail == 0)
  1.2066 -		{
  1.2067 -			// Copy to history
  1.2068 -			QString s=model->getSelectString(sel);
  1.2069 -			saveState (PartOfMap, s, "nop ()", s, "copy ()","Copy selection to clipboard",sel  );
  1.2070 -			curClipboard=curStep;
  1.2071 -		}
  1.2072 -
  1.2073 -		// Copy also to global clipboard, because we are at last step in history
  1.2074 -		QString bakMapName(QString("history-%1").arg(curStep));
  1.2075 -		QString bakMapDir(tmpMapDir +"/"+bakMapName);
  1.2076 -		copyDir (bakMapDir,clipboardDir );
  1.2077 -
  1.2078 -		clipboardEmpty=false;
  1.2079 -		updateActions();
  1.2080 -	}	    
  1.2081 -}
  1.2082 -
  1.2083 -void MapEditor::redo()
  1.2084 -{
  1.2085 -	// Can we undo at all?
  1.2086 -	if (redosAvail<1) return;
  1.2087 -
  1.2088 -	bool blockSaveStateOrg=blockSaveState;
  1.2089 -	blockSaveState=true;
  1.2090 -	
  1.2091 -	redosAvail--;
  1.2092 -
  1.2093 -	if (undosAvail<stepsTotal) undosAvail++;
  1.2094 -	curStep++;
  1.2095 -	if (curStep>stepsTotal) curStep=1;
  1.2096 -	QString undoCommand=  undoSet.readEntry (QString("/history/step-%1/undoCommand").arg(curStep));
  1.2097 -	QString undoSelection=undoSet.readEntry (QString("/history/step-%1/undoSelection").arg(curStep));
  1.2098 -	QString redoCommand=  undoSet.readEntry (QString("/history/step-%1/redoCommand").arg(curStep));
  1.2099 -	QString redoSelection=undoSet.readEntry (QString("/history/step-%1/redoSelection").arg(curStep));
  1.2100 -	QString comment=undoSet.readEntry (QString("/history/step-%1/comment").arg(curStep));
  1.2101 -	QString version=undoSet.readEntry ("/history/version");
  1.2102 -
  1.2103 -	/* TODO Maybe check for version, if we save the history
  1.2104 -	if (!checkVersion(version))
  1.2105 -		QMessageBox::warning(0,tr("Warning"),
  1.2106 -			tr("Version %1 of saved undo/redo data\ndoes not match current vym version %2.").arg(version).arg(vymVersion));
  1.2107 -	*/ 
  1.2108 -
  1.2109 -	// Find out current undo directory
  1.2110 -	QString bakMapDir(QString(tmpMapDir+"/undo-%1").arg(curStep));
  1.2111 -
  1.2112 -	if (debug)
  1.2113 -	{
  1.2114 -		cout << "ME::redo() begin\n";
  1.2115 -		cout << "    undosAvail="<<undosAvail<<endl;
  1.2116 -		cout << "    redosAvail="<<redosAvail<<endl;
  1.2117 -		cout << "       curStep="<<curStep<<endl;
  1.2118 -		cout << "    ---------------------------"<<endl;
  1.2119 -		cout << "    comment="<<comment.toStdString()<<endl;
  1.2120 -		cout << "    undoCom="<<undoCommand.toStdString()<<endl;
  1.2121 -		cout << "    undoSel="<<undoSelection.toStdString()<<endl;
  1.2122 -		cout << "    redoCom="<<redoCommand.toStdString()<<endl;
  1.2123 -		cout << "    redoSel="<<redoSelection.toStdString()<<endl;
  1.2124 -		cout << "    ---------------------------"<<endl<<endl;
  1.2125 -	}
  1.2126 -
  1.2127 -	// select  object before redo
  1.2128 -	if (!redoSelection.isEmpty())
  1.2129 -		select (redoSelection);
  1.2130 -
  1.2131 -
  1.2132 -	parseAtom (redoCommand);
  1.2133 -	model->reposition();
  1.2134 -
  1.2135 -	blockSaveState=blockSaveStateOrg;
  1.2136 -
  1.2137 -	undoSet.setEntry ("/history/undosAvail",QString::number(undosAvail));
  1.2138 -	undoSet.setEntry ("/history/redosAvail",QString::number(redosAvail));
  1.2139 -	undoSet.setEntry ("/history/curStep",QString::number(curStep));
  1.2140 -	undoSet.writeSettings(histPath);
  1.2141 -
  1.2142 -	mainWindow->updateHistory (undoSet);
  1.2143 -	updateActions();
  1.2144 -
  1.2145 -	/* TODO remove testing
  1.2146 -	cout << "ME::redo() end\n";
  1.2147 -	cout << "    undosAvail="<<undosAvail<<endl;
  1.2148 -	cout << "    redosAvail="<<redosAvail<<endl;
  1.2149 -	cout << "       curStep="<<curStep<<endl;
  1.2150 -	cout << "    ---------------------------"<<endl<<endl;
  1.2151 -	*/
  1.2152 -
  1.2153 -
  1.2154 -}
  1.2155 -
  1.2156 -bool MapEditor::isRedoAvailable()
  1.2157 -{
  1.2158 -	if (undoSet.readNumEntry("/history/redosAvail",0)>0)
  1.2159 -		return true;
  1.2160 -	else	
  1.2161 -		return false;
  1.2162 -}
  1.2163 -
  1.2164 -void MapEditor::undo()
  1.2165 -{
  1.2166 -	// Can we undo at all?
  1.2167 -	if (undosAvail<1) return;
  1.2168 -
  1.2169 -	mainWindow->statusMessage (tr("Autosave disabled during undo."));
  1.2170 -
  1.2171 -	bool blockSaveStateOrg=blockSaveState;
  1.2172 -	blockSaveState=true;
  1.2173 -	
  1.2174 -	QString undoCommand=  undoSet.readEntry (QString("/history/step-%1/undoCommand").arg(curStep));
  1.2175 -	QString undoSelection=undoSet.readEntry (QString("/history/step-%1/undoSelection").arg(curStep));
  1.2176 -	QString redoCommand=  undoSet.readEntry (QString("/history/step-%1/redoCommand").arg(curStep));
  1.2177 -	QString redoSelection=undoSet.readEntry (QString("/history/step-%1/redoSelection").arg(curStep));
  1.2178 -	QString comment=undoSet.readEntry (QString("/history/step-%1/comment").arg(curStep));
  1.2179 -	QString version=undoSet.readEntry ("/history/version");
  1.2180 -
  1.2181 -	/* TODO Maybe check for version, if we save the history
  1.2182 -	if (!checkVersion(version))
  1.2183 -		QMessageBox::warning(0,tr("Warning"),
  1.2184 -			tr("Version %1 of saved undo/redo data\ndoes not match current vym version %2.").arg(version).arg(vymVersion));
  1.2185 -	*/
  1.2186 -
  1.2187 -	// Find out current undo directory
  1.2188 -	QString bakMapDir(QString(tmpMapDir+"/undo-%1").arg(curStep));
  1.2189 -
  1.2190 -	// select  object before undo
  1.2191 -	if (!undoSelection.isEmpty())
  1.2192 -		select (undoSelection);
  1.2193 -
  1.2194 -	if (debug)
  1.2195 -	{
  1.2196 -		cout << "ME::undo() begin\n";
  1.2197 -		cout << "    undosAvail="<<undosAvail<<endl;
  1.2198 -		cout << "    redosAvail="<<redosAvail<<endl;
  1.2199 -		cout << "       curStep="<<curStep<<endl;
  1.2200 -		cout << "    ---------------------------"<<endl;
  1.2201 -		cout << "    comment="<<comment.toStdString()<<endl;
  1.2202 -		cout << "    undoCom="<<undoCommand.toStdString()<<endl;
  1.2203 -		cout << "    undoSel="<<undoSelection.toStdString()<<endl;
  1.2204 -		cout << "    redoCom="<<redoCommand.toStdString()<<endl;
  1.2205 -		cout << "    redoSel="<<redoSelection.toStdString()<<endl;
  1.2206 -		cout << "    ---------------------------"<<endl<<endl;
  1.2207 -	}	
  1.2208 -	parseAtom (undoCommand);
  1.2209 -	model->reposition();
  1.2210 -
  1.2211 -	undosAvail--;
  1.2212 -	curStep--; 
  1.2213 -	if (curStep<1) curStep=stepsTotal;
  1.2214 -
  1.2215 -	redosAvail++;
  1.2216 -
  1.2217 -	blockSaveState=blockSaveStateOrg;
  1.2218 -/* TODO remove testing
  1.2219 -	cout << "ME::undo() end\n";
  1.2220 -	cout << "    undosAvail="<<undosAvail<<endl;
  1.2221 -	cout << "    redosAvail="<<redosAvail<<endl;
  1.2222 -	cout << "       curStep="<<curStep<<endl;
  1.2223 -	cout << "    ---------------------------"<<endl<<endl;
  1.2224 -*/
  1.2225 -
  1.2226 -	undoSet.setEntry ("/history/undosAvail",QString::number(undosAvail));
  1.2227 -	undoSet.setEntry ("/history/redosAvail",QString::number(redosAvail));
  1.2228 -	undoSet.setEntry ("/history/curStep",QString::number(curStep));
  1.2229 -	undoSet.writeSettings(histPath);
  1.2230 -
  1.2231 -	mainWindow->updateHistory (undoSet);
  1.2232 -	updateActions();
  1.2233 -	xelection.update();
  1.2234 -	ensureSelectionVisible();
  1.2235 -}
  1.2236 -
  1.2237 -bool MapEditor::isUndoAvailable()
  1.2238 -{
  1.2239 -	if (undoSet.readNumEntry("/history/undosAvail",0)>0)
  1.2240 -		return true;
  1.2241 -	else	
  1.2242 -		return false;
  1.2243 -}
  1.2244 -
  1.2245 -void MapEditor::gotoHistoryStep (int i)
  1.2246 -{
  1.2247 -	// Restore variables
  1.2248 -	int undosAvail=undoSet.readNumEntry (QString("/history/undosAvail"));
  1.2249 -	int redosAvail=undoSet.readNumEntry (QString("/history/redosAvail"));
  1.2250 -
  1.2251 -	if (i<0) i=undosAvail+redosAvail;
  1.2252 -
  1.2253 -	// Clicking above current step makes us undo things
  1.2254 -	if (i<undosAvail) 
  1.2255 -	{	
  1.2256 -		for (int j=0; j<undosAvail-i; j++) undo();
  1.2257 -		return;
  1.2258 -	}	
  1.2259 -	// Clicking below current step makes us redo things
  1.2260 -	if (i>undosAvail) 
  1.2261 -		for (int j=undosAvail; j<i; j++) 
  1.2262 -		{
  1.2263 -			if (debug) cout << "ME::gotoHistoryStep redo "<<j<<"/"<<undosAvail<<" i="<<i<<endl;
  1.2264 -			redo();
  1.2265 -		}
  1.2266 -
  1.2267 -	// And ignore clicking the current row ;-)	
  1.2268 -}
  1.2269 -
  1.2270 -void MapEditor::addMapReplaceInt(const QString &undoSel, const QString &path)
  1.2271 -{
  1.2272 -	QString pathDir=path.left(path.findRev("/"));
  1.2273 -	QDir d(pathDir);
  1.2274 -	QFile file (path);
  1.2275 -
  1.2276 -	if (d.exists() )
  1.2277 -	{
  1.2278 -		// We need to parse saved XML data
  1.2279 -		parseVYMHandler handler;
  1.2280 -		QXmlInputSource source( file);
  1.2281 -		QXmlSimpleReader reader;
  1.2282 -		reader.setContentHandler( &handler );
  1.2283 -		reader.setErrorHandler( &handler );
  1.2284 -		handler.setModel ( model);
  1.2285 -		handler.setTmpDir ( pathDir );	// needed to load files with rel. path
  1.2286 -		if (undoSel.isEmpty())
  1.2287 -		{
  1.2288 -			unselect();
  1.2289 -			model->clear();
  1.2290 -			handler.setLoadMode (NewMap);
  1.2291 -		} else	
  1.2292 -		{
  1.2293 -			select (undoSel);
  1.2294 -			handler.setLoadMode (ImportReplace);
  1.2295 -		}	
  1.2296 -		blockReposition=true;
  1.2297 -		bool ok = reader.parse( source );
  1.2298 -		blockReposition=false;
  1.2299 -		if (! ok ) 
  1.2300 -		{	
  1.2301 -			// This should never ever happen
  1.2302 -			QMessageBox::critical( 0, tr( "Critical Parse Error while reading %1").arg(path),
  1.2303 -								    handler.errorProtocol());
  1.2304 -		}
  1.2305 -	} else	
  1.2306 -		QMessageBox::critical( 0, tr( "Critical Error" ), tr("Could not read %1").arg(path));
  1.2307 -}
  1.2308 -
  1.2309 -void MapEditor::addMapInsertInt (const QString &path, int pos)
  1.2310 -{
  1.2311 -	BranchObj *sel=xelection.getBranch();
  1.2312 -	if (sel)
  1.2313 -	{
  1.2314 -		QString pathDir=path.left(path.findRev("/"));
  1.2315 -		QDir d(pathDir);
  1.2316 -		QFile file (path);
  1.2317 -
  1.2318 -		if (d.exists() )
  1.2319 -		{
  1.2320 -			// We need to parse saved XML data
  1.2321 -			parseVYMHandler handler;
  1.2322 -			QXmlInputSource source( file);
  1.2323 -			QXmlSimpleReader reader;
  1.2324 -			reader.setContentHandler( &handler );
  1.2325 -			reader.setErrorHandler( &handler );
  1.2326 -			handler.setModel (model);
  1.2327 -			handler.setTmpDir ( pathDir );	// needed to load files with rel. path
  1.2328 -			handler.setLoadMode (ImportAdd);
  1.2329 -			blockReposition=true;
  1.2330 -			bool ok = reader.parse( source );
  1.2331 -			blockReposition=false;
  1.2332 -			if (! ok ) 
  1.2333 -			{	
  1.2334 -				// This should never ever happen
  1.2335 -				QMessageBox::critical( 0, tr( "Critical Parse Error while reading %1").arg(path),
  1.2336 -										handler.errorProtocol());
  1.2337 -			}
  1.2338 -			if (sel->getDepth()>0)
  1.2339 -				sel->getLastBranch()->linkTo (sel,pos);
  1.2340 -		} else	
  1.2341 -			QMessageBox::critical( 0, tr( "Critical Error" ), tr("Could not read %1").arg(path));
  1.2342 -	}		
  1.2343 -}
  1.2344 -
  1.2345 -void MapEditor::pasteNoSave(const int &n)
  1.2346 -{
  1.2347 -	bool old=blockSaveState;
  1.2348 -	blockSaveState=true;
  1.2349 -	bool zippedOrg=zipped;
  1.2350 -	if (redosAvail > 0 || n!=0)
  1.2351 -	{
  1.2352 -		// Use the "historical" buffer
  1.2353 -		QString bakMapName(QString("history-%1").arg(n));
  1.2354 -		QString bakMapDir(tmpMapDir +"/"+bakMapName);
  1.2355 -		load (bakMapDir+"/"+clipboardFile,ImportAdd, VymMap);
  1.2356 -	} else
  1.2357 -		// Use the global buffer
  1.2358 -		load (clipboardDir+"/"+clipboardFile,ImportAdd, VymMap);
  1.2359 -	zipped=zippedOrg;
  1.2360 -	blockSaveState=old;
  1.2361 -}
  1.2362 -
  1.2363 -void MapEditor::paste()		
  1.2364 -{   
  1.2365 -	BranchObj *sel=xelection.getBranch();
  1.2366 -	if (sel)
  1.2367 -	{
  1.2368 -		saveStateChangingPart(
  1.2369 -			sel,
  1.2370 -			sel,
  1.2371 -			QString ("paste (%1)").arg(curClipboard),
  1.2372 -			QString("Paste to %1").arg( getName(sel))
  1.2373 -		);
  1.2374 -		pasteNoSave(0);
  1.2375 -		model->reposition();
  1.2376 -	}
  1.2377 -}
  1.2378 -
  1.2379 -void MapEditor::cut()
  1.2380 -{
  1.2381 -	LinkableMapObj *sel=xelection.single();
  1.2382 -	if ( sel && (xelection.type() == Selection::Branch ||
  1.2383 -		xelection.type()==Selection::MapCenter ||
  1.2384 -		xelection.type()==Selection::FloatImage))
  1.2385 -	{
  1.2386 -	/* No savestate! savestate is called in cutNoSave
  1.2387 -		saveStateChangingPart(
  1.2388 -			sel->getParObj(),
  1.2389 -			sel,
  1.2390 -			"cut ()",
  1.2391 -			QString("Cut %1").arg(getName(sel ))
  1.2392 -		);
  1.2393 -	*/	
  1.2394 -		copy();
  1.2395 -		deleteSelection();
  1.2396 -		model->reposition();
  1.2397 -	}
  1.2398 -}
  1.2399 -
  1.2400 -void MapEditor::move(const double &x, const double &y)
  1.2401 -{
  1.2402 -	LinkableMapObj *sel=xelection.single();
  1.2403 -	if (sel)
  1.2404 -	{
  1.2405 -        QPointF ap(sel->getAbsPos());
  1.2406 -        QPointF to(x, y);
  1.2407 -        if (ap != to)
  1.2408 -        {
  1.2409 -            QString ps=qpointfToString(ap);
  1.2410 -            QString s=xelection.getSelectString();
  1.2411 -            saveState(
  1.2412 -                s, "move "+ps, 
  1.2413 -                s, "move "+qpointfToString(to), 
  1.2414 -                QString("Move %1 to %2").arg(getName(sel)).arg(ps));
  1.2415 -            sel->move(x,y);
  1.2416 -            model->reposition();
  1.2417 -            xelection.update();
  1.2418 -        }
  1.2419 -	}
  1.2420 -}
  1.2421 -
  1.2422 -void MapEditor::moveRel (const double &x, const double &y)
  1.2423 -{
  1.2424 -	LinkableMapObj *sel=xelection.single();
  1.2425 -	if (sel)
  1.2426 -	{
  1.2427 -        QPointF rp(sel->getRelPos());
  1.2428 -        QPointF to(x, y);
  1.2429 -        if (rp != to)
  1.2430 -        {
  1.2431 -            QString ps=qpointfToString (sel->getRelPos());
  1.2432 -            QString s=model->getSelectString(sel);
  1.2433 -            saveState(
  1.2434 -                s, "moveRel "+ps, 
  1.2435 -                s, "moveRel "+qpointfToString(to), 
  1.2436 -                QString("Move %1 to relative position %2").arg(getName(sel)).arg(ps));
  1.2437 -            ((OrnamentedObj*)sel)->move2RelPos (x,y);
  1.2438 -            model->reposition();
  1.2439 -            sel->updateLink();
  1.2440 -            xelection.update();
  1.2441 -        }
  1.2442 -	}
  1.2443 -}
  1.2444 -
  1.2445 -void MapEditor::moveBranchUp()
  1.2446 -{
  1.2447 -	BranchObj* bo=xelection.getBranch();
  1.2448 -	BranchObj* par;
  1.2449 -	if (bo)
  1.2450 -	{
  1.2451 -		if (!bo->canMoveBranchUp()) return;
  1.2452 -		par=(BranchObj*)(bo->getParObj());
  1.2453 -		BranchObj *obo=par->moveBranchUp (bo);	// bo will be the one below selection
  1.2454 -		saveState (model->getSelectString(bo),"moveBranchDown ()",model->getSelectString(obo),"moveBranchUp ()",QString("Move up %1").arg(getName(bo)));
  1.2455 -		model->reposition();
  1.2456 -		scene()->update();
  1.2457 -		xelection.update();
  1.2458 -		ensureSelectionVisible();
  1.2459 -	}
  1.2460 -}
  1.2461 -
  1.2462 -void MapEditor::moveBranchDown()
  1.2463 -{
  1.2464 -	BranchObj* bo=xelection.getBranch();
  1.2465 -	BranchObj* par;
  1.2466 -	if (bo)
  1.2467 -	{
  1.2468 -		if (!bo->canMoveBranchDown()) return;
  1.2469 -		par=(BranchObj*)(bo->getParObj());
  1.2470 -		BranchObj *obo=par->moveBranchDown(bo);	// bo will be the one above selection
  1.2471 -		saveState(model->getSelectString(bo),"moveBranchUp ()",model->getSelectString(obo),"moveBranchDown ()",QString("Move down %1").arg(getName(bo)));
  1.2472 -		model->reposition();
  1.2473 -		scene()->update();
  1.2474 -		xelection.update();
  1.2475 -		ensureSelectionVisible();
  1.2476 -	}	
  1.2477 -}
  1.2478 -
  1.2479 -void MapEditor::sortChildren()
  1.2480 -{
  1.2481 -	BranchObj* bo=xelection.getBranch();
  1.2482 -	if (bo)
  1.2483 -	{
  1.2484 -		if(bo->countBranches()>1)
  1.2485 -		{
  1.2486 -			saveStateChangingPart(bo,bo, "sortChildren ()",QString("Sort children of %1").arg(getName(bo)));
  1.2487 -			bo->sortChildren();
  1.2488 -			model->reposition();
  1.2489 -			ensureSelectionVisible();
  1.2490 -		}
  1.2491 -	}
  1.2492 -}
  1.2493 -
  1.2494 -void MapEditor::linkTo(const QString &dstString)	
  1.2495 -{
  1.2496 -	FloatImageObj *fio=xelection.getFloatImage();
  1.2497 -	if (fio)
  1.2498 -	{
  1.2499 -		BranchObj *dst=(BranchObj*)(model->findObjBySelect(dstString));
  1.2500 -		if (dst && (typeid(*dst)==typeid (BranchObj) || 
  1.2501 -					typeid(*dst)==typeid (MapCenterObj)))
  1.2502 -		{			
  1.2503 -			LinkableMapObj *dstPar=dst->getParObj();
  1.2504 -			QString parString=model->getSelectString(dstPar);
  1.2505 -			QString fioPreSelectString=model->getSelectString(fio);
  1.2506 -			QString fioPreParentSelectString=model->getSelectString (fio->getParObj());
  1.2507 -			((BranchObj*)(dst))->addFloatImage (fio);
  1.2508 -			xelection.unselect();
  1.2509 -			((BranchObj*)(fio->getParObj()))->removeFloatImage (fio);
  1.2510 -			fio=((BranchObj*)(dst))->getLastFloatImage();
  1.2511 -			fio->setRelPos();
  1.2512 -			fio->reposition();
  1.2513 -			xelection.select(fio);
  1.2514 -			saveState(
  1.2515 -				model->getSelectString(fio),
  1.2516 -				QString("linkTo (\"%1\")").arg(fioPreParentSelectString), 
  1.2517 -				fioPreSelectString, 
  1.2518 -				QString ("linkTo (\"%1\")").arg(dstString),
  1.2519 -				QString ("Link floatimage to %1").arg(getName(dst)));
  1.2520 -		}
  1.2521 -	}
  1.2522 -}
  1.2523 -
  1.2524 -QString MapEditor::getHeading(bool &ok, QPoint &p)
  1.2525 -{
  1.2526 -	BranchObj *bo=xelection.getBranch();
  1.2527 -	if (bo)
  1.2528 -	{
  1.2529 -		ok=true;
  1.2530 -		p=mapFromScene(bo->getAbsPos());
  1.2531 -		return bo->getHeading();
  1.2532 -	}
  1.2533 -	ok=false;
  1.2534 -	return QString();
  1.2535 -}
  1.2536 -
  1.2537 -void MapEditor::setHeading(const QString &s)
  1.2538 -{
  1.2539 -	BranchObj *sel=xelection.getBranch();
  1.2540 -	if (sel)
  1.2541 -	{
  1.2542 -		saveState(
  1.2543 -			sel,
  1.2544 -			"setHeading (\""+sel->getHeading()+"\")", 
  1.2545 -			sel,
  1.2546 -			"setHeading (\""+s+"\")", 
  1.2547 -			QString("Set heading of %1 to \"%2\"").arg(getName(sel)).arg(s) );
  1.2548 -		sel->setHeading(s );
  1.2549 -		model->reposition();
  1.2550 -		xelection.update();
  1.2551 -		ensureSelectionVisible();
  1.2552 -	}
  1.2553 -}
  1.2554 -
  1.2555 -void MapEditor::setHeadingInt(const QString &s)
  1.2556 -{
  1.2557 -	BranchObj *bo=xelection.getBranch();
  1.2558 -	if (bo)
  1.2559 -	{
  1.2560 -		bo->setHeading(s);
  1.2561 -		model->reposition();
  1.2562 -		xelection.update();
  1.2563 -		ensureSelectionVisible();
  1.2564 -	}
  1.2565 -}
  1.2566 -
  1.2567 -void MapEditor::setVymLinkInt (const QString &s)
  1.2568 -{
  1.2569 -	// Internal function, no saveState needed
  1.2570 -	BranchObj *bo=xelection.getBranch();
  1.2571 -	if (bo)
  1.2572 -	{
  1.2573 -		bo->setVymLink(s);
  1.2574 -		model->reposition();
  1.2575 -		updateActions();
  1.2576 -		xelection.update();
  1.2577 -		ensureSelectionVisible();
  1.2578 -	}
  1.2579 -}
  1.2580 -
  1.2581 -BranchObj* MapEditor::addMapCenter ()
  1.2582 -{
  1.2583 -	MapCenterObj *mco= model->addMapCenter(contextMenuPos);
  1.2584 -	xelection.select (mco);
  1.2585 -	updateActions();
  1.2586 -	ensureSelectionVisible();
  1.2587 -	saveState (
  1.2588 -		mco,
  1.2589 -		"delete()",
  1.2590 -		NULL,
  1.2591 -		QString ("addMapCenter (%1,%2)").arg (contextMenuPos.x()).arg(contextMenuPos.y()),
  1.2592 -		QString ("Adding MapCenter to (%1,%2").arg (contextMenuPos.x()).arg(contextMenuPos.y())
  1.2593 -	);	
  1.2594 -	return mco;	
  1.2595 -}
  1.2596 -
  1.2597 -BranchObj* MapEditor::addNewBranchInt(int num)
  1.2598 -{
  1.2599 -	// Depending on pos:
  1.2600 -	// -3		insert in childs of parent  above selection 
  1.2601 -	// -2		add branch to selection 
  1.2602 -	// -1		insert in childs of parent below selection 
  1.2603 -	// 0..n		insert in childs of parent at pos
  1.2604 -	BranchObj *newbo=NULL;
  1.2605 -	BranchObj *bo=xelection.getBranch();
  1.2606 -	if (bo)
  1.2607 -	{
  1.2608 -		if (num==-2)
  1.2609 -		{
  1.2610 -			// save scroll state. If scrolled, automatically select
  1.2611 -			// new branch in order to tmp unscroll parent...
  1.2612 -			newbo=bo->addBranch();
  1.2613 -			
  1.2614 -		}else if (num==-1)
  1.2615 -		{
  1.2616 -			num=bo->getNum()+1;
  1.2617 -			bo=(BranchObj*)bo->getParObj();
  1.2618 -			if (bo) newbo=bo->insertBranch(num);
  1.2619 -		}else if (num==-3)
  1.2620 -		{
  1.2621 -			num=bo->getNum();
  1.2622 -			bo=(BranchObj*)bo->getParObj();
  1.2623 -			if (bo) newbo=bo->insertBranch(num);
  1.2624 -		}
  1.2625 -		if (!newbo) return NULL;
  1.2626 -	}	
  1.2627 -	return newbo;
  1.2628 -}	
  1.2629 -
  1.2630 -BranchObj* MapEditor::addNewBranch(int pos)
  1.2631 -{
  1.2632 -	// Different meaning than num in addNewBranchInt!
  1.2633 -	// -1	add above
  1.2634 -	//  0	add as child
  1.2635 -	// +1	add below
  1.2636 -	BranchObj *bo = xelection.getBranch();
  1.2637 -	BranchObj *newbo=NULL;
  1.2638 -
  1.2639 -	if (bo)
  1.2640 -	{
  1.2641 -		setCursor (Qt::ArrowCursor);
  1.2642 -
  1.2643 -		newbo=addNewBranchInt (pos-2);
  1.2644 -
  1.2645 -		if (newbo)
  1.2646 -		{
  1.2647 -			saveState(
  1.2648 -				newbo,		
  1.2649 -				"delete ()",
  1.2650 -				bo,
  1.2651 -				QString ("addBranch (%1)").arg(pos),
  1.2652 -				QString ("Add new branch to %1").arg(getName(bo)));	
  1.2653 -
  1.2654 -			model->reposition();
  1.2655 -			xelection.update();
  1.2656 -			latestSelection=model->getSelectString(newbo);
  1.2657 -			// In Network mode, the client needs to know where the new branch is,
  1.2658 -			// so we have to pass on this information via saveState.
  1.2659 -			// TODO: Get rid of this positioning workaround
  1.2660 -			QString ps=qpointfToString (newbo->getAbsPos());
  1.2661 -			sendData ("selectLatestAdded ()");
  1.2662 -			sendData (QString("move %1").arg(ps));
  1.2663 -			sendSelection();
  1.2664 -		}
  1.2665 -	}	
  1.2666 -	return newbo;
  1.2667 -}
  1.2668 -
  1.2669 -
  1.2670 -BranchObj* MapEditor::addNewBranchBefore()
  1.2671 -{
  1.2672 -	BranchObj *newbo=NULL;
  1.2673 -	BranchObj *bo = xelection.getBranch();
  1.2674 -	if (bo && xelection.type()==Selection::Branch)
  1.2675 -		 // We accept no MapCenterObj here, so we _have_ a parent
  1.2676 -	{
  1.2677 -		QPointF p=bo->getRelPos();
  1.2678 -
  1.2679 -
  1.2680 -		BranchObj *parbo=(BranchObj*)(bo->getParObj());
  1.2681 -
  1.2682 -		// add below selection
  1.2683 -		newbo=parbo->insertBranch(bo->getNum()+1);
  1.2684 -		if (newbo)
  1.2685 -		{
  1.2686 -			newbo->move2RelPos (p);
  1.2687 -
  1.2688 -			// Move selection to new branch
  1.2689 -			bo->linkTo (newbo,-1);
  1.2690 -
  1.2691 -			saveState (newbo, "deleteKeepChilds ()", newbo, "addBranchBefore ()", 
  1.2692 -				QString ("Add branch before %1").arg(getName(bo)));
  1.2693 -
  1.2694 -			model->reposition();
  1.2695 -			xelection.update();
  1.2696 -		}
  1.2697 -	}	
  1.2698 -	latestSelection=xelection.getSelectString();
  1.2699 -	return newbo;
  1.2700 -}
  1.2701 -
  1.2702 -void MapEditor::deleteSelection()
  1.2703 -{
  1.2704 -	BranchObj *bo = xelection.getBranch();
  1.2705 -	if (bo && xelection.type()==Selection::MapCenter)
  1.2706 -	{
  1.2707 -	//	BranchObj* par=(BranchObj*)(bo->getParObj());
  1.2708 -		xelection.unselect();
  1.2709 -	/* FIXME Note:  does saveStateRemovingPart work for MCO? (No parent!)
  1.2710 -		saveStateRemovingPart (bo, QString ("Delete %1").arg(getName(bo)));
  1.2711 -		*/
  1.2712 -		bo=model->removeMapCenter ((MapCenterObj*)bo);
  1.2713 -		if (bo) 
  1.2714 -		{
  1.2715 -			xelection.select (bo);
  1.2716 -			ensureSelectionVisible();
  1.2717 -			xelection.update();
  1.2718 -		}	
  1.2719 -		model->reposition();
  1.2720 -		return;
  1.2721 -	}
  1.2722 -	if (bo && xelection.type()==Selection::Branch)
  1.2723 -	{
  1.2724 -		BranchObj* par=(BranchObj*)bo->getParObj();
  1.2725 -		xelection.unselect();
  1.2726 -		saveStateRemovingPart (bo, QString ("Delete %1").arg(getName(bo)));
  1.2727 -		par->removeBranch(bo);
  1.2728 -		xelection.select (par);
  1.2729 -		ensureSelectionVisible();
  1.2730 -		model->reposition();
  1.2731 -//		xelection.update();
  1.2732 -		xelection.update();
  1.2733 -		return;
  1.2734 -	}
  1.2735 -	FloatImageObj *fio=xelection.getFloatImage();
  1.2736 -	if (fio)
  1.2737 -	{
  1.2738 -		BranchObj* par=(BranchObj*)fio->getParObj();
  1.2739 -		saveStateChangingPart(
  1.2740 -			par, 
  1.2741 -			fio,
  1.2742 -			"delete ()",
  1.2743 -			QString("Delete %1").arg(getName(fio))
  1.2744 -		);
  1.2745 -		xelection.unselect();
  1.2746 -		par->removeFloatImage(fio);
  1.2747 -		xelection.select (par);
  1.2748 -		model->reposition();
  1.2749 -		xelection.update();
  1.2750 -		ensureSelectionVisible();
  1.2751 -		return;
  1.2752 -	}
  1.2753 -}
  1.2754 -
  1.2755 -LinkableMapObj* MapEditor::getSelection()
  1.2756 -{
  1.2757 -	return xelection.single();
  1.2758 -}
  1.2759 -
  1.2760 -BranchObj* MapEditor::getSelectedBranch()
  1.2761 -{
  1.2762 -	return xelection.getBranch();
  1.2763 -}
  1.2764 -
  1.2765 -FloatImageObj* MapEditor::getSelectedFloatImage()
  1.2766 -{
  1.2767 -	return xelection.getFloatImage();
  1.2768 -}
  1.2769 -
  1.2770 -void MapEditor::unselect()
  1.2771 -{
  1.2772 -	xelection.unselect();
  1.2773 -}	
  1.2774 -
  1.2775 -void MapEditor::reselect()
  1.2776 -{
  1.2777 -	xelection.reselect();
  1.2778 -}	
  1.2779 -
  1.2780 -bool MapEditor::select (const QString &s)
  1.2781 -{
  1.2782 -	if (xelection.select(s))
  1.2783 -	{
  1.2784 -		xelection.update();
  1.2785 -		ensureSelectionVisible();
  1.2786 -		sendSelection ();
  1.2787 -		return true;
  1.2788 -	}
  1.2789 -	return false;
  1.2790 -}
  1.2791 -
  1.2792 -bool MapEditor::select (LinkableMapObj *lmo)
  1.2793 -{
  1.2794 -	if (xelection.select(lmo))
  1.2795 -	{
  1.2796 -		xelection.update();
  1.2797 -		ensureSelectionVisible();
  1.2798 -		sendSelection ();
  1.2799 -		return true;
  1.2800 -	}
  1.2801 -	return false;
  1.2802 -}
  1.2803 -
  1.2804 -QString MapEditor::getSelectString()
  1.2805 -{
  1.2806 -	return xelection.getSelectString();
  1.2807 -}
  1.2808 -
  1.2809 -void MapEditor::selectInt (LinkableMapObj *lmo)
  1.2810 -{
  1.2811 -	if (lmo && xelection.single()!= lmo && isSelectBlocked()==false )
  1.2812 -	{
  1.2813 -		xelection.select(lmo);
  1.2814 -		xelection.update();
  1.2815 -		sendSelection ();
  1.2816 -	}	
  1.2817 -}
  1.2818 -
  1.2819 -void MapEditor::selectNextBranchInt()
  1.2820 -{
  1.2821 -	// Increase number of branch
  1.2822 -	LinkableMapObj *sel=xelection.single();
  1.2823 -	if (sel)
  1.2824 -	{
  1.2825 -		QString s=xelection.getSelectString();
  1.2826 -		QString part;
  1.2827 -		QString typ;
  1.2828 -		QString num;
  1.2829 -
  1.2830 -		// Where am I? 
  1.2831 -		part=s.section(",",-1);
  1.2832 -		typ=part.left (3);
  1.2833 -		num=part.right(part.length() - 3);
  1.2834 -
  1.2835 -		s=s.left (s.length() -num.length());
  1.2836 -
  1.2837 -		// Go to next lmo
  1.2838 -		num=QString ("%1").arg(num.toUInt()+1);
  1.2839 -
  1.2840 -		s=s+num;
  1.2841 -		
  1.2842 -		// Try to select this one
  1.2843 -		if (select (s)) return;
  1.2844 -
  1.2845 -		// We have no direct successor, 
  1.2846 -		// try to increase the parental number in order to
  1.2847 -		// find a successor with same depth
  1.2848 -
  1.2849 -		int d=xelection.single()->getDepth();
  1.2850 -		int oldDepth=d;
  1.2851 -		int i;
  1.2852 -		bool found=false;
  1.2853 -		bool b;
  1.2854 -		while (!found && d>0)
  1.2855 -		{
  1.2856 -			s=s.section (",",0,d-1);
  1.2857 -			// replace substring of current depth in s with "1"
  1.2858 -			part=s.section(",",-1);
  1.2859 -			typ=part.left (3);
  1.2860 -			num=part.right(part.length() - 3);
  1.2861 -
  1.2862 -			if (d>1)
  1.2863 -			{	
  1.2864 -				// increase number of parent
  1.2865 -				num=QString ("%1").arg(num.toUInt()+1);
  1.2866 -				s=s.section (",",0,d-2) + ","+ typ+num;
  1.2867 -			} else
  1.2868 -			{
  1.2869 -				// Special case, look at orientation
  1.2870 -				if (xelection.single()->getOrientation()==LinkableMapObj::RightOfCenter)
  1.2871 -					num=QString ("%1").arg(num.toUInt()+1);
  1.2872 -				else	
  1.2873 -					num=QString ("%1").arg(num.toUInt()-1);
  1.2874 -				s=typ+num;
  1.2875 -			}	
  1.2876 -
  1.2877 -			if (select (s))
  1.2878 -				// pad to oldDepth, select the first branch for each depth
  1.2879 -				for (i=d;i<oldDepth;i++)
  1.2880 -				{
  1.2881 -					b=select (s);
  1.2882 -					if (b)
  1.2883 -					{	
  1.2884 -						if ( xelection.getBranch()->countBranches()>0)
  1.2885 -							s+=",bo:0";
  1.2886 -						else	
  1.2887 -							break;
  1.2888 -					} else
  1.2889 -						break;
  1.2890 -				}	
  1.2891 -
  1.2892 -			// try to select the freshly built string
  1.2893 -			found=select(s);
  1.2894 -			d--;
  1.2895 -		}
  1.2896 -		return;
  1.2897 -	}	
  1.2898 -}
  1.2899 -
  1.2900 -void MapEditor::selectPrevBranchInt()
  1.2901 -{
  1.2902 -	// Decrease number of branch
  1.2903 -	BranchObj *bo=xelection.getBranch();
  1.2904 -	if (bo)
  1.2905 -	{
  1.2906 -		QString s=xelection.getSelectString();
  1.2907 -		QString part;
  1.2908 -		QString typ;
  1.2909 -		QString num;
  1.2910 -
  1.2911 -		// Where am I? 
  1.2912 -		part=s.section(",",-1);
  1.2913 -		typ=part.left (3);
  1.2914 -		num=part.right(part.length() - 3);
  1.2915 -
  1.2916 -		s=s.left (s.length() -num.length());
  1.2917 -
  1.2918 -		int n=num.toInt()-1;
  1.2919 -		
  1.2920 -		// Go to next lmo
  1.2921 -		num=QString ("%1").arg(n);
  1.2922 -		s=s+num;
  1.2923 -		
  1.2924 -		// Try to select this one
  1.2925 -		if (n>=0 && select (s)) return;
  1.2926 -
  1.2927 -		// We have no direct precessor, 
  1.2928 -		// try to decrease the parental number in order to
  1.2929 -		// find a precessor with same depth
  1.2930 -
  1.2931 -		int d=xelection.single()->getDepth();
  1.2932 -		int oldDepth=d;
  1.2933 -		int i;
  1.2934 -		bool found=false;
  1.2935 -		bool b;
  1.2936 -		while (!found && d>0)
  1.2937 -		{
  1.2938 -			s=s.section (",",0,d-1);
  1.2939 -			// replace substring of current depth in s with "1"
  1.2940 -			part=s.section(",",-1);
  1.2941 -			typ=part.left (3);
  1.2942 -			num=part.right(part.length() - 3);
  1.2943 -
  1.2944 -			if (d>1)
  1.2945 -			{
  1.2946 -				// decrease number of parent
  1.2947 -				num=QString ("%1").arg(num.toInt()-1);
  1.2948 -				s=s.section (",",0,d-2) + ","+ typ+num;
  1.2949 -			} else
  1.2950 -			{
  1.2951 -				// Special case, look at orientation
  1.2952 -				if (xelection.single()->getOrientation()==LinkableMapObj::RightOfCenter)
  1.2953 -					num=QString ("%1").arg(num.toInt()-1);
  1.2954 -				else	
  1.2955 -					num=QString ("%1").arg(num.toInt()+1);
  1.2956 -				s=typ+num;
  1.2957 -			}	
  1.2958 -
  1.2959 -			if (select(s))
  1.2960 -				// pad to oldDepth, select the last branch for each depth
  1.2961 -				for (i=d;i<oldDepth;i++)
  1.2962 -				{
  1.2963 -					b=select (s);
  1.2964 -					if (b)
  1.2965 -						if ( xelection.getBranch()->countBranches()>0)
  1.2966 -							s+=",bo:"+ QString ("%1").arg( xelection.getBranch()->countBranches()-1 );
  1.2967 -						else	
  1.2968 -							break;
  1.2969 -					else
  1.2970 -						break;
  1.2971 -				}	
  1.2972 -			
  1.2973 -			// try to select the freshly built string
  1.2974 -			found=select(s);
  1.2975 -			d--;
  1.2976 -		}
  1.2977 -		return;
  1.2978 -	}	
  1.2979 -}
  1.2980 -
  1.2981 -void MapEditor::selectUpperBranch()
  1.2982 -{
  1.2983 -	if (isSelectBlocked() ) return;
  1.2984 -
  1.2985 -	BranchObj *bo=xelection.getBranch();
  1.2986 -	if (bo && xelection.type()==Selection::Branch)
  1.2987 -	{
  1.2988 -		if (bo->getOrientation()==LinkableMapObj::RightOfCenter)
  1.2989 -			selectPrevBranchInt();
  1.2990 -		else
  1.2991 -			if (bo->getDepth()==1)
  1.2992 -				selectNextBranchInt();
  1.2993 -			else
  1.2994 -				selectPrevBranchInt();
  1.2995 -	}
  1.2996 -}
  1.2997 -
  1.2998 -void MapEditor::selectLowerBranch()
  1.2999 -{
  1.3000 -	if (isSelectBlocked() ) return;
  1.3001 -
  1.3002 -	BranchObj *bo=xelection.getBranch();
  1.3003 -	if (bo && xelection.type()==Selection::Branch)
  1.3004 -	{
  1.3005 -		if (bo->getOrientation()==LinkableMapObj::RightOfCenter)
  1.3006 -			selectNextBranchInt();
  1.3007 -		else
  1.3008 -			if (bo->getDepth()==1)
  1.3009 -				selectPrevBranchInt();
  1.3010 -			else
  1.3011 -				selectNextBranchInt();
  1.3012 -	}			
  1.3013 -}
  1.3014 -
  1.3015 -
  1.3016 -void MapEditor::selectLeftBranch()
  1.3017 -{
  1.3018 -	if (isSelectBlocked() ) return;
  1.3019 -
  1.3020 -	BranchObj* bo;
  1.3021 -	BranchObj* par;
  1.3022 -	LinkableMapObj *sel=xelection.single();
  1.3023 -	if (sel)
  1.3024 -	{
  1.3025 -		if (xelection.type()== Selection::MapCenter)
  1.3026 -		{
  1.3027 -			par=xelection.getBranch();
  1.3028 -			bo=par->getLastSelectedBranch();
  1.3029 -			if (bo)
  1.3030 -			{
  1.3031 -				// Workaround for reselecting on left and right side
  1.3032 -				if (bo->getOrientation()==LinkableMapObj::RightOfCenter)
  1.3033 -					bo=par->getLastBranch();
  1.3034 -				if (bo)
  1.3035 -				{
  1.3036 -					bo=par->getLastBranch();
  1.3037 -					xelection.select(bo);
  1.3038 -					xelection.update();
  1.3039 -					ensureSelectionVisible();
  1.3040 -					sendSelection();
  1.3041 -				}
  1.3042 -			}	
  1.3043 -		} else
  1.3044 -		{
  1.3045 -			par=(BranchObj*)(sel->getParObj());
  1.3046 -			if (sel->getOrientation()==LinkableMapObj::RightOfCenter)
  1.3047 -			{
  1.3048 -				if (xelection.type() == Selection::Branch ||
  1.3049 -					xelection.type() == Selection::FloatImage)
  1.3050 -				{
  1.3051 -					xelection.select(par);
  1.3052 -					xelection.update();
  1.3053 -					ensureSelectionVisible();
  1.3054 -					sendSelection();
  1.3055 -				}
  1.3056 -			} else
  1.3057 -			{
  1.3058 -				if (xelection.type() == Selection::Branch )
  1.3059 -				{
  1.3060 -					bo=xelection.getBranch()->getLastSelectedBranch();
  1.3061 -					if (bo) 
  1.3062 -					{
  1.3063 -						xelection.select(bo);
  1.3064 -						xelection.update();
  1.3065 -						ensureSelectionVisible();
  1.3066 -					sendSelection();
  1.3067 -					}
  1.3068 -				}
  1.3069 -			}
  1.3070 -		}	
  1.3071 -	}
  1.3072 -}
  1.3073 -
  1.3074 -void MapEditor::selectRightBranch()
  1.3075 -{
  1.3076 -	if (isSelectBlocked() ) return;
  1.3077 -
  1.3078 -	BranchObj* bo;
  1.3079 -	BranchObj* par;
  1.3080 -	LinkableMapObj *sel=xelection.single();
  1.3081 -	if (sel)
  1.3082 -	{
  1.3083 -		if (xelection.type()==Selection::MapCenter) 
  1.3084 -		{
  1.3085 -			par=xelection.getBranch();
  1.3086 -			bo=par->getLastSelectedBranch();
  1.3087 -			if (bo)
  1.3088 -			{
  1.3089 -				// Workaround for reselecting on left and right side
  1.3090 -				if (bo->getOrientation()==LinkableMapObj::LeftOfCenter)
  1.3091 -					bo=par->getFirstBranch();
  1.3092 -				if (bo)
  1.3093 -				{
  1.3094 -					xelection.select(bo);
  1.3095 -					xelection.update();
  1.3096 -					ensureSelectionVisible();
  1.3097 -					sendSelection();
  1.3098 -				}
  1.3099 -			}
  1.3100 -		} else
  1.3101 -		{
  1.3102 -			par=(BranchObj*)(xelection.single()->getParObj());
  1.3103 -			if (xelection.single()->getOrientation()==LinkableMapObj::LeftOfCenter)
  1.3104 -			{
  1.3105 -				if (xelection.type() == Selection::Branch ||
  1.3106 -					xelection.type() == Selection::FloatImage)
  1.3107 -				{
  1.3108 -					xelection.select(par);
  1.3109 -					xelection.update();
  1.3110 -					ensureSelectionVisible();
  1.3111 -					sendSelection();
  1.3112 -				}
  1.3113 -			} else
  1.3114 -			{
  1.3115 -				if (xelection.type()  == Selection::Branch) 
  1.3116 -				{
  1.3117 -					bo=xelection.getBranch()->getLastSelectedBranch();
  1.3118 -					if (bo) 
  1.3119 -					{
  1.3120 -						xelection.select(bo);
  1.3121 -						xelection.update();
  1.3122 -						ensureSelectionVisible();
  1.3123 -					sendSelection();
  1.3124 -					}
  1.3125 -				}
  1.3126 -			}
  1.3127 -		}
  1.3128 -	}
  1.3129 -}
  1.3130 -
  1.3131 -void MapEditor::selectFirstBranch()
  1.3132 -{
  1.3133 -	BranchObj *bo1=xelection.getBranch();
  1.3134 -	BranchObj *bo2;
  1.3135 -	BranchObj* par;
  1.3136 -	if (bo1)
  1.3137 -	{
  1.3138 -		par=(BranchObj*)(bo1->getParObj());
  1.3139 -		if (!par) return;
  1.3140 -		bo2=par->getFirstBranch();
  1.3141 -		if (bo2) {
  1.3142 -			xelection.select(bo2);
  1.3143 -			xelection.update();
  1.3144 -			ensureSelectionVisible();
  1.3145 -			sendSelection();
  1.3146 -		}
  1.3147 -	}		
  1.3148 -}
  1.3149 -
  1.3150 -void MapEditor::selectLastBranch()
  1.3151 -{
  1.3152 -	BranchObj *bo1=xelection.getBranch();
  1.3153 -	BranchObj *bo2;
  1.3154 -	BranchObj* par;
  1.3155 -	if (bo1)
  1.3156 -	{
  1.3157 -		par=(BranchObj*)(bo1->getParObj());
  1.3158 -		if (!par) return;
  1.3159 -		bo2=par->getLastBranch();
  1.3160 -		if (bo2) 
  1.3161 -		{
  1.3162 -			xelection.select(bo2);
  1.3163 -			xelection.update();
  1.3164 -			ensureSelectionVisible();
  1.3165 -			sendSelection();
  1.3166 -		}
  1.3167 -	}		
  1.3168 -}
  1.3169 -
  1.3170 -void MapEditor::selectMapBackgroundImage ()
  1.3171 -{
  1.3172 -	Q3FileDialog *fd=new Q3FileDialog( this);
  1.3173 -	fd->setMode (Q3FileDialog::ExistingFile);
  1.3174 -	fd->addFilter (QString (tr("Images") + " (*.png *.bmp *.xbm *.jpg *.png *.xpm *.gif *.pnm)"));
  1.3175 -	ImagePreview *p =new ImagePreview (fd);
  1.3176 -	fd->setContentsPreviewEnabled( TRUE );
  1.3177 -	fd->setContentsPreview( p, p );
  1.3178 -	fd->setPreviewMode( Q3FileDialog::Contents );
  1.3179 -	fd->setCaption(vymName+" - " +tr("Load background image"));
  1.3180 -	fd->setDir (lastImageDir);
  1.3181 -	fd->show();
  1.3182 -
  1.3183 -	if ( fd->exec() == QDialog::Accepted )
  1.3184 -	{
  1.3185 -		// TODO selectMapBackgroundImg in QT4 use:	lastImageDir=fd->directory();
  1.3186 -		lastImageDir=QDir (fd->dirPath());
  1.3187 -		setMapBackgroundImage (fd->selectedFile());
  1.3188 -	}
  1.3189 -}	
  1.3190 -
  1.3191 -void MapEditor::setMapBackgroundImage (const QString &fn)	//FIXME missing savestate
  1.3192 -{
  1.3193 -	QColor oldcol=mapScene->backgroundBrush().color();
  1.3194 -	/*
  1.3195 -	saveState(
  1.3196 -		selection,
  1.3197 -		QString ("setMapBackgroundImage (%1)").arg(oldcol.name()),
  1.3198 -		selection,
  1.3199 -		QString ("setMapBackgroundImage (%1)").arg(col.name()),
  1.3200 -		QString("Set background color of map to %1").arg(col.name()));
  1.3201 -	*/	
  1.3202 -	QBrush brush;
  1.3203 -	brush.setTextureImage (QPixmap (fn));
  1.3204 -	mapScene->setBackgroundBrush(brush);
  1.3205 -}
  1.3206 -
  1.3207 -void MapEditor::selectMapBackgroundColor()
  1.3208 -{
  1.3209 -	QColor col = QColorDialog::getColor( mapScene->backgroundBrush().color(), this );
  1.3210 -	if ( !col.isValid() ) return;
  1.3211 -	setMapBackgroundColor( col );
  1.3212 -}
  1.3213 -
  1.3214 -
  1.3215 -void MapEditor::setMapBackgroundColor(QColor col)
  1.3216 -{
  1.3217 -	QColor oldcol=mapScene->backgroundBrush().color();
  1.3218 -	saveState(
  1.3219 -		QString ("setMapBackgroundColor (\"%1\")").arg(oldcol.name()),
  1.3220 -		QString ("setMapBackgroundColor (\"%1\")").arg(col.name()),
  1.3221 -		QString("Set background color of map to %1").arg(col.name()));
  1.3222 -	mapScene->setBackgroundBrush(col);
  1.3223 -}
  1.3224 -
  1.3225 -QColor MapEditor::getMapBackgroundColor()
  1.3226 -{
  1.3227 -    return mapScene->backgroundBrush().color();
  1.3228 -}
  1.3229 -
  1.3230 -QColor MapEditor::getCurrentHeadingColor()
  1.3231 -{
  1.3232 -	BranchObj *bo=xelection.getBranch();
  1.3233 -	if (bo) return bo->getColor(); 
  1.3234 -	
  1.3235 -	QMessageBox::warning(0,tr("Warning"),tr("Can't get color of heading,\nthere's no branch selected"));
  1.3236 -	return Qt::black;
  1.3237 -}
  1.3238 -
  1.3239 -void MapEditor::colorBranch (QColor c)
  1.3240 -{
  1.3241 -	BranchObj *bo=xelection.getBranch();
  1.3242 -	if (bo)
  1.3243 -	{
  1.3244 -		saveState(
  1.3245 -			bo, 
  1.3246 -			QString ("colorBranch (\"%1\")").arg(bo->getColor().name()),
  1.3247 -			bo,
  1.3248 -			QString ("colorBranch (\"%1\")").arg(c.name()),
  1.3249 -			QString("Set color of %1 to %2").arg(getName(bo)).arg(c.name())
  1.3250 -		);	
  1.3251 -		bo->setColor(c); // color branch
  1.3252 -	}
  1.3253 -}
  1.3254 -
  1.3255 -void MapEditor::colorSubtree (QColor c)
  1.3256 -{
  1.3257 -	BranchObj *bo=xelection.getBranch();
  1.3258 -	if (bo) 
  1.3259 -	{
  1.3260 -		saveStateChangingPart(
  1.3261 -			bo, 
  1.3262 -			bo,
  1.3263 -			QString ("colorSubtree (\"%1\")").arg(c.name()),
  1.3264 -			QString ("Set color of %1 and childs to %2").arg(getName(bo)).arg(c.name())
  1.3265 -		);	
  1.3266 -		bo->setColorSubtree (c); // color links, color childs
  1.3267 -	}
  1.3268 -}
  1.3269 -
  1.3270 -
  1.3271  void MapEditor::toggleStandardFlag(QString f)
  1.3272  {
  1.3273 -	BranchObj *bo=xelection.getBranch();
  1.3274 +	BranchObj *bo=model->getSelectedBranch();
  1.3275  	if (bo) 
  1.3276  	{
  1.3277  		QString u,r;
  1.3278 @@ -3377,1042 +263,21 @@
  1.3279  			u="unsetFlag";
  1.3280  			r="setFlag";
  1.3281  		}	
  1.3282 -		saveState(
  1.3283 +		model->saveState(
  1.3284  			bo,
  1.3285  			QString("%1 (\"%2\")").arg(u).arg(f), 
  1.3286  			bo,
  1.3287  			QString("%1 (\"%2\")").arg(r).arg(f),
  1.3288  			QString("Toggling standard flag \"%1\" of %2").arg(f).arg(getName(bo)));
  1.3289  		bo->toggleStandardFlag (f,mainWindow->useFlagGroups());
  1.3290 -		xelection.update();
  1.3291 +		model->updateSelection();
  1.3292  	}
  1.3293  }
  1.3294  
  1.3295 -
  1.3296 -BranchObj* MapEditor::findText (QString s, bool cs)
  1.3297 -{
  1.3298 -	QTextDocument::FindFlags flags=0;
  1.3299 -	if (cs) flags=QTextDocument::FindCaseSensitively;
  1.3300 -
  1.3301 -	if (!itFind) 
  1.3302 -	{	// Nothing found or new find process
  1.3303 -		if (EOFind)
  1.3304 -			// nothing found, start again
  1.3305 -			EOFind=false;
  1.3306 -		itFind=model->first();
  1.3307 -	}	
  1.3308 -	bool searching=true;
  1.3309 -	bool foundNote=false;
  1.3310 -	while (searching && !EOFind)
  1.3311 -	{
  1.3312 -		if (itFind)
  1.3313 -		{
  1.3314 -			// Searching in Note
  1.3315 -			if (itFind->getNote().contains(s,cs))
  1.3316 -			{
  1.3317 -				if (xelection.single()!=itFind) 
  1.3318 -				{
  1.3319 -					xelection.select(itFind);
  1.3320 -					ensureSelectionVisible();
  1.3321 -				}
  1.3322 -				if (textEditor->findText(s,flags)) 
  1.3323 -				{
  1.3324 -					searching=false;
  1.3325 -					foundNote=true;
  1.3326 -				}	
  1.3327 -			}
  1.3328 -			// Searching in Heading
  1.3329 -			if (searching && itFind->getHeading().contains (s,cs) ) 
  1.3330 -			{
  1.3331 -				xelection.select(itFind);
  1.3332 -				ensureSelectionVisible();
  1.3333 -				searching=false;
  1.3334 -			}
  1.3335 -		}	
  1.3336 -		if (!foundNote)
  1.3337 -		{
  1.3338 -			itFind=model->next(itFind);
  1.3339 -			if (!itFind) EOFind=true;
  1.3340 -		}
  1.3341 -	//cout <<"still searching...  "<<qPrintable( itFind->getHeading())<<endl;
  1.3342 -	}	
  1.3343 -	if (!searching)
  1.3344 -		return xelection.getBranch();
  1.3345 -	else
  1.3346 -		return NULL;
  1.3347 -}
  1.3348 -
  1.3349 -void MapEditor::findReset()
  1.3350 -{	// Necessary if text to find changes during a find process
  1.3351 -	itFind=NULL;
  1.3352 -	EOFind=false;
  1.3353 -}
  1.3354 -void MapEditor::setURL(const QString &url)
  1.3355 -{
  1.3356 -	BranchObj *bo=xelection.getBranch();
  1.3357 -	if (bo)
  1.3358 -	{
  1.3359 -		QString oldurl=bo->getURL();
  1.3360 -		bo->setURL (url);
  1.3361 -		saveState (
  1.3362 -			bo,
  1.3363 -			QString ("setURL (\"%1\")").arg(oldurl),
  1.3364 -			bo,
  1.3365 -			QString ("setURL (\"%1\")").arg(url),
  1.3366 -			QString ("set URL of %1 to %2").arg(getName(bo)).arg(url)
  1.3367 -		);
  1.3368 -		updateActions();
  1.3369 -		model->reposition();
  1.3370 -		xelection.update();
  1.3371 -		ensureSelectionVisible();
  1.3372 -	}
  1.3373 -}	
  1.3374 -
  1.3375 -void MapEditor::editURL()
  1.3376 -{
  1.3377 -	BranchObj *bo=xelection.getBranch();
  1.3378 -	if (bo)
  1.3379 -	{		
  1.3380 -		bool ok;
  1.3381 -		QString text = QInputDialog::getText(
  1.3382 -				"VYM", tr("Enter URL:"), QLineEdit::Normal,
  1.3383 -				bo->getURL(), &ok, this );
  1.3384 -		if ( ok) 
  1.3385 -			// user entered something and pressed OK
  1.3386 -			setURL (text);
  1.3387 -	}
  1.3388 -}
  1.3389 -
  1.3390 -void MapEditor::editLocalURL()
  1.3391 -{
  1.3392 -	BranchObj *bo=xelection.getBranch();
  1.3393 -	if (bo)
  1.3394 -	{		
  1.3395 -		QStringList filters;
  1.3396 -		filters <<"All files (*)";
  1.3397 -		filters << tr("Text","Filedialog") + " (*.txt)";
  1.3398 -		filters << tr("Spreadsheet","Filedialog") + " (*.odp,*.sxc)";
  1.3399 -		filters << tr("Textdocument","Filedialog") +" (*.odw,*.sxw)";
  1.3400 -		filters << tr("Images","Filedialog") + " (*.png *.bmp *.xbm *.jpg *.png *.xpm *.gif *.pnm)";
  1.3401 -		QFileDialog *fd=new QFileDialog( this,vymName+" - " +tr("Set URL to a local file"));
  1.3402 -		fd->setFilters (filters);
  1.3403 -		fd->setCaption(vymName+" - " +tr("Set URL to a local file"));
  1.3404 -		fd->setDirectory (lastFileDir);
  1.3405 -		if (! bo->getVymLink().isEmpty() )
  1.3406 -			fd->selectFile( bo->getURL() );
  1.3407 -		fd->show();
  1.3408 -
  1.3409 -		if ( fd->exec() == QDialog::Accepted )
  1.3410 -		{
  1.3411 -			lastFileDir=QDir (fd->directory().path());
  1.3412 -			setURL (fd->selectedFile() );
  1.3413 -		}
  1.3414 -	}
  1.3415 -}
  1.3416 -
  1.3417 -QString MapEditor::getURL()
  1.3418 -{
  1.3419 -	BranchObj *bo=xelection.getBranch();
  1.3420 -	if (bo)
  1.3421 -		return bo->getURL();
  1.3422 -	else
  1.3423 -		return "";
  1.3424 -}
  1.3425 -
  1.3426 -QStringList MapEditor::getURLs()
  1.3427 -{
  1.3428 -	QStringList urls;
  1.3429 -	BranchObj *bo=xelection.getBranch();
  1.3430 -	if (bo)
  1.3431 -	{		
  1.3432 -		bo=bo->first();	
  1.3433 -		while (bo) 
  1.3434 -		{
  1.3435 -			if (!bo->getURL().isEmpty()) urls.append( bo->getURL());
  1.3436 -			bo=bo->next();
  1.3437 -		}	
  1.3438 -	}	
  1.3439 -	return urls;
  1.3440 -}
  1.3441 -
  1.3442 -
  1.3443 -void MapEditor::editHeading2URL()
  1.3444 -{
  1.3445 -	BranchObj *bo=xelection.getBranch();
  1.3446 -	if (bo)
  1.3447 -		setURL (bo->getHeading());
  1.3448 -}	
  1.3449 -
  1.3450 -void MapEditor::editBugzilla2URL()
  1.3451 -{
  1.3452 -	BranchObj *bo=xelection.getBranch();
  1.3453 -	if (bo)
  1.3454 -	{		
  1.3455 -		QString url= "https://bugzilla.novell.com/show_bug.cgi?id="+bo->getHeading();
  1.3456 -		setURL (url);
  1.3457 -	}
  1.3458 -}	
  1.3459 -
  1.3460 -void MapEditor::editFATE2URL()
  1.3461 -{
  1.3462 -	BranchObj *bo=xelection.getBranch();
  1.3463 -	if (bo)
  1.3464 -	{		
  1.3465 -		QString url= "http://keeper.suse.de:8080/webfate/match/id?value=ID"+bo->getHeading();
  1.3466 -		saveState(
  1.3467 -			bo,
  1.3468 -			"setURL (\""+bo->getURL()+"\")",
  1.3469 -			bo,
  1.3470 -			"setURL (\""+url+"\")",
  1.3471 -			QString("Use heading of %1 as link to FATE").arg(getName(bo))
  1.3472 -		);	
  1.3473 -		bo->setURL (url);
  1.3474 -		updateActions();
  1.3475 -	}
  1.3476 -}	
  1.3477 -
  1.3478 -void MapEditor::editVymLink()
  1.3479 -{
  1.3480 -	BranchObj *bo=xelection.getBranch();
  1.3481 -	if (bo)
  1.3482 -	{		
  1.3483 -		QStringList filters;
  1.3484 -		filters <<"VYM map (*.vym)";
  1.3485 -		QFileDialog *fd=new QFileDialog( this,vymName+" - " +tr("Link to another map"));
  1.3486 -		fd->setFilters (filters);
  1.3487 -		fd->setCaption(vymName+" - " +tr("Link to another map"));
  1.3488 -		fd->setDirectory (lastFileDir);
  1.3489 -		if (! bo->getVymLink().isEmpty() )
  1.3490 -			fd->selectFile( bo->getVymLink() );
  1.3491 -		fd->show();
  1.3492 -
  1.3493 -		QString fn;
  1.3494 -		if ( fd->exec() == QDialog::Accepted )
  1.3495 -		{
  1.3496 -			lastFileDir=QDir (fd->directory().path());
  1.3497 -			saveState(
  1.3498 -				bo,
  1.3499 -				"setVymLink (\""+bo->getVymLink()+"\")",
  1.3500 -				bo,
  1.3501 -				"setVymLink (\""+fd->selectedFile()+"\")",
  1.3502 -				QString("Set vymlink of %1 to %2").arg(getName(bo)).arg(fd->selectedFile())
  1.3503 -			);	
  1.3504 -			setVymLinkInt (fd->selectedFile() );
  1.3505 -		}
  1.3506 -	}
  1.3507 -}
  1.3508 -
  1.3509 -void MapEditor::deleteVymLink()
  1.3510 -{
  1.3511 -	BranchObj *bo=xelection.getBranch();
  1.3512 -	if (bo)
  1.3513 -	{		
  1.3514 -		saveState(
  1.3515 -			bo,
  1.3516 -			"setVymLink (\""+bo->getVymLink()+"\")",
  1.3517 -			bo,
  1.3518 -			"setVymLink (\"\")",
  1.3519 -			QString("Unset vymlink of %1").arg(getName(bo))
  1.3520 -		);	
  1.3521 -		bo->setVymLink ("" );
  1.3522 -		updateActions();
  1.3523 -		model->reposition();
  1.3524 -		scene()->update();
  1.3525 -	}
  1.3526 -}
  1.3527 -
  1.3528 -void MapEditor::setHideExport(bool b)
  1.3529 -{
  1.3530 -	BranchObj *bo=xelection.getBranch();
  1.3531 -	if (bo)
  1.3532 -	{
  1.3533 -		bo->setHideInExport (b);
  1.3534 -		QString u= b ? "false" : "true";
  1.3535 -		QString r=!b ? "false" : "true";
  1.3536 -		
  1.3537 -		saveState(
  1.3538 -			bo,
  1.3539 -			QString ("setHideExport (%1)").arg(u),
  1.3540 -			bo,
  1.3541 -			QString ("setHideExport (%1)").arg(r),
  1.3542 -			QString ("Set HideExport flag of %1 to %2").arg(getName(bo)).arg (r)
  1.3543 -		);	
  1.3544 -		updateActions();
  1.3545 -		model->reposition();
  1.3546 -		xelection.update();
  1.3547 -		scene()->update();
  1.3548 -	}
  1.3549 -}
  1.3550 -
  1.3551 -void MapEditor::toggleHideExport()
  1.3552 -{
  1.3553 -	BranchObj *bo=xelection.getBranch();
  1.3554 -	if (bo)
  1.3555 -		setHideExport ( !bo->hideInExport() );
  1.3556 -}
  1.3557 -
  1.3558 -QString MapEditor::getVymLink()
  1.3559 -{
  1.3560 -	BranchObj *bo=xelection.getBranch();
  1.3561 -	if (bo)
  1.3562 -		return bo->getVymLink();
  1.3563 -	else	
  1.3564 -		return "";
  1.3565 -	
  1.3566 -}
  1.3567 -
  1.3568 -QStringList MapEditor::getVymLinks()
  1.3569 -{
  1.3570 -	QStringList links;
  1.3571 -	BranchObj *bo=xelection.getBranch();
  1.3572 -	if (bo)
  1.3573 -	{		
  1.3574 -		bo=bo->first();	
  1.3575 -		while (bo) 
  1.3576 -		{
  1.3577 -			if (!bo->getVymLink().isEmpty()) links.append( bo->getVymLink());
  1.3578 -			bo=bo->next();
  1.3579 -		}	
  1.3580 -	}	
  1.3581 -	return links;
  1.3582 -}
  1.3583 -
  1.3584 -
  1.3585 -void MapEditor::deleteKeepChilds()
  1.3586 -{
  1.3587 -	BranchObj *bo=xelection.getBranch();
  1.3588 -	BranchObj *par;
  1.3589 -	if (bo)
  1.3590 -	{
  1.3591 -		par=(BranchObj*)(bo->getParObj());
  1.3592 -		QPointF p=bo->getRelPos();
  1.3593 -		saveStateChangingPart(
  1.3594 -			bo->getParObj(),
  1.3595 -			bo,
  1.3596 -			"deleteKeepChilds ()",
  1.3597 -			QString("Remove %1 and keep its childs").arg(getName(bo))
  1.3598 -		);
  1.3599 -
  1.3600 -		QString sel=model->getSelectString(bo);
  1.3601 -		unselect();
  1.3602 -		par->removeBranchHere(bo);
  1.3603 -		model->reposition();
  1.3604 -		select (sel);
  1.3605 -		xelection.getBranch()->move2RelPos (p);
  1.3606 -		model->reposition();
  1.3607 -	}	
  1.3608 -}
  1.3609 -
  1.3610 -void MapEditor::deleteChilds()
  1.3611 -{
  1.3612 -	BranchObj *bo=xelection.getBranch();
  1.3613 -	if (bo)
  1.3614 -	{		
  1.3615 -		saveStateChangingPart(
  1.3616 -			bo, 
  1.3617 -			bo,
  1.3618 -			"deleteChilds ()",
  1.3619 -			QString( "Remove childs of branch %1").arg(getName(bo))
  1.3620 -		);
  1.3621 -		bo->removeChilds();
  1.3622 -		model->reposition();
  1.3623 -	}	
  1.3624 -}
  1.3625 -
  1.3626 -void MapEditor::editMapInfo()
  1.3627 -{
  1.3628 -	ExtraInfoDialog dia;
  1.3629 -	dia.setMapName (getFileName() );
  1.3630 -	dia.setAuthor (model->getAuthor() );
  1.3631 -	dia.setComment(model->getComment() );
  1.3632 -
  1.3633 -	// Calc some stats
  1.3634 -	QString stats;
  1.3635 -    stats+=tr("%1 items on map\n","Info about map").arg (mapScene->items().size(),6);
  1.3636 -
  1.3637 -	uint b=0;
  1.3638 -	uint f=0;
  1.3639 -	uint n=0;
  1.3640 -	uint xl=0;
  1.3641 -	BranchObj *bo;
  1.3642 -	bo=model->first();
  1.3643 -	while (bo) 
  1.3644 -	{
  1.3645 -		if (!bo->getNote().isEmpty() ) n++;
  1.3646 -		f+= bo->countFloatImages();
  1.3647 -		b++;
  1.3648 -		xl+=bo->countXLinks();
  1.3649 -		bo=model->next(bo);
  1.3650 -	}
  1.3651 -    stats+=QString ("%1 branches\n").arg (b-1,6);
  1.3652 -    stats+=QString ("%1 xLinks \n").arg (xl,6);
  1.3653 -    stats+=QString ("%1 notes\n").arg (n,6);
  1.3654 -    stats+=QString ("%1 images\n").arg (f,6);
  1.3655 -	dia.setStats (stats);
  1.3656 -
  1.3657 -	// Finally show dialog
  1.3658 -	if (dia.exec() == QDialog::Accepted)
  1.3659 -	{
  1.3660 -		setMapAuthor (dia.getAuthor() );
  1.3661 -		setMapComment (dia.getComment() );
  1.3662 -	}
  1.3663 -}
  1.3664 -
  1.3665 -void MapEditor::ensureSelectionVisible()
  1.3666 -{
  1.3667 -	LinkableMapObj *lmo=xelection.single();
  1.3668 -	if (lmo) ensureVisible (lmo->getBBox() );
  1.3669 -	
  1.3670 -}
  1.3671 -
  1.3672  void MapEditor::updateSelection()
  1.3673  {
  1.3674  	// Tell selection to update geometries
  1.3675 -	xelection.update();
  1.3676 -}
  1.3677 -
  1.3678 -void MapEditor::updateActions()
  1.3679 -{
  1.3680 -	// Tell mainwindow to update states of actions
  1.3681 -	mainWindow->updateActions();
  1.3682 -	// TODO maybe don't update if blockReposition is set
  1.3683 -}
  1.3684 -
  1.3685 -void MapEditor::updateNoteFlag()
  1.3686 -{
  1.3687 -	setChanged();
  1.3688 -	BranchObj *bo=xelection.getBranch();
  1.3689 -	if (bo) 
  1.3690 -	{
  1.3691 -		bo->updateNoteFlag();
  1.3692 -		mainWindow->updateActions();
  1.3693 -	}	
  1.3694 -}
  1.3695 -
  1.3696 -void MapEditor::setMapAuthor (const QString &s)
  1.3697 -{
  1.3698 -	saveState (
  1.3699 -		QString ("setMapAuthor (\"%1\")").arg(model->getAuthor()),
  1.3700 -		QString ("setMapAuthor (\"%1\")").arg(s),
  1.3701 -		QString ("Set author of map to \"%1\"").arg(s)
  1.3702 -	);
  1.3703 -	model->setAuthor (s);
  1.3704 -}
  1.3705 -
  1.3706 -void MapEditor::setMapComment (const QString &s)
  1.3707 -{
  1.3708 -	saveState (
  1.3709 -		QString ("setMapComment (\"%1\")").arg(model->getComment()),
  1.3710 -		QString ("setMapComment (\"%1\")").arg(s),
  1.3711 -		QString ("Set comment of map")
  1.3712 -	);
  1.3713 -	model->setComment (s);
  1.3714 -}
  1.3715 -
  1.3716 -void MapEditor::setMapLinkStyle (const QString & s)
  1.3717 -{
  1.3718 -	QString snow;
  1.3719 -	if (linkstyle==LinkableMapObj::Line)
  1.3720 -		snow="StyleLine";
  1.3721 -	else if (linkstyle==LinkableMapObj::Parabel)
  1.3722 -		snow="StyleParabel";
  1.3723 -	else if (linkstyle==LinkableMapObj::PolyLine)
  1.3724 -		snow="StylePolyLine";
  1.3725 -	else if (linkstyle==LinkableMapObj::PolyParabel)
  1.3726 -		snow="StyleParabel";
  1.3727 -
  1.3728 -	saveState (
  1.3729 -		QString("setMapLinkStyle (\"%1\")").arg(s),
  1.3730 -		QString("setMapLinkStyle (\"%1\")").arg(snow),
  1.3731 -		QString("Set map link style (\"%1\")").arg(s)
  1.3732 -	);	
  1.3733 -
  1.3734 -	if (s=="StyleLine")
  1.3735 -		linkstyle=LinkableMapObj::Line;
  1.3736 -	else if (s=="StyleParabel")
  1.3737 -		linkstyle=LinkableMapObj::Parabel;
  1.3738 -	else if (s=="StylePolyLine")
  1.3739 -		linkstyle=LinkableMapObj::PolyLine;
  1.3740 -	else	
  1.3741 -		linkstyle=LinkableMapObj::PolyParabel;
  1.3742 -
  1.3743 -	BranchObj *bo;
  1.3744 -	bo=model->first();
  1.3745 -	bo=model->next(bo);
  1.3746 -	while (bo) 
  1.3747 -	{
  1.3748 -		bo->setLinkStyle(bo->getDefLinkStyle());
  1.3749 -		bo=model->next(bo);
  1.3750 -	}
  1.3751 -	model->reposition();
  1.3752 -}
  1.3753 -
  1.3754 -LinkableMapObj::Style MapEditor::getMapLinkStyle ()
  1.3755 -{
  1.3756 -	return linkstyle;
  1.3757 -}	
  1.3758 -
  1.3759 -void MapEditor::setMapDefLinkColor(QColor c)
  1.3760 -{
  1.3761 -	defLinkColor=c;
  1.3762 -	BranchObj *bo;
  1.3763 -	bo=model->first();
  1.3764 -	while (bo) 
  1.3765 -	{
  1.3766 -		bo->setLinkColor();
  1.3767 -		bo=model->next(bo);
  1.3768 -	}
  1.3769 -	updateActions();
  1.3770 -}
  1.3771 -
  1.3772 -void MapEditor::setMapLinkColorHintInt()
  1.3773 -{
  1.3774 -	// called from setMapLinkColorHint(lch) or at end of parse
  1.3775 -	BranchObj *bo;
  1.3776 -	bo=model->first();
  1.3777 -	while (bo) 
  1.3778 -	{
  1.3779 -		bo->setLinkColor();
  1.3780 -		bo=model->next(bo);
  1.3781 -	}
  1.3782 -}
  1.3783 -
  1.3784 -void MapEditor::setMapLinkColorHint(LinkableMapObj::ColorHint lch)
  1.3785 -{
  1.3786 -	linkcolorhint=lch;
  1.3787 -	setMapLinkColorHintInt();
  1.3788 -}
  1.3789 -
  1.3790 -void MapEditor::toggleMapLinkColorHint()
  1.3791 -{
  1.3792 -	if (linkcolorhint==LinkableMapObj::HeadingColor)
  1.3793 -		linkcolorhint=LinkableMapObj::DefaultColor;
  1.3794 -	else	
  1.3795 -		linkcolorhint=LinkableMapObj::HeadingColor;
  1.3796 -	BranchObj *bo;
  1.3797 -	bo=model->first();
  1.3798 -	while (bo) 
  1.3799 -	{
  1.3800 -		bo->setLinkColor();
  1.3801 -		bo=model->next(bo);
  1.3802 -	}
  1.3803 -}
  1.3804 -
  1.3805 -LinkableMapObj::ColorHint MapEditor::getMapLinkColorHint()
  1.3806 -{
  1.3807 -	return linkcolorhint;
  1.3808 -}
  1.3809 -
  1.3810 -QColor MapEditor::getMapDefLinkColor()
  1.3811 -{
  1.3812 -	return defLinkColor;
  1.3813 -}
  1.3814 -
  1.3815 -void MapEditor::setMapDefXLinkColor(QColor col)
  1.3816 -{
  1.3817 -	defXLinkColor=col;
  1.3818 -}
  1.3819 -
  1.3820 -QColor MapEditor::getMapDefXLinkColor()
  1.3821 -{
  1.3822 -	return defXLinkColor;
  1.3823 -}
  1.3824 -
  1.3825 -void MapEditor::setMapDefXLinkWidth (int w)
  1.3826 -{
  1.3827 -	defXLinkWidth=w;
  1.3828 -}
  1.3829 -
  1.3830 -int MapEditor::getMapDefXLinkWidth()
  1.3831 -{
  1.3832 -	return defXLinkWidth;
  1.3833 -}
  1.3834 -
  1.3835 -void MapEditor::selectMapLinkColor()
  1.3836 -{
  1.3837 -	QColor col = QColorDialog::getColor( defLinkColor, this );
  1.3838 -	if ( !col.isValid() ) return;
  1.3839 -	saveState (
  1.3840 -		QString("setMapDefLinkColor (\"%1\")").arg(getMapDefLinkColor().name()),
  1.3841 -		QString("setMapDefLinkColor (\"%1\")").arg(col.name()),
  1.3842 -		QString("Set map link color to %1").arg(col.name())
  1.3843 -	);
  1.3844 -	setMapDefLinkColor( col );
  1.3845 -}
  1.3846 -
  1.3847 -void MapEditor::selectMapSelectionColor()
  1.3848 -{
  1.3849 -	QColor col = QColorDialog::getColor( defLinkColor, this );
  1.3850 -	setSelectionColor (col);
  1.3851 -}
  1.3852 -
  1.3853 -void MapEditor::setSelectionColorInt (QColor col)
  1.3854 -{
  1.3855 -	if ( !col.isValid() ) return;
  1.3856 -	xelection.setColor (col);
  1.3857 -}
  1.3858 -
  1.3859 -void MapEditor::setSelectionColor(QColor col)
  1.3860 -{
  1.3861 -	if ( !col.isValid() ) return;
  1.3862 -	saveState (
  1.3863 -		QString("setSelectionColor (%1)").arg(xelection.getColor().name()),
  1.3864 -		QString("setSelectionColor (%1)").arg(col.name()),
  1.3865 -		QString("Set color of selection box to %1").arg(col.name())
  1.3866 -	);
  1.3867 -	setSelectionColorInt (col);
  1.3868 -}
  1.3869 -
  1.3870 -QColor MapEditor::getSelectionColor()
  1.3871 -{
  1.3872 -	return xelection.getColor();
  1.3873 -}
  1.3874 -
  1.3875 -bool MapEditor::scrollBranch(BranchObj *bo)
  1.3876 -{
  1.3877 -	if (bo)
  1.3878 -	{
  1.3879 -		if (bo->isScrolled()) return false;
  1.3880 -		if (bo->countBranches()==0) return false;
  1.3881 -		if (bo->getDepth()==0) return false;
  1.3882 -		QString u,r;
  1.3883 -		r="scroll";
  1.3884 -		u="unscroll";
  1.3885 -		saveState(
  1.3886 -			bo,
  1.3887 -			QString ("%1 ()").arg(u),
  1.3888 -			bo,
  1.3889 -			QString ("%1 ()").arg(r),
  1.3890 -			QString ("%1 %2").arg(r).arg(getName(bo))
  1.3891 -		);
  1.3892 -		bo->toggleScroll();
  1.3893 -		xelection.update();
  1.3894 -		scene()->update();
  1.3895 -		return true;
  1.3896 -	}	
  1.3897 -	return false;
  1.3898 -}
  1.3899 -
  1.3900 -bool MapEditor::unscrollBranch(BranchObj *bo)
  1.3901 -{
  1.3902 -	if (bo)
  1.3903 -	{
  1.3904 -		if (!bo->isScrolled()) return false;
  1.3905 -		if (bo->countBranches()==0) return false;
  1.3906 -		if (bo->getDepth()==0) return false;
  1.3907 -		QString u,r;
  1.3908 -		u="scroll";
  1.3909 -		r="unscroll";
  1.3910 -		saveState(
  1.3911 -			bo,
  1.3912 -			QString ("%1 ()").arg(u),
  1.3913 -			bo,
  1.3914 -			QString ("%1 ()").arg(r),
  1.3915 -			QString ("%1 %2").arg(r).arg(getName(bo))
  1.3916 -		);
  1.3917 -		bo->toggleScroll();
  1.3918 -		xelection.update();
  1.3919 -		scene()->update();
  1.3920 -		return true;
  1.3921 -	}	
  1.3922 -	return false;
  1.3923 -}
  1.3924 -
  1.3925 -void MapEditor::toggleScroll()
  1.3926 -{
  1.3927 -	BranchObj *bo=xelection.getBranch();
  1.3928 -	if (xelection.type()==Selection::Branch )
  1.3929 -	{
  1.3930 -		if (bo->isScrolled())
  1.3931 -			unscrollBranch (bo);
  1.3932 -		else
  1.3933 -			scrollBranch (bo);
  1.3934 -	}
  1.3935 -}
  1.3936 -
  1.3937 -void MapEditor::unscrollChilds() 
  1.3938 -{
  1.3939 -	BranchObj *bo=xelection.getBranch();
  1.3940 -	if (bo)
  1.3941 -	{
  1.3942 -		bo->first();
  1.3943 -		while (bo) 
  1.3944 -		{
  1.3945 -			if (bo->isScrolled()) unscrollBranch (bo);
  1.3946 -			bo=bo->next();
  1.3947 -		}
  1.3948 -	}	
  1.3949 -}
  1.3950 -
  1.3951 -FloatImageObj* MapEditor::loadFloatImageInt (QString fn)
  1.3952 -{
  1.3953 -	BranchObj *bo=xelection.getBranch();
  1.3954 -	if (bo)
  1.3955 -	{
  1.3956 -		FloatImageObj *fio;
  1.3957 -		bo->addFloatImage();
  1.3958 -		fio=bo->getLastFloatImage();
  1.3959 -		fio->load(fn);
  1.3960 -		model->reposition();
  1.3961 -		scene()->update();
  1.3962 -		return fio;
  1.3963 -	}
  1.3964 -	return NULL;
  1.3965 -}	
  1.3966 -
  1.3967 -void MapEditor::loadFloatImage ()
  1.3968 -{
  1.3969 -	BranchObj *bo=xelection.getBranch();
  1.3970 -	if (bo)
  1.3971 -	{
  1.3972 -
  1.3973 -		Q3FileDialog *fd=new Q3FileDialog( this);
  1.3974 -		fd->setMode (Q3FileDialog::ExistingFiles);
  1.3975 -		fd->addFilter (QString (tr("Images") + " (*.png *.bmp *.xbm *.jpg *.png *.xpm *.gif *.pnm)"));
  1.3976 -		ImagePreview *p =new ImagePreview (fd);
  1.3977 -		fd->setContentsPreviewEnabled( TRUE );
  1.3978 -		fd->setContentsPreview( p, p );
  1.3979 -		fd->setPreviewMode( Q3FileDialog::Contents );
  1.3980 -		fd->setCaption(vymName+" - " +tr("Load image"));
  1.3981 -		fd->setDir (lastImageDir);
  1.3982 -		fd->show();
  1.3983 -
  1.3984 -		if ( fd->exec() == QDialog::Accepted )
  1.3985 -		{
  1.3986 -			// TODO loadFIO in QT4 use:	lastImageDir=fd->directory();
  1.3987 -			lastImageDir=QDir (fd->dirPath());
  1.3988 -			QString s;
  1.3989 -			FloatImageObj *fio;
  1.3990 -			for (int j=0; j<fd->selectedFiles().count(); j++)
  1.3991 -			{
  1.3992 -				s=fd->selectedFiles().at(j);
  1.3993 -				fio=loadFloatImageInt (s);
  1.3994 -				if (fio)
  1.3995 -					saveState(
  1.3996 -						(LinkableMapObj*)fio,
  1.3997 -						"delete ()",
  1.3998 -						bo, 
  1.3999 -						QString ("loadImage (%1)").arg(s ),
  1.4000 -						QString("Add image %1 to %2").arg(s).arg(getName(bo))
  1.4001 -					);
  1.4002 -				else
  1.4003 -					// TODO loadFIO error handling
  1.4004 -					qWarning ("Failed to load "+s);
  1.4005 -			}
  1.4006 -		}
  1.4007 -		delete (p);
  1.4008 -		delete (fd);
  1.4009 -	}
  1.4010 -}
  1.4011 -
  1.4012 -void MapEditor::saveFloatImageInt  (FloatImageObj *fio, const QString &type, const QString &fn)
  1.4013 -{
  1.4014 -	fio->save (fn,type);
  1.4015 -}
  1.4016 -
  1.4017 -void MapEditor::saveFloatImage ()
  1.4018 -{
  1.4019 -	FloatImageObj *fio=xelection.getFloatImage();
  1.4020 -	if (fio)
  1.4021 -	{
  1.4022 -		QFileDialog *fd=new QFileDialog( this);
  1.4023 -		fd->setFilters (imageIO.getFilters());
  1.4024 -		fd->setCaption(vymName+" - " +tr("Save image"));
  1.4025 -		fd->setFileMode( QFileDialog::AnyFile );
  1.4026 -		fd->setDirectory (lastImageDir);
  1.4027 -//		fd->setSelection (fio->getOriginalFilename());
  1.4028 -		fd->show();
  1.4029 -
  1.4030 -		QString fn;
  1.4031 -		if ( fd->exec() == QDialog::Accepted && fd->selectedFiles().count()==1)
  1.4032 -		{
  1.4033 -			fn=fd->selectedFiles().at(0);
  1.4034 -			if (QFile (fn).exists() )
  1.4035 -			{
  1.4036 -				QMessageBox mb( vymName,
  1.4037 -					tr("The file %1 exists already.\n"
  1.4038 -					"Do you want to overwrite it?").arg(fn),
  1.4039 -				QMessageBox::Warning,
  1.4040 -				QMessageBox::Yes | QMessageBox::Default,
  1.4041 -				QMessageBox::Cancel | QMessageBox::Escape,
  1.4042 -				QMessageBox::NoButton );
  1.4043 -
  1.4044 -				mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
  1.4045 -				mb.setButtonText( QMessageBox::No, tr("Cancel"));
  1.4046 -				switch( mb.exec() ) 
  1.4047 -				{
  1.4048 -					case QMessageBox::Yes:
  1.4049 -						// save 
  1.4050 -						break;
  1.4051 -					case QMessageBox::Cancel:
  1.4052 -						// do nothing
  1.4053 -						delete (fd);
  1.4054 -						return;
  1.4055 -						break;
  1.4056 -				}
  1.4057 -			}
  1.4058 -			saveFloatImageInt (fio,fd->selectedFilter(),fn );
  1.4059 -		}
  1.4060 -		delete (fd);
  1.4061 -	}
  1.4062 -}
  1.4063 -
  1.4064 -void MapEditor::setFrameType(const FrameObj::FrameType &t)
  1.4065 -{
  1.4066 -	BranchObj *bo=xelection.getBranch();
  1.4067 -	if (bo)
  1.4068 -	{
  1.4069 -		QString s=bo->getFrameTypeName();
  1.4070 -		bo->setFrameType (t);
  1.4071 -		saveState (bo, QString("setFrameType (\"%1\")").arg(s),
  1.4072 -			bo, QString ("setFrameType (\"%1\")").arg(bo->getFrameTypeName()),QString ("set type of frame to %1").arg(s));
  1.4073 -		model->reposition();
  1.4074 -		bo->updateLink();
  1.4075 -	}
  1.4076 -}
  1.4077 -
  1.4078 -void MapEditor::setFrameType(const QString &s)	
  1.4079 -{
  1.4080 -	BranchObj *bo=xelection.getBranch();
  1.4081 -	if (bo)
  1.4082 -	{
  1.4083 -		saveState (bo, QString("setFrameType (\"%1\")").arg(bo->getFrameTypeName()),
  1.4084 -			bo, QString ("setFrameType (\"%1\")").arg(s),QString ("set type of frame to %1").arg(s));
  1.4085 -		bo->setFrameType (s);
  1.4086 -		model->reposition();
  1.4087 -		bo->updateLink();
  1.4088 -	}
  1.4089 -}
  1.4090 -
  1.4091 -void MapEditor::setFramePenColor(const QColor &c)	
  1.4092 -{
  1.4093 -	BranchObj *bo=xelection.getBranch();
  1.4094 -	if (bo)
  1.4095 -	{
  1.4096 -		saveState (bo, QString("setFramePenColor (\"%1\")").arg(bo->getFramePenColor().name() ),
  1.4097 -			bo, QString ("setFramePenColor (\"%1\")").arg(c.name() ),QString ("set pen color of frame to %1").arg(c.name() ));
  1.4098 -		bo->setFramePenColor (c);
  1.4099 -	}	
  1.4100 -}
  1.4101 -
  1.4102 -void MapEditor::setFrameBrushColor(const QColor &c)	
  1.4103 -{
  1.4104 -	BranchObj *bo=xelection.getBranch();
  1.4105 -	if (bo)
  1.4106 -	{
  1.4107 -		saveState (bo, QString("setFrameBrushColor (\"%1\")").arg(bo->getFrameBrushColor().name() ),
  1.4108 -			bo, QString ("setFrameBrushColor (\"%1\")").arg(c.name() ),QString ("set brush color of frame to %1").arg(c.name() ));
  1.4109 -		bo->setFrameBrushColor (c);
  1.4110 -	}	
  1.4111 -}
  1.4112 -
  1.4113 -void MapEditor::setFramePadding (const int &i)
  1.4114 -{
  1.4115 -	BranchObj *bo=xelection.getBranch();
  1.4116 -	if (bo)
  1.4117 -	{
  1.4118 -		saveState (bo, QString("setFramePadding (\"%1\")").arg(bo->getFramePadding() ),
  1.4119 -			bo, QString ("setFramePadding (\"%1\")").arg(i),QString ("set brush color of frame to %1").arg(i));
  1.4120 -		bo->setFramePadding (i);
  1.4121 -		model->reposition();
  1.4122 -		bo->updateLink();
  1.4123 -	}	
  1.4124 -}
  1.4125 -
  1.4126 -void MapEditor::setFrameBorderWidth(const int &i)
  1.4127 -{
  1.4128 -	BranchObj *bo=xelection.getBranch();
  1.4129 -	if (bo)
  1.4130 -	{
  1.4131 -		saveState (bo, QString("setFrameBorderWidth (\"%1\")").arg(bo->getFrameBorderWidth() ),
  1.4132 -			bo, QString ("setFrameBorderWidth (\"%1\")").arg(i),QString ("set border width of frame to %1").arg(i));
  1.4133 -		bo->setFrameBorderWidth (i);
  1.4134 -		model->reposition();
  1.4135 -		bo->updateLink();
  1.4136 -	}	
  1.4137 -}
  1.4138 -
  1.4139 -void MapEditor::setIncludeImagesVer(bool b)	
  1.4140 -{
  1.4141 -	BranchObj *bo=xelection.getBranch();
  1.4142 -	if (bo)
  1.4143 -	{
  1.4144 -		QString u= b ? "false" : "true";
  1.4145 -		QString r=!b ? "false" : "true";
  1.4146 -		
  1.4147 -		saveState(
  1.4148 -			bo,
  1.4149 -			QString("setIncludeImagesVertically (%1)").arg(u),
  1.4150 -			bo, 
  1.4151 -			QString("setIncludeImagesVertically (%1)").arg(r),
  1.4152 -			QString("Include images vertically in %1").arg(getName(bo))
  1.4153 -		);	
  1.4154 -		bo->setIncludeImagesVer(b);
  1.4155 -		model->reposition();
  1.4156 -	}	
  1.4157 -}
  1.4158 -
  1.4159 -void MapEditor::setIncludeImagesHor(bool b)	
  1.4160 -{
  1.4161 -	BranchObj *bo=xelection.getBranch();
  1.4162 -	if (bo)
  1.4163 -	{
  1.4164 -		QString u= b ? "false" : "true";
  1.4165 -		QString r=!b ? "false" : "true";
  1.4166 -		
  1.4167 -		saveState(
  1.4168 -			bo,
  1.4169 -			QString("setIncludeImagesHorizontally (%1)").arg(u),
  1.4170 -			bo, 
  1.4171 -			QString("setIncludeImagesHorizontally (%1)").arg(r),
  1.4172 -			QString("Include images horizontally in %1").arg(getName(bo))
  1.4173 -		);	
  1.4174 -		bo->setIncludeImagesHor(b);
  1.4175 -		model->reposition();
  1.4176 -	}	
  1.4177 -}
  1.4178 -
  1.4179 -void MapEditor::setHideLinkUnselected (bool b)
  1.4180 -{
  1.4181 -	LinkableMapObj *sel=xelection.single();
  1.4182 -	if (sel &&
  1.4183 -		(xelection.type() == Selection::Branch || 
  1.4184 -		xelection.type() == Selection::MapCenter  ||
  1.4185 -		xelection.type() == Selection::FloatImage ))
  1.4186 -	{
  1.4187 -		QString u= b ? "false" : "true";
  1.4188 -		QString r=!b ? "false" : "true";
  1.4189 -		
  1.4190 -		saveState(
  1.4191 -			sel,
  1.4192 -			QString("setHideLinkUnselected (%1)").arg(u),
  1.4193 -			sel, 
  1.4194 -			QString("setHideLinkUnselected (%1)").arg(r),
  1.4195 -			QString("Hide link of %1 if unselected").arg(getName(sel))
  1.4196 -		);	
  1.4197 -		sel->setHideLinkUnselected(b);
  1.4198 -	}
  1.4199 -}
  1.4200 -
  1.4201 -void MapEditor::importDirInt(BranchObj *dst, QDir d)
  1.4202 -{
  1.4203 -	BranchObj *bo=xelection.getBranch();
  1.4204 -	if (bo)
  1.4205 -	{
  1.4206 -		// Traverse directories
  1.4207 -		d.setFilter( QDir::Dirs| QDir::Hidden | QDir::NoSymLinks );
  1.4208 -		QFileInfoList list = d.entryInfoList();
  1.4209 -		QFileInfo fi;
  1.4210 -
  1.4211 -		for (int i = 0; i < list.size(); ++i) 
  1.4212 -		{
  1.4213 -			fi=list.at(i);
  1.4214 -			if (fi.fileName() != "." && fi.fileName() != ".." )
  1.4215 -			{
  1.4216 -				dst->addBranch();
  1.4217 -				bo=dst->getLastBranch();
  1.4218 -				bo->setHeading (fi.fileName() );
  1.4219 -				bo->setColor (QColor("blue"));
  1.4220 -				bo->toggleScroll();
  1.4221 -				if ( !d.cd(fi.fileName()) ) 
  1.4222 -					QMessageBox::critical (0,tr("Critical Import Error"),tr("Cannot find the directory %1").arg(fi.fileName()));
  1.4223 -				else 
  1.4224 -				{
  1.4225 -					// Recursively add subdirs
  1.4226 -					importDirInt (bo,d);
  1.4227 -					d.cdUp();
  1.4228 -				}
  1.4229 -			}	
  1.4230 -		}		
  1.4231 -		// Traverse files
  1.4232 -		d.setFilter( QDir::Files| QDir::Hidden | QDir::NoSymLinks );
  1.4233 -		list = d.entryInfoList();
  1.4234 -
  1.4235 -		for (int i = 0; i < list.size(); ++i) 
  1.4236 -		{
  1.4237 -			fi=list.at(i);
  1.4238 -			dst->addBranch();
  1.4239 -			bo=dst->getLastBranch();
  1.4240 -			bo->setHeading (fi.fileName() );
  1.4241 -			bo->setColor (QColor("black"));
  1.4242 -			if (fi.fileName().right(4) == ".vym" )
  1.4243 -				bo->setVymLink (fi.filePath());
  1.4244 -		}	
  1.4245 -	}		
  1.4246 -}
  1.4247 -
  1.4248 -void MapEditor::importDirInt (const QString &s)
  1.4249 -{
  1.4250 -	BranchObj *bo=xelection.getBranch();
  1.4251 -	if (bo)
  1.4252 -	{
  1.4253 -		saveStateChangingPart (bo,bo,QString ("importDir (\"%1\")").arg(s),QString("Import directory structure from %1").arg(s));
  1.4254 -
  1.4255 -		QDir d(s);
  1.4256 -		importDirInt (bo,d);
  1.4257 -	}
  1.4258 -}	
  1.4259 -
  1.4260 -void MapEditor::importDir()
  1.4261 -{
  1.4262 -	BranchObj *bo=xelection.getBranch();
  1.4263 -	if (bo)
  1.4264 -	{
  1.4265 -		QStringList filters;
  1.4266 -		filters <<"VYM map (*.vym)";
  1.4267 -		QFileDialog *fd=new QFileDialog( this,vymName+ " - " +tr("Choose directory structure to import"));
  1.4268 -		fd->setMode (QFileDialog::DirectoryOnly);
  1.4269 -		fd->setFilters (filters);
  1.4270 -		fd->setCaption(vymName+" - " +tr("Choose directory structure to import"));
  1.4271 -		fd->show();
  1.4272 -
  1.4273 -		QString fn;
  1.4274 -		if ( fd->exec() == QDialog::Accepted )
  1.4275 -		{
  1.4276 -			importDirInt (fd->selectedFile() );
  1.4277 -			model->reposition();
  1.4278 -			scene()->update();
  1.4279 -		}
  1.4280 -	}	
  1.4281 -}
  1.4282 -
  1.4283 -void MapEditor::followXLink(int i)
  1.4284 -{
  1.4285 -	BranchObj *bo=xelection.getBranch();
  1.4286 -	if (bo)
  1.4287 -	{
  1.4288 -		bo=bo->XLinkTargetAt(i);
  1.4289 -		if (bo) 
  1.4290 -		{
  1.4291 -			xelection.select(bo);
  1.4292 -			ensureSelectionVisible();
  1.4293 -		}
  1.4294 -	}
  1.4295 -}
  1.4296 -
  1.4297 -void MapEditor::editXLink(int i)	// FIXME missing saveState
  1.4298 -{
  1.4299 -	BranchObj *bo=xelection.getBranch();
  1.4300 -	if (bo)
  1.4301 -	{
  1.4302 -		XLinkObj *xlo=bo->XLinkAt(i);
  1.4303 -		if (xlo) 
  1.4304 -		{
  1.4305 -			EditXLinkDialog dia;
  1.4306 -			dia.setXLink (xlo);
  1.4307 -			dia.setSelection(bo);
  1.4308 -			if (dia.exec() == QDialog::Accepted)
  1.4309 -			{
  1.4310 -				if (dia.useSettingsGlobal() )
  1.4311 -				{
  1.4312 -					setMapDefXLinkColor (xlo->getColor() );
  1.4313 -					setMapDefXLinkWidth (xlo->getWidth() );
  1.4314 -				}
  1.4315 -				if (dia.deleteXLink())
  1.4316 -					bo->deleteXLinkAt(i);
  1.4317 -			}
  1.4318 -		}	
  1.4319 -	}
  1.4320 +	model->updateSelection();
  1.4321  }
  1.4322  
  1.4323  AttributeTable* MapEditor::attributeTable()
  1.4324 @@ -4422,8 +287,9 @@
  1.4325  
  1.4326  void MapEditor::testFunction1()
  1.4327  {
  1.4328 -	BranchObj *bo=xelection.getBranch();
  1.4329 -	if (bo) model->moveAway (bo);
  1.4330 +	BranchObj *bo=model->getSelectedBranch();
  1.4331 +	//if (bo) model->moveAway (bo);
  1.4332 +	if (bo) bo->setLinkStyle (LinkableMapObj::Line);
  1.4333  	
  1.4334  /* TODO Hide hidden stuff temporary, maybe add this as regular function somewhere
  1.4335  	if (hidemode==HideNone)
  1.4336 @@ -4464,6 +330,42 @@
  1.4337  */		
  1.4338  }
  1.4339  
  1.4340 +void MapEditor::editHeading()
  1.4341 +{
  1.4342 +	if (editingHeading)
  1.4343 +	{
  1.4344 +		editHeadingFinished();
  1.4345 +		return;
  1.4346 +	}
  1.4347 +	BranchObj *bo=model->getSelectedBranch();
  1.4348 +	if (bo)
  1.4349 +	{
  1.4350 +		model->setSelectionBlocked(true);
  1.4351 +
  1.4352 +		lineEdit->setText (bo->getHeading());
  1.4353 +		QPoint p = mapTo (this,bo->getAbsPos().toPoint() );
  1.4354 +		lineEdit->setGeometry(p.x(),p.y(),230,25);
  1.4355 +		lineEdit->selectAll();
  1.4356 +		lineEdit->show();
  1.4357 +		lineEdit->setFocus();
  1.4358 +		lineEdit->grabKeyboard();
  1.4359 +		editingHeading=true;
  1.4360 +	}
  1.4361 +
  1.4362 +}
  1.4363 +void MapEditor::editHeadingFinished()
  1.4364 +{
  1.4365 +	editingHeading=false;
  1.4366 +	lineEdit->releaseKeyboard();
  1.4367 +	model->setHeading (lineEdit->text() );
  1.4368 +	model->setSelectionBlocked(false);
  1.4369 +	lineEdit->hide();
  1.4370 +
  1.4371 +	// Maybe reselect previous branch 
  1.4372 +	mainWindow->editHeadingFinished (model);
  1.4373 +}
  1.4374 +
  1.4375 +
  1.4376  void MapEditor::contextMenuEvent ( QContextMenuEvent * e )
  1.4377  {
  1.4378  	// Lineedits are already closed by preceding
  1.4379 @@ -4474,30 +376,30 @@
  1.4380  	
  1.4381      if (lmo) 
  1.4382  	{	// MapObj was found
  1.4383 -		if (xelection.single() != lmo)
  1.4384 +		if (model->getSelection() != lmo)
  1.4385  		{
  1.4386  			// select the MapObj
  1.4387 -			xelection.select(lmo);
  1.4388 +			model->select(lmo);
  1.4389  		}
  1.4390  		// Context Menu 
  1.4391 -		if (xelection.getBranch() ) 
  1.4392 +		if (model->getSelectedBranch() ) 
  1.4393  		{
  1.4394  			// Context Menu on branch or mapcenter
  1.4395 -			updateActions();
  1.4396 +			model->updateActions();
  1.4397  			branchContextMenu->popup(e->globalPos() );
  1.4398  		} else
  1.4399  		{
  1.4400 -			if (xelection.getFloatImage() )
  1.4401 +			if (model->getSelectedFloatImage() )
  1.4402  			{
  1.4403  				// Context Menu on floatimage
  1.4404 -				updateActions();
  1.4405 +				model->updateActions();
  1.4406  				floatimageContextMenu->popup(e->globalPos() );
  1.4407  			}	
  1.4408  		}	
  1.4409  	} else 
  1.4410  	{ // No MapObj found, we are on the Canvas itself
  1.4411  		// Context Menu on scene
  1.4412 -		updateActions();
  1.4413 +		model->updateActions();
  1.4414  		contextMenuPos=p;
  1.4415  		canvasContextMenu->popup(e->globalPos() );
  1.4416      } 
  1.4417 @@ -4542,7 +444,7 @@
  1.4418  	}
  1.4419  
  1.4420  	//Ignore clicks while editing heading
  1.4421 -	if (isSelectBlocked() ) 
  1.4422 +	if (model->isSelectionBlocked() ) 
  1.4423  	{
  1.4424  		e->ignore();
  1.4425  		return;
  1.4426 @@ -4562,7 +464,7 @@
  1.4427  		if (!foname.isEmpty())
  1.4428  		{
  1.4429  			// systemFlag clicked
  1.4430 -			selectInt (lmo);
  1.4431 +			model->selectInt (lmo);
  1.4432  			if (foname=="url") 
  1.4433  			{
  1.4434  				if (e->state() & Qt::ControlModifier)
  1.4435 @@ -4578,12 +480,11 @@
  1.4436  			} else if (foname=="note")
  1.4437  				mainWindow->windowToggleNoteEditor();
  1.4438  			else if (foname=="hideInExport")		
  1.4439 -				toggleHideExport();
  1.4440 -			xelection.update();	
  1.4441 +				model->toggleHideExport();
  1.4442 +			// FIXME needed? xelection.update();	
  1.4443  			return;	
  1.4444  		} 
  1.4445 -	} 
  1.4446 -
  1.4447 +	}	
  1.4448  	// No system flag clicked, take care of modmodes (CTRL-Click)
  1.4449  	if (e->state() & Qt::ControlModifier)
  1.4450  	{
  1.4451 @@ -4599,8 +500,7 @@
  1.4452  			if (lmo)
  1.4453  				bo_begin=(BranchObj*)(lmo);
  1.4454  			else	
  1.4455 -				if (xelection.getBranch() ) 
  1.4456 -					bo_begin=xelection.getBranch();
  1.4457 +				bo_begin=model->getSelectedBranch();
  1.4458  			if (bo_begin)	
  1.4459  			{
  1.4460  				drawingLink=true;
  1.4461 @@ -4608,8 +508,8 @@
  1.4462  				tmpXLink=new XLinkObj (mapScene);
  1.4463  				tmpXLink->setBegin (bo_begin);
  1.4464  				tmpXLink->setEnd   (p);
  1.4465 -				tmpXLink->setColor(defXLinkColor);
  1.4466 -				tmpXLink->setWidth(defXLinkWidth);
  1.4467 +				tmpXLink->setColor(model->getMapDefXLinkColor());
  1.4468 +				tmpXLink->setWidth(model->getMapDefXLinkWidth());
  1.4469  				tmpXLink->updateXLink();
  1.4470  				tmpXLink->setVisibility (true);
  1.4471  				return;
  1.4472 @@ -4620,7 +520,7 @@
  1.4473      if (lmo) 
  1.4474  	{	
  1.4475  		// Select the clicked object
  1.4476 -		selectInt (lmo);
  1.4477 +		model->selectInt (lmo);
  1.4478  
  1.4479  		// Left Button	    Move Branches
  1.4480  		if (e->button() == Qt::LeftButton )
  1.4481 @@ -4631,6 +531,7 @@
  1.4482  			movingObj_start.setY( p.y() - lmo->y() );	
  1.4483  			movingObj_orgPos.setX (lmo->x() );
  1.4484  			movingObj_orgPos.setY (lmo->y() );
  1.4485 +			lmo->setRelPos();
  1.4486  			movingObj_orgRelPos=lmo->getRelPos();
  1.4487  
  1.4488  			// If modMode==copy, then we want to "move" the _new_ object around
  1.4489 @@ -4638,26 +539,26 @@
  1.4490  			if (mainWindow->getModMode()==Main::ModModeCopy &&
  1.4491  				e->state() & Qt::ControlModifier)
  1.4492  			{
  1.4493 -				BranchObj *bo=xelection.getBranch();
  1.4494 +				BranchObj *bo=model->getSelectedBranch();
  1.4495  				if (bo)
  1.4496  				{
  1.4497  					copyingObj=true;
  1.4498 -					bo->addBranch ((BranchObj*)xelection.single());
  1.4499 -					unselect();
  1.4500 -					xelection.select(bo->getLastBranch());
  1.4501 +					bo->addBranch ((BranchObj*)model->getSelection());
  1.4502 +					model->unselect();
  1.4503 +					model->select(bo->getLastBranch());
  1.4504  					model->reposition();
  1.4505  				}
  1.4506  			} 
  1.4507  
  1.4508 -			movingObj=xelection.single();	
  1.4509 +			movingObj=model->getSelection();	
  1.4510  		} else
  1.4511  			// Middle Button    Toggle Scroll
  1.4512  			// (On Mac OS X this won't work, but we still have 
  1.4513  			// a button in the toolbar)
  1.4514  			if (e->button() == Qt::MidButton )
  1.4515 -				toggleScroll();
  1.4516 -		updateActions();
  1.4517 -		xelection.update();
  1.4518 +				model->toggleScroll();
  1.4519 +		model->updateActions();
  1.4520 +		// FIXME needed? xelection.update();
  1.4521  	} else 
  1.4522  	{ // No MapObj found, we are on the scene itself
  1.4523  		// Left Button	    move Pos of sceneView
  1.4524 @@ -4677,7 +578,7 @@
  1.4525  void MapEditor::mouseMoveEvent(QMouseEvent* e)
  1.4526  {
  1.4527      QPointF p = mapToScene(e->pos());
  1.4528 -	LinkableMapObj *lmosel=xelection.single();
  1.4529 +	LinkableMapObj *lmosel=model->getSelection();
  1.4530  
  1.4531      // Move the selected MapObj
  1.4532      if ( lmosel && movingObj) 
  1.4533 @@ -4689,7 +590,7 @@
  1.4534  		// To avoid jumping of the sceneView, only 
  1.4535  		// ensureSelectionVisible, if not tmp linked
  1.4536  		if (!lmosel->hasParObjTmp())
  1.4537 -			ensureSelectionVisible ();
  1.4538 +			model->ensureSelectionVisible ();
  1.4539  		
  1.4540  		// Now move the selection, but add relative position 
  1.4541  		// (movingObj_start) where selection was chosen with 
  1.4542 @@ -4700,13 +601,13 @@
  1.4543  		LinkableMapObj* lmo=model->findMapObj(p, lmosel);
  1.4544  		
  1.4545  
  1.4546 -		FloatObj *fio=xelection.getFloatImage();
  1.4547 +		FloatObj *fio=model->getSelectedFloatImage();
  1.4548  		if (fio)
  1.4549  		{
  1.4550  			fio->move   (p.x() -movingObj_start.x(), p.y()-movingObj_start.y() );		
  1.4551  			fio->setRelPos();
  1.4552  			fio->updateLink(); //no need for reposition, if we update link here
  1.4553 -			xelection.update();
  1.4554 +			model->updateSelection();
  1.4555  
  1.4556  			// Relink float to new mapcenter or branch, if shift is pressed	
  1.4557  			// Only relink, if selection really has a new parent
  1.4558 @@ -4724,7 +625,7 @@
  1.4559  					// Also save the move which was done so far
  1.4560  					QString pold=qpointfToString(movingObj_orgRelPos);
  1.4561  					QString pnow=qpointfToString(fio->getRelPos());
  1.4562 -					saveState(
  1.4563 +					model->saveState(
  1.4564  						fio,
  1.4565  						"moveRel "+pold,
  1.4566  						fio,
  1.4567 @@ -4733,7 +634,7 @@
  1.4568  					fio->getParObj()->requestReposition();
  1.4569  					model->reposition();
  1.4570  
  1.4571 -					linkTo (model->getSelectString(lmo));
  1.4572 +					model->linkFloatImageTo (model->getSelectString(lmo));
  1.4573  					//movingObj=lmosel;
  1.4574  					//movingObj_orgRelPos=lmosel->getRelPos();	
  1.4575  
  1.4576 @@ -4762,14 +663,15 @@
  1.4577  					// Move ordinary branch
  1.4578  					if (lmosel->getOrientation() == LinkableMapObj::LeftOfCenter)
  1.4579  						// Add width of bbox here, otherwise alignRelTo will cause jumping around
  1.4580 -						lmosel->move(p.x() -movingObj_start.x()+lmosel->getBBox().width(), 
  1.4581 +						lmosel->move(p.x() -movingObj_start.x() , //lmosel->getBBox().width(), 
  1.4582  							p.y()-movingObj_start.y() +lmosel->getTopPad() );		
  1.4583  					else	
  1.4584  						lmosel->move(p.x() -movingObj_start.x(), p.y()-movingObj_start.y() -lmosel->getTopPad());
  1.4585 +					lmosel->setRelPos();	
  1.4586  				} 
  1.4587  
  1.4588  				// Maybe we can relink temporary?
  1.4589 -				if (lmo && (lmo!=lmosel) && xelection.getBranch() && 
  1.4590 +				if (lmo && (lmo!=lmosel) && model->getSelectedBranch() && 
  1.4591  					 (typeid(*lmo)==typeid(BranchObj) ||
  1.4592  					  typeid(*lmo)==typeid(MapCenterObj)) ) 
  1.4593  
  1.4594 @@ -4791,7 +693,7 @@
  1.4595  				lmosel->reposition();	
  1.4596  			} // depth>0
  1.4597  
  1.4598 -			xelection.update();
  1.4599 +			model->updateSelection();// FIXME needed? 
  1.4600  		} // no FloatImageObj
  1.4601  
  1.4602  		scene()->update();
  1.4603 @@ -4821,7 +723,7 @@
  1.4604  {
  1.4605      QPointF p = mapToScene(e->pos());
  1.4606  	LinkableMapObj *dst;
  1.4607 -	LinkableMapObj *lmosel=xelection.single();
  1.4608 +	LinkableMapObj *lmosel=model->getSelection();
  1.4609  	// Have we been picking color?
  1.4610  	if (pickingColor)
  1.4611  	{
  1.4612 @@ -4832,9 +734,9 @@
  1.4613  		if (dst && lmosel) 
  1.4614  		{	
  1.4615  			if (e->state() & Qt::ShiftModifier)
  1.4616 -				colorBranch (((BranchObj*)dst)->getColor());
  1.4617 +				model->colorBranch (((BranchObj*)dst)->getColor());
  1.4618  			else	
  1.4619 -				colorSubtree (((BranchObj*)dst)->getColor());
  1.4620 +				model->colorSubtree (((BranchObj*)dst)->getColor());
  1.4621  		} 
  1.4622  		return;
  1.4623  	}
  1.4624 @@ -4850,7 +752,7 @@
  1.4625  			tmpXLink->setEnd ( ((BranchObj*)(dst)) );
  1.4626  			tmpXLink->updateXLink();
  1.4627  			tmpXLink->activate(); //FIXME savestate missing
  1.4628 -			//saveStateComplete(QString("Activate xLink from %1 to %2").arg(getName(tmpXLink->getBegin())).arg(getName(tmpXLink->getEnd())) );	
  1.4629 +			//model->saveStateComplete(QString("Activate xLink from %1 to %2").arg(getName(tmpXLink->getBegin())).arg(getName(tmpXLink->getEnd())) );	
  1.4630  		} else
  1.4631  		{
  1.4632  			delete(tmpXLink);
  1.4633 @@ -4862,13 +764,13 @@
  1.4634      // Have we been moving something?
  1.4635      if ( lmosel && movingObj ) 
  1.4636      {	
  1.4637 -		FloatImageObj *fo=xelection.getFloatImage();
  1.4638 +		FloatImageObj *fo=model->getSelectedFloatImage();
  1.4639  		if(fo)
  1.4640  		{
  1.4641  			// Moved FloatObj. Maybe we need to reposition
  1.4642  		    QString pold=qpointfToString(movingObj_orgRelPos);
  1.4643  		    QString pnow=qpointfToString(fo->getRelPos());
  1.4644 -			saveState(
  1.4645 +			model->saveState(
  1.4646  				fo,
  1.4647  				"moveRel "+pold,
  1.4648  				fo,
  1.4649 @@ -4886,14 +788,14 @@
  1.4650  		if (dst && (typeid(*dst)!=typeid(BranchObj) && typeid(*dst)!=typeid(MapCenterObj))) 
  1.4651  			dst=NULL;
  1.4652  		
  1.4653 -		BranchObj *bo=xelection.getBranch();
  1.4654 +		BranchObj *bo=model->getSelectedBranch();
  1.4655  		if (bo && bo->getDepth()==0)
  1.4656  		{	
  1.4657              if (movingObj_orgPos != bo->getAbsPos())
  1.4658              {
  1.4659                  QString pold=qpointfToString(movingObj_orgPos);
  1.4660                  QString pnow=qpointfToString(bo->getAbsPos());
  1.4661 -                saveState(
  1.4662 +                model->saveState(
  1.4663                      fo,
  1.4664                      "move "+pold,
  1.4665                      fo,
  1.4666 @@ -4902,7 +804,7 @@
  1.4667              }
  1.4668  		}
  1.4669  	
  1.4670 -		if (xelection.type() == Selection::Branch )
  1.4671 +		if (model->selectionType() == Selection::Branch )
  1.4672  		{	// A branch was moved
  1.4673  			
  1.4674  			// save the position in case we link to mapcenter
  1.4675 @@ -4919,7 +821,7 @@
  1.4676  			{
  1.4677  				// We have a destination, relink to that
  1.4678  
  1.4679 -				BranchObj* bsel=xelection.getBranch();
  1.4680 +				BranchObj* bsel=model->getSelectedBranch();
  1.4681  				BranchObj* bdst=(BranchObj*)dst;
  1.4682  
  1.4683  				QString preParStr=model->getSelectString (bsel->getParObj());
  1.4684 @@ -4953,7 +855,7 @@
  1.4685  					preDstParStr + "\"," + postNum + "," +
  1.4686  					QString ("%1,%2").arg(savePos.x()).arg(savePos.y())+ ")";
  1.4687  
  1.4688 -				saveState (
  1.4689 +				model->saveState (
  1.4690  					postSelStr,undoCom,
  1.4691  					preSelStr, redoCom,
  1.4692  					QString("Relink %1 to %2").arg(getName(bsel)).arg(getName(dst)) );
  1.4693 @@ -4973,7 +875,7 @@
  1.4694                      if (rp != movingObj_orgRelPos)
  1.4695                      {
  1.4696                          QString ps=qpointfToString(rp);
  1.4697 -                        saveState(
  1.4698 +                        model->saveState(
  1.4699                              model->getSelectString(lmosel), "moveRel "+qpointfToString(movingObj_orgRelPos), 
  1.4700                              preSelStr, "moveRel "+ps, 
  1.4701                              QString("Move %1 to relative position %2").arg(getName(lmosel)).arg(ps));
  1.4702 @@ -4983,23 +885,26 @@
  1.4703  				// Draw the original link, before selection was moved around
  1.4704  				if (settings.value("/animation/use",false).toBool() && lmosel->getDepth()>1) 
  1.4705  				{
  1.4706 -					QPointF p=bo->getParObj()->getChildPos();
  1.4707 -					lmosel->setRelPos();	// calc relPos first
  1.4708 +					lmosel->setRelPos();	// calc relPos first for starting point
  1.4709 +					QPointF dst=bo->getParObj()->getChildPos();
  1.4710 +			//		if (lmosel->getOrientation()==LinkableMapObj::LeftOfCenter) dst.setX (dst.x()+lmosel->width() );
  1.4711 +					
  1.4712  					model->startAnimation(
  1.4713  						lmosel->getRelPos(),
  1.4714 -						QPointF (movingObj_orgPos.x() - p.x(), movingObj_orgPos.y() - p.y() )
  1.4715 +						movingObj_orgRelPos
  1.4716 +//						QPointF (movingObj_orgPos.x() - dst.x(), movingObj_orgPos.y() - dst.y() )
  1.4717  					);	
  1.4718  				} else	
  1.4719  					model->reposition();
  1.4720  			}
  1.4721  		}
  1.4722 -		 xelection.update();
  1.4723 +		 model->updateSelection();
  1.4724  		// Finally resize scene, if needed
  1.4725  		scene()->update();
  1.4726  		movingObj=NULL;		
  1.4727  
  1.4728  		// Just make sure, that actions are still ok,e.g. the move branch up/down buttons...
  1.4729 -		updateActions();
  1.4730 +		model->updateActions();
  1.4731  	} else 
  1.4732  		// maybe we moved View: set old cursor
  1.4733  		setCursor (Qt::ArrowCursor);
  1.4734 @@ -5008,7 +913,7 @@
  1.4735  
  1.4736  void MapEditor::mouseDoubleClickEvent(QMouseEvent* e)
  1.4737  {
  1.4738 -	if (isSelectBlocked() ) 
  1.4739 +	if (model->isSelectionBlocked() ) 
  1.4740  	{
  1.4741  		e->ignore();
  1.4742  		return;
  1.4743 @@ -5020,8 +925,8 @@
  1.4744  		LinkableMapObj *lmo=model->findMapObj(p, NULL);
  1.4745  		if (lmo) {	// MapObj was found
  1.4746  			// First select the MapObj than edit heading
  1.4747 -			xelection.select(lmo);
  1.4748 -			mainWindow->editHeading();
  1.4749 +			model->select (lmo);
  1.4750 +			editHeading();
  1.4751  		}
  1.4752  	}
  1.4753  }
  1.4754 @@ -5054,7 +959,7 @@
  1.4755  
  1.4756  void MapEditor::dropEvent(QDropEvent *event)
  1.4757  {
  1.4758 -	BranchObj *sel=xelection.getBranch();
  1.4759 +	BranchObj *sel=model->getSelectedBranch();
  1.4760  	if (sel)
  1.4761  	{
  1.4762  		if (debug)
  1.4763 @@ -5066,7 +971,7 @@
  1.4764  		if (event->mimeData()->hasImage()) 
  1.4765  		{
  1.4766  			 QVariant imageData = event->mimeData()->imageData();
  1.4767 -			 addFloatImageInt (qvariant_cast<QPixmap>(imageData));
  1.4768 +			 model->addFloatImage (qvariant_cast<QPixmap>(imageData));
  1.4769  		} else
  1.4770  		if (event->mimeData()->hasUrls())
  1.4771  			uris=event->mimeData()->urls();
  1.4772 @@ -5114,258 +1019,6 @@
  1.4773  }
  1.4774  
  1.4775  
  1.4776 -void MapEditor::sendSelection()
  1.4777 -{
  1.4778 -	if (netstate!=Server) return;
  1.4779 -	sendData (QString("select (\"%1\")").arg(xelection.getSelectString()) );
  1.4780 -}
  1.4781 -
  1.4782 -void MapEditor::newServer()
  1.4783 -{
  1.4784 -	port=54321;
  1.4785 -	sendCounter=0;
  1.4786 -    tcpServer = new QTcpServer(this);
  1.4787 -    if (!tcpServer->listen(QHostAddress::Any,port)) {
  1.4788 -        QMessageBox::critical(this, "vym server",
  1.4789 -                              QString("Unable to start the server: %1.").arg(tcpServer->errorString()));
  1.4790 -        close();
  1.4791 -        return;
  1.4792 -    }
  1.4793 -	connect(tcpServer, SIGNAL(newConnection()), this, SLOT(newClient()));
  1.4794 -	netstate=Server;
  1.4795 -	cout<<"Server is running on port "<<tcpServer->serverPort()<<endl;
  1.4796 -}
  1.4797 -
  1.4798 -void MapEditor::connectToServer()
  1.4799 -{
  1.4800 -	port=54321;
  1.4801 -	server="salam.suse.de";
  1.4802 -	server="localhost";
  1.4803 -	clientSocket = new QTcpSocket (this);
  1.4804 -	clientSocket->abort();
  1.4805 -    clientSocket->connectToHost(server ,port);
  1.4806 -	connect(clientSocket, SIGNAL(readyRead()), this, SLOT(readData()));
  1.4807 -    connect(clientSocket, SIGNAL(error(QAbstractSocket::SocketError)),
  1.4808 -            this, SLOT(displayNetworkError(QAbstractSocket::SocketError)));
  1.4809 -	netstate=Client;		
  1.4810 -	cout<<"connected to "<<qPrintable (server)<<" port "<<port<<endl;
  1.4811 -
  1.4812 -	
  1.4813 -}
  1.4814 -
  1.4815 -void MapEditor::newClient()
  1.4816 -{
  1.4817 -    QTcpSocket *newClient = tcpServer->nextPendingConnection();
  1.4818 -    connect(newClient, SIGNAL(disconnected()),
  1.4819 -            newClient, SLOT(deleteLater()));
  1.4820 -
  1.4821 -	cout <<"ME::newClient  at "<<qPrintable( newClient->peerAddress().toString() )<<endl;
  1.4822 -
  1.4823 -	clientList.append (newClient);
  1.4824 -}
  1.4825 -
  1.4826 -
  1.4827 -void MapEditor::sendData(const QString &s)
  1.4828 -{
  1.4829 -	if (clientList.size()==0) return;
  1.4830 -
  1.4831 -	// Create bytearray to send
  1.4832 -	QByteArray block;
  1.4833 -    QDataStream out(&block, QIODevice::WriteOnly);
  1.4834 -    out.setVersion(QDataStream::Qt_4_0);
  1.4835 -
  1.4836 -	// Reserve some space for blocksize
  1.4837 -    out << (quint16)0;
  1.4838 -
  1.4839 -	// Write sendCounter
  1.4840 -    out << sendCounter++;
  1.4841 -
  1.4842 -	// Write data
  1.4843 -    out << s;
  1.4844 -
  1.4845 -	// Go back and write blocksize so far
  1.4846 -    out.device()->seek(0);
  1.4847 -    quint16 bs=(quint16)(block.size() - 2*sizeof(quint16));
  1.4848 -	out << bs;
  1.4849 -
  1.4850 -	if (debug)
  1.4851 -		cout << "ME::sendData  bs="<<bs<<"  counter="<<sendCounter<<"  s="<<qPrintable(s)<<endl;
  1.4852 -
  1.4853 -	for (int i=0; i<clientList.size(); ++i)
  1.4854 -	{
  1.4855 -		//cout << "Sending \""<<qPrintable (s)<<"\" to "<<qPrintable (clientList.at(i)->peerAddress().toString())<<endl;
  1.4856 -		clientList.at(i)->write (block);
  1.4857 -	}
  1.4858 -}
  1.4859 -
  1.4860 -void MapEditor::readData ()
  1.4861 -{
  1.4862 -	while (clientSocket->bytesAvailable() >=(int)sizeof(quint16) )
  1.4863 -	{
  1.4864 -		if (debug)
  1.4865 -			cout <<"readData  bytesAvail="<<clientSocket->bytesAvailable();
  1.4866 -		quint16 recCounter;
  1.4867 -		quint16 blockSize;
  1.4868 -
  1.4869 -		QDataStream in(clientSocket);
  1.4870 -		in.setVersion(QDataStream::Qt_4_0);
  1.4871 -
  1.4872 -		in >> blockSize;
  1.4873 -		in >> recCounter;
  1.4874 -		
  1.4875 -		QString t;
  1.4876 -		in >>t;
  1.4877 -		if (debug)
  1.4878 -			cout << "  t="<<qPrintable (t)<<endl;
  1.4879 -		parseAtom (t);
  1.4880 -	}
  1.4881 -	return;
  1.4882 -}
  1.4883 -
  1.4884 -void MapEditor::displayNetworkError(QAbstractSocket::SocketError socketError)
  1.4885 -{
  1.4886 -    switch (socketError) {
  1.4887 -    case QAbstractSocket::RemoteHostClosedError:
  1.4888 -        break;
  1.4889 -    case QAbstractSocket::HostNotFoundError:
  1.4890 -        QMessageBox::information(this, vymName +" Network client",
  1.4891 -                                 "The host was not found. Please check the "
  1.4892 -                                    "host name and port settings.");
  1.4893 -        break;
  1.4894 -    case QAbstractSocket::ConnectionRefusedError:
  1.4895 -        QMessageBox::information(this, vymName + " Network client",
  1.4896 -                                 "The connection was refused by the peer. "
  1.4897 -                                    "Make sure the fortune server is running, "
  1.4898 -                                    "and check that the host name and port "
  1.4899 -                                    "settings are correct.");
  1.4900 -        break;
  1.4901 -    default:
  1.4902 -        QMessageBox::information(this, vymName + " Network client",
  1.4903 -                                 QString("The following error occurred: %1.")
  1.4904 -                                 .arg(clientSocket->errorString()));
  1.4905 -    }
  1.4906 -}
  1.4907 -
  1.4908 -void MapEditor::autosave()
  1.4909 -{
  1.4910 -	QDateTime now=QDateTime().currentDateTime();
  1.4911 -	/* FIXME debug
  1.4912 -	cout << "ME::autosave checking "<<qPrintable(filePath)<<"...\n"; 
  1.4913 -	cout << "fsaved: "<<qPrintable (fileChangedTime.toString())<<endl;
  1.4914 -	cout << "  fnow: "<<qPrintable (QFileInfo(filePath).lastModified().toString())<<endl;
  1.4915 -	cout << "  time: "<<qPrintable (now.toString())<<endl;
  1.4916 -	cout << " zipped="<<zipped<<endl;
  1.4917 -	*/
  1.4918 -	// Disable autosave, while we have gone back in history
  1.4919 -	int redosAvail=undoSet.readNumEntry (QString("/history/redosAvail"));
  1.4920 -	if (redosAvail>0) return;
  1.4921 -
  1.4922 -	// Also disable autosave for new map without filename
  1.4923 -	if (filePath.isEmpty()) return;
  1.4924 -
  1.4925 -
  1.4926 -	if (mapUnsaved &&mapChanged && settings.value ("/mapeditor/autosave/use",true).toBool() )
  1.4927 -	{
  1.4928 -		if (QFileInfo(filePath).lastModified()<=fileChangedTime) 
  1.4929 -			mainWindow->fileSave (this);
  1.4930 -		else
  1.4931 -			if (debug)
  1.4932 -				cout <<"  ME::autosave  rejected, file on disk is newer than last save.\n"; 
  1.4933 -
  1.4934 -	}	
  1.4935 -}
  1.4936 -
  1.4937 -void MapEditor::fileChanged()
  1.4938 -{
  1.4939 -	// Check if file on disk has changed meanwhile
  1.4940 -	if (!filePath.isEmpty())
  1.4941 -	{
  1.4942 -		QDateTime tmod=QFileInfo (filePath).lastModified();
  1.4943 -		if (tmod>fileChangedTime)
  1.4944 -		{
  1.4945 -			
  1.4946 -			/* FIXME debug message, sometimes there's a glitch in the metrics...
  1.4947 -			cout << "ME::fileChanged()\n" 
  1.4948 -			     << "  last saved:     "<<qPrintable (fileChangedTime.toString())<<endl
  1.4949 -				 << "  last modififed: "<<qPrintable (tmod.toString())<<endl;
  1.4950 -			*/	 
  1.4951 -			// FIXME switch to current mapeditor and finish lineedits...
  1.4952 -			QMessageBox mb( vymName,
  1.4953 -				tr("The file of the map  on disk has changed:\n\n"  
  1.4954 -				   "   %1\n\nDo you want to reload that map with the new file?").arg(filePath),
  1.4955 -				QMessageBox::Question,
  1.4956 -				QMessageBox::Yes ,
  1.4957 -				QMessageBox::Cancel | QMessageBox::Default,
  1.4958 -				QMessageBox::NoButton );
  1.4959 -
  1.4960 -			mb.setButtonText( QMessageBox::Yes, tr("Reload"));
  1.4961 -			mb.setButtonText( QMessageBox::No, tr("Ignore"));
  1.4962 -			switch( mb.exec() ) 
  1.4963 -			{
  1.4964 -				case QMessageBox::Yes:
  1.4965 -					// Reload map
  1.4966 -					load (filePath,NewMap,fileType);
  1.4967 -		        case QMessageBox::Cancel:
  1.4968 -					fileChangedTime=tmod; // allow autosave to overwrite newer file!
  1.4969 -			}
  1.4970 -		}
  1.4971 -	}	
  1.4972 -
  1.4973 -}
  1.4974 -
  1.4975 -
  1.4976 -/*TODO not needed? void MapEditor::contentsDropEvent(QDropEvent *event) 
  1.4977 -{
  1.4978 -
  1.4979 -		} else if (event->provides("application/x-moz-file-promise-url") && 
  1.4980 -			 event->provides("application/x-moz-nativeimage")) 
  1.4981 -		{
  1.4982 -			// Contains url to the img src in unicode16
  1.4983 -			QByteArray d = event->encodedData("application/x-moz-file-promise-url");
  1.4984 -			QString url = QString((const QChar*)d.data(),d.size()/2);
  1.4985 -			fetchImage(url);
  1.4986 -			event->accept();
  1.4987 -			update=true;
  1.4988 -		} else if (event->provides ("text/uri-list"))
  1.4989 -		{	// Uris provided e.g. by konqueror
  1.4990 -			Q3UriDrag::decode (event,uris);
  1.4991 -		} else if (event->provides ("_NETSCAPE_URL"))
  1.4992 -		{	// Uris provided by Mozilla
  1.4993 -		  QStringList l = QStringList::split("\n", event->encodedData("_NETSCAPE_URL"));
  1.4994 -		  uris.append(l[0]);
  1.4995 -		  heading = l[1];
  1.4996 -		} else if (event->provides("text/html")) {
  1.4997 -
  1.4998 -		  // Handels text mime types
  1.4999 -		  // Look like firefox allways handle text as unicode16 (2 bytes per char.)
  1.5000 -		  QByteArray d = event->encodedData("text/html");
  1.5001 -		  QString text;
  1.5002 -		  if (isUnicode16(d)) 
  1.5003 -		    text = QString((const QChar*)d.data(),d.size()/2);
  1.5004 -		  else 
  1.5005 -		    text = QString(d);
  1.5006 -
  1.5007 -		  textEditor->setText(text);
  1.5008 -
  1.5009 -		  event->accept();
  1.5010 -		  update=true;
  1.5011 -		} else if (event->provides("text/plain")) {
  1.5012 -		  QByteArray d = event->encodedData("text/plain");
  1.5013 -		  QString text;
  1.5014 -		  if (isUnicode16(d))
  1.5015 -		    text = QString((const QChar*)d.data(),d.size()/2);
  1.5016 -		  else 
  1.5017 -		    text = QString(d);
  1.5018 -
  1.5019 -		  textEditor->setText(text);
  1.5020 -		  
  1.5021 -		  event->accept();
  1.5022 -		  update= true;
  1.5023 -		}
  1.5024 -
  1.5025 -		*/
  1.5026 -
  1.5027 -
  1.5028  
  1.5029  bool isUnicode16(const QByteArray &d) 
  1.5030  {
  1.5031 @@ -5377,66 +1030,7 @@
  1.5032    return false;
  1.5033  }
  1.5034        
  1.5035 -void MapEditor::addFloatImageInt (const QPixmap &img) 
  1.5036 -{
  1.5037 -	BranchObj *bo=xelection.getBranch();
  1.5038 -	if (bo)
  1.5039 -  {
  1.5040 -	FloatImageObj *fio=bo->addFloatImage();
  1.5041 -    fio->load(img);
  1.5042 -    fio->setOriginalFilename("No original filename (image added by dropevent)");	
  1.5043 -	QString s=model->getSelectString(bo);
  1.5044 -	saveState (PartOfMap, s, "nop ()", s, "copy ()","Copy dropped image to clipboard",fio  );
  1.5045 -	saveState (fio,"delete ()", bo,QString("paste(%1)").arg(curStep),"Pasting dropped image");
  1.5046 -    model->reposition();
  1.5047 -    scene()->update();
  1.5048 -  }
  1.5049 -}
  1.5050  
  1.5051 -/*
  1.5052 +// FIXME the following are not needed...
  1.5053 +QString MapEditor::getName(const LinkableMapObj*) {return QString();}
  1.5054  
  1.5055 -void MapEditor::imageDataFetched(const QByteArray &a, Q3NetworkOperation * / *nop* /) 
  1.5056 -{
  1.5057 -  if (!imageBuffer) imageBuffer = new QBuffer();
  1.5058 -  if (!imageBuffer->isOpen()) {
  1.5059 -    imageBuffer->open(QIODevice::WriteOnly | QIODevice::Append);
  1.5060 -  }
  1.5061 -  imageBuffer->at(imageBuffer->at()+imageBuffer->writeBlock(a));
  1.5062 -}
  1.5063 -
  1.5064 -
  1.5065 -void MapEditor::imageDataFinished(Q3NetworkOperation *nop) 
  1.5066 -{
  1.5067 -	if (nop->state()==Q3NetworkProtocol::StDone) {
  1.5068 -		QPixmap img(imageBuffer->buffer());
  1.5069 -		addFloatImageInt (img);
  1.5070 -	}
  1.5071 -
  1.5072 -	if (imageBuffer) {
  1.5073 -		imageBuffer->close();
  1.5074 -		if (imageBuffer) {
  1.5075 -			imageBuffer->close();
  1.5076 -			delete imageBuffer;
  1.5077 -			imageBuffer = 0;
  1.5078 -		}
  1.5079 -	}
  1.5080 -}
  1.5081 -
  1.5082 -void MapEditor::fetchImage(const QString &url) 
  1.5083 -{
  1.5084 -  if (urlOperator) {
  1.5085 -    urlOperator->stop();
  1.5086 -    disconnect(urlOperator);
  1.5087 -    delete urlOperator;
  1.5088 -  }
  1.5089 -  
  1.5090 -  urlOperator = new Q3UrlOperator(url);
  1.5091 -  connect(urlOperator, SIGNAL(finished(Q3NetworkOperation *)), 
  1.5092 -	  this, SLOT(imageDataFinished(Q3NetworkOperation*)));
  1.5093 -
  1.5094 -  connect(urlOperator, SIGNAL(data(const QByteArray &, Q3NetworkOperation *)),
  1.5095 -	  this, SLOT(imageDataFetched(const QByteArray &, Q3NetworkOperation *)));
  1.5096 -  urlOperator->get();
  1.5097 -}
  1.5098 -*/
  1.5099 -
     2.1 --- a/mapeditor.h	Mon Jul 14 11:25:09 2008 +0000
     2.2 +++ b/mapeditor.h	Wed Jul 16 10:44:44 2008 +0000
     2.3 @@ -2,370 +2,46 @@
     2.4  #define MAPEDITOR_H
     2.5  
     2.6  #include <QGraphicsView>
     2.7 -#include <QtNetwork>
     2.8  
     2.9  #include "attribute.h"
    2.10 -#include "file.h"
    2.11 -#include "misc.h"
    2.12 -#include "parser.h"
    2.13  #include "ornamentedobj.h"
    2.14 -#include "selection.h"
    2.15 +#include "selection.h"		// FIXME should not be needed
    2.16  #include "settings.h"
    2.17  #include "vymmodel.h"
    2.18  
    2.19 -class VymModel;
    2.20 -class Selection;
    2.21  
    2.22  /*! \brief Main widget in vym to display and edit a map */
    2.23  
    2.24 -class MapEditor : public QGraphicsView, public XMLObj {
    2.25 +class MapEditor : public QGraphicsView  {	
    2.26      Q_OBJECT
    2.27  
    2.28  public:
    2.29 -    /*! \brief State of the mapeditor 
    2.30 -		
    2.31 -		While a heading is edited, the state has to change, so
    2.32 -		that e.g. no other object might get selected. This is done
    2.33 -		in Main by calling setStateEditHeading
    2.34 -	*/
    2.35 -	enum State {
    2.36 -		Idle,			//!< Idle, waiting for user event
    2.37 -		EditHeading		//!< Editing heading (dont't select another branch now)
    2.38 -	};
    2.39 -    /*! \brief Networking states
    2.40 -		
    2.41 -		In Network modus we want to switch of saveState, autosave, ...
    2.42 -	*/
    2.43 -	enum NetState {
    2.44 -		Offline,			//!< Offline
    2.45 -		Client,				//!< I am the client and connected to server
    2.46 -		Server				//!< I am the server
    2.47 -	};
    2.48 -    MapEditor(QWidget* parent=0);
    2.49 +    MapEditor(VymModel *vm);
    2.50  	~MapEditor();
    2.51  	VymModel* getModel();
    2.52  	QGraphicsScene * getScene();
    2.53 -	State getState();					//!< Return State of MapEditor
    2.54 -	void setStateEditHeading (bool);	//!< If set to true, State will change to EditHeading
    2.55 -	bool isRepositionBlocked(); //!< While load or undo there is no need to update graphicsview
    2.56 -	bool isSaveStateBlocked();			//!< block while undo/redo or while running scripts
    2.57 -	void setSaveStateBlocked(bool);		//!< block saving the undo/redo state
    2.58 -	bool isSelectBlocked();		//!< true, if no change of selection is possible, e.g. while editing the heading of abranch
    2.59 -	
    2.60 -protected:
    2.61 -	/*! \brief Get name of object
    2.62 -	  
    2.63 -	  Returns heading of a branch or name of an object for use in comment
    2.64 -	  of undo/redo history
    2.65 -	*/ 
    2.66 -	QString getName(const LinkableMapObj*);	// Get e.g. heading or filename
    2.67 -	void makeTmpDirs();		// create temporary directories
    2.68 -
    2.69 -	/*! This function saves all information of the map to disc.
    2.70 -	    saveToDir also calls the functions for all BranchObj and other objects in the map.
    2.71 -		The structure of the map itself is returned as QString and passed back to Main, 
    2.72 -		where saveToDir is called initially
    2.73 -	*/	
    2.74 -    QString saveToDir (const QString &tmpdir, const QString &prefix, bool writeflags, const QPointF &offset, LinkableMapObj *saveSel);
    2.75 -
    2.76 -	/*! \brief Get directory, where current step in history is save
    2.77 -
    2.78 -		saveState creates a directory for each step in history. This function returns the
    2.79 -		path of the current directory
    2.80 -	*/
    2.81 -	QString getHistoryDir();
    2.82 -
    2.83 -	/*! \brief Save the current changes in map 
    2.84 -
    2.85 -		Two commands and selections are saved:
    2.86 -
    2.87 -			- undocommand and undoselection to undo the change
    2.88 -			- redocommand and redoselection to redo the action after an undo
    2.89 -
    2.90 -		Additionally a comment is logged. 
    2.91 -
    2.92 -	*/	
    2.93 -    void saveState(
    2.94 -		const SaveMode& savemode, 
    2.95 -		const QString &undoSelection, 
    2.96 -		const QString &undoCommand, 
    2.97 -		const QString &redoSelection, 
    2.98 -		const QString &redoCommand, 
    2.99 -		const QString &comment, 
   2.100 -		LinkableMapObj *saveSelection);
   2.101 -	/*! Overloaded for convenience */
   2.102 -    void saveStateChangingPart(
   2.103 -		LinkableMapObj *undoSelection, 
   2.104 -		LinkableMapObj* redoSelection, 
   2.105 -		const QString &redoCommand, 
   2.106 -		const QString &comment);
   2.107 -	/*! Overloaded for convenience */
   2.108 -    void saveStateRemovingPart(
   2.109 -		LinkableMapObj *redoSelection, 
   2.110 -		const QString &comment);
   2.111 -	/*! Overloaded for convenience */
   2.112 -    void saveState(
   2.113 -		LinkableMapObj *undoSelection, 
   2.114 -		const QString &undoCommand, 
   2.115 -		LinkableMapObj *redoSelection, 
   2.116 -		const QString &redoCommand, 
   2.117 -		const QString &comment); 
   2.118 -	/*! Overloaded for convenience */
   2.119 -    void saveState(
   2.120 -		const QString &undoSelection, 
   2.121 -		const QString &undoCommand, 
   2.122 -		const QString &redoSelection, 
   2.123 -		const QString &redoCommand, 
   2.124 -		const QString &comment) ;
   2.125 -    void saveState(
   2.126 -		const QString &undoCommand, 
   2.127 -		const QString &redoCommand, 
   2.128 -		const QString &comment) ;
   2.129 -
   2.130 -public:	
   2.131 -
   2.132 -	/* \brief Process one command and its parameters */
   2.133 -    void parseAtom (const QString &atom);	
   2.134 -
   2.135 -	/* \brief Runs the script */
   2.136 -	void runScript (QString script);
   2.137 -private:
   2.138 -    void addFloatImageInt(const QPixmap &img);
   2.139  
   2.140  public:
   2.141 -	bool isDefault();		//!< true, if map is still the empty default map
   2.142 -    bool hasChanged();		//!< true, if something has changed and is not saved yet
   2.143 -	void setChanged();		//!< called from TextEditor via LinkableMapObj
   2.144 -	void closeMap();		//!< Closes the map
   2.145 -
   2.146 -	/*! \brief Sets filepath, filename and mapname
   2.147 -
   2.148 -	     If the filepath is "/home/tux/map.xml", then the filename will be set
   2.149 -		 to map.xml. The destname is needed for vymLinks, pointing to another map. 
   2.150 -		 The destname holds the real name of the file, after it has been compressed, e.g. "map.vym"
   2.151 -	*/	 
   2.152 -
   2.153 -	/*! \brief Set File path
   2.154 -
   2.155 -	     The destname is needed to construct the references between maps
   2.156 -	*/	 
   2.157 -	void setFilePath (QString filepath,QString destname);	
   2.158 -	void setFilePath (QString);	//!< Overloaded for convenience
   2.159 -	QString getFilePath ();	//!< Full path e.g. "/home/tux/map.xml"
   2.160 -	QString getFileName ();	//!< e.g. "map.xml"
   2.161 -	QString getMapName ();	//!< e.g. "map"
   2.162 -	QString getDestPath (); //!< e.g. "/home/tux/map.vym"
   2.163 -
   2.164 -	/*! \brief Load map
   2.165 -
   2.166 -		The data is read from file. Depending on LoadMode the current
   2.167 -		selection gets replaced by data or the data is appended.
   2.168 -	*/	
   2.169 -    ErrorCode load (QString, const LoadMode &, const FileType& );	// newmap, import/replace selection
   2.170 -public:
   2.171 -	/*! \brief Save the map to file */
   2.172 -    ErrorCode save(const SaveMode &);	
   2.173 -	/* FIXME no needed any longer
   2.174 -	void setZipped(bool);		//!< Set or unset compression of map with zip save map zipped
   2.175 -	bool saveZipped();			//!< True, if file will be saved zipped
   2.176 -	*/
   2.177      void print();				//!< Print the map
   2.178  	void setAntiAlias (bool);	//!< Set or unset antialiasing
   2.179  	void setSmoothPixmap(bool); //!< Set or unset smoothing of pixmaps
   2.180 -private:
   2.181 -    QPixmap getPixmap();
   2.182 -	void setHideTmpMode (HideTmpMode);	// temporary hide stuff
   2.183 -	HideTmpMode getHideTmpMode();		// temporary hide stuff
   2.184  public:
   2.185 -	/*! Set or unset temporary hiding of objects during export  */
   2.186 -	void setExportMode (bool);
   2.187 +	void toggleStandardFlag(QString);
   2.188  
   2.189 -	/*! Export as ASCII text to file */
   2.190 -	void exportASCII (QString fname="",bool askForName=true);  
   2.191 +	void updateSelection();					// update geometry of selection
   2.192  
   2.193 -	/*! Save as image */
   2.194 -    void exportImage (QString fname="",bool askForName=true,QString format="PNG");
   2.195 -
   2.196 -    /*! Export as OpenOfficeOrg presentation */
   2.197 -    void exportOOPresentation(const QString &,const QString &);	
   2.198 -
   2.199 -	/*! Export as XHTML to directory */
   2.200 -    void exportXHTML(const QString& dir="", bool askForName=true);	
   2.201 -
   2.202 -	/*! Export as XTML to directory */
   2.203 -    void exportXML(QString dir="", bool askForName=true);
   2.204 -
   2.205 -    void clear();						//!< Clear map
   2.206 -    void copy();						//!< Copy to clipboard
   2.207 -    void redo();						//!< Redo last action
   2.208 -	bool isRedoAvailable();				//!< True, if redo is available
   2.209 -    void undo();						//!< Undo last action
   2.210 -	bool isUndoAvailable();				//!< True, if undo is available
   2.211 -	void gotoHistoryStep (int);			//!< Goto a specifig step in history
   2.212 -private:	
   2.213 -    void addMapReplaceInt(const QString & undoSel, const QString & path);
   2.214 -    void addMapInsertInt (const QString & path, int pos);
   2.215 -    void pasteNoSave(const int &n);		//!< paste clipboard to branch
   2.216 -public:	
   2.217 -    void paste();		//!< Paste clipboard to branch and backup
   2.218 -    void cut();			//!< Cut to clipboard (and copy)
   2.219 -	/*! \brief Move absolutly
   2.220 -
   2.221 -		Move absolutly to (x,y).
   2.222 -	*/	
   2.223 -    void move    (const double &x, const double &y);
   2.224 -	/*! \brief Move relativly
   2.225 -
   2.226 -		Move relativly to (x,y).
   2.227 -	*/	
   2.228 -    void moveRel (const double &x, const double &y);
   2.229 -    void moveBranchUp();	//!< Move branch up
   2.230 -    void moveBranchDown();	//!< Move branch down
   2.231 -	void sortChildren();	//!< Sort children lexically
   2.232 -private:	
   2.233 -	void linkTo(const QString &);
   2.234 -public:	
   2.235 -	QString getHeading (bool &ok,QPoint &p); //!< Get heading, ok if selection is branch
   2.236 -	void setHeading(const QString &);		//!< Set heading of branch	
   2.237 -private:
   2.238 -	void setHeadingInt(const QString &);
   2.239 -	void setVymLinkInt(const QString &);	// Set vymLink for selection
   2.240 -	/*! \brief Add new mapcenter
   2.241 -
   2.242 -	    Disclaimer: Still experimental, not fully supported.
   2.243 -	*/	
   2.244 -public:	
   2.245 -    BranchObj* addMapCenter();		
   2.246 -
   2.247 -	/*! \brief Add new branch
   2.248 -
   2.249 -		Depending on num the new branch is created
   2.250 -
   2.251 -		-3 above selection as child of selections parent
   2.252 -		-2 as child of selection
   2.253 -		-1 below selection as child of selections parent
   2.254 -		0..n	insert at a specific position in selections parent
   2.255 -		(needed for free relinking)
   2.256 -	*/	
   2.257 -private:	
   2.258 -    BranchObj* addNewBranchInt(int);		// pos allows to add above/below selection
   2.259 -public:	
   2.260 -	/*! \Add new branch
   2.261 -		
   2.262 -		Depending on num the new branch is created
   2.263 -		-1 above selection
   2.264 -		 0 as child of selection
   2.265 -		 1 below selection
   2.266 -	*/
   2.267 -    BranchObj* addNewBranch(int pos);		
   2.268 -    BranchObj* addNewBranchBefore();		//!< Insert branch between selection and its parent
   2.269 -    void deleteSelection();					//!< Delete selection
   2.270 -	LinkableMapObj* getSelection();			//!< Returns selection
   2.271 -	BranchObj* getSelectedBranch();			// returns selected branch or NULL
   2.272 -	FloatImageObj* getSelectedFloatImage();	// returns selected branch or NULL
   2.273 -	void unselect();						// before changing current noteedit
   2.274 -	void reselect();						// after  changing current noteedit
   2.275 -	bool select(const QString &);			// Select by string
   2.276 -	bool select(LinkableMapObj *lmo);		// Select by pointer
   2.277 -	QString getSelectString();
   2.278 -private:	
   2.279 -	void selectInt(LinkableMapObj*);	
   2.280 -	void selectNextBranchInt();		// Increment number of branch
   2.281 -	void selectPrevBranchInt();		// Decrement number of branch
   2.282 -public:	
   2.283 -    void selectUpperBranch();
   2.284 -    void selectLowerBranch();
   2.285 -    void selectLeftBranch();
   2.286 -    void selectRightBranch();
   2.287 -    void selectFirstBranch();
   2.288 -    void selectLastBranch();
   2.289 -    void selectMapBackgroundImage();
   2.290 -    void setMapBackgroundImage(const QString &);
   2.291 -    void selectMapBackgroundColor();
   2.292 -    void setMapBackgroundColor(QColor);
   2.293 -    QColor getMapBackgroundColor();
   2.294 -    QColor getCurrentHeadingColor();
   2.295 -    void colorBranch(QColor);
   2.296 -    void colorSubtree(QColor);
   2.297 -	void toggleStandardFlag(QString);
   2.298 -    BranchObj* findText(QString,bool);		// Find object
   2.299 -    void findReset();						// Reset Find 
   2.300 -	void setURL(const QString &);			// set  URL
   2.301 -	void editURL();							// edit URL
   2.302 -	void editLocalURL();					// edit URL to local file
   2.303 -	QString getURL();						// returns URL of selection or ""
   2.304 -	QStringList getURLs();					// returns URLs of subtree
   2.305 -	void editHeading2URL();					// copy heading to URL
   2.306 -	void editBugzilla2URL();				// create URL to Bugzilla
   2.307 -	void editFATE2URL();					// create URL to FATE
   2.308 -	void editVymLink();						// edit link to another map
   2.309 -	void deleteVymLink();					// delete link to another map
   2.310 -	QString getVymLink();					// return path to map
   2.311 -	QStringList getVymLinks();				// return paths in subtree
   2.312 -	void setHideExport(bool);				// toggle the export flag
   2.313 -	void toggleHideExport();				// toggle the export flag
   2.314 -	void deleteKeepChilds();				// remove but keep childs
   2.315 -	void deleteChilds();					// remove childs
   2.316 -	void editMapInfo();						// dialog to enter author, ...
   2.317 -	void ensureSelectionVisible();		
   2.318 -	void updateSelection();					// update geometry of selection
   2.319 -	void updateActions();					// update e.g. format buttons
   2.320 -	void updateNoteFlag();					// when TextEditor changes
   2.321 -	void setMapAuthor (const QString &);
   2.322 -	void setMapComment(const QString &);
   2.323 -	void setMapLinkStyle (const QString &);	// Set style of link
   2.324 -	LinkableMapObj::Style getMapLinkStyle ();	// requested in LMO
   2.325 -	void setMapDefLinkColor(QColor);		// default color of links
   2.326 -	void setMapLinkColorHintInt();			// color of links
   2.327 -	void setMapLinkColorHint(LinkableMapObj::ColorHint);// color of links
   2.328 -	LinkableMapObj::ColorHint getMapLinkColorHint();
   2.329 -	QColor getMapDefLinkColor();
   2.330 -	void setMapDefXLinkColor(QColor);
   2.331 -	QColor getMapDefXLinkColor();
   2.332 -	void setMapDefXLinkWidth (int);
   2.333 -	int getMapDefXLinkWidth();
   2.334 -	void toggleMapLinkColorHint();			// after changing linkStyles
   2.335 -    void selectMapLinkColor();
   2.336 -    void selectMapSelectionColor();
   2.337 -private:	
   2.338 -    void setSelectionColorInt(QColor);
   2.339 -public:	
   2.340 -    void setSelectionColor(QColor);
   2.341 -    QColor getSelectionColor();
   2.342 -	bool scrollBranch(BranchObj*);
   2.343 -	bool unscrollBranch(BranchObj*);
   2.344 -    void toggleScroll();
   2.345 -    void unscrollChilds();
   2.346 -private:	
   2.347 -	FloatImageObj* loadFloatImageInt (QString);
   2.348 -public:	
   2.349 -	void loadFloatImage ();
   2.350 -private:	
   2.351 -	void saveFloatImageInt (FloatImageObj*, const QString &, const QString &);
   2.352 -public:	
   2.353 -	void saveFloatImage ();
   2.354 -	void setFrameType(const FrameObj::FrameType &);
   2.355 -	void setFrameType(const QString &);
   2.356 -	void setFramePenColor (const QColor &);
   2.357 -	void setFrameBrushColor (const QColor &);
   2.358 -	void setFramePadding (const int &);
   2.359 -	void setFrameBorderWidth (const int &);
   2.360 -	void setIncludeImagesVer(bool);
   2.361 -	void setIncludeImagesHor(bool);
   2.362 -	void setHideLinkUnselected (bool);
   2.363 -	bool getHideLinkUnselected ();
   2.364 -private:	
   2.365 -    void importDirInt(BranchObj *,QDir);
   2.366 -    void importDirInt(const QString&);
   2.367 -public:	
   2.368 -    void importDir();
   2.369 -	void followXLink (int);
   2.370 -	void editXLink (int);
   2.371  	AttributeTable* attributeTable();
   2.372      void testFunction1();					// just testing new stuff
   2.373      void testFunction2();					// just testing new stuff
   2.374  											// set /mainwindo/showTestMenu=true...
   2.375  
   2.376 +public slots:
   2.377 +	void editHeading();
   2.378 +	void editHeadingFinished();
   2.379 +private:
   2.380 +	bool editingHeading;
   2.381 +	QLineEdit *lineEdit;
   2.382 +
   2.383  protected:
   2.384  	virtual void contextMenuEvent ( QContextMenuEvent *e );
   2.385      virtual void keyPressEvent(QKeyEvent*);
   2.386 @@ -382,39 +58,13 @@
   2.387  	void dropEvent (QDropEvent *);
   2.388  
   2.389  
   2.390 -protected:
   2.391 -	void sendSelection();
   2.392 -
   2.393 -public:
   2.394 -	void newServer();
   2.395 -	void connectToServer();
   2.396 -
   2.397 -private slots:	
   2.398 -	void newClient();
   2.399 -	void sendData(const QString &s);
   2.400 -	void readData();
   2.401 -	void displayNetworkError (QAbstractSocket::SocketError);
   2.402 -
   2.403 -	void autosave ();
   2.404 -	void fileChanged();
   2.405 -
   2.406  private:
   2.407 -	State state;				// State of MapEditor
   2.408  	QGraphicsScene *mapScene;
   2.409  	VymModel *model;					// Vym Map, includding several mapCenters
   2.410 -	QTimer *autosaveTimer;
   2.411 -	QTimer *fileChangedTimer;
   2.412 -	QDateTime fileChangedTime;
   2.413  
   2.414  	bool adjustCanvasRequested;	// collect requests until end of user event
   2.415  	BranchObj *editingBO;		// entering Text into BO
   2.416  
   2.417 -	QColor defLinkColor;		// default color for links
   2.418 -	QColor defXLinkColor;		// default color for xlinks
   2.419 -	int defXLinkWidth;			// default width for xlinks
   2.420 -	LinkableMapObj::ColorHint linkcolorhint;// use heading color or own color
   2.421 -	LinkableMapObj::Style linkstyle;		// default style for links
   2.422 -
   2.423      QCursor HandOpenCursor;		// cursor while moving canvas view
   2.424  	QCursor PickColorCursor;	// cursor while picking color 
   2.425  	QCursor CopyCursor;			// cursor while picking color 
   2.426 @@ -424,11 +74,7 @@
   2.427  	bool copyingObj;			// true while creating a link
   2.428  	XLinkObj* tmpXLink;
   2.429  
   2.430 -	Selection xelection;	
   2.431 -
   2.432 -	QString latestSelection;		// select string of latest added object
   2.433 -
   2.434 -    MapObj* movingObj;				// moving a MapObj
   2.435 +	MapObj* movingObj;				// moving a MapObj
   2.436  	MapObj* linkingObj_src;			// part of a link
   2.437      QPointF movingObj_orgPos;		// org. pos of mouse before move
   2.438      QPointF movingObj_orgRelPos;	// org. relative pos of mouse before move
   2.439 @@ -436,58 +82,19 @@
   2.440      QPointF movingCont_start;		// inital pos of moving Content or
   2.441      QPointF movingVec;				// how far has Content moved
   2.442  
   2.443 -	QPointF contextMenuPos;					// position where context event was triggered
   2.444 +	QPointF contextMenuPos;			// position where context event was triggered
   2.445  
   2.446      QPrinter* printer;				// Printing
   2.447  
   2.448 -    bool mapDefault;				// Flag if map is untouched
   2.449 -    bool mapChanged;				// Flag if undo is possible
   2.450 -	bool mapUnsaved;				// Flag if map should be saved
   2.451 -
   2.452 -	Parser parser;				// Parser stuff for scripting
   2.453 -
   2.454  	AttributeTable *attrTable;
   2.455  
   2.456  	bool printFrame;			// Print frame around map
   2.457  	bool printFooter;			// Print footer below map
   2.458  
   2.459 -	bool zipped;				// should map be zipped
   2.460 -	static	int mapNum;			// unique number for Editor
   2.461 -	FileType fileType;			// type of file, e.g. vym, freemind...
   2.462 -	QString fileName;			// short name of file (for tab)
   2.463 -	QString filePath;			// path to file which will be saved
   2.464 -	QString fileDir;			// dir where file is saved
   2.465 -	QString destPath;			// path to .vym file (needed for vymlinks)
   2.466 -	QString mapName;			// fileName without ".vym"
   2.467 +	QPoint exportOffset;		// set before export, used in save
   2.468  
   2.469 -	QString tmpMapDir;			// tmp directory with undo history
   2.470 -	QString histPath;			// Path to history file
   2.471 -	SimpleSettings undoSet;		// undo/redo commands, saved in histPath
   2.472 -	int stepsTotal;				// total number of steps (undos+redos) 
   2.473 -	int curStep;				// Current step in history (ring buffer)
   2.474 -	int curClipboard;			// number of history step, which is the current clipboard
   2.475 -	int redosAvail;				// Available number of redo steps
   2.476 -	int undosAvail;				// Available number of undo steps
   2.477 -	bool blockReposition;		// block while load or undo
   2.478 -	bool blockSaveState;		// block while load or undo
   2.479 -
   2.480 -	BranchObj* itFind;			// next object in find process
   2.481 -	bool EOFind;				// true, if search failed
   2.482 -
   2.483 -	QPoint exportOffset;		// set before export, used in save
   2.484 -	HideTmpMode hidemode;	// true while exporting to hide some stuff
   2.485 -
   2.486 -	// Network connections **Experimental**
   2.487 -	NetState netstate;			// offline, client, server
   2.488 -	QTcpServer *tcpServer;		// Act as server in conference mode (experimental)
   2.489 -	QList <QTcpSocket*> clientList;		// List of connected clients
   2.490 -	quint16 sendCounter;		// Increased with every sent command
   2.491 -
   2.492 -	QTcpSocket	*clientSocket;	// socket of this client
   2.493 -	QString server;				// server address of this client
   2.494 -	int port;					// server port of this client
   2.495 -	void displayClientError(QAbstractSocket::SocketError socketError);
   2.496 -
   2.497 +	Selection xelection;					// FIXME only here to get rid of some gcc errors...
   2.498 +	QString getName(const LinkableMapObj*);	// FIXME see above, renamed to getObjectName in VymModel...
   2.499  };
   2.500  #endif
   2.501