1.7.5 Multiple undos, LaTeX Export (experimental)
authorinsilmaril
Mon, 12 Sep 2005 19:52:51 +0000
changeset 16330b22f7bd009
parent 162 2cf3413b6ac9
child 164 d442a66e9121
1.7.5 Multiple undos, LaTeX Export (experimental)
demos/todo.vym
exports.cpp
exports.h
main.cpp
mainwindow.cpp
mainwindow.h
mapeditor.cpp
mapeditor.h
misc.cpp
misc.h
settings.cpp
settings.h
tex/vym.changelog
version.h
     1.1 Binary file demos/todo.vym has changed
     2.1 --- a/exports.cpp	Tue Sep 06 15:04:50 2005 +0000
     2.2 +++ b/exports.cpp	Mon Sep 12 19:52:51 2005 +0000
     2.3 @@ -21,6 +21,23 @@
     2.4  	mapCenter=mc;
     2.5  }
     2.6  
     2.7 +QString Export::getSectionString(BranchObj *bostart)
     2.8 +{
     2.9 +	QString r;
    2.10 +	BranchObj *bo=bostart;
    2.11 +	int depth=bo->getDepth();
    2.12 +	while (depth>0)
    2.13 +	{
    2.14 +		r=QString("%1").arg(1+bo->getNum(),0,10)+"." + r;
    2.15 +		bo=(BranchObj*)(bo->getParObj());
    2.16 +		depth=bo->getDepth();
    2.17 +	}	
    2.18 +	if (r.isEmpty())
    2.19 +		return r;
    2.20 +	else	
    2.21 +		return r + " ";
    2.22 +}
    2.23 +
    2.24  void Export::exportMap()
    2.25  {
    2.26  	QFile file (filepath);
    2.27 @@ -72,20 +89,129 @@
    2.28  	file.close();
    2.29  }
    2.30  
    2.31 -QString Export::getSectionString(BranchObj *bostart)
    2.32 +// Exports a map to a LaTex file.  This file needs to be included or inported into a LaTex document
    2.33 +// it will not add a preamble, or anything that makes a full LaTex document.
    2.34 +void Export::exportLaTeX() 
    2.35  {
    2.36 -	QString r;
    2.37 -	BranchObj *bo=bostart;
    2.38 -	int depth=bo->getDepth();
    2.39 -	while (depth>0)
    2.40 -	{
    2.41 -		r=QString("%1").arg(1+bo->getNum(),0,10)+"." + r;
    2.42 -		bo=(BranchObj*)(bo->getParObj());
    2.43 -		depth=bo->getDepth();
    2.44 -	}	
    2.45 -	if (r.isEmpty())
    2.46 -		return r;
    2.47 -	else	
    2.48 -		return r + " ";
    2.49 +  QFile file (filepath);
    2.50 +  if ( !file.open( IO_WriteOnly ) ) {
    2.51 +    // FIXME
    2.52 +    cout << "Export::exportMap  couldn't open "<<filepath<<endl;
    2.53 +    return;
    2.54 +  }
    2.55 +  QTextStream ts( &file );	// use LANG decoding here...
    2.56 +  ts.setEncoding (QTextStream::UnicodeUTF8); // Force UTF8
    2.57 +  
    2.58 +  // Main loop over all branches
    2.59 +  QString s;
    2.60 +  // QString actIndent("");
    2.61 +  // int i;
    2.62 +  BranchObj *bo;
    2.63 +  bo=mapCenter->first();
    2.64 +  while (bo) {
    2.65 +    if (bo->getDepth()==0);
    2.66 +    else if (bo->getDepth()==1) {
    2.67 +      ts << ("\\chapter{" + bo->getHeading()+ "}\n");
    2.68 +    }
    2.69 +    else if (bo->getDepth()==2) {
    2.70 +      ts << ("\\section{" + bo->getHeading()+ "}\n");
    2.71 +    }
    2.72 +    else if (bo->getDepth()==3) {
    2.73 +      ts << ("\\subsection{" + bo->getHeading()+ "}\n");
    2.74 +    }
    2.75 +    else if (bo->getDepth()==4) {
    2.76 +      ts << ("\\subsubsection{" + bo->getHeading()+ "}\n");
    2.77 +    }
    2.78 +    else {
    2.79 +      ts << ("\\paragraph*{" + bo->getHeading()+ "}\n");
    2.80 +    }
    2.81 +    
    2.82 +    // If necessary, write note
    2.83 +    if (!bo->getNote().isEmpty()) {
    2.84 +      ts << (textConvertToASCII(bo->getNote()));
    2.85 +      ts << ("\n");
    2.86 +    }
    2.87 +    
    2.88 +    bo=bo->next();
    2.89 +   }
    2.90 +  file.close();
    2.91  }
    2.92  
    2.93 +#include "settings.h"
    2.94 +
    2.95 +void Export::exportOOPresentation()
    2.96 +{
    2.97 +	QString templateDir="oo-test/suse-template/";
    2.98 +	QString templateContent="content.xml";
    2.99 +	QString tmpDir="/tmp/vym-ootest/";
   2.100 +	QString header="";
   2.101 +
   2.102 +
   2.103 +	// Create tmpdir
   2.104 +		// TODO
   2.105 +
   2.106 +	// Copy template to tmpdir
   2.107 +		// TODO
   2.108 +
   2.109 +
   2.110 +	// Read content-template
   2.111 +		// TODO
   2.112 +	QString content;
   2.113 +	if (!loadStringFromDisk (templateDir+templateContent,content))
   2.114 +	{
   2.115 +		qWarning ("Export::exportOOPresentation() Couldn't load from "+templateDir+templateContent);
   2.116 +		return;
   2.117 +	}
   2.118 +
   2.119 +
   2.120 +	// Walk through map
   2.121 +	QString s;
   2.122 +	QString actIndent("");
   2.123 +	uint j;
   2.124 +	int i;
   2.125 +	BranchObj *bo;
   2.126 +	bo=mapCenter->first();
   2.127 +	while (bo) 
   2.128 +	{
   2.129 +		// Make indentstring
   2.130 +		for (i=0;i<bo->getDepth();i++) actIndent+= indentPerDepth;
   2.131 +
   2.132 +		// Write heading
   2.133 +		//	write (actIndent + getSectionString(bo) + bo->getHeading()+ "\n");
   2.134 +		if (bo->getDepth()==0)
   2.135 +		{
   2.136 +			s+= (bo->getHeading()+ "\n");
   2.137 +			for (j=0;j<bo->getHeading().length();j++) s+="=";
   2.138 +			s+= "\n";
   2.139 +		} else 	if (bo->getDepth()==1)
   2.140 +			s+= ("\n"+getSectionString(bo) + bo->getHeading()+ "\n");
   2.141 +		else	if (bo->getDepth()==2)
   2.142 +			s+= (actIndent + " o " + bo->getHeading()+ "\n");
   2.143 +		else	
   2.144 +			s+ (actIndent + " - " + bo->getHeading()+ "\n");
   2.145 +		
   2.146 +		/*
   2.147 +		// If necessary, write note
   2.148 +		if (!bo->getNote().isEmpty())
   2.149 +		{
   2.150 +			s =textConvertToASCII(bo->getNote());
   2.151 +			s=s.replace ("\n","\n"+actIndent);
   2.152 +			ts << (s+"\n\n");
   2.153 +		}
   2.154 +		*/
   2.155 +		bo=bo->next();
   2.156 +		actIndent="";
   2.157 +	}
   2.158 +
   2.159 +	
   2.160 +	// Insert new content
   2.161 +		// TODO
   2.162 +	cout <<"\n\ns="<<s<<endl;
   2.163 +	content.replace ("<!--INSERT PAGES HERE-->",s);
   2.164 +	cout << "ExportOO: content=\n"<<content<<endl;
   2.165 +
   2.166 +	// zip tmpdir to destination
   2.167 +		// TODO
   2.168 +
   2.169 +}
   2.170 +
     3.1 --- a/exports.h	Tue Sep 06 15:04:50 2005 +0000
     3.2 +++ b/exports.h	Mon Sep 12 19:52:51 2005 +0000
     3.3 @@ -17,9 +17,12 @@
     3.4  	void setPath(const QString &);
     3.5  	void setMapCenter (MapCenterObj*);
     3.6  	void setIndentPerDepth (QString);
     3.7 -	void exportMap();
     3.8  protected:  
     3.9  	QString getSectionString (BranchObj*);
    3.10 +public:	
    3.11 +	void exportMap();
    3.12 +	void exportLaTeX();
    3.13 +	void exportOOPresentation();
    3.14  
    3.15  private:
    3.16  	QDir outdir;
     4.1 --- a/main.cpp	Tue Sep 06 15:04:50 2005 +0000
     4.2 +++ b/main.cpp	Mon Sep 12 19:52:51 2005 +0000
     4.3 @@ -33,6 +33,7 @@
     4.4  QAction *actionFileSave;
     4.5  QAction *actionFilePrint;
     4.6  QAction *actionEditUndo;
     4.7 +QAction *actionEditRedo;
     4.8  QAction *actionEditCopy;
     4.9  QAction *actionEditCut;
    4.10  QAction *actionEditPaste;
     5.1 --- a/mainwindow.cpp	Tue Sep 06 15:04:50 2005 +0000
     5.2 +++ b/mainwindow.cpp	Mon Sep 12 19:52:51 2005 +0000
     5.3 @@ -27,7 +27,7 @@
     5.4  #include "icons/filesave.xpm"
     5.5  #include "icons/fileprint.xpm"
     5.6  #include "icons/editundo.xpm"
     5.7 -//#include "icons/editredo.xpm"	// TODO
     5.8 +#include "icons/editredo.xpm"	
     5.9  #include "icons/editcopy.xpm"
    5.10  #include "icons/editcut.xpm"
    5.11  #include "icons/editpaste.xpm"
    5.12 @@ -69,6 +69,7 @@
    5.13  extern QAction* actionFileSave;
    5.14  extern QAction* actionFilePrint;
    5.15  extern QAction* actionEditUndo;
    5.16 +extern QAction* actionEditRedo;
    5.17  extern QAction *actionEditCopy;
    5.18  extern QAction *actionEditCut;
    5.19  extern QAction *actionEditPaste;
    5.20 @@ -387,12 +388,15 @@
    5.21      a->addTo( tb );
    5.22      a->addTo( menu );
    5.23  	actionEditUndo=a;
    5.24 -    /*
    5.25 -    a = new QAction( tr( "Redo" ), QPixmap( editredo_xpm ), tr( "&Redo" ), CTRL + Key_Y, this, "editRedo" ); 
    5.26 -    connect( a, SIGNAL( activated() ), this, SLOT( editRedo() ) );
    5.27 -    a->addTo( tb );
    5.28 -    a->addTo( menu );
    5.29 -    */
    5.30 +    
    5.31 +    if (settings.readBoolEntry( "/vym/mainwindow/showTestMenu",false)) 
    5.32 +	{
    5.33 +		a = new QAction( tr( "Redo" ), QPixmap( editredo_xpm ), tr( "&Redo" ), CTRL + Key_Y, this, "editRedo" ); 
    5.34 +		connect( a, SIGNAL( activated() ), this, SLOT( editRedo() ) );
    5.35 +		a->addTo( tb );
    5.36 +		a->addTo( menu );
    5.37 +	}
    5.38 +   
    5.39      menu->insertSeparator();
    5.40      a = new QAction( tr( "Copy" ), QPixmap( editcopy_xpm ), tr( "&Copy" ), CTRL + Key_C, this, "editCopy" );
    5.41      connect( a, SIGNAL( activated() ), this, SLOT( editCopy() ) );
    5.42 @@ -972,13 +976,24 @@
    5.43      connect( a, SIGNAL( activated() ), this, SLOT( fileExportASCII() ) );
    5.44  	a->addTo( exportMenu );
    5.45  
    5.46 -	a = new QAction( tr( "Export XML" ), QPixmap(), tr( "Export XML" ),  0, this, "exportXML"+QString("...") );
    5.47 +    a = new QAction( tr( "Export as LaTeX (still experimental)" ), QPixmap(), tr( "Export (LaTeX)" +QString("...")), 0, this, "exportLaTeX" );
    5.48 +    connect( a, SIGNAL( activated() ), this, SLOT( fileExportLaTeX() ) );
    5.49 +	a->addTo( exportMenu );
    5.50 +
    5.51 +    if (settings.readBoolEntry( "/vym/mainwindow/showTestMenu",false)) 
    5.52 +	{
    5.53 +		a = new QAction( tr( "Export as Open Office 1.3.x Presentation (still experimental)" ), QPixmap(), tr( "Export (OO Presentation)" +QString("...")), 0, this, "exportOOPresentation" );
    5.54 +		connect( a, SIGNAL( activated() ), this, SLOT( fileExportOOPresentation() ) );
    5.55 +		a->addTo( exportMenu );
    5.56 +	}
    5.57 +
    5.58 +	a = new QAction( tr( "Export (XML)" ), QPixmap(), tr( "Export (XML)" )+QString("..."),  0, this, "exportXML" );
    5.59      connect( a, SIGNAL( activated() ), this, SLOT( fileExportXML() ) );
    5.60      a->addTo( exportMenu );
    5.61  	
    5.62      if (settings.readBoolEntry( "/vym/mainwindow/showTestMenu",false)) 
    5.63  	{
    5.64 -		a = new QAction( tr( "Export HTML" ), QPixmap(), tr( "Export HTML" ), 0, this, "exportHTML"+QString("...") );
    5.65 +		a = new QAction( tr( "Export HTML" ), QPixmap(), tr( "Export (HTML)" )+QString("..."), 0, this, "exportHTML");
    5.66  		connect( a, SIGNAL( activated() ), this, SLOT( fileExportHTML() ) );
    5.67  		a->addTo( exportMenu );
    5.68  	}
    5.69 @@ -1723,6 +1738,18 @@
    5.70  		currentMapEditor()->exportASCII();	
    5.71  }
    5.72  
    5.73 +void Main::fileExportLaTeX()
    5.74 +{
    5.75 +	if (currentMapEditor())
    5.76 +		currentMapEditor()->exportLaTeX();	
    5.77 +}
    5.78 +
    5.79 +void Main::fileExportOOPresentation()
    5.80 +{
    5.81 +	if (currentMapEditor())
    5.82 +		currentMapEditor()->exportOOPresentation();	
    5.83 +}
    5.84 +
    5.85  void Main::fileCloseMap()
    5.86  {
    5.87  	if (currentMapEditor())
    5.88 @@ -1817,8 +1844,10 @@
    5.89  		currentMapEditor()->undo();
    5.90  }
    5.91  
    5.92 -void Main::editRedo()	    // TODO
    5.93 +void Main::editRedo()	   
    5.94  {
    5.95 +	if (currentMapEditor())
    5.96 +		currentMapEditor()->redo();
    5.97  }
    5.98  
    5.99  void Main::editCopy()
     6.1 --- a/mainwindow.h	Tue Sep 06 15:04:50 2005 +0000
     6.2 +++ b/mainwindow.h	Mon Sep 12 19:52:51 2005 +0000
     6.3 @@ -70,6 +70,8 @@
     6.4      void fileExportXHTML();
     6.5      void fileExportImage(int);
     6.6      void fileExportASCII();
     6.7 +    void fileExportLaTeX();
     6.8 +    void fileExportOOPresentation();
     6.9      void fileCloseMap();
    6.10      void filePrint();
    6.11      void fileExitVYM();
     7.1 --- a/mapeditor.cpp	Tue Sep 06 15:04:50 2005 +0000
     7.2 +++ b/mapeditor.cpp	Mon Sep 12 19:52:51 2005 +0000
     7.3 @@ -355,6 +355,11 @@
     7.4  	fileName="unnamed";
     7.5  	mapName="";
     7.6  
     7.7 +
     7.8 +	undosTotal=15;	
     7.9 +	undosAvail=0;	
    7.10 +	undoNum=0;
    7.11 +	
    7.12  	// Initialize find routine
    7.13  	itFind=NULL;				
    7.14  	EOFind=false;
    7.15 @@ -480,21 +485,26 @@
    7.16  {
    7.17  	// Create unique temporary directories
    7.18  	char tmpdir[]="/tmp/vym-XXXXXX";	
    7.19 -	bakMapDir=mkdtemp(tmpdir);
    7.20 -	makeSubDirs(bakMapDir);
    7.21 -	// FIXME set permissions and maybe use QT method for portability
    7.22 +	// TODO set permissions and maybe use QT method for portability
    7.23 +	tmpMapDir=mkdtemp(tmpdir);
    7.24 +	QString bakMapDir;
    7.25 +	for (int i=undosTotal;i>0;i--)
    7.26 +	{
    7.27 +		bakMapDir=tmpMapDir+QString("/undo-%1").arg(i);
    7.28 +		makeSubDirs(bakMapDir);
    7.29 +	}	
    7.30  }
    7.31  
    7.32  void MapEditor::delTmpDirs()
    7.33  {
    7.34 -	//FIXME delete tmp directory, better use QT methods here:
    7.35 -	system ( "rm -rf "+ bakMapDir );
    7.36 +	removeDir (QDir(tmpMapDir));
    7.37  }
    7.38  
    7.39  
    7.40  void MapEditor::makeSubDirs(const QString &s)
    7.41  {
    7.42  	QDir d(s);
    7.43 +	d.mkdir(s);
    7.44  	d.mkdir ("images");	
    7.45  	d.mkdir ("flags");	
    7.46  }
    7.47 @@ -502,7 +512,7 @@
    7.48  
    7.49  QString MapEditor::saveToDir(const QString &tmpdir, const QString &prefix, bool writeflags, const QPoint &offset, LinkableMapObj *saveSelection)
    7.50  {
    7.51 -	// tmpdir		temporary directory to which data will be writte
    7.52 +	// tmpdir		temporary directory to which data will be written
    7.53  	// prefix		mapname, which will be appended to images etc.
    7.54  	// writeflags	Only write flags for "real" save of map, not undo
    7.55  	// offset		offset of bbox of whole map in canvas. 
    7.56 @@ -560,7 +570,7 @@
    7.57  		else	
    7.58  			if (selection && typeid(*selection)==typeid(BranchObj))
    7.59  				// This is used if selected branch is saved from mainwindow
    7.60 -				s+=((BranchObj*)(selection))->saveToDir(tmpdir,prefix,offset);
    7.61 +				s+=((BranchObj*)selection)->saveToDir(tmpdir,prefix,offset);
    7.62  	}
    7.63  
    7.64  	// Save local settings
    7.65 @@ -580,44 +590,70 @@
    7.66  
    7.67  void MapEditor::saveState()
    7.68  {
    7.69 -	saveState (CompleteMap,NULL,"","");
    7.70 +	// Save complete map
    7.71 +	saveState (CompleteMap,"",NULL,"",NULL);
    7.72  }
    7.73  
    7.74  void MapEditor::saveState(LinkableMapObj *undoSel)
    7.75  {
    7.76 -	saveState (PartOfMap,undoSel,"","");
    7.77 +	// save the given part of the map 
    7.78 +	saveState (PartOfMap,"",undoSel,"",NULL);
    7.79  }
    7.80  
    7.81 -void MapEditor::saveState(const QString & uc, const QString &rc)
    7.82 +void MapEditor::saveState(const QString &uc, const QString &rc)
    7.83  {
    7.84 -	LinkableMapObj *undoSel;
    7.85 +	// selection does not change during action,
    7.86 +	// so just save commands for undo and redo
    7.87 +	LinkableMapObj *unsel;
    7.88  	if (selection)
    7.89 -		undoSel=selection;
    7.90 +		unsel=selection;
    7.91  	else
    7.92 -		undoSel=NULL;
    7.93 -	saveState (UndoCommand,undoSel,uc,rc);
    7.94 +		unsel=NULL;
    7.95 +	saveState (UndoCommand,uc,unsel,rc,unsel);
    7.96  }
    7.97  
    7.98 -void MapEditor::saveState(const SaveMode &savemode, LinkableMapObj *undoSel, const QString &undoCom, const QString &redoCom)
    7.99 +void MapEditor::saveState(const QString & uncom, LinkableMapObj *unsel) 
   7.100  {
   7.101 +	saveState (UndoCommand,uncom,unsel,"FIXME-redoCom",NULL);
   7.102 +}
   7.103 +
   7.104 +void MapEditor::saveState(const SaveMode &savemode, const QString &undoCom, LinkableMapObj *undoSel, const QString &redoCom, LinkableMapObj *redoSel)
   7.105 +{
   7.106 +	// Main saveState
   7.107 +
   7.108  	if (blockSaveState) return;
   7.109  
   7.110 +	/* TODO remove after testing
   7.111 +	cout << "ME::saveState()  begin\n"<<endl;
   7.112 +	cout << "    undosTotal="<<undosTotal<<endl;
   7.113 +	cout << "    undosAvail="<<undosAvail<<endl;
   7.114 +	cout << "       undoNum="<<undoNum<<endl;
   7.115 +	cout << "    ---------------------------"<<endl;
   7.116 +	*/
   7.117  	setChanged();
   7.118  
   7.119 +	// Find out current undo directory
   7.120 +	if (undosAvail<undosTotal) undosAvail++;
   7.121 +	undoNum++;
   7.122 +	if (undoNum>undosTotal) undoNum=1;
   7.123 +	
   7.124 +	QString backupXML;
   7.125 +	QString bakMapDir=QDir::convertSeparators (QString(tmpMapDir+"/undo-%1").arg(undoNum));
   7.126 +	QString bakMapPath=bakMapDir+"/map.xml";
   7.127 +
   7.128 +
   7.129  	// Save current selection 
   7.130 -	redoCommand=redoCom;
   7.131 -	if (selection)
   7.132 -		redoSelection=selection->getSelectString();
   7.133 -	else	
   7.134 -		redoSelection="";
   7.135 +	QString redoSelection="";
   7.136 +	if (redoSel)
   7.137 +		redoSelection=redoSel->getSelectString();
   7.138  
   7.139  	// Save the object, which should be undone
   7.140 +	QString undoSelection="";
   7.141  	if (undoSel)
   7.142  		undoSelection=undoSel->getSelectString();
   7.143 -	else
   7.144 -		undoSelection="";
   7.145  		
   7.146  	// Save depending on how much needs to be saved	
   7.147 +	QString undoCommand="";
   7.148  	if (savemode==UndoCommand)
   7.149  	{
   7.150  		undoCommand=undoCom;
   7.151 @@ -625,28 +661,43 @@
   7.152  	}	
   7.153  	else if (savemode==PartOfMap && undoSel)
   7.154  	{
   7.155 -		undoCommand="undoPart (\""+undoSelection+"\")";
   7.156 +		undoCommand="undoPart (\""+ undoSelection+"\",\""+bakMapPath+"\")";
   7.157  		backupXML=saveToDir (bakMapDir,mapName+"-",false, QPoint (),undoSel);
   7.158  	} else
   7.159  	{
   7.160 -		undoCommand="undoMap ()";
   7.161 +		undoCommand="undoMap (\""+bakMapPath+"\")";
   7.162  		backupXML=saveToDir (bakMapDir,mapName+"-",false, QPoint (),NULL);
   7.163  		undoSelection="";
   7.164  	}
   7.165 -	/* FIXME testing
   7.166 -	cout << "ME::saveState()\n";
   7.167 -	cout << "  undoCom="<<undoCommand<<endl;
   7.168 -	cout << "  undoSel="<<undoSelection<<endl;
   7.169 -	cout << "  ---------------------------"<<endl;
   7.170 -	cout << "  redoCom="<<redoCommand<<endl;
   7.171 -	cout << "  redoSel="<<redoSelection<<endl<<endl;
   7.172 +	if (!backupXML.isEmpty())
   7.173 +		// Write XML Data to disk
   7.174 +		saveStringToDisk (QString(bakMapPath),backupXML);
   7.175 +
   7.176 +	SimpleSettings set;
   7.177 +	set.setEntry (QString("undoCommand"),undoCommand);
   7.178 +	set.setEntry (QString("undoSelection"),undoSelection);
   7.179 +	set.setEntry (QString("redoCommand"),redoCom);
   7.180 +	set.setEntry (QString("redoSelection"),redoSelection);
   7.181 +	set.writeSettings(QString(bakMapDir+"/commands"));
   7.182 +
   7.183 +	/* TODO remove after testing
   7.184 +	cout << "          into="<< bakMapDir<<endl;
   7.185 +	cout << "    undosAvail="<<undosAvail<<endl;
   7.186 +	cout << "       undoNum="<<undoNum<<endl;
   7.187 +	cout << "    ---------------------------"<<endl;
   7.188 +	cout << "    undoCom="<<undoCommand<<endl;
   7.189 +	cout << "    undoSel="<<undoSelection<<endl;
   7.190 +	cout << "    ---------------------------"<<endl;
   7.191 +	cout << "    redoCom="<<redoCom<<endl;
   7.192 +	cout << "    redoSel="<<redoSelection<<endl;
   7.193 +	cout << "    ---------------------------"<<endl<<endl;
   7.194  	*/
   7.195  }
   7.196  
   7.197  void MapEditor::parseAtom(const QString &atom)
   7.198  {
   7.199  	API api;
   7.200 -	QString s;
   7.201 +	QString s,t;
   7.202  	int x,y;
   7.203  	bool ok;
   7.204  
   7.205 @@ -655,7 +706,7 @@
   7.206  	QString com=api.command();
   7.207  	
   7.208  	// External commands
   7.209 -	if (com==QString("moveBranchUp"))
   7.210 +	if (com=="moveBranchUp")
   7.211  		moveBranchUp();
   7.212  	else if (com=="moveBranchDown")
   7.213  		moveBranchDown();
   7.214 @@ -686,16 +737,16 @@
   7.215  						// Get number in parent
   7.216  						x=api.parInt (ok,1);
   7.217  						if (ok)
   7.218 -							((BranchObj*)(selection))->moveBranchTo ((BranchObj*)(dst),x);
   7.219 +							((BranchObj*)selection)->moveBranchTo ((BranchObj*)(dst),x);
   7.220  					} else if (typeid(*dst) == typeid(MapCenterObj) ) 
   7.221  					{
   7.222 -						((BranchObj*)(selection))->moveBranchTo ((BranchObj*)(dst),-1);
   7.223 +						((BranchObj*)selection)->moveBranchTo ((BranchObj*)(dst),-1);
   7.224  						// Get coordinates of mainbranch
   7.225  						x=api.parInt (ok,2);
   7.226  						if (ok)
   7.227  						{
   7.228  							y=api.parInt (ok,3);
   7.229 -							if (ok) ((BranchObj*)(selection))->move (x,y);
   7.230 +							if (ok) ((BranchObj*)selection)->move (x,y);
   7.231  						}
   7.232  					}	
   7.233  				}	
   7.234 @@ -723,18 +774,18 @@
   7.235  			if (ok) setVymLink(s);
   7.236  		}	
   7.237  	}
   7.238 -
   7.239  	// Internal commands, used for undo etc.	
   7.240  	else if (com==QString("undoMap"))
   7.241  	{
   7.242 -		if (api.checkParamCount(0))
   7.243 -			undoXML("");
   7.244 +		if (api.checkParamCount(1))
   7.245 +			undoXML("",api.parString (ok,0));
   7.246  	} else if (com==QString("undoPart"))
   7.247  	{
   7.248 -		if (api.checkParamCount(1))
   7.249 +		if (api.checkParamCount(2))
   7.250  		{
   7.251  			s=api.parString (ok,0);
   7.252 -			undoXML(s);
   7.253 +			t=api.parString (ok,1);
   7.254 +			undoXML(s,t);	
   7.255  		}
   7.256  	} else if (com=="select")
   7.257  		if (api.checkParamCount(1))
   7.258 @@ -743,7 +794,10 @@
   7.259  			if (ok) select (s);
   7.260  		}	
   7.261  	else
   7.262 +	{
   7.263  		api.setError ("Unknown command in: "+atom);
   7.264 +		cout << "ME::parse   api should have error now...\n";
   7.265 +	}
   7.266  
   7.267  	// Any errors?
   7.268  	if (api.error())
   7.269 @@ -908,8 +962,10 @@
   7.270  		handler.setMapEditor( this );
   7.271  		handler.setTmpDir (filePath.left(filePath.findRev("/",-1)));	// needed to load files with rel. path
   7.272  		handler.setLoadMode (lmode);
   7.273 +		blockSaveState=true;
   7.274  		bool ok = reader.parse( source );
   7.275  		blockReposition=false;
   7.276 +		blockSaveState=false;
   7.277  		file.close();
   7.278  		if ( ok ) 
   7.279  		{
   7.280 @@ -955,35 +1011,14 @@
   7.281  		fname=fileName;
   7.282  
   7.283  
   7.284 -	// Check if fname is writeable
   7.285 -	QFile file( fileDir+fname);
   7.286 -	if (!file.open( IO_WriteOnly ) ) 
   7.287 -	{
   7.288 -		QMessageBox::critical( 0, tr( "Critical Save Error" ),
   7.289 -					   tr("Couldn't write to ") +fileDir+fname);
   7.290 -		return 1;
   7.291 -	}	
   7.292 -	file.close();
   7.293 -
   7.294  	QString saveFile;
   7.295  	if (savemode==CompleteMap || selection==NULL)
   7.296  		saveFile=saveToDir (fileDir,mapName+"-",true,QPoint(),NULL);
   7.297  	else	
   7.298  		saveFile=saveToDir (fileDir,mapName+"-",true,QPoint(),selection);
   7.299  
   7.300 -	file.setName ( fileDir  + fname);
   7.301 -	if ( !file.open( IO_WriteOnly ) )
   7.302 -	{
   7.303 -		// This should neverever happen
   7.304 -		QMessageBox::critical(0, tr("Critcal Save error"),"MapEditor::save() Couldn't open "+file.name());
   7.305 +	if (!saveStringToDisk(fileDir+fname,saveFile))
   7.306  		return 1;
   7.307 -	}	
   7.308 -
   7.309 -	// Write it finally, and write in UTF8, no matter what 
   7.310 -	QTextStream ts( &file );
   7.311 -	ts.setEncoding (QTextStream::UnicodeUTF8);
   7.312 -	ts << saveFile;
   7.313 -	file.close();
   7.314  
   7.315  	if (returnCode==0)
   7.316  	{
   7.317 @@ -1074,7 +1109,7 @@
   7.318  				frame->setZ(0);
   7.319  				frame->show();    
   7.320  			}		
   7.321 -			/* FIXME testing
   7.322 +			/* TODO remove after testing 
   7.323  			QCanvasLine *l=new QCanvasLine (mapCanvas);
   7.324  			l->setPoints (0,0,mapRect.width(),mapRect.height());
   7.325  			l->setPen (QPen(QColor(black), 1));
   7.326 @@ -1227,6 +1262,93 @@
   7.327  	}
   7.328  }
   7.329  
   7.330 +void MapEditor::exportLaTeX()
   7.331 +{
   7.332 +	// FIXME still experimental
   7.333 +	QFileDialog *fd=new QFileDialog( this, tr("VYM - Export (LaTex)"));
   7.334 +	fd->addFilter ("TEX (*.tex)");
   7.335 +	fd->setCaption("VYM - Export (LaTex) (still experimental)");
   7.336 +	fd->setMode( QFileDialog::AnyFile );
   7.337 +	fd->show();
   7.338 +
   7.339 +	if ( fd->exec() == QDialog::Accepted )
   7.340 +	{
   7.341 +		if (QFile (fd->selectedFile()).exists() )
   7.342 +		{
   7.343 +			QMessageBox mb( "VYM",
   7.344 +				tr("The file ") + fd->selectedFile() + 
   7.345 +				tr(" exists already. Do you want to overwrite it?"),
   7.346 +			QMessageBox::Warning,
   7.347 +			QMessageBox::Yes | QMessageBox::Default,
   7.348 +			QMessageBox::Cancel | QMessageBox::Escape,
   7.349 +			QMessageBox::NoButton );
   7.350 +
   7.351 +			mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
   7.352 +			mb.setButtonText( QMessageBox::No, tr("Cancel"));
   7.353 +			Export ex;
   7.354 +			switch( mb.exec() ) 
   7.355 +			{
   7.356 +				case QMessageBox::Yes:
   7.357 +					// save 
   7.358 +					break;;
   7.359 +				case QMessageBox::Cancel:
   7.360 +					// do nothing
   7.361 +					return;
   7.362 +					break;
   7.363 +			}
   7.364 +		}
   7.365 +		Export ex;
   7.366 +		ex.setPath (fd->selectedFile() );
   7.367 +		ex.setMapCenter(mapCenter);
   7.368 +		ex.exportLaTeX();
   7.369 +	}
   7.370 +}
   7.371 +
   7.372 +void MapEditor::exportOOPresentation()
   7.373 +{
   7.374 +	// FIXME still experimental
   7.375 +	/*
   7.376 +	QFileDialog *fd=new QFileDialog( this, tr("VYM - Export (Open Office 1.3.x Presentation)"));
   7.377 +	fd->addFilter ("Open Office 1.3.x presentation (*.sxi)");
   7.378 +	fd->setCaption("VYM - Export (Open Office 1.3.x presentation) (still experimental)");
   7.379 +	fd->setMode( QFileDialog::AnyFile );
   7.380 +	fd->show();
   7.381 +
   7.382 +	if ( fd->exec() == QDialog::Accepted )
   7.383 +	{
   7.384 +		if (QFile (fd->selectedFile()).exists() )
   7.385 +		{
   7.386 +			QMessageBox mb( "VYM",
   7.387 +				tr("The file ") + fd->selectedFile() + 
   7.388 +				tr(" exists already. Do you want to overwrite it?"),
   7.389 +			QMessageBox::Warning,
   7.390 +			QMessageBox::Yes | QMessageBox::Default,
   7.391 +			QMessageBox::Cancel | QMessageBox::Escape,
   7.392 +			QMessageBox::NoButton );
   7.393 +
   7.394 +			mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
   7.395 +			mb.setButtonText( QMessageBox::No, tr("Cancel"));
   7.396 +			Export ex;
   7.397 +			switch( mb.exec() ) 
   7.398 +			{
   7.399 +				case QMessageBox::Yes:
   7.400 +					// save 
   7.401 +					break;;
   7.402 +				case QMessageBox::Cancel:
   7.403 +					// do nothing
   7.404 +					return;
   7.405 +					break;
   7.406 +			}
   7.407 +		}
   7.408 +		*/
   7.409 +		Export ex;
   7.410 +		//ex.setPath (fd->selectedFile() );
   7.411 +		ex.setMapCenter(mapCenter);
   7.412 +		ex.exportOOPresentation();
   7.413 +//	}
   7.414 +}
   7.415 +
   7.416 +
   7.417  
   7.418  void MapEditor::exportXML(const QString &dir)
   7.419  {
   7.420 @@ -1282,7 +1404,7 @@
   7.421  			to=clipboardME->getMapCenter()->getLastBranch();
   7.422  			if (to) 
   7.423  			{
   7.424 -				from=(BranchObj*)(selection);
   7.425 +				from=(BranchObj*)selection;
   7.426  				to->copy(from);
   7.427  
   7.428  				// keep position relative to parent
   7.429 @@ -1310,7 +1432,7 @@
   7.430  			to=clipboardME->getMapCenter()->getLastFloatImage();
   7.431  			if (to) 
   7.432  			{
   7.433 -				from=(FloatImageObj*)(selection);
   7.434 +				from=(FloatImageObj*)selection;
   7.435  				to->copy(from);
   7.436  
   7.437  				// select data in clipboard
   7.438 @@ -1319,9 +1441,7 @@
   7.439  				// repositioning makes testing nicer,
   7.440  				// but is not needed usually:
   7.441  				if (clipboardME->isVisible())
   7.442 -				{
   7.443  					clipboardME->getMapCenter()->reposition();  
   7.444 -				}	
   7.445  				else
   7.446  					clipboardME->hide();
   7.447  			}
   7.448 @@ -1329,36 +1449,143 @@
   7.449  	}	    
   7.450  }
   7.451  
   7.452 +void MapEditor::redo()
   7.453 +{
   7.454 +	// Finish open lineEdits
   7.455 +	if (lineedit) finishedLineEditNoSave();
   7.456 +
   7.457 +	blockSaveState=true;
   7.458 +	
   7.459 +	// Find out current undo directory
   7.460 +	QString bakMapDir=QDir::convertSeparators (QString(tmpMapDir+"/undo-%1").arg(undoNum));
   7.461 +
   7.462 +	// Restore variables
   7.463 +	QString undoCommand;
   7.464 +	QString undoSelection;
   7.465 +	QString redoCommand;
   7.466 +	QString redoSelection;
   7.467 +	SimpleSettings set;
   7.468 +	set.readSettings(QString(bakMapDir+"/commands"));
   7.469 +	undoCommand=set.readEntry ("undoCommand");
   7.470 +	undoSelection=set.readEntry ("undoSelection");
   7.471 +	redoCommand=set.readEntry ("redoCommand");
   7.472 +	redoSelection=set.readEntry ("redoSelection");
   7.473 +
   7.474 +	// select  object before redo
   7.475 +	if (!redoSelection.isEmpty())
   7.476 +		select (redoSelection);
   7.477 +
   7.478 +/* TODO remove testing
   7.479 +	cout << "ME::redo() begin\n";
   7.480 +	cout << "    undosTotal="<<undosTotal<<endl;
   7.481 +	cout << "    undosAvail="<<undosAvail<<endl;
   7.482 +	cout << "       undoNum="<<undoNum<<endl;
   7.483 +	cout << "    ---------------------------"<<endl;
   7.484 +	cout << "    undoCom="<<undoCommand<<endl;
   7.485 +	cout << "    undoSel="<<undoSelection<<endl;
   7.486 +	cout << "    ---------------------------"<<endl;
   7.487 +	cout << "    redoCom="<<redoCommand<<endl;
   7.488 +	cout << "    redoSel="<<redoSelection<<endl;
   7.489 +	cout << "    ---------------------------"<<endl;
   7.490 +*/
   7.491 +	parseAtom (undoCommand);
   7.492 +	mapCenter->reposition();
   7.493 +
   7.494 +	//mapChanged=false;  FIXME  still needed???
   7.495 +
   7.496 +	//if (!redoSelection.isEmpty())
   7.497 +	//	select (redoSelection);
   7.498 +
   7.499 +	undosAvail--;
   7.500 +	if (undosAvail<1)
   7.501 +		// Undo not longer available now
   7.502 +		actionEditUndo->setEnabled (false);
   7.503 +	else	
   7.504 +		undoNum--; if (undoNum<1) undoNum=undosTotal;
   7.505 +
   7.506 +	blockSaveState=false;
   7.507 +/* TODO remove testing
   7.508 +	cout << "ME::redo() end\n";
   7.509 +	cout << "    undosAvail="<<undosAvail<<endl;
   7.510 +	cout << "       undoNum="<<undoNum<<endl;
   7.511 +	cout << "    ---------------------------"<<endl<<endl;
   7.512 +*/	
   7.513 +}
   7.514 +
   7.515  void MapEditor::undo()
   7.516  {
   7.517  	// Finish open lineEdits
   7.518  	if (lineedit) finishedLineEditNoSave();
   7.519  
   7.520 +	blockSaveState=true;
   7.521 +	
   7.522 +	// Find out current undo directory
   7.523 +	QString bakMapDir=QDir::convertSeparators (QString(tmpMapDir+"/undo-%1").arg(undoNum));
   7.524 +
   7.525 +	// Restore variables
   7.526 +	QString undoCommand;
   7.527 +	QString undoSelection;
   7.528 +	QString redoCommand;
   7.529 +	QString redoSelection;
   7.530 +	SimpleSettings set;
   7.531 +	set.readSettings(QString(bakMapDir+"/commands"));
   7.532 +	undoCommand=  set.readEntry ("undoCommand");
   7.533 +	undoSelection=set.readEntry ("undoSelection");
   7.534 +	redoCommand=  set.readEntry ("redoCommand");
   7.535 +	redoSelection=set.readEntry ("redoSelection");
   7.536 +
   7.537  	// select  object before undo
   7.538  	if (!undoSelection.isEmpty())
   7.539  		select (undoSelection);
   7.540  
   7.541 +/* TODO remove testing
   7.542 +	cout << "ME::undo() begin\n";
   7.543 +	cout << "    undosTotal="<<undosTotal<<endl;
   7.544 +	cout << "    undosAvail="<<undosAvail<<endl;
   7.545 +	cout << "       undoNum="<<undoNum<<endl;
   7.546 +	cout << "    ---------------------------"<<endl;
   7.547 +	cout << "    undoCom="<<undoCommand<<endl;
   7.548 +	cout << "    undoSel="<<undoSelection<<endl;
   7.549 +	cout << "    ---------------------------"<<endl;
   7.550 +	cout << "    redoCom="<<redoCommand<<endl;
   7.551 +	cout << "    redoSel="<<redoSelection<<endl;
   7.552 +	cout << "    ---------------------------"<<endl;
   7.553 +*/	
   7.554  	parseAtom (undoCommand);
   7.555  	mapCenter->reposition();
   7.556  
   7.557 -	// Undo not longer available now
   7.558 -	actionEditUndo->setEnabled (false);
   7.559 -	mapChanged=false;
   7.560 -
   7.561 -	if (!redoSelection.isEmpty())
   7.562 -		select (redoSelection);
   7.563 +	//mapChanged=false;  FIXME  still needed???
   7.564 +
   7.565 +	//if (!redoSelection.isEmpty())
   7.566 +	//	select (redoSelection);
   7.567 +
   7.568 +	undosAvail--;
   7.569 +	if (undosAvail<1)
   7.570 +		// Undo not longer available now
   7.571 +		actionEditUndo->setEnabled (false);
   7.572 +	else	
   7.573 +		undoNum--; if (undoNum<1) undoNum=undosTotal;
   7.574 +
   7.575 +	blockSaveState=false;
   7.576 +/* TODO remove testing
   7.577 +	cout << "ME::undo() end\n";
   7.578 +	cout << "    undosAvail="<<undosAvail<<endl;
   7.579 +	cout << "       undoNum="<<undoNum<<endl;
   7.580 +	cout << "    ---------------------------"<<endl<<endl;
   7.581 +*/
   7.582  }
   7.583  
   7.584 -void MapEditor::undoXML(const QString &undoSel)
   7.585 +void MapEditor::undoXML(const QString &undoSel, const QString &bakMapPath)
   7.586  {
   7.587 -	QDir d;
   7.588 -	d.setPath(bakMapDir);
   7.589 +	QString bakMapDir=bakMapPath.left(bakMapPath.findRev("/"));
   7.590 +	QDir d(bakMapDir);
   7.591 +	QFile file (bakMapPath);
   7.592 +
   7.593  	if (d.exists() )
   7.594  	{
   7.595  		// We need to parse saved XML data
   7.596  		mapBuilderHandler handler;
   7.597 -		QXmlInputSource source;
   7.598 -		source.setData(backupXML);
   7.599 +		QXmlInputSource source( file);
   7.600  		QXmlSimpleReader reader;
   7.601  		reader.setContentHandler( &handler );
   7.602  		reader.setErrorHandler( &handler );
   7.603 @@ -1375,15 +1602,13 @@
   7.604  			handler.setLoadMode (ImportReplace);
   7.605  		}	
   7.606  		blockReposition=true;
   7.607 -		blockSaveState=true;
   7.608  		bool ok = reader.parse( source );
   7.609  		blockReposition=false;
   7.610 -		blockSaveState=false;
   7.611  		if (! ok ) 
   7.612  		{	
   7.613  			// This should never ever happen
   7.614  			QMessageBox::critical( 0, tr( "Critical Parse Error by reading backupFile" ),
   7.615 -								   tr( handler.errorProtocol() )+" in "+backupXML );
   7.616 +								   tr( handler.errorProtocol() )+" in "+bakMapDir );
   7.617  		}
   7.618  	} else	
   7.619  	{
   7.620 @@ -1414,13 +1639,13 @@
   7.621  				((BranchObj*)(returnLMO))->move2RelPos(normalise(fromLMO->getRelPos() ) );
   7.622  			}     
   7.623  			if (typeid(*selection) == typeid(BranchObj)) 
   7.624 -					returnLMO=((BranchObj*)(selection))->addBranch((BranchObj*)(fromLMO) );
   7.625 +					returnLMO=((BranchObj*)selection)->addBranch((BranchObj*)(fromLMO) );
   7.626  		}
   7.627  		
   7.628  		if (typeid(*fromLMO) == typeid(FloatImageObj) &&
   7.629  			(typeid(*selection) == typeid (BranchObj) || 
   7.630  			 typeid(*selection)==typeid(MapCenterObj)) )
   7.631 -			returnLMO=((BranchObj*) (selection))->addFloatImage ((FloatImageObj*)(fromLMO));
   7.632 +			returnLMO=((BranchObj*) selection)->addFloatImage ((FloatImageObj*)(fromLMO));
   7.633  		
   7.634  	}	    
   7.635  	return returnLMO;
   7.636 @@ -1436,7 +1661,7 @@
   7.637  	if (selection != NULL) {
   7.638  		if (typeid(*selection) == typeid(BranchObj) ) 
   7.639  		{
   7.640 -			bo=(BranchObj*)(selection);
   7.641 +			bo=(BranchObj*)selection;
   7.642  			par=(BranchObj*)(bo->getParObj());
   7.643  			bo->unselect();
   7.644  			selection=NULL;
   7.645 @@ -1446,7 +1671,7 @@
   7.646  		}
   7.647  		if (typeid(*selection) == typeid(FloatImageObj) ) 
   7.648  		{
   7.649 -			FloatImageObj* fio=(FloatImageObj*)(selection);
   7.650 +			FloatImageObj* fio=(FloatImageObj*)selection;
   7.651  			par=(BranchObj*)(fio->getParObj());
   7.652  			fio->unselect();
   7.653  			selection=NULL;
   7.654 @@ -1479,7 +1704,7 @@
   7.655  	// FIXME  no saveState, because this is only internal at undo so far
   7.656  	if (selection) selection->move(x,y);
   7.657  	if (typeid(*selection) == typeid(FloatImageObj))
   7.658 -		((FloatImageObj*)(selection))->setRelPos();
   7.659 +		((FloatImageObj*)selection)->setRelPos();
   7.660  }
   7.661  
   7.662  void MapEditor::moveBranchUp()
   7.663 @@ -1491,12 +1716,12 @@
   7.664  	BranchObj* par;
   7.665  	if (typeid(*selection) == typeid(BranchObj)  ) 
   7.666  	{
   7.667 -		bo=(BranchObj*)(selection);
   7.668 +		bo=(BranchObj*)selection;
   7.669  		par=(BranchObj*)(bo->getParObj());
   7.670  		selection->unselect();
   7.671  		selection=par->moveBranchUp (bo);
   7.672  		selection->select();
   7.673 -		saveState("moveBranchDown ()",bo->getSelectString());
   7.674 +		saveState("moveBranchDown ()",bo);
   7.675  		mapCenter->reposition();
   7.676  		ensureSelectionVisible();
   7.677  	}
   7.678 @@ -1511,12 +1736,12 @@
   7.679  	BranchObj* par;
   7.680  	if (typeid(*selection) == typeid(BranchObj)  ) 
   7.681  	{
   7.682 -		bo=(BranchObj*)(selection);
   7.683 +		bo=(BranchObj*)selection;
   7.684  		par=(BranchObj*)(bo->getParObj());
   7.685  		selection->unselect(); 
   7.686  		selection=par->moveBranchDown(bo);
   7.687  		selection->select();
   7.688 -		saveState("moveBranchUp ()",bo->getSelectString());
   7.689 +		saveState("moveBranchUp ()",bo);
   7.690  		mapCenter->reposition();
   7.691  		ensureSelectionVisible();
   7.692  	}	
   7.693 @@ -1531,8 +1756,8 @@
   7.694  		 (typeid(*selection) == typeid(BranchObj) || 
   7.695  		  typeid(*selection) == typeid(MapCenterObj) ) ) 
   7.696  	{
   7.697 -		editingBO=(BranchObj*)(selection);
   7.698 -		saveState("setHeading (\""+((BranchObj*)(selection))->getHeading()+"\")",editingBO->getSelectString() );
   7.699 +		editingBO=(BranchObj*)selection;
   7.700 +		saveState("setHeading (\""+((BranchObj*)selection)->getHeading()+"\")",editingBO );
   7.701  
   7.702  		ensureSelectionVisible();
   7.703  		QPoint p = worldMatrix().map(QPoint (editingBO->x(),editingBO->y()));
   7.704 @@ -1543,7 +1768,6 @@
   7.705  		if (actionSettingsAutoselectText->isOn() && !s.isEmpty() && actionSettingsPasteNewHeading->isOn() )
   7.706  			lineedit->selectAll();
   7.707  		lineedit->show();
   7.708 -
   7.709  		lineedit->grabKeyboard();
   7.710  		lineedit->setFocus();
   7.711  	}				
   7.712 @@ -1556,7 +1780,7 @@
   7.713  		 (typeid(*selection) == typeid(BranchObj) || 
   7.714  		  typeid(*selection) == typeid(MapCenterObj) ) ) 
   7.715  	{
   7.716 -		((BranchObj*)(selection))->setHeading(s);
   7.717 +		((BranchObj*)selection)->setHeading(s);
   7.718  		mapCenter->reposition();
   7.719  		adjustCanvasSize();
   7.720  		ensureSelectionVisible();
   7.721 @@ -1570,7 +1794,7 @@
   7.722  		 (typeid(*selection) == typeid(BranchObj) || 
   7.723  		  typeid(*selection) == typeid(MapCenterObj) ) ) 
   7.724  	{
   7.725 -		((BranchObj*)(selection))->setURL(s);
   7.726 +		((BranchObj*)selection)->setURL(s);
   7.727  		mapCenter->reposition();
   7.728  		adjustCanvasSize();
   7.729  		ensureSelectionVisible();
   7.730 @@ -1584,7 +1808,7 @@
   7.731  		 (typeid(*selection) == typeid(BranchObj) || 
   7.732  		  typeid(*selection) == typeid(MapCenterObj) ) ) 
   7.733  	{
   7.734 -		((BranchObj*)(selection))->setVymLink(s);
   7.735 +		((BranchObj*)selection)->setVymLink(s);
   7.736  		mapCenter->reposition();
   7.737  		adjustCanvasSize();
   7.738  		ensureSelectionVisible();
   7.739 @@ -1602,7 +1826,7 @@
   7.740  	{
   7.741  		saveState(selection);	//FIXME undoCommand
   7.742  
   7.743 -		BranchObj* bo1 = (BranchObj*) (selection);
   7.744 +		BranchObj* bo1 = (BranchObj*) selection;
   7.745  		bool wasScrolled=false;
   7.746  		BranchObj *newbo=NULL;
   7.747  		if (pos==0)
   7.748 @@ -1640,7 +1864,7 @@
   7.749  			selection->select();
   7.750  			if (actionSettingsPasteNewHeading->isOn() )
   7.751  			{
   7.752 -				BranchObj *bo2= (BranchObj*)(selection);
   7.753 +				BranchObj *bo2= (BranchObj*)selection;
   7.754  				bo2->setHeading("");
   7.755  			}	
   7.756  			if (actionSettingsAutoedit->isOn() )
   7.757 @@ -1667,7 +1891,7 @@
   7.758  	{
   7.759  		saveState(selection);
   7.760  
   7.761 -		BranchObj* bo1 = (BranchObj*) (selection);
   7.762 +		BranchObj* bo1 = (BranchObj*) selection;
   7.763  		bool wasScrolled=false;
   7.764  		BranchObj *newbo=NULL;
   7.765  		BranchObj *parbo=(BranchObj*)(selection->getParObj());
   7.766 @@ -1678,7 +1902,7 @@
   7.767  		} 
   7.768  
   7.769  		LinkableMapObj *oldselection=selection;
   7.770 -		((BranchObj*)(selection))->moveBranchTo (newbo,-1);
   7.771 +		((BranchObj*)selection)->moveBranchTo (newbo,-1);
   7.772  
   7.773  		mapCenter->reposition();
   7.774  		adjustCanvasSize();
   7.775 @@ -1690,7 +1914,7 @@
   7.776  			selection->select();
   7.777  			if (actionSettingsPasteNewHeading->isOn() )
   7.778  			{
   7.779 -				BranchObj *bo2= (BranchObj*)(selection);
   7.780 +				BranchObj *bo2= (BranchObj*)selection;
   7.781  				bo2->setHeading("");
   7.782  			}	
   7.783  			if (actionSettingsAutoedit->isOn() )
   7.784 @@ -1854,7 +2078,7 @@
   7.785  					b=select (s);
   7.786  					if (b)
   7.787  					{	
   7.788 -						if ( ((BranchObj*)(selection))->countBranches()>0)
   7.789 +						if ( ((BranchObj*)selection)->countBranches()>0)
   7.790  							s+=",bo:0";
   7.791  						else	
   7.792  							break;
   7.793 @@ -1933,8 +2157,8 @@
   7.794  				{
   7.795  					b=select (s);
   7.796  					if (b)
   7.797 -						if ( ((BranchObj*)(selection))->countBranches()>0)
   7.798 -							s+=",bo:"+ QString ("%1").arg( ((BranchObj*)(selection))->countBranches()-1 );
   7.799 +						if ( ((BranchObj*)selection)->countBranches()>0)
   7.800 +							s+=",bo:"+ QString ("%1").arg( ((BranchObj*)selection)->countBranches()-1 );
   7.801  						else	
   7.802  							break;
   7.803  					else
   7.804 @@ -2001,7 +2225,7 @@
   7.805  	{
   7.806  		if (typeid(*selection) == typeid(MapCenterObj))
   7.807  		{
   7.808 -			par=  (BranchObj*) (selection);
   7.809 +			par=  (BranchObj*) selection;
   7.810  			bo=par->getLastSelectedBranch();
   7.811  			if (bo)
   7.812  			{
   7.813 @@ -2037,7 +2261,7 @@
   7.814  			{
   7.815  				if (typeid(*selection) == typeid(BranchObj) )
   7.816  				{
   7.817 -					bo=((BranchObj*)(selection))->getLastSelectedBranch();
   7.818 +					bo=((BranchObj*)selection)->getLastSelectedBranch();
   7.819  					if (bo) 
   7.820  					{
   7.821  						selection->unselect();
   7.822 @@ -2064,7 +2288,7 @@
   7.823  	{
   7.824  		if (typeid(*selection) == typeid(MapCenterObj))
   7.825  		{
   7.826 -			par=  (BranchObj*) (selection);
   7.827 +			par=  (BranchObj*) selection;
   7.828  			bo=par->getLastSelectedBranch();
   7.829  			if (bo)
   7.830  			{
   7.831 @@ -2097,7 +2321,7 @@
   7.832  			{
   7.833  				if (typeid(*selection) == typeid(BranchObj) )
   7.834  				{
   7.835 -					bo=((BranchObj*)(selection))->getLastSelectedBranch();
   7.836 +					bo=((BranchObj*)selection)->getLastSelectedBranch();
   7.837  					if (bo) 
   7.838  					{
   7.839  						selection->unselect();
   7.840 @@ -2123,7 +2347,7 @@
   7.841  	if (selection) {
   7.842  		if (typeid(*selection) == typeid(BranchObj))
   7.843  		{
   7.844 -			bo1=  (BranchObj*) (selection);
   7.845 +			bo1=  (BranchObj*) selection;
   7.846  			par=(BranchObj*)(bo1->getParObj());
   7.847  			bo2=par->getFirstBranch();
   7.848  			if (bo2) {
   7.849 @@ -2148,7 +2372,7 @@
   7.850  	if (selection) {
   7.851  		if (typeid(*selection) == typeid(BranchObj))
   7.852  		{
   7.853 -			bo1=  (BranchObj*) (selection);
   7.854 +			bo1=  (BranchObj*) selection;
   7.855  			par=(BranchObj*)(bo1->getParObj());
   7.856  			bo2=par->getLastBranch();
   7.857  			if (bo2) {
   7.858 @@ -2190,7 +2414,7 @@
   7.859  		if (typeid(*selection) == typeid(BranchObj) ||
   7.860  			typeid(*selection) == typeid(MapCenterObj))
   7.861  		{
   7.862 -			BranchObj *bo=(BranchObj*)(selection);
   7.863 +			BranchObj *bo=(BranchObj*)selection;
   7.864  			actColor=bo->getColor(); 
   7.865  		}    
   7.866  	}
   7.867 @@ -2205,7 +2429,7 @@
   7.868  			typeid(*selection) == typeid(MapCenterObj))
   7.869  		{
   7.870  			saveState(selection);	//FIXME undoCommand
   7.871 -			BranchObj *bo=(BranchObj*)(selection);
   7.872 +			BranchObj *bo=(BranchObj*)selection;
   7.873  			bo->setColor(actColor, false); // color links, color childs
   7.874  		}    
   7.875  	}
   7.876 @@ -2219,7 +2443,7 @@
   7.877  			typeid(*selection) == typeid(MapCenterObj))
   7.878  		{
   7.879  			saveState(selection);
   7.880 -			BranchObj *bo=(BranchObj*)(selection);
   7.881 +			BranchObj *bo=(BranchObj*)selection;
   7.882  			bo->setColor(actColor, true); // color links, color childs
   7.883  		}    
   7.884  	}
   7.885 @@ -2231,7 +2455,7 @@
   7.886  	if (selection)
   7.887  	{
   7.888  		saveState(selection);// FIXME undoCommand	
   7.889 -		((BranchObj*)(selection))->toggleStandardFlag (f,actionSettingsUseFlagGroups);
   7.890 +		((BranchObj*)selection)->toggleStandardFlag (f,actionSettingsUseFlagGroups);
   7.891  	}	
   7.892  }
   7.893  
   7.894 @@ -2263,7 +2487,7 @@
   7.895  			{
   7.896  				if (selection!=itFind) 
   7.897  				{
   7.898 -					if (selection) ((BranchObj*)(selection))->unselect();
   7.899 +					if (selection) ((BranchObj*)selection)->unselect();
   7.900  					selection=itFind;
   7.901  					selection->select();
   7.902  					adjustCanvasSize();
   7.903 @@ -2278,7 +2502,7 @@
   7.904  			// Searching in Heading
   7.905  			if (searching && itFind->getHeading().contains (s,cs) ) 
   7.906  			{
   7.907 -				if (selection) ((BranchObj*)(selection))->unselect();
   7.908 +				if (selection) ((BranchObj*)selection)->unselect();
   7.909  				selection=itFind;
   7.910  				selection->select();
   7.911  				adjustCanvasSize();
   7.912 @@ -2295,7 +2519,7 @@
   7.913  	if (!searching)
   7.914  	{
   7.915  		adjustCanvasSize();
   7.916 -		return (BranchObj*)(selection);
   7.917 +		return (BranchObj*)selection;
   7.918  	}	else
   7.919  		return NULL;
   7.920  }
   7.921 @@ -2313,7 +2537,7 @@
   7.922  		if (typeid(*selection) == typeid(BranchObj) ||
   7.923  			typeid(*selection) == typeid(MapCenterObj))
   7.924  		{
   7.925 -			QString url=((BranchObj*)(selection))->getURL();
   7.926 +			QString url=((BranchObj*)selection)->getURL();
   7.927  
   7.928  			QProcess *proc = new QProcess( this );
   7.929  
   7.930 @@ -2334,7 +2558,7 @@
   7.931  			typeid(*selection) == typeid(MapCenterObj)) )
   7.932  	{		
   7.933  		bool ok;
   7.934 -		BranchObj *bo=(BranchObj*)(selection);
   7.935 +		BranchObj *bo=(BranchObj*)selection;
   7.936  		QString text = QInputDialog::getText(
   7.937  				"VYM", tr("Enter URL:"), QLineEdit::Normal,
   7.938  				bo->getURL(), &ok, this );
   7.939 @@ -2353,7 +2577,7 @@
   7.940  	if (selection && (typeid(*selection) == typeid(BranchObj) ||
   7.941  			typeid(*selection) == typeid(MapCenterObj)) )
   7.942  	{		
   7.943 -		BranchObj *bo=(BranchObj*)(selection);
   7.944 +		BranchObj *bo=(BranchObj*)selection;
   7.945  		saveState("setURL (\""+bo->getURL()+"\")","setURL (\""+bo->getHeading()+"\")");	
   7.946  		bo->setURL (bo->getHeading());
   7.947  		updateActions();
   7.948 @@ -2365,7 +2589,7 @@
   7.949  	if (selection && (typeid(*selection) == typeid(BranchObj) ||
   7.950  			typeid(*selection) == typeid(MapCenterObj)) )
   7.951  	{		
   7.952 -		BranchObj *bo=(BranchObj*)(selection);
   7.953 +		BranchObj *bo=(BranchObj*)selection;
   7.954  		QString url= "https://bugzilla.novell.com/show_bug.cgi?id="+bo->getHeading();
   7.955  		saveState("setURL (\""+bo->getURL()+"\")","setURL (\""+url+"\")");	
   7.956  		bo->setURL (url);
   7.957 @@ -2378,7 +2602,7 @@
   7.958  	if (selection && (typeid(*selection) == typeid(BranchObj) ||
   7.959  			typeid(*selection) == typeid(MapCenterObj)) )
   7.960  	{		
   7.961 -		BranchObj *bo=(BranchObj*)(selection);
   7.962 +		BranchObj *bo=(BranchObj*)selection;
   7.963  		QFileDialog *fd=new QFileDialog( this,tr("VYM - Link to another map"));
   7.964  		fd->addFilter (QString (tr("vym map") + " (*.vym)"));
   7.965  		fd->setCaption(tr("VYM - Link to another map"));
   7.966 @@ -2404,7 +2628,7 @@
   7.967  	if (selection && (typeid(*selection) == typeid(BranchObj) ||
   7.968  			typeid(*selection) == typeid(MapCenterObj)) )
   7.969  	{		
   7.970 -		BranchObj *bo=(BranchObj*)(selection);
   7.971 +		BranchObj *bo=(BranchObj*)selection;
   7.972  		saveState("setVymLink (\""+bo->getVymLink()+"\")","setVymLink (\"\")");	
   7.973  		bo->setVymLink ("" );
   7.974  		updateActions();
   7.975 @@ -2419,7 +2643,7 @@
   7.976  	if (selection && (typeid(*selection) == typeid(BranchObj) ||
   7.977  			typeid(*selection) == typeid(MapCenterObj)) )
   7.978  	{		
   7.979 -		return ((BranchObj*)(selection))->getVymLink();
   7.980 +		return ((BranchObj*)selection)->getVymLink();
   7.981  	}
   7.982  	return "";
   7.983  	
   7.984 @@ -2429,7 +2653,7 @@
   7.985  {
   7.986  	if (selection && (typeid(*selection) == typeid(BranchObj) ))
   7.987  	{		
   7.988 -		BranchObj* bo=(BranchObj*)(selection);
   7.989 +		BranchObj* bo=(BranchObj*)selection;
   7.990  		BranchObj* par=(BranchObj*)(bo->getParObj());
   7.991  		if (bo->getDepth()==1)
   7.992  			saveState();
   7.993 @@ -2448,7 +2672,7 @@
   7.994  	if (selection && (typeid(*selection) == typeid(BranchObj) ))
   7.995  	{		
   7.996  		saveState(selection->getParObj());
   7.997 -		((BranchObj*)(selection))->removeChilds();
   7.998 +		((BranchObj*)selection)->removeChilds();
   7.999  		mapCenter->reposition();
  7.1000  	}	
  7.1001  }
  7.1002 @@ -2537,7 +2761,7 @@
  7.1003  		if ( (typeid(*selection) == typeid(BranchObj)) || 
  7.1004  			(typeid(*selection) == typeid(MapCenterObj))  )
  7.1005  		{
  7.1006 -			BranchObj *bo=(BranchObj*)(selection);
  7.1007 +			BranchObj *bo=(BranchObj*)selection;
  7.1008  			// Take care of links
  7.1009  			if (bo->countXLinks()==0)
  7.1010  			{
  7.1011 @@ -2622,7 +2846,7 @@
  7.1012  				a->setEnabled(false);
  7.1013  			actionEditDelete->setEnabled (true);
  7.1014  			actionEditToggleFloatExport->setOn
  7.1015 -				( ((FloatImageObj*)(selection))->getFloatExport() );
  7.1016 +				( ((FloatImageObj*)selection)->getFloatExport() );
  7.1017  			actionFormatHideLinkUnselected->setOn
  7.1018  				( selection->getHideLinkUnselected());
  7.1019  		}
  7.1020 @@ -2649,11 +2873,9 @@
  7.1021  void MapEditor::updateNoteFlag()
  7.1022  {
  7.1023  	if (selection)
  7.1024 -	{
  7.1025  		if ( (typeid(*selection) == typeid(BranchObj)) || 
  7.1026  			(typeid(*selection) == typeid(MapCenterObj))  )
  7.1027  			((BranchObj*)selection)->updateNoteFlag();
  7.1028 -	}
  7.1029  }
  7.1030  
  7.1031  void MapEditor::setLinkStyle (LinkStyle ls)
  7.1032 @@ -2762,7 +2984,7 @@
  7.1033  {
  7.1034  	if (selection && (typeid(*selection) == typeid(BranchObj)) )
  7.1035  	{
  7.1036 -		BranchObj *bo=((BranchObj*)(selection));
  7.1037 +		BranchObj *bo=((BranchObj*)selection);
  7.1038  		if (bo->countBranches()==0) return;
  7.1039  		if (bo->getDepth()==0) return;
  7.1040  		saveState(selection);
  7.1041 @@ -2789,7 +3011,7 @@
  7.1042  		(typeid(*selection) == typeid(BranchObj)) || 
  7.1043  		(typeid(*selection) == typeid(MapCenterObj))  )
  7.1044  	{
  7.1045 -		BranchObj *bo=((BranchObj*)(selection));
  7.1046 +		BranchObj *bo=((BranchObj*)selection);
  7.1047  
  7.1048  		QFileDialog *fd=new QFileDialog( this,tr("vym - load image"));
  7.1049  		fd->addFilter (QString (tr("Images") + " (*.png *.bmp *.xbm *.jpg *.png *.xpm *.gif *.pnm)"));
  7.1050 @@ -2823,7 +3045,7 @@
  7.1051  	if (selection && 
  7.1052  		(typeid(*selection) == typeid(FloatImageObj)) )
  7.1053  	{
  7.1054 -		FloatImageObj *fio=((FloatImageObj*)(selection));
  7.1055 +		FloatImageObj *fio=((FloatImageObj*)selection);
  7.1056  		const char* fmt = saveImageFormatMenu->text(item);
  7.1057  
  7.1058  		QFileDialog *fd=new QFileDialog( this, tr("vym - save image as") + fmt);
  7.1059 @@ -2877,7 +3099,7 @@
  7.1060  		(typeid(*selection) == typeid(FloatImageObj))|| 
  7.1061  		(typeid(*selection) == typeid(FloatObj)) )
  7.1062  	{
  7.1063 -		FloatImageObj *fio=((FloatImageObj*)(selection));
  7.1064 +		FloatImageObj *fio=((FloatImageObj*)selection);
  7.1065  		fio->setFloatExport (actionEditToggleFloatExport->isOn() );
  7.1066  	}
  7.1067  }
  7.1068 @@ -2971,7 +3193,7 @@
  7.1069  		QString fn;
  7.1070  		if ( fd->exec() == QDialog::Accepted )
  7.1071  		{
  7.1072 -			BranchObj *bo=((BranchObj*)(selection));
  7.1073 +			BranchObj *bo=((BranchObj*)selection);
  7.1074  			importDir (bo,QDir(fd->selectedFile()) );
  7.1075  			mapCenter->reposition();
  7.1076  			adjustCanvasSize();
  7.1077 @@ -2986,7 +3208,7 @@
  7.1078  		(typeid(*selection) == typeid(BranchObj)) || 
  7.1079  		(typeid(*selection) == typeid(MapCenterObj))  )
  7.1080  	{
  7.1081 -		BranchObj *bo=((BranchObj*)(selection))->XLinkTargetAt(i);
  7.1082 +		BranchObj *bo=((BranchObj*)selection)->XLinkTargetAt(i);
  7.1083  		if (bo) 
  7.1084  		{
  7.1085  			selection->unselect();
  7.1086 @@ -3003,7 +3225,7 @@
  7.1087  		(typeid(*selection) == typeid(BranchObj)) || 
  7.1088  		(typeid(*selection) == typeid(MapCenterObj))  )
  7.1089  	{
  7.1090 -		XLinkObj *xlo=((BranchObj*)(selection))->XLinkAt(i);
  7.1091 +		XLinkObj *xlo=((BranchObj*)selection)->XLinkAt(i);
  7.1092  		if (xlo) 
  7.1093  		{
  7.1094  			EditXLinkDialog dia;
  7.1095 @@ -3017,7 +3239,7 @@
  7.1096  					setDefXLinkWidth (xlo->getWidth() );
  7.1097  				}
  7.1098  				if (dia.deleteXLink())
  7.1099 -					((BranchObj*)(selection))->deleteXLinkAt(i);
  7.1100 +					((BranchObj*)selection)->deleteXLinkAt(i);
  7.1101  				saveState();	//FIXME undoCommand
  7.1102  			}
  7.1103  		}	
  7.1104 @@ -3030,7 +3252,7 @@
  7.1105  	if (selection && 
  7.1106  		(typeid(*selection) == typeid(BranchObj)) )
  7.1107  	{
  7.1108 -		QString s=((BranchObj*)(selection))->getHeading();
  7.1109 +		QString s=((BranchObj*)selection)->getHeading();
  7.1110  		parseAtom(s);
  7.1111  	}
  7.1112  }
  7.1113 @@ -3132,7 +3354,7 @@
  7.1114  				if (selection && 
  7.1115  					((typeid(*selection) == typeid(BranchObj)) || 
  7.1116  					(typeid(*selection) == typeid(MapCenterObj)))  )
  7.1117 -				bo_begin=(BranchObj*)(selection);
  7.1118 +				bo_begin=(BranchObj*)selection;
  7.1119  			if (bo_begin)	
  7.1120  			{
  7.1121  				drawingLink=true;
  7.1122 @@ -3165,7 +3387,7 @@
  7.1123  		if (typeid(*selection)==typeid(BranchObj) ||
  7.1124  			typeid(*selection)==typeid(MapCenterObj) )
  7.1125  		{
  7.1126 -			QString foname=((BranchObj*)(selection))->getSystemFlagName(p);
  7.1127 +			QString foname=((BranchObj*)selection)->getSystemFlagName(p);
  7.1128  			if (!foname.isEmpty())
  7.1129  			{
  7.1130  				// Do not move, if systemFlag clicked
  7.1131 @@ -3200,7 +3422,7 @@
  7.1132  				if (typeid(*selection)==typeid(BranchObj) )
  7.1133  				{
  7.1134  					copyingObj=true;
  7.1135 -					mapCenter->addBranch ((BranchObj*)(selection));
  7.1136 +					mapCenter->addBranch ((BranchObj*)selection);
  7.1137  					unselect();
  7.1138  					selection=mapCenter->getLastBranch();
  7.1139  					selection->select();
  7.1140 @@ -3252,7 +3474,7 @@
  7.1141  
  7.1142  		if (typeid(*selection) == typeid(FloatImageObj))
  7.1143  		{
  7.1144 -			FloatObj *fo=(FloatObj*)(selection);
  7.1145 +			FloatObj *fo=(FloatObj*)selection;
  7.1146  			saveState("move "+qpointToString(movingObj_orgPos),fo->getSelectString() );
  7.1147  			if (fo->getLinkStyle()==StyleUndef) 
  7.1148  			{
  7.1149 @@ -3304,7 +3526,6 @@
  7.1150  				if (lmosel->getDepth()==1)
  7.1151  				{
  7.1152  					// depth==1, mainbranch
  7.1153 -					saveState("move "+qpointToString(movingObj_orgPos), lmosel->getSelectString() );
  7.1154  					lmosel->move(p.x() -movingObj_start.x(), p.y()-movingObj_start.y() );		
  7.1155  				} else
  7.1156  				{
  7.1157 @@ -3389,13 +3610,13 @@
  7.1158  		{	
  7.1159  			if (e->state() & QMouseEvent::ShiftButton)
  7.1160  			{
  7.1161 -				((BranchObj*)(selection))->setColor (((BranchObj*)(dst))->getColor(),false);
  7.1162 -				((BranchObj*)(selection))->setLinkColor ();
  7.1163 +				((BranchObj*)selection)->setColor (((BranchObj*)(dst))->getColor(),false);
  7.1164 +				((BranchObj*)selection)->setLinkColor ();
  7.1165  			}	
  7.1166  			else	
  7.1167  			{
  7.1168 -				((BranchObj*)(selection))->setColor (((BranchObj*)(dst))->getColor(),true);
  7.1169 -				((BranchObj*)(selection))->setLinkColor ();
  7.1170 +				((BranchObj*)selection)->setColor (((BranchObj*)(dst))->getColor(),true);
  7.1171 +				((BranchObj*)selection)->setLinkColor ();
  7.1172  			}	
  7.1173  		} 
  7.1174  		return;
  7.1175 @@ -3427,13 +3648,11 @@
  7.1176  		// Check if we are over another branch, but ignore 
  7.1177  		// any found LMOs, which are FloatObjs
  7.1178  		dst=mapCenter->findMapObj(inverseWorldMatrix().map(e->pos() ), 
  7.1179 -			((LinkableMapObj*)(selection)) );
  7.1180 +			((LinkableMapObj*)selection) );
  7.1181  
  7.1182  		if (dst &&
  7.1183  		(typeid(*dst)!=typeid(BranchObj)&&typeid(*dst)!=typeid(MapCenterObj))) 
  7.1184 -		{
  7.1185  			dst=NULL;
  7.1186 -		}	
  7.1187  		
  7.1188  		// Now check, if we have been moving a branch 
  7.1189  		if (typeid(*selection) == typeid(BranchObj)  )
  7.1190 @@ -3442,13 +3661,13 @@
  7.1191  			QPoint savePos=QPoint (selection->x(),selection->y() );
  7.1192  
  7.1193  			// Reset the temporary drawn link to the original one
  7.1194 -			((LinkableMapObj*)(selection))->unsetParObjTmp();
  7.1195 +			((LinkableMapObj*)selection)->unsetParObjTmp();
  7.1196  
  7.1197  
  7.1198  			copyingObj=false;	
  7.1199  			if (dst ) 
  7.1200  			{
  7.1201 -				BranchObj* bs=((BranchObj*)(selection));
  7.1202 +				BranchObj* bs=((BranchObj*)selection);
  7.1203  				QString undoCom="linkBranchToPos (\""+ 
  7.1204  					(bs->getParObj())->getSelectString()+
  7.1205  					"\","+
  7.1206 @@ -3474,7 +3693,11 @@
  7.1207  						bs->move (savePos);
  7.1208  				} 
  7.1209  				saveState (undoCom,bs->getSelectString() );
  7.1210 -			}	
  7.1211 +			} else
  7.1212 +				if (selection->getDepth()==1)
  7.1213 +					// If we have moved mainbranch only save endposition
  7.1214 +					saveState("move "+qpointToString(movingObj_orgPos), selection->getSelectString() );
  7.1215 +			
  7.1216  			// Draw the original link, before selection was moved around
  7.1217  			mapCenter->reposition();
  7.1218  		}
  7.1219 @@ -3646,7 +3869,7 @@
  7.1220  			BranchObj *bo;
  7.1221  			for (const char* u=uris.first(); u; u=uris.next())
  7.1222  			{
  7.1223 -				bo=((BranchObj*)(selection))->addBranch();
  7.1224 +				bo=((BranchObj*)selection)->addBranch();
  7.1225  				if (bo)
  7.1226  				{
  7.1227  					s=QUriDrag::uriToLocalFile(u);
  7.1228 @@ -3688,7 +3911,7 @@
  7.1229        (typeid(*selection) == typeid(BranchObj)) || 
  7.1230        (typeid(*selection) == typeid(MapCenterObj))  )
  7.1231    {
  7.1232 -    BranchObj *bo=((BranchObj*)(selection));
  7.1233 +    BranchObj *bo=((BranchObj*)selection);
  7.1234      saveState(selection);
  7.1235      //QString fn=fd->selectedFile();
  7.1236      //lastImageDir=fn.left(fn.findRev ("/"));
     8.1 --- a/mapeditor.h	Tue Sep 06 15:04:50 2005 +0000
     8.2 +++ b/mapeditor.h	Mon Sep 12 19:52:51 2005 +0000
     8.3 @@ -37,7 +37,8 @@
     8.4      void saveState();		// save actual state to backup
     8.5      void saveState(LinkableMapObj *);
     8.6      void saveState(const QString &, const QString &);
     8.7 -    void saveState(const SaveMode&, LinkableMapObj *, const QString &, const QString &);
     8.8 +    void saveState(const QString &, LinkableMapObj *);
     8.9 +    void saveState(const SaveMode&, const QString &, LinkableMapObj *, const QString &, LinkableMapObj *);
    8.10      void parseAtom(const QString &);	
    8.11  
    8.12      void addFloatImage(const QPixmap &img);
    8.13 @@ -61,6 +62,7 @@
    8.14  	QString getMapName ();	// e.g. "map"
    8.15  	QString getDestPath (); // e.g. "/home/tux/map.vym"
    8.16      int load (QString&, const LoadMode &);	// newmap, import/replace selection
    8.17 +public:
    8.18      int save(const SaveMode &);	// Save map 
    8.19  	void setZipped(bool);		// save map zipped
    8.20  	bool saveZipped();			// 1 if file will be saved zipped
    8.21 @@ -71,12 +73,15 @@
    8.22      void exportImage (QString fn);		// export as PNG	
    8.23      void exportImage (QString fn, int);	// export in given format
    8.24      void exportASCII();
    8.25 +    void exportLaTeX();
    8.26 +    void exportOOPresentation();
    8.27      void exportXML(const QString&);		// export to directory
    8.28      void clear();		// clear map
    8.29      void copy();		// copy branch to clipboard
    8.30 +    void redo();		// redo last action
    8.31      void undo();		// undo last action
    8.32  private:	
    8.33 -    void undoXML(const QString &);	// undo by replacing with saved data
    8.34 +    void undoXML(const QString &, const QString &);
    8.35      LinkableMapObj* pasteNoSave();		// paste clipboard to branch
    8.36      void cutNoSave();	// cut to clipboard
    8.37  public:	
    8.38 @@ -194,8 +199,6 @@
    8.39  	
    8.40      LinkableMapObj* selection;		// select a LinkableMapObj
    8.41      LinkableMapObj* selectionLast;	// last selection 
    8.42 -	QString undoSelection;			// selection for undo
    8.43 -	QString redoSelection;			// selection for redo
    8.44      MapObj* movingObj;				// moving a MapObj
    8.45  	MapObj* linkingObj_src;			// part of a link
    8.46      QPoint movingObj_orgPos;		// org. pos of mouse before move
    8.47 @@ -208,10 +211,6 @@
    8.48      bool mapDefault;				// Flag if map is untouched
    8.49      bool mapChanged;				// Flag if undo is possible
    8.50  	bool mapUnsaved;				// Flag if map should be saved
    8.51 -    QString backupXML;				// backup (XML) for undo
    8.52 -	QString undoCommand;			// FIXME testing
    8.53 -	QString redoCommand;			// FIXME testing
    8.54 -									// if != NULL
    8.55  
    8.56  	bool printFrame;			// Print frame around map
    8.57  	bool printFooter;			// Print footer below map
    8.58 @@ -225,7 +224,10 @@
    8.59  	QString lastImageDir;		// save dir for adding images
    8.60  
    8.61  	bool isInteractive;			// non interactive don't need tmpdirs
    8.62 -	QString bakMapDir;			// tmp directory with data for undo
    8.63 +	QString tmpMapDir;			// tmp directory with data for undo/redo
    8.64 +	int undosTotal;				// total number of undos 
    8.65 +	int undoNum;				// current number of bakMapDir to be used 
    8.66 +	int undosAvail;				// how many actions can currently be undone
    8.67  	bool blockReposition;		// block while load or undo
    8.68  	bool blockSaveState;		// block while load or undo
    8.69  
     9.1 --- a/misc.cpp	Tue Sep 06 15:04:50 2005 +0000
     9.2 +++ b/misc.cpp	Mon Sep 12 19:52:51 2005 +0000
     9.3 @@ -123,6 +123,45 @@
     9.4  	return d;
     9.5  }
     9.6  
     9.7 +void removeDir(QDir d)
     9.8 +{
     9.9 +	// Traverse directories
    9.10 +	d.setFilter( QDir::Dirs| QDir::Hidden | QDir::NoSymLinks );
    9.11 +	const QFileInfoList *dirlist = d.entryInfoList();
    9.12 +	QFileInfoListIterator itdir( *dirlist );
    9.13 +	QFileInfo *fi;
    9.14 +
    9.15 +	while ( (fi = itdir.current()) != 0 ) 
    9.16 +	{
    9.17 +		if (fi->fileName() != "." && fi->fileName() != ".." )
    9.18 +		{
    9.19 +			if ( !d.cd(fi->fileName()) ) 
    9.20 +				qWarning ("removeDir() cannot find the directory "+fi->fileName());
    9.21 +			else 
    9.22 +			{
    9.23 +				// Recursively remove subdirs
    9.24 +				removeDir (d);
    9.25 +				d.cdUp();
    9.26 +			}
    9.27 +		}	
    9.28 +		++itdir;
    9.29 +	}		
    9.30 +	// Traverse files
    9.31 +	d.setFilter( QDir::Files| QDir::Hidden | QDir::NoSymLinks );
    9.32 +	const QFileInfoList *filelist = d.entryInfoList();
    9.33 +	QFileInfoListIterator itfile( *filelist );
    9.34 +
    9.35 +	while ( (fi = itfile.current()) != 0 ) 
    9.36 +	{
    9.37 +		QFile (fi->filePath()).remove();
    9.38 +		
    9.39 +		++itfile;
    9.40 +	}	
    9.41 +
    9.42 +	if (!d.rmdir(d.path()))
    9.43 +		qWarning ("removeDir("+d.path()+") failed!");
    9.44 +}		
    9.45 +
    9.46  // returns masked "<" ">" "&"
    9.47  QString quotemeta(const QString &s)
    9.48  {
    10.1 --- a/misc.h	Tue Sep 06 15:04:50 2005 +0000
    10.2 +++ b/misc.h	Mon Sep 12 19:52:51 2005 +0000
    10.3 @@ -2,6 +2,7 @@
    10.4  #define MISC_H
    10.5  
    10.6  #include <qpoint.h>
    10.7 +#include <qdir.h>
    10.8  #include <iostream>
    10.9  
   10.10  using namespace std;
   10.11 @@ -16,6 +17,7 @@
   10.12  QPoint normalise (const QPoint &);
   10.13  QString maskPath (QString );
   10.14  QString convertToRel (const QString &,const QString &);
   10.15 +void removeDir(QDir);
   10.16  QString quotemeta(const QString&);	
   10.17  int max (int,int);
   10.18  class BranchObj;
    11.1 --- a/settings.cpp	Tue Sep 06 15:04:50 2005 +0000
    11.2 +++ b/settings.cpp	Mon Sep 12 19:52:51 2005 +0000
    11.3 @@ -1,8 +1,145 @@
    11.4  #include <iostream>
    11.5 +#include <qregexp.h>
    11.6  #include "settings.h"
    11.7 -#include "misc.h"
    11.8  
    11.9  using namespace std;
   11.10 +
   11.11 +bool loadStringFromDisk (const QString &fname, QString &s)
   11.12 +{
   11.13 +	s="";
   11.14 +	QFile file ( fname);
   11.15 +	if ( !file.open( IO_ReadOnly ) ) return false;
   11.16 +
   11.17 +	QTextStream ts( &file );
   11.18 +	ts.setEncoding (QTextStream::UnicodeUTF8);
   11.19 +	while ( !ts.atEnd() ) 
   11.20 +		s+=ts.readLine()+"\n"; 
   11.21 +	file.close();
   11.22 +	return true;
   11.23 +}
   11.24 +
   11.25 +bool saveStringToDisk (const QString &fname, const QString &s)
   11.26 +{
   11.27 +	QFile file( fname);
   11.28 +
   11.29 +	file.setName ( fname);
   11.30 +	if ( !file.open( IO_WriteOnly ) ) 
   11.31 +	{
   11.32 +		file.close();
   11.33 +		return false;
   11.34 +	}	
   11.35 +
   11.36 +	// Write it finally, and write in UTF8, no matter what 
   11.37 +	QTextStream ts( &file );
   11.38 +	ts.setEncoding (QTextStream::UnicodeUTF8);
   11.39 +	ts << s;
   11.40 +	file.close();
   11.41 +	return true;
   11.42 +}
   11.43 +
   11.44 +/////////////////////////////////////////////////////////////////
   11.45 +// SimpleSettings
   11.46 +/////////////////////////////////////////////////////////////////
   11.47 +SimpleSettings::SimpleSettings()
   11.48 +{
   11.49 +	clear();		 
   11.50 +}
   11.51 +
   11.52 +SimpleSettings::~SimpleSettings()
   11.53 +{
   11.54 +}
   11.55 +
   11.56 +void SimpleSettings::clear()
   11.57 +{
   11.58 +	keylist.clear();
   11.59 +	valuelist.clear();
   11.60 +}
   11.61 +
   11.62 +void SimpleSettings::readSettings (const QString &path)
   11.63 +{
   11.64 +	QString s;
   11.65 +	if (!loadStringFromDisk(path,s)) 
   11.66 +	{
   11.67 +		qWarning ("SimpleSettings::readSettings() Couldn't read "+path);
   11.68 +		return;
   11.69 +	}	
   11.70 +	QStringList lines;
   11.71 +	lines=QStringList::split (QRegExp("\n"),s,false);
   11.72 +	int i;
   11.73 +	QStringList::Iterator it=lines.begin();
   11.74 +	while (it !=lines.end() )
   11.75 +	{
   11.76 +		i=(*it).find("=",0);
   11.77 +		keylist.append((*it).left(i));
   11.78 +		valuelist.append((*it).right((*it).length()-i-1));
   11.79 +		it++;
   11.80 +	}
   11.81 +}
   11.82 +
   11.83 +void SimpleSettings::writeSettings (const QString &path)
   11.84 +{
   11.85 +	QString s;
   11.86 +	QStringList::Iterator itk=keylist.begin();
   11.87 +	QStringList::Iterator itv=valuelist.begin();
   11.88 +
   11.89 +	// First search for value in settings saved in map
   11.90 +	while (itk !=keylist.end() )
   11.91 +	{
   11.92 +		s+=*itk+"="+*itv+"\n";
   11.93 +		itk++;
   11.94 +		itv++;
   11.95 +	}
   11.96 +	if (!saveStringToDisk(path,s)) 
   11.97 +		qWarning ("SimpleSettings::writeSettings() Couldn't write "+path);
   11.98 +}
   11.99 +
  11.100 +QString SimpleSettings::readEntry (const QString &key)
  11.101 +{
  11.102 +	QStringList::Iterator itk=keylist.begin();
  11.103 +	QStringList::Iterator itv=valuelist.begin();
  11.104 +
  11.105 +	// First search for value in settings saved in map
  11.106 +	while (itk !=keylist.end() )
  11.107 +	{
  11.108 +		if (*itk == key)
  11.109 +			return *itv;
  11.110 +		itk++;
  11.111 +		itv++;
  11.112 +	}
  11.113 +	qWarning ("SimpleSettings::readEntry()  Couldn't find key "+key);
  11.114 +	return "";
  11.115 +}
  11.116 +
  11.117 +void SimpleSettings::setEntry (const QString &key, const QString &value)
  11.118 +{
  11.119 +	QStringList::Iterator itk=keylist.begin();
  11.120 +	QStringList::Iterator itv=valuelist.begin();
  11.121 +
  11.122 +	if (!key.isEmpty() )
  11.123 +	{
  11.124 +		// Search for existing entry first
  11.125 +		while (itk !=keylist.end() )
  11.126 +		{
  11.127 +			if (*itk == key)
  11.128 +			{
  11.129 +				if (!value.isEmpty())
  11.130 +					*itv=value;
  11.131 +				else
  11.132 +					*itv="";
  11.133 +				return;
  11.134 +			}
  11.135 +			itk++;
  11.136 +			itv++;
  11.137 +		}
  11.138 +		
  11.139 +		// If no entry exists, append a new one
  11.140 +		keylist.append (key);
  11.141 +		valuelist.append (value);
  11.142 +	}
  11.143 +}
  11.144 +
  11.145 +
  11.146 +
  11.147  /////////////////////////////////////////////////////////////////
  11.148  // Settings
  11.149  /////////////////////////////////////////////////////////////////
  11.150 @@ -116,17 +253,3 @@
  11.151  	return s;
  11.152  }
  11.153  
  11.154 -void Settings::write()
  11.155 -{
  11.156 -	QStringList::Iterator itp=pathlist.begin();
  11.157 -	QStringList::Iterator itk=keylist.begin();
  11.158 -	QStringList::Iterator itv=valuelist.begin();
  11.159 -
  11.160 -	while (itp !=pathlist.end() )
  11.161 -	{
  11.162 -		itp++;
  11.163 -		itk++;
  11.164 -		itv++;
  11.165 -	}
  11.166 -}
  11.167 -
    12.1 --- a/settings.h	Tue Sep 06 15:04:50 2005 +0000
    12.2 +++ b/settings.h	Mon Sep 12 19:52:51 2005 +0000
    12.3 @@ -7,7 +7,29 @@
    12.4  
    12.5  #include "misc.h"
    12.6  
    12.7 +// Some helper functions and simplified settings class
    12.8 +// to read and parse settings e.g.  in undo/redo directories
    12.9 +bool loadStringFromDisk (const QString &, QString &);
   12.10 +bool saveStringToDisk (const QString &, const QString &s);
   12.11  
   12.12 +class SimpleSettings
   12.13 +{
   12.14 +public:
   12.15 +    SimpleSettings ();
   12.16 +	~SimpleSettings ();
   12.17 +	void clear();
   12.18 +	void readSettings(const QString &);
   12.19 +	void writeSettings(const QString &);
   12.20 +	QString readEntry (const QString &);
   12.21 +	void setEntry (const QString &,const QString &);
   12.22 +private:	
   12.23 +	QStringList keylist;
   12.24 +	QStringList valuelist;
   12.25 +};
   12.26 +
   12.27 +
   12.28 +// Overloaded QSettings class, used to save some settings in 
   12.29 +// a map instead of users home directory
   12.30  class Settings:public QSettings,public xmlObj
   12.31  {
   12.32  public:
   12.33 @@ -18,7 +40,6 @@
   12.34  	QString readLocalEntry ( const QString &, const QString &, const QString &);
   12.35  	void setLocalEntry (const QString &, const QString &, const QString &);
   12.36  	QString getXMLData (const QString &);
   12.37 -	void write ();
   12.38  
   12.39  protected:
   12.40  	QStringList pathlist;
    13.1 --- a/tex/vym.changelog	Tue Sep 06 15:04:50 2005 +0000
    13.2 +++ b/tex/vym.changelog	Mon Sep 12 19:52:51 2005 +0000
    13.3 @@ -1,3 +1,10 @@
    13.4 +-------------------------------------------------------------------
    13.5 +Mon Sep 12 21:39:38 CEST 2005 - uwedr
    13.6 +
    13.7 +- Version 1.7.5
    13.8 +- Feature: Currently 15 levels of undo (GUI to set value still missing)
    13.9 +- Feature: Experimental LaTeX Export (without headers and opions so far)
   13.10 +
   13.11  -------------------------------------------------------------------
   13.12  Sun Sep  5 10:26:15 CEST 2005 - uwedr
   13.13  
    14.1 --- a/version.h	Tue Sep 06 15:04:50 2005 +0000
    14.2 +++ b/version.h	Mon Sep 12 19:52:51 2005 +0000
    14.3 @@ -1,7 +1,7 @@
    14.4  #ifndef VERSION_H 
    14.5  #define VERSION_H
    14.6  
    14.7 -#define __VYM_VERSION__ "1.7.4"
    14.8 -#define __BUILD_DATE__ "September 5, 2005"
    14.9 +#define __VYM_VERSION__ "1.7.5"
   14.10 +#define __BUILD_DATE__ "September 12, 2005"
   14.11  
   14.12  #endif