mainwindow.cpp
changeset 721 12958f987bcf
parent 714 3368b54c7946
child 723 11f9124c1cca
     1.1 --- a/mainwindow.cpp	Wed Jul 16 10:44:44 2008 +0000
     1.2 +++ b/mainwindow.cpp	Wed Jul 16 10:46:14 2008 +0000
     1.3 @@ -79,8 +79,6 @@
     1.4  {
     1.5  	mainWindow=this;
     1.6  
     1.7 -	setObjectName ("MainWindow");
     1.8 -
     1.9  	setCaption ("VYM - View Your Mind");
    1.10  
    1.11  	// Load window settings
    1.12 @@ -496,6 +494,7 @@
    1.13  	editMenu->addAction (a);
    1.14  	actionEditPaste=a;
    1.15  
    1.16 +/*
    1.17      // Shortcuts to modify heading:
    1.18      a = new QAction(tr( "Edit heading","Edit menu" ),this);
    1.19  	a->setStatusTip ( tr( "edit Heading" ));
    1.20 @@ -513,6 +512,8 @@
    1.21  	actionListBranches.append(a);
    1.22  	editMenu->addAction (a);
    1.23  	actionEditHeading=a;
    1.24 +
    1.25 +*/	
    1.26      a = new QAction( tr( "Edit heading","Edit menu" ), this);
    1.27  	a->setStatusTip (tr( "edit Heading" ));
    1.28  	//a->setShortcut ( Qt::Key_F2 );					//Edit heading
    1.29 @@ -660,10 +661,10 @@
    1.30  	addAction (alt);
    1.31  	actionListBranches.append(actionEditToggleScroll);
    1.32  	
    1.33 -    a = new QAction( tr( "Unscroll childs","Edit menu" ), this);
    1.34 +    a = new QAction( tr( "Unscroll children","Edit menu" ), this);
    1.35  	a->setStatusTip (tr( "Unscroll all scrolled branches in selected subtree" ));
    1.36  	editMenu->addAction (a);
    1.37 -    connect( a, SIGNAL( triggered() ), this, SLOT( editUnscrollChilds() ) );
    1.38 +    connect( a, SIGNAL( triggered() ), this, SLOT( editUnscrollChildren() ) );
    1.39  	
    1.40  	editMenu->addSeparator();
    1.41  
    1.42 @@ -803,24 +804,24 @@
    1.43  	actionListBranches.append(a);
    1.44  	actionEditSaveBranch=a;
    1.45  
    1.46 -	// Only remove branch, not its childs
    1.47 +	// Only remove branch, not its children
    1.48      a = new QAction(tr( "Remove only branch ","Edit menu" ), this);
    1.49 -	a->setStatusTip ( tr( "Remove only branch and keep its childs" ));
    1.50 +	a->setStatusTip ( tr( "Remove only branch and keep its children" ));
    1.51  	a->setShortcut (Qt::ALT + Qt::Key_Delete );
    1.52 -    connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteKeepChilds() ) );
    1.53 +    connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteKeepChildren() ) );
    1.54  	a->setEnabled (false);
    1.55  	addAction (a);
    1.56  	actionListBranches.append(a);
    1.57 -	actionEditDeleteKeepChilds=a;
    1.58 -
    1.59 -	// Only remove childs of a branch
    1.60 -    a = new QAction( tr( "Remove childs","Edit menu" ), this);
    1.61 -	a->setStatusTip (tr( "Remove childs of branch" ));
    1.62 +	actionEditDeleteKeepChildren=a;
    1.63 +
    1.64 +	// Only remove children of a branch
    1.65 +    a = new QAction( tr( "Remove children","Edit menu" ), this);
    1.66 +	a->setStatusTip (tr( "Remove children of branch" ));
    1.67  	a->setShortcut (Qt::SHIFT + Qt::Key_Delete );
    1.68 -    connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteChilds() ) );
    1.69 +    connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteChildren() ) );
    1.70  	a->setEnabled (false);
    1.71  	actionListBranches.append(a);
    1.72 -	actionEditDeleteChilds=a;
    1.73 +	actionEditDeleteChildren=a;
    1.74  
    1.75      // Shortcuts for navigating with cursor:
    1.76      a = new QAction(tr( "Select upper branch","Edit menu" ), this);
    1.77 @@ -1554,8 +1555,8 @@
    1.78  		branchRemoveContextMenu =branchContextMenu->addMenu (tr ("Remove","Context menu name"));
    1.79  		branchRemoveContextMenu->addAction (actionEditCut);
    1.80  		branchRemoveContextMenu->addAction ( actionEditDelete );
    1.81 -		branchRemoveContextMenu->addAction ( actionEditDeleteKeepChilds );
    1.82 -		branchRemoveContextMenu->addAction ( actionEditDeleteChilds );
    1.83 +		branchRemoveContextMenu->addAction ( actionEditDeleteKeepChildren );
    1.84 +		branchRemoveContextMenu->addAction ( actionEditDeleteChildren );
    1.85  		
    1.86  
    1.87  	actionEditSaveBranch->addTo( branchContextMenu );
    1.88 @@ -1690,12 +1691,24 @@
    1.89  
    1.90  MapEditor* Main::currentMapEditor() const
    1.91  {
    1.92 +	// FIXME currentMapEditor should return the latest used editor for a model, or NULL if no editor is open
    1.93      if ( tabWidget->currentPage() &&
    1.94  	 tabWidget->currentPage()->inherits( "MapEditor" ) )
    1.95  		return (MapEditor*)tabWidget->currentPage();
    1.96      return NULL;	
    1.97  }
    1.98  
    1.99 +VymModel* Main::currentModel() const
   1.100 +{
   1.101 +	// FIXME better get currentModel from a maintained list,
   1.102 +	// just in case we allow other views in tabs later
   1.103 +	MapEditor *me=currentMapEditor();
   1.104 +	if (me) 
   1.105 +		return me->getModel();
   1.106 +	else
   1.107 +		return NULL;
   1.108 +}
   1.109 +
   1.110  
   1.111  void Main::editorChanged(QWidget *)
   1.112  {
   1.113 @@ -1704,11 +1717,11 @@
   1.114  	MapEditor *me;
   1.115  	for (int i=0;i<=tabWidget->count() -1;i++)
   1.116  	{
   1.117 +		
   1.118  		me=(MapEditor*)tabWidget->page(i);
   1.119 -		me->unselect();
   1.120 +		me->getModel()->unselect();
   1.121  	}	
   1.122 -	me=currentMapEditor();
   1.123 -	if (me) me->reselect();
   1.124 +	currentModel()->reselect();
   1.125  
   1.126  	// Update actions to in menus and toolbars according to editor
   1.127  	updateActions();
   1.128 @@ -1716,8 +1729,10 @@
   1.129  
   1.130  void Main::fileNew()
   1.131  {
   1.132 +	VymModel *m=new VymModel;
   1.133 +	models.append (m);
   1.134 +	MapEditor* me = new MapEditor (m);
   1.135  	QString fn="unnamed";
   1.136 -	MapEditor* me = new MapEditor ( NULL);
   1.137  	tabWidget->addTab (me,fn);
   1.138  	tabWidget->showPage(me);
   1.139  	me->viewport()->setFocus();
   1.140 @@ -1725,7 +1740,7 @@
   1.141  	me->setSmoothPixmap(actionViewToggleSmoothPixmapTransform->isOn());
   1.142  	
   1.143  	// For the very first map we do not have flagrows yet...
   1.144 -	me->select("mc:");
   1.145 +	currentModel()->select("mc:");
   1.146  }
   1.147  
   1.148  void Main::fileNewCopy()
   1.149 @@ -1734,8 +1749,10 @@
   1.150  	MapEditor* oldME =currentMapEditor();
   1.151  	if (oldME)
   1.152  	{
   1.153 -		oldME->copy();
   1.154 -		MapEditor* newME = new MapEditor ( NULL);
   1.155 +		oldME->getModel()->copy();
   1.156 +		VymModel *m=new VymModel;
   1.157 +		models.append (m);
   1.158 +		MapEditor* newME = new MapEditor ( m);
   1.159  		if (newME)
   1.160  		{
   1.161  			tabWidget->addTab (newME,fn);
   1.162 @@ -1744,8 +1761,8 @@
   1.163  			newME->setAntiAlias (actionViewToggleAntiAlias->isOn());
   1.164  			newME->setSmoothPixmap(actionViewToggleSmoothPixmapTransform->isOn());
   1.165  			// For the very first map we do not have flagrows yet...
   1.166 -			newME->select("mc:");
   1.167 -			newME->load (clipboardDir+"/"+clipboardFile,ImportReplace, VymMap);
   1.168 +			m->select("mc:");
   1.169 +			m->load (clipboardDir+"/"+clipboardFile,ImportReplace, VymMap);
   1.170  		}
   1.171  
   1.172  	}
   1.173 @@ -1770,7 +1787,7 @@
   1.174  		while (i<=tabWidget->count() -1)
   1.175  		{
   1.176  			me=(MapEditor*)tabWidget->page(i);
   1.177 -			if (me->getFilePath() == fn)
   1.178 +			if (me->getModel()->getFilePath() == fn)
   1.179  			{
   1.180  				// Already there, ask for confirmation
   1.181  				QMessageBox mb( vymName,
   1.182 @@ -1809,9 +1826,11 @@
   1.183  		// Check first, if mapeditor exists
   1.184  		// If it is not default AND we want a new map, 
   1.185  		// create a new mapeditor in a new tab
   1.186 -		if ( lmode==NewMap && (!me || !me->isDefault() ) )
   1.187 +		if ( lmode==NewMap && (!me || !me->getModel()->isDefault() )  )
   1.188  		{
   1.189 -			me= new MapEditor ( NULL);
   1.190 +			VymModel *m=new VymModel;
   1.191 +			models.append (m);
   1.192 +			me= new MapEditor ( m);
   1.193  			tabWidget->addTab (me,fn);
   1.194  			tabIndex=tabWidget->indexOf (me);
   1.195  			tabWidget->setCurrentPage (tabIndex);
   1.196 @@ -1821,8 +1840,6 @@
   1.197  		
   1.198  		// Check, if file exists (important for creating new files
   1.199  		// from command line
   1.200 -		/*
   1.201 -		*/
   1.202  		if (!QFile(fn).exists() )
   1.203  		{
   1.204  			QMessageBox mb( vymName,
   1.205 @@ -1838,9 +1855,9 @@
   1.206  			{
   1.207  				case QMessageBox::Yes:
   1.208  					// Create new map
   1.209 -					currentMapEditor()->setFilePath(fn);
   1.210 +					currentMapEditor()->getModel()->setFilePath(fn);
   1.211  					tabWidget->setTabLabel (currentMapEditor(),
   1.212 -						currentMapEditor()->getFileName() );
   1.213 +						currentMapEditor()->getModel()->getFileName() );
   1.214  					statusBar()->message( "Created " + fn , statusbarTime );
   1.215  					return success;
   1.216  						
   1.217 @@ -1852,6 +1869,7 @@
   1.218  			}
   1.219  		}	
   1.220  
   1.221 +
   1.222  		//tabWidget->currentPage() won't be NULL here, because of above...
   1.223  		tabWidget->showPage(me);
   1.224  		me->viewport()->setFocus();
   1.225 @@ -1859,15 +1877,15 @@
   1.226  		if (err!=aborted)
   1.227  		{
   1.228  			// Save existing filename in case  we import
   1.229 -			QString fn_org=me->getFilePath();
   1.230 +			QString fn_org=me->getModel()->getFilePath();
   1.231  
   1.232  			// Finally load map into mapEditor
   1.233 -			me->setFilePath (fn);
   1.234 -			err=me->load(fn,lmode,ftype);
   1.235 +			me->getModel()->setFilePath (fn);
   1.236 +			err=me->getModel()->load(fn,lmode,ftype);
   1.237  
   1.238  			// Restore old (maybe empty) filepath, if this is an import
   1.239  			if (lmode!=NewMap)
   1.240 -				me->setFilePath (fn_org);
   1.241 +				me->getModel()->setFilePath (fn_org);
   1.242  		}	
   1.243  
   1.244  		// Finally check for errors and go home
   1.245 @@ -1879,13 +1897,13 @@
   1.246  		{
   1.247  			if (lmode==NewMap)
   1.248  			{
   1.249 -				me->setFilePath (fn);
   1.250 -				tabWidget->changeTab(tabWidget->page(tabIndex), me->getFileName());
   1.251 +				me->getModel()->setFilePath (fn);
   1.252 +				tabWidget->changeTab(tabWidget->page(tabIndex), me->getModel()->getFileName());
   1.253  				if (!isInTmpDir (fn))
   1.254  				{
   1.255  					// Only append to lastMaps if not loaded from a tmpDir
   1.256  					// e.g. imported bookmarks are in a tmpDir
   1.257 -					addRecentMap(me->getFilePath() );
   1.258 +					addRecentMap(me->getModel()->getFilePath() );
   1.259  				}
   1.260  				actionFilePrint->setEnabled (true);
   1.261  			}	
   1.262 @@ -1960,40 +1978,40 @@
   1.263  	setupRecentMapsMenu();
   1.264  }
   1.265  
   1.266 -void Main::fileSave(MapEditor *me, const SaveMode &savemode)
   1.267 +void Main::fileSave(VymModel *m, const SaveMode &savemode)
   1.268  {
   1.269 -	if (!me) return;
   1.270 -
   1.271 -	if ( me->getFilePath().isEmpty() ) 
   1.272 +	if (!m) return;
   1.273 +
   1.274 +	if ( m->getFilePath().isEmpty() ) 
   1.275  	{
   1.276  		// We have  no filepath yet,
   1.277  		// call fileSaveAs() now, this will call fileSave() 
   1.278  		// again.
   1.279  		// First switch to editor
   1.280 -		tabWidget->setCurrentWidget (me);
   1.281 +		tabWidget->setCurrentWidget (m->getMapEditor());
   1.282  		fileSaveAs(savemode);
   1.283  	}
   1.284  
   1.285 -	if (me->save (savemode)==success)
   1.286 +	if (m->save (savemode)==success)
   1.287  	{
   1.288  		statusBar()->message( 
   1.289 -			tr("Saved  %1").arg(me->getFilePath()), 
   1.290 +			tr("Saved  %1").arg(m->getFilePath()), 
   1.291  			statusbarTime );
   1.292 -		addRecentMap (me->getFilePath() );
   1.293 +		addRecentMap (m->getFilePath() );
   1.294  	} else		
   1.295  		statusBar()->message( 
   1.296 -			tr("Couldn't save ").arg(me->getFilePath()), 
   1.297 +			tr("Couldn't save ").arg(m->getFilePath()), 
   1.298  			statusbarTime );
   1.299  }
   1.300  
   1.301  void Main::fileSave()
   1.302  {
   1.303 -	fileSave (currentMapEditor(), CompleteMap);
   1.304 +	fileSave (currentModel(), CompleteMap);
   1.305  }
   1.306  
   1.307 -void Main::fileSave(MapEditor *me)
   1.308 +void Main::fileSave(VymModel *m)
   1.309  {
   1.310 -	fileSave (me,CompleteMap);
   1.311 +	fileSave (m,CompleteMap);
   1.312  }
   1.313  
   1.314  void Main::fileSaveAs(const SaveMode& savemode)
   1.315 @@ -2048,13 +2066,13 @@
   1.316  
   1.317  
   1.318  			// Save now
   1.319 -			currentMapEditor()->setFilePath(fn);
   1.320 -			fileSave(currentMapEditor(), savemode);
   1.321 +			currentModel()->setFilePath(fn);
   1.322 +			fileSave(currentModel(), savemode);
   1.323  
   1.324  			// Set name of tab
   1.325  			if (savemode==CompleteMap)
   1.326  				tabWidget->setTabLabel (currentMapEditor(),
   1.327 -					currentMapEditor()->getFileName() );
   1.328 +					currentModel()->getFileName() );
   1.329  			return;
   1.330  		} 
   1.331  	}
   1.332 @@ -2070,7 +2088,7 @@
   1.333  	ImportKDEBookmarks im;
   1.334  	im.transform();
   1.335  	if (success==fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() )
   1.336 -		currentMapEditor()->setFilePath ("");
   1.337 +		currentMapEditor()->getModel()->setFilePath ("");
   1.338  }
   1.339  
   1.340  void Main::fileImportFirefoxBookmarks()
   1.341 @@ -2093,7 +2111,7 @@
   1.342  			if (im.transform() && 
   1.343  				success==fileLoad (im.getTransformedFile(),NewMap,FreemindMap) && 
   1.344  				currentMapEditor() )
   1.345 -				currentMapEditor()->setFilePath ("");
   1.346 +				currentMapEditor()->getModel()->setFilePath ("");
   1.347  			++it;
   1.348  		}
   1.349  	}
   1.350 @@ -2122,7 +2140,7 @@
   1.351  			fn = *it;
   1.352  			if ( fileLoad (fn,NewMap, FreemindMap)  )
   1.353  			{	
   1.354 -				currentMapEditor()->setFilePath ("");
   1.355 +				currentMapEditor()->getModel()->setFilePath ("");
   1.356  			}	
   1.357  			++it;
   1.358  		}
   1.359 @@ -2153,80 +2171,78 @@
   1.360  			if (im.transform() && 
   1.361  				success==fileLoad (im.getTransformedFile(),NewMap) && 
   1.362  				currentMapEditor() )
   1.363 -				currentMapEditor()->setFilePath ("");
   1.364 -
   1.365 +				currentMapEditor()->getModel()->setFilePath ("");
   1.366  			++it;
   1.367  		}
   1.368  	}
   1.369  	delete (fd);
   1.370 -
   1.371  }
   1.372  
   1.373  void Main::fileImportDir()
   1.374  {
   1.375 -	if (currentMapEditor())
   1.376 -		currentMapEditor()->importDir();	
   1.377 +	VymModel *m=currentModel();
   1.378 +	if (m) m->importDir();
   1.379  }
   1.380  
   1.381  void Main::fileExportXML()	
   1.382  {
   1.383 -	MapEditor *me=currentMapEditor();
   1.384 -	if (me) me->exportXML();
   1.385 +	VymModel *m=currentModel();
   1.386 +	if (m) m->exportXML();
   1.387  }
   1.388  
   1.389  
   1.390  void Main::fileExportXHTML()	
   1.391  {
   1.392 -	MapEditor *me=currentMapEditor();
   1.393 -	if (me) me->exportXHTML();
   1.394 +	VymModel *m=currentModel();
   1.395 +	if (m) m->exportXHTML();
   1.396  }
   1.397  
   1.398  void Main::fileExportImage()	
   1.399  {
   1.400 -	MapEditor *me=currentMapEditor();
   1.401 -	if (me) me->exportImage();
   1.402 +	VymModel *m=currentModel();
   1.403 +	if (m) m->exportImage();
   1.404  }
   1.405  
   1.406  void Main::fileExportASCII()
   1.407  {
   1.408 -	MapEditor *me=currentMapEditor();
   1.409 -	if (me) me->exportASCII();
   1.410 +	VymModel *m=currentModel();
   1.411 +	if (m) m->exportASCII();
   1.412  }
   1.413  
   1.414  void Main::fileExportCSV()	//FIXME not scriptable yet
   1.415  {
   1.416 -	MapEditor *me=currentMapEditor();
   1.417 -	if (me)
   1.418 +	VymModel *m=currentModel();
   1.419 +	if (m)
   1.420  	{
   1.421  		ExportCSV ex;
   1.422 -		ex.setModel (me->getModel());
   1.423 +		ex.setModel (m);
   1.424  		ex.addFilter ("CSV (*.csv)");
   1.425  		ex.setDir(lastImageDir);
   1.426  		ex.setCaption(vymName+ " -" +tr("Export as CSV")+" "+tr("(still experimental)"));
   1.427  		if (ex.execDialog() ) 
   1.428  		{
   1.429 -			me->setExportMode(true);
   1.430 +			m->setExportMode(true);
   1.431  			ex.doExport();
   1.432 -			me->setExportMode(false);
   1.433 +			m->setExportMode(false);
   1.434  		}
   1.435  	}
   1.436  }
   1.437  
   1.438  void Main::fileExportLaTeX()	//FIXME not scriptable yet
   1.439  {
   1.440 -	MapEditor *me=currentMapEditor();
   1.441 -	if (me)
   1.442 +	VymModel *m=currentModel();
   1.443 +	if (m)
   1.444  	{
   1.445  		ExportLaTeX ex;
   1.446 -		ex.setModel (me->getModel());
   1.447 +		ex.setModel (m);
   1.448  		ex.addFilter ("Tex (*.tex)");
   1.449  		ex.setDir(lastImageDir);
   1.450  		ex.setCaption(vymName+ " -" +tr("Export as LaTeX")+" "+tr("(still experimental)"));
   1.451  		if (ex.execDialog() ) 
   1.452  		{
   1.453 -			me->setExportMode(true);
   1.454 +			m->setExportMode(true);
   1.455  			ex.doExport();
   1.456 -			me->setExportMode(false);
   1.457 +			m->setExportMode(false);
   1.458  		}
   1.459  	}
   1.460  }
   1.461 @@ -2234,10 +2250,10 @@
   1.462  void Main::fileExportKDEBookmarks()	//FIXME not scriptable yet
   1.463  {
   1.464  	ExportKDEBookmarks ex;
   1.465 -	MapEditor *me=currentMapEditor();
   1.466 -	if (me)
   1.467 +	VymModel *m=currentModel();
   1.468 +	if (m)
   1.469  	{
   1.470 -		ex.setModel (me->getModel());
   1.471 +		ex.setModel (m);
   1.472  		ex.doExport();
   1.473  	}	
   1.474  }
   1.475 @@ -2245,18 +2261,18 @@
   1.476  void Main::fileExportTaskjuggler()	//FIXME not scriptable yet
   1.477  {
   1.478  	ExportTaskjuggler ex;
   1.479 -	MapEditor *me=currentMapEditor();
   1.480 -	if (me)
   1.481 +	VymModel *m=currentModel();
   1.482 +	if (m)
   1.483  	{
   1.484 -		ex.setModel (me->getModel());
   1.485 +		ex.setModel (m);
   1.486  		ex.setCaption ( vymName+" - "+tr("Export to")+" Taskjuggler"+tr("(still experimental)"));
   1.487  		ex.setDir(lastImageDir);
   1.488  		ex.addFilter ("Taskjuggler (*.tjp)");
   1.489  		if (ex.execDialog() ) 
   1.490  		{
   1.491 -			me->setExportMode(true);
   1.492 +			m->setExportMode(true);
   1.493  			ex.doExport();
   1.494 -			me->setExportMode(false);
   1.495 +			m->setExportMode(false);
   1.496  		}
   1.497  	}	
   1.498  }
   1.499 @@ -2282,8 +2298,8 @@
   1.500  				fn +=".odp";
   1.501  
   1.502  			//lastImageDir=fn.left(fn.findRev ("/"));
   1.503 -			if (currentMapEditor())
   1.504 -				currentMapEditor()->exportOOPresentation(fn,fd->selectedConfig());	
   1.505 +			VymModel *m=currentModel();
   1.506 +			if (m) m->exportOOPresentation(fn,fd->selectedConfig());	
   1.507  		}
   1.508  	} else
   1.509  	{
   1.510 @@ -2296,12 +2312,13 @@
   1.511  void Main::fileCloseMap()
   1.512  {
   1.513  	MapEditor *me = currentMapEditor();
   1.514 -	if (me)
   1.515 +	VymModel *m=currentModel();
   1.516 +	if (m)
   1.517  	{
   1.518 -		if (me->hasChanged())
   1.519 +		if (m->hasChanged())
   1.520  		{
   1.521  			QMessageBox mb( vymName,
   1.522 -				tr("The map %1 has been modified but not saved yet. Do you want to").arg(me->getFileName()),
   1.523 +				tr("The map %1 has been modified but not saved yet. Do you want to").arg(me->getModel()->getFileName()),
   1.524  				QMessageBox::Warning,
   1.525  				QMessageBox::Yes | QMessageBox::Default,
   1.526  				QMessageBox::No,
   1.527 @@ -2312,7 +2329,7 @@
   1.528  			{
   1.529  				case QMessageBox::Yes:
   1.530  					// save and close
   1.531 -					fileSave(me, CompleteMap);
   1.532 +					fileSave(m, CompleteMap);
   1.533  					break;
   1.534  				case QMessageBox::No:
   1.535  				// close  without saving
   1.536 @@ -2322,13 +2339,12 @@
   1.537  				return;
   1.538  			}
   1.539  		} 
   1.540 -		//me->closeMap(); 
   1.541 -		tabWidget->removePage(me);
   1.542 +		//me->closeMap(); FIXME should not be necessary any longer
   1.543 +		me->close();
   1.544 +		tabWidget->removePage(m->getMapEditor());
   1.545  		if (tabWidget->count()==0)
   1.546  			actionFilePrint->setEnabled (false);
   1.547 -
   1.548 -        //delete me;
   1.549 -		me->clear();
   1.550 +        delete me;
   1.551  	}
   1.552  }
   1.553  
   1.554 @@ -2349,7 +2365,7 @@
   1.555  		me=(MapEditor*)tabWidget->page(i);
   1.556  
   1.557  		// If something changed, ask what to do
   1.558 -		if (me->hasChanged())
   1.559 +		if (me->getModel()->hasChanged())
   1.560  		{
   1.561  			tabWidget->setCurrentPage(i);
   1.562  			QMessageBox mb( vymName,
   1.563 @@ -2366,7 +2382,7 @@
   1.564  			switch( mb.exec() ) {
   1.565  				case QMessageBox::Yes:
   1.566  					// save (the changed editors) and exit
   1.567 -					fileSave(currentMapEditor(), CompleteMap);
   1.568 +					fileSave(currentModel(), CompleteMap);
   1.569  					break;
   1.570  				case QMessageBox::No:
   1.571  					// exit without saving
   1.572 @@ -2382,38 +2398,38 @@
   1.573  
   1.574  void Main::editUndo()
   1.575  {
   1.576 -	if (currentMapEditor())
   1.577 -		currentMapEditor()->undo();
   1.578 +	VymModel *m=currentModel();
   1.579 +	if (m) m->undo();
   1.580  }
   1.581  
   1.582  void Main::editRedo()	   
   1.583  {
   1.584 -	if (currentMapEditor())
   1.585 -		currentMapEditor()->redo();
   1.586 +	VymModel *m=currentModel();
   1.587 +	if (m) m->redo();
   1.588  }
   1.589  
   1.590  void Main::gotoHistoryStep (int i)	   
   1.591  {
   1.592 -	if (currentMapEditor())
   1.593 -		currentMapEditor()->gotoHistoryStep (i);
   1.594 +	VymModel *m=currentModel();
   1.595 +	if (m) m->gotoHistoryStep(i);
   1.596  }
   1.597  
   1.598  void Main::editCopy()
   1.599  {
   1.600 -	if (currentMapEditor())
   1.601 -		currentMapEditor()->copy();
   1.602 +	VymModel *m=currentModel();
   1.603 +	if (m) m->copy();
   1.604  }
   1.605  
   1.606  void Main::editPaste()
   1.607  {
   1.608 -	if (currentMapEditor())
   1.609 -		currentMapEditor()->paste();
   1.610 +	VymModel *m=currentModel();
   1.611 +	if (m) m->paste();
   1.612  }
   1.613  
   1.614  void Main::editCut()
   1.615  {
   1.616 -	if (currentMapEditor())
   1.617 -		currentMapEditor()->cut();
   1.618 +	VymModel *m=currentModel();
   1.619 +	if (m) m->cut();
   1.620  }
   1.621  
   1.622  void Main::editOpenFindWindow()
   1.623 @@ -2425,21 +2441,26 @@
   1.624  
   1.625  void Main::editFind(QString s)
   1.626  {
   1.627 -	bool cs=false;
   1.628 -	BranchObj *bo=currentMapEditor()->findText(s, cs);
   1.629 -	if (bo)
   1.630 -	{	
   1.631 -		statusBar()->message( "Found: " + bo->getHeading(), statusbarTime );
   1.632 -	} else
   1.633 +	VymModel *m=currentModel();
   1.634 +	if (m)
   1.635  	{
   1.636 -		QMessageBox::information( findWindow, tr( "VYM -Information:" ),
   1.637 -							   tr("No matches found for \"%1\"").arg(s));
   1.638 -	}	
   1.639 +		bool cs=false;
   1.640 +		BranchObj *bo=m->findText(s, cs);
   1.641 +		if (bo)
   1.642 +		{	
   1.643 +			statusBar()->message( "Found: " + bo->getHeading(), statusbarTime );
   1.644 +		} else
   1.645 +		{
   1.646 +			QMessageBox::information( findWindow, tr( "VYM -Information:" ),
   1.647 +								   tr("No matches found for \"%1\"").arg(s));
   1.648 +		}	
   1.649 +	}
   1.650  }
   1.651  
   1.652  void Main::editFindChanged()
   1.653  {	// Notify editor, to abort the current find process
   1.654 -	currentMapEditor()->findReset();
   1.655 +	VymModel *m=currentModel();
   1.656 +	if (m) m->findReset();
   1.657  }
   1.658  
   1.659  void Main::openTabs(QStringList urls)
   1.660 @@ -2527,9 +2548,10 @@
   1.661  void Main::editOpenURL()
   1.662  {
   1.663  	// Open new browser
   1.664 -	if (currentMapEditor())
   1.665 +	VymModel *m=currentModel();
   1.666 +	if (m)
   1.667  	{	
   1.668 -	    QString url=currentMapEditor()->getURL();
   1.669 +	    QString url=m->getURL();
   1.670  		QStringList args;
   1.671  		if (url=="") return;
   1.672  		QString browser=settings.value("/mainwindow/readerURL" ).toString();
   1.673 @@ -2549,19 +2571,21 @@
   1.674  }
   1.675  void Main::editOpenURLTab()
   1.676  {
   1.677 -	if (currentMapEditor())
   1.678 +	VymModel *m=currentModel();
   1.679 +	if (m)
   1.680  	{	
   1.681  	    QStringList urls;
   1.682 -		urls.append(currentMapEditor()->getURL());
   1.683 +		urls.append(m->getURL());
   1.684  		openTabs (urls);
   1.685  	}	
   1.686  }
   1.687  void Main::editOpenMultipleURLTabs()
   1.688  {
   1.689 -	if (currentMapEditor())
   1.690 +	VymModel *m=currentModel();
   1.691 +	if (m)
   1.692  	{	
   1.693  	    QStringList urls;
   1.694 -		urls=currentMapEditor()->getURLs();
   1.695 +		urls=m->getURLs();
   1.696  		openTabs (urls);
   1.697  	}	
   1.698  }
   1.699 @@ -2569,49 +2593,58 @@
   1.700  
   1.701  void Main::editURL()
   1.702  {
   1.703 -	if (currentMapEditor())
   1.704 -	    currentMapEditor()->editURL();
   1.705 +	VymModel *m=currentModel();
   1.706 +	if (m) m->editURL();
   1.707  }
   1.708  
   1.709  void Main::editLocalURL()
   1.710  {
   1.711 -	if (currentMapEditor())
   1.712 -	    currentMapEditor()->editLocalURL();
   1.713 +	VymModel *m=currentModel();
   1.714 +	if (m) m->editLocalURL();
   1.715  }
   1.716  
   1.717  void Main::editHeading2URL()
   1.718  {
   1.719 -	if (currentMapEditor())
   1.720 -	    currentMapEditor()->editHeading2URL();
   1.721 +	VymModel *m=currentModel();
   1.722 +	if (m) m->editHeading2URL();
   1.723  }
   1.724  
   1.725  void Main::editBugzilla2URL()
   1.726  {
   1.727 -	if (currentMapEditor())
   1.728 -	    currentMapEditor()->editBugzilla2URL();
   1.729 +	VymModel *m=currentModel();
   1.730 +	if (m) m->editBugzilla2URL();
   1.731  }
   1.732  
   1.733  void Main::editFATE2URL()
   1.734  {
   1.735 -	if (currentMapEditor())
   1.736 -	    currentMapEditor()->editFATE2URL();
   1.737 +	VymModel *m=currentModel();
   1.738 +	if (m) m->editFATE2URL();
   1.739  }
   1.740  
   1.741 -void Main::editHeadingFinished()
   1.742 +void Main::editHeadingFinished(VymModel *m)
   1.743  {
   1.744 +	if (m)
   1.745 +	{
   1.746 +		if (!actionSettingsAutoSelectNewBranch->isOn() && 
   1.747 +			!prevSelection.isEmpty()) 
   1.748 +			m->select(prevSelection);
   1.749 +		prevSelection="";
   1.750 +	}
   1.751 +
   1.752 +/* FIXME old code, remove now
   1.753  	// only called from editHeading(), so there is a currentME
   1.754 -	MapEditor *me=currentMapEditor();
   1.755 -	if (me)
   1.756 +	VymModel *m=currentModel();
   1.757 +	if (m)
   1.758  	{
   1.759 -		me->setStateEditHeading (false);
   1.760 +		m->setSelectionBlocked (false);
   1.761  		QPoint p;	//Not used here, only to find out pos of branch
   1.762  		bool ok;
   1.763 -		QString s=me->getHeading(ok,p);
   1.764 +		QString s=m->getHeading(ok,p);
   1.765  
   1.766  #if defined(Q_OS_MACX) || defined(Q_OS_WIN32)
   1.767  #else
   1.768  		if (ok && s!=lineedit->text())
   1.769 -			me->setHeading(lineedit->text());
   1.770 +			m->setHeading(lineedit->text());
   1.771  			
   1.772  		lineedit->releaseKeyboard();
   1.773  		lineedit->hide();
   1.774 @@ -2619,17 +2652,20 @@
   1.775  #endif	
   1.776  		if (!actionSettingsAutoSelectNewBranch->isOn() && 
   1.777  			!prevSelection.isEmpty()) 
   1.778 -			me->select(prevSelection);
   1.779 +			m->select(prevSelection);
   1.780  		prevSelection="";
   1.781  	}
   1.782 +*/
   1.783  }
   1.784  
   1.785 +/*
   1.786  void Main::editHeading()
   1.787  {
   1.788 -	if (currentMapEditor())
   1.789 +	MapEditor *me=currentMapEditor();
   1.790 +	VymModel *m=currentModel();
   1.791 +	if (me && m)
   1.792  	{
   1.793 -		MapEditor *me=currentMapEditor();
   1.794 -		QString oldSel=me->getSelectString();
   1.795 +		QString oldSel=m->getSelectString();
   1.796  
   1.797  		if (lineedit->isVisible())
   1.798  			editHeadingFinished();
   1.799 @@ -2637,11 +2673,11 @@
   1.800  		{
   1.801  			bool ok;
   1.802  			QPoint p;
   1.803 -			QString s=me->getHeading(ok,p);
   1.804 +			QString s=m->getHeading(ok,p);
   1.805  
   1.806  			if (ok)
   1.807  			{
   1.808 -				me->setStateEditHeading (true);
   1.809 +				m->setSelectionBlocked(true);
   1.810  #if defined(Q_OS_MACX) || defined(Q_OS_WIN32)
   1.811  				p=me->mapToGlobal (p);
   1.812  				QDialog *d =new QDialog(NULL);
   1.813 @@ -2654,7 +2690,7 @@
   1.814  				connect (le, SIGNAL (returnPressed()), d, SLOT (accept()));
   1.815  				d->activateWindow();
   1.816  				d->exec();
   1.817 -				me->setHeading (le->text());
   1.818 +				m->setHeading (le->text());
   1.819  				delete (le);
   1.820  				delete (d);
   1.821  				editHeadingFinished();
   1.822 @@ -2670,8 +2706,9 @@
   1.823  #endif
   1.824  			}
   1.825  		}
   1.826 -	} // currentMapEditor()	
   1.827 +	}
   1.828  }
   1.829 +*/	
   1.830  
   1.831  void Main::editAttributeFinished()
   1.832  {
   1.833 @@ -2707,10 +2744,11 @@
   1.834  #include "attributedialog.h"
   1.835  void Main::editAttribute()
   1.836  {
   1.837 +/*
   1.838  	MapEditor *me=currentMapEditor();
   1.839  	if (me)
   1.840  	{
   1.841 -		BranchObj *bo=me->getSelectedBranch();
   1.842 +		BranchObj *bo=me->getModel()->getSelectedBranch();
   1.843  		if (bo)
   1.844  		{
   1.845  			AttributeDialog dia(this);
   1.846 @@ -2721,6 +2759,7 @@
   1.847  			dia.exec();
   1.848  		}
   1.849  	}	
   1.850 +	*/
   1.851  	/*
   1.852  	if (currentMapEditor())
   1.853  	{
   1.854 @@ -2782,7 +2821,7 @@
   1.855  		for (i=0;i<=tabWidget->count() -1;i++)
   1.856  		{
   1.857  			me=(MapEditor*)tabWidget->page(i);
   1.858 -			if (vl.at(j)==me->getFilePath() )
   1.859 +			if (vl.at(j)==me->getModel()->getFilePath() )
   1.860  			{
   1.861  				index=i;
   1.862  				break;
   1.863 @@ -2807,10 +2846,11 @@
   1.864  
   1.865  void Main::editOpenVymLink()
   1.866  {
   1.867 -	if (currentMapEditor())
   1.868 +	VymModel *m=currentModel();
   1.869 +	if (m)
   1.870  	{
   1.871  		QStringList vl;
   1.872 -		vl.append(currentMapEditor()->getVymLink());	
   1.873 +		vl.append(m->getVymLink());	
   1.874  		openVymLinks (vl);
   1.875  	}
   1.876  }
   1.877 @@ -2818,168 +2858,204 @@
   1.878  void Main::editOpenMultipleVymLinks()
   1.879  {
   1.880  	QString currentVymLink;
   1.881 -	if (currentMapEditor())
   1.882 +	VymModel *m=currentModel();
   1.883 +	if (m)
   1.884  	{
   1.885 -		QStringList vl=currentMapEditor()->getVymLinks();
   1.886 +		QStringList vl=m->getVymLinks();
   1.887  		openVymLinks (vl);
   1.888  	}
   1.889  }
   1.890  
   1.891  void Main::editVymLink()
   1.892  {
   1.893 -	if (currentMapEditor())
   1.894 -		currentMapEditor()->editVymLink();	
   1.895 +	VymModel *m=currentModel();
   1.896 +	if (m)
   1.897 +		m->editVymLink();	
   1.898  }
   1.899  
   1.900  void Main::editDeleteVymLink()
   1.901  {
   1.902 -	if (currentMapEditor())
   1.903 -		currentMapEditor()->deleteVymLink();	
   1.904 +	VymModel *m=currentModel();
   1.905 +	if (m) m->deleteVymLink();	
   1.906  }
   1.907  
   1.908  void Main::editToggleHideExport()
   1.909  {
   1.910 -	if (currentMapEditor())
   1.911 -		currentMapEditor()->toggleHideExport();	
   1.912 +	VymModel *m=currentModel();
   1.913 +	if (m) m->toggleHideExport();	
   1.914  }
   1.915  
   1.916  void Main::editMapInfo()
   1.917  {
   1.918 -	if (currentMapEditor())
   1.919 -		currentMapEditor()->editMapInfo();	
   1.920 +	VymModel *m=currentModel();
   1.921 +
   1.922 +	ExtraInfoDialog dia;
   1.923 +	dia.setMapName (m->getFileName() );
   1.924 +	dia.setAuthor (m->getAuthor() );
   1.925 +	dia.setComment(m->getComment() );
   1.926 +
   1.927 +/* FIXME no stats at the moment (view dependent...)
   1.928 +	// Calc some stats
   1.929 +	QString stats;
   1.930 +    stats+=tr("%1 items on map\n","Info about map").arg (mapScene->items().size(),6);
   1.931 +
   1.932 +	uint b=0;
   1.933 +	uint f=0;
   1.934 +	uint n=0;
   1.935 +	uint xl=0;
   1.936 +	BranchObj *bo;
   1.937 +	bo=m->first();
   1.938 +	while (bo) 
   1.939 +	{
   1.940 +		if (!bo->getNote().isEmpty() ) n++;
   1.941 +		f+= bo->countFloatImages();
   1.942 +		b++;
   1.943 +		xl+=bo->countXLinks();
   1.944 +		bo=m->next(bo);
   1.945 +	}
   1.946 +    stats+=QString ("%1 branches\n").arg (b-1,6);
   1.947 +    stats+=QString ("%1 xLinks \n").arg (xl,6);
   1.948 +    stats+=QString ("%1 notes\n").arg (n,6);
   1.949 +    stats+=QString ("%1 images\n").arg (f,6);
   1.950 +	dia.setStats (stats);
   1.951 +
   1.952 +*/
   1.953 +	// Finally show dialog
   1.954 +	if (dia.exec() == QDialog::Accepted)
   1.955 +	{
   1.956 +		m->setAuthor (dia.getAuthor() );
   1.957 +		m->setComment (dia.getComment() );
   1.958 +	}
   1.959  }
   1.960  
   1.961  void Main::editMoveUp()
   1.962  {
   1.963 -	if (currentMapEditor())
   1.964 -	    currentMapEditor()->moveBranchUp();
   1.965 +	VymModel *m=currentModel();
   1.966 +	if (m) m->moveBranchUp();
   1.967  }
   1.968  
   1.969  void Main::editMoveDown()
   1.970  {
   1.971 -	if (currentMapEditor())
   1.972 -		currentMapEditor()->moveBranchDown();
   1.973 +	VymModel *m=currentModel();
   1.974 +	if (m) m->moveBranchDown();
   1.975  }
   1.976  
   1.977  void Main::editSortChildren()
   1.978  {
   1.979 -	if (currentMapEditor())
   1.980 -		currentMapEditor()->sortChildren();
   1.981 +	VymModel *m=currentModel();
   1.982 +	if (m) m->sortChildren();
   1.983  }
   1.984  
   1.985  void Main::editToggleScroll()
   1.986  {
   1.987 -	if (currentMapEditor())
   1.988 +	VymModel *m=currentModel();
   1.989 +	if (m) m->toggleScroll();
   1.990 +}
   1.991 +
   1.992 +void Main::editUnscrollChildren()
   1.993 +{
   1.994 +	VymModel *m=currentModel();
   1.995 +	if (m) m->unscrollChildren();
   1.996 +}
   1.997 +
   1.998 +void Main::editAddMapCenter()
   1.999 +{
  1.1000 +	VymModel *m=currentModel();
  1.1001 +	if (!lineedit->isVisible() && m)
  1.1002  	{
  1.1003 -		currentMapEditor()->toggleScroll();	
  1.1004 +		m->addMapCenter ();
  1.1005  	}	
  1.1006  }
  1.1007  
  1.1008 -void Main::editUnscrollChilds()
  1.1009 -{
  1.1010 -	if (currentMapEditor())
  1.1011 -		currentMapEditor()->unscrollChilds();	
  1.1012 -}
  1.1013 -
  1.1014 -void Main::editAddMapCenter()
  1.1015 -{
  1.1016 -	MapEditor *me=currentMapEditor();
  1.1017 -	if (!lineedit->isVisible() && me)
  1.1018 -	{
  1.1019 -		me->addMapCenter ();
  1.1020 -	}	
  1.1021 -}
  1.1022 -
  1.1023  void Main::editNewBranch()
  1.1024  {
  1.1025 -	MapEditor *me=currentMapEditor();
  1.1026 -	if (!lineedit->isVisible() && me)
  1.1027 +	VymModel *m=currentModel();
  1.1028 +	if (!lineedit->isVisible() && m)
  1.1029  	{
  1.1030 -		BranchObj *bo=(BranchObj*)me->getSelection();
  1.1031 -		BranchObj *newbo=me->addNewBranch(0);
  1.1032 -
  1.1033 -		prevSelection=me->getModel()->getSelectString(bo);
  1.1034 +		BranchObj *bo=(BranchObj*)m->getSelection();
  1.1035 +		BranchObj *newbo=m->addNewBranch(0);
  1.1036 +
  1.1037 +		prevSelection=m->getSelectString(bo);
  1.1038  		if (newbo) 
  1.1039 -			me->select (newbo);
  1.1040 +			m->select (newbo);
  1.1041  		else
  1.1042  			return;
  1.1043  
  1.1044  		if (actionSettingsAutoEditNewBranch->isOn())
  1.1045  		{
  1.1046 -			editHeading();
  1.1047 +			currentMapEditor()->editHeading();
  1.1048  			return;
  1.1049  		}	
  1.1050  		if (!prevSelection.isEmpty()) 
  1.1051  		{
  1.1052 -			me->select(prevSelection);
  1.1053 +			m->select(prevSelection);
  1.1054  			prevSelection="";
  1.1055  		}
  1.1056 -
  1.1057  	}	
  1.1058  }
  1.1059  
  1.1060  void Main::editNewBranchBefore()
  1.1061  {
  1.1062 -	MapEditor *me=currentMapEditor();
  1.1063 -	if (!lineedit->isVisible() && me)
  1.1064 +	VymModel *m=currentModel();
  1.1065 +	if (!lineedit->isVisible() &&  m)
  1.1066  	{
  1.1067 -		BranchObj *bo=(BranchObj*)me->getSelection();
  1.1068 -		BranchObj *newbo=me->addNewBranchBefore();
  1.1069 +		BranchObj *bo=(BranchObj*)m->getSelection();
  1.1070 +		BranchObj *newbo=m->addNewBranchBefore();
  1.1071  
  1.1072  		if (newbo) 
  1.1073 -			me->select (newbo);
  1.1074 +			m->select (newbo);
  1.1075  		else
  1.1076  			return;
  1.1077  
  1.1078  		if (actionSettingsAutoEditNewBranch->isOn())
  1.1079  		{
  1.1080  			if (!actionSettingsAutoSelectNewBranch->isOn())
  1.1081 -				prevSelection=me->getModel()->getSelectString(bo); //TODO access directly
  1.1082 -			editHeading();
  1.1083 +				prevSelection=m->getSelectString(bo); 
  1.1084 +			currentMapEditor()->editHeading();
  1.1085  		}
  1.1086  	}	
  1.1087  }
  1.1088  
  1.1089  void Main::editNewBranchAbove()
  1.1090  {
  1.1091 -	MapEditor *me=currentMapEditor();
  1.1092 -	if (!lineedit->isVisible() && me)
  1.1093 +	VymModel *m=currentModel();
  1.1094 +	if (!lineedit->isVisible() &&  m)
  1.1095  	{
  1.1096 -		BranchObj *bo=(BranchObj*)me->getSelection();
  1.1097 -		BranchObj *newbo=me->addNewBranch (-1);
  1.1098 +		BranchObj *bo=(BranchObj*)m->getSelection();
  1.1099 +		BranchObj *newbo=m->addNewBranch (-1);
  1.1100  
  1.1101  		if (newbo) 
  1.1102 -			me->select (newbo);
  1.1103 +			m->select (newbo);
  1.1104  		else
  1.1105  			return;
  1.1106  
  1.1107  		if (actionSettingsAutoEditNewBranch->isOn())
  1.1108  		{
  1.1109  			if (!actionSettingsAutoSelectNewBranch->isOn())
  1.1110 -				prevSelection=me->getModel()->getSelectString (bo);	// TODO access directly
  1.1111 -			editHeading();
  1.1112 +				prevSelection=m->getSelectString (bo);	
  1.1113 +			currentMapEditor()->editHeading();
  1.1114  		}
  1.1115  	}	
  1.1116  }
  1.1117  
  1.1118  void Main::editNewBranchBelow()
  1.1119  {
  1.1120 -	MapEditor *me=currentMapEditor();
  1.1121 -	if (!lineedit->isVisible() && me)
  1.1122 +	VymModel *m=currentModel();
  1.1123 +	if (!lineedit->isVisible() &&  m)
  1.1124  	{
  1.1125 -		BranchObj *bo=(BranchObj*)me->getSelection();
  1.1126 -		BranchObj *newbo=me->addNewBranch (1);
  1.1127 +		BranchObj *bo=(BranchObj*)m->getSelection();
  1.1128 +		BranchObj *newbo=m->addNewBranch (1);
  1.1129  
  1.1130  		if (newbo) 
  1.1131 -			me->select (newbo);
  1.1132 +			m->select (newbo);
  1.1133  		else
  1.1134  			return;
  1.1135  
  1.1136  		if (actionSettingsAutoEditNewBranch->isOn())
  1.1137  		{
  1.1138  			if (!actionSettingsAutoSelectNewBranch->isOn())
  1.1139 -				prevSelection=me->getModel()->getSelectString(bo);	//TODO access directly
  1.1140 -			editHeading();
  1.1141 +				prevSelection=m->getSelectString(bo);
  1.1142 +			currentMapEditor()->editHeading();
  1.1143  		}
  1.1144  	}	
  1.1145  }
  1.1146 @@ -2999,99 +3075,100 @@
  1.1147  	fileSaveAs (PartOfMap);
  1.1148  }
  1.1149  
  1.1150 -void Main::editDeleteKeepChilds()
  1.1151 +void Main::editDeleteKeepChildren()
  1.1152  {
  1.1153 -	if (currentMapEditor())
  1.1154 -		currentMapEditor()->deleteKeepChilds();
  1.1155 +	VymModel *m=currentModel();
  1.1156 +	 if (m) m->deleteKeepChildren();
  1.1157  }
  1.1158  
  1.1159 -void Main::editDeleteChilds()
  1.1160 +void Main::editDeleteChildren()
  1.1161  {
  1.1162 -	if (currentMapEditor())
  1.1163 -		currentMapEditor()->deleteChilds();
  1.1164 +	VymModel *m=currentModel();
  1.1165 +	if (m) m->deleteChildren();
  1.1166  }
  1.1167  
  1.1168  void Main::editDeleteSelection()
  1.1169  {
  1.1170 -	if (currentMapEditor() && actionSettingsUseDelKey->isOn())
  1.1171 -		currentMapEditor()->deleteSelection();
  1.1172 +	VymModel *m=currentModel();
  1.1173 +	if (m && actionSettingsUseDelKey->isOn())
  1.1174 +		m->deleteSelection();
  1.1175  }
  1.1176  
  1.1177  void Main::editUpperBranch()
  1.1178  {
  1.1179 -	if (currentMapEditor())
  1.1180 -		currentMapEditor()->selectUpperBranch();
  1.1181 +	VymModel *m=currentModel();
  1.1182 +	if (m) m->selectUpperBranch();
  1.1183  }
  1.1184  
  1.1185  void Main::editLowerBranch()
  1.1186  {
  1.1187 -	if (currentMapEditor())
  1.1188 -		currentMapEditor()->selectLowerBranch();
  1.1189 +	VymModel *m=currentModel();
  1.1190 +	if (m) m->selectLowerBranch();
  1.1191  }
  1.1192  
  1.1193  void Main::editLeftBranch()
  1.1194  {
  1.1195 -	if (currentMapEditor())
  1.1196 -		currentMapEditor()->selectLeftBranch();
  1.1197 +	VymModel *m=currentModel();
  1.1198 +	if (m) m->selectLeftBranch();
  1.1199  }
  1.1200  
  1.1201  void Main::editRightBranch()
  1.1202  {
  1.1203 -	if (currentMapEditor())
  1.1204 -		currentMapEditor()->selectRightBranch();
  1.1205 +	VymModel *m=currentModel();
  1.1206 +	if (m) m->selectRightBranch();
  1.1207  }
  1.1208  
  1.1209  void Main::editFirstBranch()
  1.1210  {
  1.1211 -	if (currentMapEditor())
  1.1212 -		currentMapEditor()->selectFirstBranch();
  1.1213 +	VymModel *m=currentModel();
  1.1214 +	if (m) m->selectFirstBranch();
  1.1215  }
  1.1216  
  1.1217  void Main::editLastBranch()
  1.1218  {
  1.1219 -	if (currentMapEditor())
  1.1220 -		currentMapEditor()->selectLastBranch();
  1.1221 +	VymModel *m=currentModel();
  1.1222 +	if (m) m->selectLastBranch();
  1.1223  }
  1.1224  
  1.1225  void Main::editLoadImage()
  1.1226  {
  1.1227 -	if (currentMapEditor())
  1.1228 -		currentMapEditor()->loadFloatImage();
  1.1229 +	VymModel *m=currentModel();
  1.1230 +	if (m) m->loadFloatImage();
  1.1231  }
  1.1232  
  1.1233  void Main::editSaveImage()
  1.1234  {
  1.1235 -	if (currentMapEditor())
  1.1236 -		currentMapEditor()->saveFloatImage();
  1.1237 +	VymModel *m=currentModel();
  1.1238 +	if (m) m->saveFloatImage();
  1.1239  }
  1.1240  
  1.1241  void Main::editFollowXLink(QAction *a)
  1.1242  {
  1.1243  
  1.1244 -	if (currentMapEditor())
  1.1245 -		currentMapEditor()->followXLink(branchXLinksContextMenuFollow->actions().indexOf(a));
  1.1246 +	VymModel *m=currentModel();
  1.1247 +	if (m)
  1.1248 +		m->followXLink(branchXLinksContextMenuFollow->actions().indexOf(a));
  1.1249  }
  1.1250  
  1.1251  void Main::editEditXLink(QAction *a)
  1.1252  {
  1.1253 -	if (currentMapEditor())
  1.1254 -		currentMapEditor()->editXLink(branchXLinksContextMenuEdit->actions().indexOf(a));
  1.1255 +	VymModel *m=currentModel();
  1.1256 +	if (m)
  1.1257 +		m->editXLink(branchXLinksContextMenuEdit->actions().indexOf(a));
  1.1258  }
  1.1259  
  1.1260  void Main::formatSelectColor()
  1.1261  {
  1.1262 -	if (currentMapEditor())
  1.1263 -	{
  1.1264 -		QColor col = QColorDialog::getColor((currentColor ), this );
  1.1265 -		if ( !col.isValid() ) return;
  1.1266 -		colorChanged( col );
  1.1267 -	}	
  1.1268 +	QColor col = QColorDialog::getColor((currentColor ), this );
  1.1269 +	if ( !col.isValid() ) return;
  1.1270 +	colorChanged( col );
  1.1271  }
  1.1272  
  1.1273  void Main::formatPickColor()
  1.1274  {
  1.1275 -	if (currentMapEditor())
  1.1276 -		colorChanged( currentMapEditor()->getCurrentHeadingColor() );
  1.1277 +	VymModel *m=currentModel();
  1.1278 +	if (m)
  1.1279 +		colorChanged( m->getCurrentHeadingColor() );
  1.1280  }
  1.1281  
  1.1282  void Main::colorChanged(QColor c)
  1.1283 @@ -3104,86 +3181,102 @@
  1.1284  
  1.1285  void Main::formatColorBranch()
  1.1286  {
  1.1287 -	if (currentMapEditor())
  1.1288 -		currentMapEditor()->colorBranch(currentColor);
  1.1289 +	VymModel *m=currentModel();
  1.1290 +	if (m) m->colorBranch(currentColor);
  1.1291  }
  1.1292  
  1.1293  void Main::formatColorSubtree()
  1.1294  {
  1.1295 -	if (currentMapEditor())
  1.1296 -		currentMapEditor()->colorSubtree (currentColor);
  1.1297 +	VymModel *m=currentModel();
  1.1298 +	if (m) m->colorSubtree (currentColor);
  1.1299  }
  1.1300  
  1.1301  void Main::formatLinkStyleLine()
  1.1302  {
  1.1303 -	if (currentMapEditor())
  1.1304 +	VymModel *m=currentModel();
  1.1305 +	if (m)
  1.1306      {
  1.1307 -		currentMapEditor()->setMapLinkStyle("StyleLine");
  1.1308 +		m->setMapLinkStyle("StyleLine");
  1.1309          actionFormatLinkStyleLine->setOn(true);
  1.1310      }
  1.1311  }
  1.1312  
  1.1313  void Main::formatLinkStyleParabel()
  1.1314  {
  1.1315 -	if (currentMapEditor())
  1.1316 +	VymModel *m=currentModel();
  1.1317 +	if (m)
  1.1318      {
  1.1319 -		currentMapEditor()->setMapLinkStyle("StyleParabel");
  1.1320 +		m->setMapLinkStyle("StyleParabel");
  1.1321          actionFormatLinkStyleParabel->setOn(true);
  1.1322      }
  1.1323  }
  1.1324  
  1.1325  void Main::formatLinkStylePolyLine()
  1.1326  {
  1.1327 -	if (currentMapEditor())
  1.1328 +	VymModel *m=currentModel();
  1.1329 +	if (m)
  1.1330      {
  1.1331 -		currentMapEditor()->setMapLinkStyle("StylePolyLine");
  1.1332 +		m->setMapLinkStyle("StylePolyLine");
  1.1333          actionFormatLinkStylePolyLine->setOn(true);
  1.1334      }
  1.1335  }
  1.1336  
  1.1337  void Main::formatLinkStylePolyParabel()
  1.1338  {
  1.1339 -	if (currentMapEditor())
  1.1340 +	VymModel *m=currentModel();
  1.1341 +	if (m)
  1.1342      {
  1.1343 -		currentMapEditor()->setMapLinkStyle("StylePolyParabel");
  1.1344 +		m->setMapLinkStyle("StylePolyParabel");
  1.1345          actionFormatLinkStylePolyParabel->setOn(true);
  1.1346      }
  1.1347  }
  1.1348  
  1.1349  void Main::formatSelectBackColor()
  1.1350  {
  1.1351 -	if (currentMapEditor())
  1.1352 -		currentMapEditor()->selectMapBackgroundColor();
  1.1353 +	VymModel *m=currentModel();
  1.1354 +	if (m) m->selectMapBackgroundColor();
  1.1355  }
  1.1356  
  1.1357  void Main::formatSelectBackImage()
  1.1358  {
  1.1359 -	if (currentMapEditor())
  1.1360 -		currentMapEditor()->selectMapBackgroundImage();
  1.1361 +	VymModel *m=currentModel();
  1.1362 +	if (m)
  1.1363 +		m->selectMapBackgroundImage();
  1.1364  }
  1.1365  
  1.1366  void Main::formatSelectLinkColor()
  1.1367  {
  1.1368 -	if (currentMapEditor())
  1.1369 -		currentMapEditor()->selectMapLinkColor();
  1.1370 +	VymModel *m=currentModel();
  1.1371 +	if (m)
  1.1372 +	{
  1.1373 +		QColor col = QColorDialog::getColor( m->getMapDefLinkColor(), this );
  1.1374 +		m->setMapDefLinkColor( col );
  1.1375 +	}
  1.1376  }
  1.1377  
  1.1378  void Main::formatSelectSelectionColor()
  1.1379  {
  1.1380 -	if (currentMapEditor())
  1.1381 -		currentMapEditor()->selectMapSelectionColor();
  1.1382 +	VymModel *m=currentModel();
  1.1383 +	if (m)
  1.1384 +	{
  1.1385 +		QColor col = QColorDialog::getColor( m->getMapDefLinkColor(), this );
  1.1386 +		m->setSelectionColor (col);
  1.1387 +	}
  1.1388 +
  1.1389  }
  1.1390  
  1.1391  void Main::formatToggleLinkColorHint()
  1.1392  {
  1.1393 -	currentMapEditor()->toggleMapLinkColorHint();
  1.1394 +	VymModel *m=currentModel();
  1.1395 +	if (m) m->toggleMapLinkColorHint();
  1.1396  }
  1.1397  
  1.1398  
  1.1399  void Main::formatHideLinkUnselected()	//FIXME get rid of this with imagepropertydialog
  1.1400  {
  1.1401 -	if (currentMapEditor())
  1.1402 -		currentMapEditor()->setHideLinkUnselected(actionFormatHideLinkUnselected->isOn());
  1.1403 +	VymModel *m=currentModel();
  1.1404 +	if (m)
  1.1405 +		m->setHideLinkUnselected(actionFormatHideLinkUnselected->isOn());
  1.1406  }
  1.1407  
  1.1408  void Main::viewZoomReset()
  1.1409 @@ -3218,23 +3311,20 @@
  1.1410  
  1.1411  void Main::viewCenter()
  1.1412  {
  1.1413 -	MapEditor *me=currentMapEditor();
  1.1414 -	if (me)
  1.1415 -	{
  1.1416 -		me->ensureSelectionVisible();
  1.1417 -	}	
  1.1418 +	VymModel *m=currentModel();
  1.1419 +	if (m) m->ensureSelectionVisible();
  1.1420  }
  1.1421  
  1.1422  void Main::networkStartServer()
  1.1423  {
  1.1424 -	MapEditor *me=currentMapEditor();
  1.1425 -	if (me) me->newServer();
  1.1426 +	VymModel *m=currentModel();
  1.1427 +	if (m) m->newServer();
  1.1428  }
  1.1429  
  1.1430  void Main::networkConnect()
  1.1431  {
  1.1432 -	MapEditor *me=currentMapEditor();
  1.1433 -	if (me) me->connectToServer();
  1.1434 +	VymModel *m=currentModel();
  1.1435 +	if (m) m->connectToServer();
  1.1436  }
  1.1437  
  1.1438  bool Main::settingsPDF()
  1.1439 @@ -3352,19 +3442,7 @@
  1.1440  		branchPropertyWindow->hide();
  1.1441  	else	
  1.1442  		branchPropertyWindow->show();
  1.1443 -
  1.1444 -	if(currentMapEditor())
  1.1445 -	{
  1.1446 -		BranchObj *bo=currentMapEditor()->getSelectedBranch();
  1.1447 -		if (bo) 
  1.1448 -		{
  1.1449 -			branchPropertyWindow->setMapEditor(currentMapEditor());
  1.1450 -			branchPropertyWindow->setBranch(bo);
  1.1451 -			return;
  1.1452 -		}
  1.1453 -		
  1.1454 -	}	
  1.1455 -	branchPropertyWindow->setBranch(NULL);
  1.1456 +	branchPropertyWindow->setModel (currentModel() );
  1.1457  }
  1.1458  
  1.1459  void Main::windowToggleAntiAlias()
  1.1460 @@ -3373,7 +3451,6 @@
  1.1461  	MapEditor *me;
  1.1462  	for (int i=0;i<tabWidget->count();i++)
  1.1463  	{
  1.1464 -		
  1.1465  		me=(MapEditor*)tabWidget->page(i);
  1.1466  		me->setAntiAlias(b);
  1.1467  	}	
  1.1468 @@ -3399,33 +3476,35 @@
  1.1469  
  1.1470  void Main::updateNoteFlag()
  1.1471  {
  1.1472 -	if (currentMapEditor())
  1.1473 -		currentMapEditor()->updateNoteFlag();
  1.1474 +	// this slot is connected to TextEditor::textHasChanged()
  1.1475 +
  1.1476 +	VymModel *m=currentModel();
  1.1477 +	if (m) m->updateNoteFlag();
  1.1478  }
  1.1479  
  1.1480  void Main::updateSatellites(MapEditor *me)
  1.1481  {
  1.1482 -	branchPropertyWindow->setMapEditor (me);
  1.1483 +	branchPropertyWindow->setModel (me->getModel() );
  1.1484  }
  1.1485  
  1.1486  void Main::updateActions()
  1.1487  {
  1.1488 -	MapEditor *me=currentMapEditor();
  1.1489 -	if (!me) return;
  1.1490 -
  1.1491 -	historyWindow->setCaption (vymName + " - " +tr("History for %1","Window Caption").arg(currentMapEditor()->getFileName()));
  1.1492 +	VymModel  *m =currentModel();
  1.1493 +	if (!m) return;
  1.1494 +
  1.1495 +	historyWindow->setCaption (vymName + " - " +tr("History for %1","Window Caption").arg(m->getFileName()));
  1.1496  
  1.1497  	// updateActions is also called when NoteEditor is closed
  1.1498  	actionViewToggleNoteEditor->setOn (textEditor->isVisible());
  1.1499  	actionViewToggleHistoryWindow->setOn (historyWindow->isVisible());
  1.1500  	actionViewTogglePropertyWindow->setOn (branchPropertyWindow->isVisible());
  1.1501  
  1.1502 -	if (me->getMapLinkColorHint()==LinkableMapObj::HeadingColor) 
  1.1503 +	if (m->getMapLinkColorHint()==LinkableMapObj::HeadingColor) 
  1.1504  		actionFormatLinkColorHint->setOn(true);
  1.1505  	else	
  1.1506  		actionFormatLinkColorHint->setOn(false);
  1.1507  
  1.1508 -	switch (me->getMapLinkStyle())
  1.1509 +	switch (m->getMapLinkStyle())
  1.1510  	{
  1.1511  		case LinkableMapObj::Line: 
  1.1512  			actionFormatLinkStyleLine->setOn(true);
  1.1513 @@ -3445,26 +3524,26 @@
  1.1514  
  1.1515  	// Update colors
  1.1516  	QPixmap pix( 16, 16 );
  1.1517 -    pix.fill( me->getMapBackgroundColor() );
  1.1518 +    pix.fill( m->getMapBackgroundColor() );
  1.1519      actionFormatBackColor->setIconSet( pix );
  1.1520 -    pix.fill( me->getSelectionColor() );
  1.1521 +    pix.fill( m->getSelectionColor() );
  1.1522      actionFormatSelectionColor->setIconSet( pix );
  1.1523 -    pix.fill( me->getMapDefLinkColor() );
  1.1524 +    pix.fill( m->getMapDefLinkColor() );
  1.1525      actionFormatLinkColor->setIconSet( pix );
  1.1526  
  1.1527  
  1.1528 -	actionFileSave->setEnabled( me->hasChanged() );
  1.1529 -	if (me->isUndoAvailable())
  1.1530 +	actionFileSave->setEnabled( m->hasChanged() );
  1.1531 +	if (m->isUndoAvailable())
  1.1532  		actionEditUndo->setEnabled( true);
  1.1533  	else	
  1.1534  		actionEditUndo->setEnabled( false);
  1.1535  
  1.1536 -	if (me->isRedoAvailable())
  1.1537 +	if (m->isRedoAvailable())
  1.1538  		actionEditRedo->setEnabled( true);
  1.1539  	else	
  1.1540  		actionEditRedo->setEnabled( false);
  1.1541  
  1.1542 -	LinkableMapObj *selection=me->getSelection();
  1.1543 +	LinkableMapObj *selection=m->getSelection();
  1.1544  	if (selection)
  1.1545  	{
  1.1546  		if ( (typeid(*selection) == typeid(BranchObj)) || 
  1.1547 @@ -3636,8 +3715,8 @@
  1.1548  
  1.1549  void Main::runScript (const QString &script)
  1.1550  {
  1.1551 -	if (currentMapEditor())
  1.1552 -		currentMapEditor()->runScript (script);
  1.1553 +	VymModel *m=currentModel();
  1.1554 +	if (m) m->runScript (script);
  1.1555  }
  1.1556  
  1.1557  void Main::runScriptEverywhere (const QString &script)
  1.1558 @@ -3646,7 +3725,7 @@
  1.1559  	for (int i=0;i<=tabWidget->count() -1;i++)
  1.1560  	{
  1.1561  		me=(MapEditor*)tabWidget->page(i);
  1.1562 -		if (me) me->runScript (script);
  1.1563 +		if (me) me->getModel()->runScript (script);
  1.1564  	}	
  1.1565  }
  1.1566  
  1.1567 @@ -3828,41 +3907,13 @@
  1.1568  		}	
  1.1569  
  1.1570  		QTextStream ts( &f );
  1.1571 -		QString m= ts.read();
  1.1572 -
  1.1573 -		if (! m.isEmpty())
  1.1574 +		QString macro= ts.read();
  1.1575 +
  1.1576 +		if (! macro.isEmpty())
  1.1577  		{
  1.1578 -			//cout <<"Main::callMacro  m="<<qPrintable (m)<<endl;
  1.1579 -			currentMapEditor()->runScript (m);
  1.1580 +			VymModel *m=currentModel();
  1.1581 +			if (m) m->runScript(macro);
  1.1582  		}	
  1.1583  	}	
  1.1584  }
  1.1585  
  1.1586 -
  1.1587 -
  1.1588 -//////////////////////////////////
  1.1589 -/*
  1.1590 -@@ -2544,18 +2576,27 @@
  1.1591 - 				// Try to open new tab in existing konqueror started previously by vym
  1.1592 - 				p=new QProcess (this);
  1.1593 - 				args.clear();
  1.1594 --				args<< QString("konqueror-%1").arg(procBrowser->pid())<< 
  1.1595 --					"konqueror-mainwindow#1"<< 
  1.1596 --					"newTab" << 
  1.1597 -+#if defined(Q_OS_WIN32)
  1.1598 -+                // In Win32, pid is not a longlong, but a pointer to a _PROCESS_INFORMATION structure.
  1.1599 -+                // Redundant change in Win32, as there's no konqueror, but I wanted to follow the original logic.
  1.1600 -+				args<< QString("konqueror-%1").arg(procBrowser->pid()->dwProcessId)<<
  1.1601 -+					"konqueror-mainwindow#1"<<
  1.1602 -+					"newTab" <<
  1.1603 - 					urls.at(i);
  1.1604 -+#else
  1.1605 -+				args<< QString("konqueror-%1").arg(procBrowser->pid())<<
  1.1606 -+					"konqueror-mainwindow#1"<<
  1.1607 -+					"newTab" <<
  1.1608 -+					urls.at(i);
  1.1609 -+#endif
  1.1610 - 				p->start ("dcop",args);
  1.1611 - 				if ( !p->waitForStarted() ) success=false;
  1.1612 - 			}
  1.1613 -*/