# HG changeset patch
# User insilmaril
# Date 1118742097 0
# Node ID 4083860dd82ebbf81f413106f4b522b22eebf99e
# Parent  67a91e28b30f32a7553ec45151c8ea942712b4bc
fixed import into empty map

diff -r 67a91e28b30f -r 4083860dd82e api.cpp
--- a/api.cpp	Mon Jun 06 20:27:42 2005 +0000
+++ b/api.cpp	Tue Jun 14 09:41:37 2005 +0000
@@ -12,7 +12,7 @@
 
 	// Get command
 	re.setPattern ("(.*)\\s");
-	re.setMinimal (false);
+	re.setMinimal (true);
 	pos=re.search (s);
 	if (pos>=0)
 		command=re.cap(1);
diff -r 67a91e28b30f -r 4083860dd82e branchobj.cpp
--- a/branchobj.cpp	Mon Jun 06 20:27:42 2005 +0000
+++ b/branchobj.cpp	Tue Jun 14 09:41:37 2005 +0000
@@ -1293,7 +1293,11 @@
 
 	// set Text in Editor	
 	textEditor->setText(note.getNote() );
-	textEditor->setFilename(note.getFilenameHint() );
+	QString fnh=note.getFilenameHint();
+	if (fnh!="")
+		textEditor->setFilenameHint(note.getFilenameHint() );
+	else	
+		textEditor->setFilenameHint(getHeading() );
 	textEditor->setFontHint (note.getFontHint() );
 	connect (textEditor, SIGNAL (textHasChanged() ), this, SLOT (updateNoteFlag() ) ); 
 	connect (textEditor, SIGNAL (fontSizeHasChanged() ), this, SLOT (updateNoteFlag() ) ); 
diff -r 67a91e28b30f -r 4083860dd82e demos/todo.vym
Binary file demos/todo.vym has changed
diff -r 67a91e28b30f -r 4083860dd82e exportxhtmldialog.ui
--- a/exportxhtmldialog.ui	Mon Jun 06 20:27:42 2005 +0000
+++ b/exportxhtmldialog.ui	Tue Jun 14 09:41:37 2005 +0000
@@ -273,15 +273,15 @@
         </widget>
         <widget class="QGroupBox">
             <property name="name">
-                <cstring>groupBox1</cstring>
+                <cstring>groupBox2</cstring>
             </property>
             <property name="title">
-                <string>Scripts</string>
+                <string>groupBox2</string>
             </property>
         </widget>
         <widget class="QLayoutWidget">
             <property name="name">
-                <cstring>layout34</cstring>
+                <cstring>layout6</cstring>
             </property>
             <grid>
                 <property name="name">
@@ -309,25 +309,9 @@
                         <set>AlignVCenter|AlignRight</set>
                     </property>
                 </widget>
-                <widget class="QPushButton" row="1" column="2">
+                <widget class="QLineEdit" row="0" column="1">
                     <property name="name">
-                        <cstring>browsePostExportButton</cstring>
-                    </property>
-                    <property name="sizePolicy">
-                        <sizepolicy>
-                            <hsizetype>0</hsizetype>
-                            <vsizetype>0</vsizetype>
-                            <horstretch>0</horstretch>
-                            <verstretch>0</verstretch>
-                        </sizepolicy>
-                    </property>
-                    <property name="text">
-                        <string>Browse</string>
-                    </property>
-                </widget>
-                <widget class="QLineEdit" row="1" column="1">
-                    <property name="name">
-                        <cstring>lineEditPostScript</cstring>
+                        <cstring>lineEditPreScript</cstring>
                     </property>
                 </widget>
                 <widget class="QPushButton" row="0" column="2">
@@ -346,11 +330,6 @@
                         <string>Browse</string>
                     </property>
                 </widget>
-                <widget class="QLineEdit" row="0" column="1">
-                    <property name="name">
-                        <cstring>lineEditPreScript</cstring>
-                    </property>
-                </widget>
                 <widget class="QLabel" row="0" column="0">
                     <property name="name">
                         <cstring>textLabel1_3</cstring>
@@ -370,6 +349,27 @@
                         <set>AlignVCenter|AlignRight</set>
                     </property>
                 </widget>
+                <widget class="QLineEdit" row="1" column="1">
+                    <property name="name">
+                        <cstring>lineEditPostScript</cstring>
+                    </property>
+                </widget>
+                <widget class="QPushButton" row="1" column="2">
+                    <property name="name">
+                        <cstring>browsePostExportButton</cstring>
+                    </property>
+                    <property name="sizePolicy">
+                        <sizepolicy>
+                            <hsizetype>0</hsizetype>
+                            <vsizetype>0</vsizetype>
+                            <horstretch>0</horstretch>
+                            <verstretch>0</verstretch>
+                        </sizepolicy>
+                    </property>
+                    <property name="text">
+                        <string>Browse</string>
+                    </property>
+                </widget>
             </grid>
         </widget>
         <spacer>
@@ -385,7 +385,7 @@
             <property name="sizeHint">
                 <size>
                     <width>20</width>
-                    <height>90</height>
+                    <height>40</height>
                 </size>
             </property>
         </spacer>
diff -r 67a91e28b30f -r 4083860dd82e linkablemapobj.cpp
--- a/linkablemapobj.cpp	Mon Jun 06 20:27:42 2005 +0000
+++ b/linkablemapobj.cpp	Tue Jun 14 09:41:37 2005 +0000
@@ -525,7 +525,7 @@
     return parObj;
 }
 
-LinkableMapObj* LinkableMapObj::findObj (QString s)
+LinkableMapObj* LinkableMapObj::findObjBySelect (QString s)
 {
 	LinkableMapObj *lmo=this;
 	QString part;
diff -r 67a91e28b30f -r 4083860dd82e linkablemapobj.h
--- a/linkablemapobj.h	Mon Jun 06 20:27:42 2005 +0000
+++ b/linkablemapobj.h	Tue Jun 14 09:41:37 2005 +0000
@@ -51,7 +51,7 @@
 											// redraw link with given style
     LinkableMapObj* getChildObj();			// returns pointer to fromObj
     LinkableMapObj* getParObj();			// returns pointer to toObj
-    virtual LinkableMapObj* findObj(QString s);	// find obj by selectstring
+    virtual LinkableMapObj* findObjBySelect(QString s);	// find obj by selectstring
     QPoint getChildPos();					// returns pos where childs dock
     QPoint getParPos();						// returns pos where parents dock
     QPoint getRelPos();						// get position relative to parent (or (0,0))
diff -r 67a91e28b30f -r 4083860dd82e mainwindow.cpp
--- a/mainwindow.cpp	Mon Jun 06 20:27:42 2005 +0000
+++ b/mainwindow.cpp	Tue Jun 14 09:41:37 2005 +0000
@@ -967,7 +967,7 @@
 
     a = new QAction( tr( "Export as ASCII (still experimental)" ), QPixmap(), tr( "Export (ASCII)" ), 0, this, "exportASCII" );
     connect( a, SIGNAL( activated() ), this, SLOT( fileExportASCII() ) );
-	// FIXME deactivated, doesn't work with QRichtext anyway
+	// TODO deactivated, doesn't work with QRichtext anyway
 	//   a->addTo( exportMenu );
 
 	a = new QAction( tr( "Export XML" ), QPixmap(), tr( "Export XML" ),  0, this, "exportXML" );
@@ -1313,8 +1313,7 @@
 						{
 							for ( QStringList::Iterator it = flist.begin(); it != flist.end(); ++it ) 
 								*it=tmpMapDir + "/" + *it;
-							// FIXME	
-							// Multiple entries, load all (but only the first one into this ME)
+							// FIXME Multiple entries, load all (but only the first one into this ME)
 							//mainWindow->fileLoadFromTmp (flist);
 							//returnCode=1;	// Silently forget this attempt to load
 							qWarning ("MainWindow::load (fn)  multimap found...");
@@ -1333,11 +1332,19 @@
 			}
 		}
 
+
+		// Save existing filename
+		QString fn_org=me->getFilePath();
+
 		// Finally load map into mapEditor
 		me->setFilePath (mapfile,fn);
 		if (me->load(mapfile,lmode))
 			err=aborted;
 
+		// Restore old (maybe empty) filepath, if this is an import
+		if (lmode!=NewMap)
+			me->setFilePath (fn_org);
+			
 		// Delete tmpDir
 		system ( "rm -rf "+tmpMapDir);
 
diff -r 67a91e28b30f -r 4083860dd82e mapeditor.cpp
--- a/mapeditor.cpp	Mon Jun 06 20:27:42 2005 +0000
+++ b/mapeditor.cpp	Tue Jun 14 09:41:37 2005 +0000
@@ -341,7 +341,6 @@
     mapChanged=false;
 	mapDefault=true;
 	mapUnsaved=false;
-	undoSelection=NULL;
 	
 	zipped=true;
 	filePath="";
@@ -468,8 +467,7 @@
 	char tmpdir[]="/tmp/vym-XXXXXX";	
 	bakMapDir=mkdtemp(tmpdir);
 	makeSubDirs(bakMapDir);
-	// FIXME set permissions
-	// and maybe use QT method for portability
+	// FIXME set permissions and maybe use QT method for portability
 }
 
 void MapEditor::delTmpDirs()
@@ -487,7 +485,7 @@
 }
 
 
-QString MapEditor::saveToDir(const QString &tmpdir, const QString &prefix, bool writeflags, const QPoint &offset, SaveMode savemode)
+QString MapEditor::saveToDir(const QString &tmpdir, const QString &prefix, bool writeflags, const QPoint &offset, LinkableMapObj *saveSelection)
 {
 	// tmpdir		temporary directory to which data will be writte
 	// prefix		mapname, which will be appended to images etc.
@@ -521,7 +519,7 @@
 		colhint=attribut("linkColorHint","HeadingColor");
 
 	QString mapAttr=attribut("version",__VYM_VERSION__);
-	if (savemode==CompleteMap)
+	if (!saveSelection)
 		mapAttr+= attribut("author",mapCenter->getAuthor()) +
 				  attribut("comment",mapCenter->getComment()) +
 			      attribut("date",mapCenter->getDate()) +
@@ -538,15 +536,15 @@
 	standardFlagsDefault->resetUsedCounter();
 	
 	// Build xml recursivly
-	if (savemode==CompleteMap)
+	if (!saveSelection)
 		s+=mapCenter->saveToDir(tmpdir,prefix,writeflags,offset);
 	else
 	{
-		if ( undoSelection &&
-			typeid(*undoSelection) == typeid(BranchObj) )
-			s+=((BranchObj*)(undoSelection))->saveToDir(tmpdir,prefix,offset);
+		if ( typeid(*saveSelection) == typeid(BranchObj) )
+			s+=((BranchObj*)(saveSelection))->saveToDir(tmpdir,prefix,offset);
 		else	
 			if (selection && typeid(*selection)==typeid(BranchObj))
+				// This is used if selected branch is saved from mainwindow
 				s+=((BranchObj*)(selection))->saveToDir(tmpdir,prefix,offset);
 	}
 
@@ -554,7 +552,7 @@
 	s+=settings.getXMLData (destPath);
 
 	// Save selection
-	if (selection) 
+	if (selection && !saveSelection) 
 		s+=valueElement("select",selection->getSelectString());
 
 	decIndent();
@@ -567,44 +565,76 @@
 
 void MapEditor::saveState()
 {
-	saveState (CompleteMap,NULL);
+	saveState (CompleteMap,NULL,"");
 }
 
-void MapEditor::saveState(const SaveMode &mode, LinkableMapObj *part)
+void MapEditor::saveState(LinkableMapObj *undoSel)
 {
-	saveState (mode,part,"");
+	saveState (PartOfMap,undoSel,"");
 }
 
-void MapEditor::saveState(const SaveMode &mode, LinkableMapObj *part, const QString &undoCom)
+void MapEditor::saveState(const QString & c)
 {
-	// all binary data is saved in bakMapDir (created in Constructor)
-	// the xml data itself is kept in memory in backupXML
-	// 
-	// For faster write/read of data, a part of the map can be
-	// written. Then the undoSelection will mark the part of the
-	// map which should be replaced if an undo is wanted later.
-
-	if (mode==PartOfMap && part && (typeid(*part) == typeid (BranchObj) ) ) 
+	saveState (UndoCommand,NULL,c);
+}
+
+void MapEditor::saveState(const SaveMode &savemode, LinkableMapObj *undoSel, const QString &undoCom)
+{
+	if (savemode==UndoCommand)
 	{
-		// So far we only test undoCommands for BranchObjs
 		undoCommand=undoCom;
-		if (undoCommand!="")
-		{
-			undoSelection=part;
-		} else
-		{
-			// Writing a vympart only is useful for BranchObj
-			undoSelection=part;
-			backupXML=saveToDir (bakMapDir,mapName+"-",false, QPoint (),PartOfMap);
-		}
-	} else	
+		backupXML="";
+	}	
+	else if (savemode==PartOfMap && undoSel)
 	{
-		undoCommand="";
-		undoSelection=NULL;
-		backupXML=saveToDir (bakMapDir,mapName+"-",false, QPoint (),CompleteMap);
+		undoCommand="undoPart (\""+undoSel->getSelectString()+"\")";
+		backupXML=saveToDir (bakMapDir,mapName+"-",false, QPoint (),undoSel);
+	} else
+	{
+		undoCommand="undoMap ()";
+		backupXML=saveToDir (bakMapDir,mapName+"-",false, QPoint (),NULL);
+	}
+	/* FIXME testing
+	cout << "ME::saveState()\n";
+	cout << "  undoCom="<<undoCommand<<endl;
+	*/
+}
+
+void MapEditor::parseAtom(const QString &s)
+{
+	API api;
+	QString c,p,p0;
+	api.parseCommand (s,c,p);
+	api.getString(p,p0);
+	/* FIXME testing
+	cout <<"ME::parseAtom  s="<<s<<endl;
+	cout <<"ME::parseAtom  c="<<c<<endl;
+	cout <<"ME::parseAtom  p="<<p<<endl;
+	*/
+
+	// External commands
+	if (c==QString("moveBranchUp"))
+		moveBranchUp();
+	else if (c=="moveBranchDown")
+		moveBranchDown();
+	else if (c=="setHeading")
+		setHeading (p0);
+	// Internal commands, used for undo etc.	
+	else if (c==QString("undoMap"))
+		undoXML("");
+	else if (c==QString("undoPart"))
+		undoXML(p0);
+	else if (c=="select")
+		select (p0);
+	else
+	{
+		cout << "MapEditor::parseAtom: Error!\n";
+		cout << "  Command unknown: \""<<c<<"\""<<endl;
+		cout << "     Used in atom: \""<<s<<"\""<<endl;
 	}	
 }
 
+
 void MapEditor::finishedLineEditNoSave()
 {
 	// This is called by finishedLineEdit or any MapEditor method,
@@ -675,20 +705,28 @@
 
 void MapEditor::setFilePath(QString fname, QString destname)
 {
-	filePath=fname;
-	fileName=fname;
-	destPath=destname;
-
-	// If fname is not an absolute path, complete it
-	filePath=QDir(fname).absPath();
-	fileDir=filePath.left (1+filePath.findRev ("/"));
-
-	// Set short name, too. Search from behind:
-	int i=fileName.findRev("/");
-	if (i>=0) fileName=fileName.remove (0,i+1);
-
-	// Forget the .vym (or .xml) for name of map
-	mapName=fileName.left(fileName.findRev(".",-1,true) );
+	if (fname.isEmpty())
+	{
+		filePath="";
+		fileName="";
+		destPath="";
+	} else
+	{
+		filePath=fname;		// becomes absolute path
+		fileName=fname;		// gets stripped of path
+		destPath=destname;	// needed for vymlinks
+
+		// If fname is not an absolute path, complete it
+		filePath=QDir(fname).absPath();
+		fileDir=filePath.left (1+filePath.findRev ("/"));
+
+		// Set short name, too. Search from behind:
+		int i=fileName.findRev("/");
+		if (i>=0) fileName=fileName.remove (0,i+1);
+
+		// Forget the .vym (or .xml) for name of map
+		mapName=fileName.left(fileName.findRev(".",-1,true) );
+	}
 }
 
 QString MapEditor::getFilePath()
@@ -728,7 +766,7 @@
 	} else
 	{
 		setChanged();
-		saveState(PartOfMap,selection);
+		saveState(selection);
 	}	
 	
     
@@ -785,6 +823,9 @@
 
 	int returnCode=0;
 
+	// The SaveMode UndoCommand is not supported here
+	if (savemode==UndoCommand) return 1;
+
 	// Create mapName and fileDir
 	makeSubDirs (fileDir);
 	QString fname;
@@ -807,7 +848,10 @@
 	file.close();
 
 	QString saveFile;
-	saveFile=saveToDir (fileDir,mapName+"-",true,QPoint(),savemode);
+	if (savemode==CompleteMap || selection==NULL)
+		saveFile=saveToDir (fileDir,mapName+"-",true,QPoint(),NULL);
+	else	
+		saveFile=saveToDir (fileDir,mapName+"-",true,QPoint(),selection);
 
 	file.setName ( fileDir  + fname);
 	if ( !file.open( IO_WriteOnly ) )
@@ -1073,7 +1117,7 @@
 	makeSubDirs (dir);
 
 	// write to directory
-	QString saveFile=saveToDir (dir,mapName+"-",true,mapCenter->getTotalBBox().topLeft() ,CompleteMap);
+	QString saveFile=saveToDir (dir,mapName+"-",true,mapCenter->getTotalBBox().topLeft() ,NULL);
 	QFile file;
 
 	file.setName ( dir + "/"+mapName+".xml");
@@ -1105,82 +1149,6 @@
 	mapCenter->clear();
 }
 
-void MapEditor::undo()
-{
-	QDir d;
-	d.setPath(bakMapDir);
-	if (d.exists() )
-	{
-		// Finish open lineEdits
-		if (lineedit) finishedLineEditNoSave();
-
-		if (selection) 
-		{
-			selection->unselect();
-			selection=NULL;
-		}	
-		
-		if (undoCommand!="" && undoSelection)
-		{
-			// We don't need to parse XML backup, but
-			// do the undoCommand
-			selection=undoSelection;
-			selection->select();
-			parseTest (undoCommand);
-
-		} else
-		{
-			// We need to parse saved XML data
-			mapBuilderHandler handler;
-			QXmlInputSource source;
-			source.setData(backupXML);
-			QXmlSimpleReader reader;
-			reader.setContentHandler( &handler );
-			reader.setErrorHandler( &handler );
-			handler.setMapEditor( this );
-			handler.setTmpDir ( bakMapDir );	// needed to load files with rel. path
-			if (undoSelection)
-			{
-				selection=undoSelection;
-				selection->select();
-				handler.setLoadMode (ImportReplace);
-
-			} else	
-			{
-				mapCenter->clear();
-				handler.setLoadMode (NewMap);
-			}	
-			blockreposition=true;
-			bool ok = reader.parse( source );
-			blockreposition=false;
-			if ( ok ) 
-				mapCenter->reposition();
-				
-			else 
-			{	
-				// This should never ever happen
-				QMessageBox::critical( 0, tr( "Critical Parse Error by reading backupFile" ),
-									   tr( handler.errorProtocol() )+" in "+backupXML );
-			}
-		} // restoring saved version	
-
-		// Undo not longer available now
-		actionEditUndo->setEnabled (false);
-		undoSelection=false;
-		mapChanged=false;
-		return;
-	} else	
-	{
-		QMessageBox::critical( 0, tr( "Critical Error" ),
-			"Temporary directory " +bakMapDir + 
-			tr (" used for undo is gone. \n"
-			"I will create a new one, but at the moment no undo is available.\n"
-			"Maybe you want to reload your original data.\n\n"
-			"Sorry for any inconveniences.") );
-		makeTmpDirs();	
-	}							
-}
-
 void MapEditor::copy()
 {
 	// Finish open lineEdits
@@ -1244,6 +1212,72 @@
 	}	    
 }
 
+void MapEditor::undo()
+{
+	// Finish open lineEdits
+	if (lineedit) finishedLineEditNoSave();
+
+	// Unselect
+	if (selection) 
+	{
+		selection->unselect();
+		selection=NULL;
+	}	
+		
+	parseAtom (undoCommand);
+	mapCenter->reposition();
+
+	// Undo not longer available now
+	actionEditUndo->setEnabled (false);
+	mapChanged=false;
+
+}
+
+void MapEditor::undoXML(const QString &undoSel)
+{
+	QDir d;
+	d.setPath(bakMapDir);
+	if (d.exists() )
+	{
+		// We need to parse saved XML data
+		mapBuilderHandler handler;
+		QXmlInputSource source;
+		source.setData(backupXML);
+		QXmlSimpleReader reader;
+		reader.setContentHandler( &handler );
+		reader.setErrorHandler( &handler );
+		handler.setMapEditor( this );
+		handler.setTmpDir ( bakMapDir );	// needed to load files with rel. path
+		if (undoSel.isEmpty())
+		{
+			mapCenter->clear();
+			handler.setLoadMode (NewMap);
+		} else	
+		{
+			select (undoSel);
+			handler.setLoadMode (ImportReplace);
+		}	
+		blockreposition=true;
+		bool ok = reader.parse( source );
+		blockreposition=false;
+		if (! ok ) 
+		{	
+			// This should never ever happen
+			QMessageBox::critical( 0, tr( "Critical Parse Error by reading backupFile" ),
+								   tr( handler.errorProtocol() )+" in "+backupXML );
+		}
+	} else	
+	{
+		QMessageBox::critical( 0, tr( "Critical Error" ),
+			"Temporary directory " +bakMapDir + 
+			tr (" used for undo is gone. \n"
+			"I will create a new one, but at the moment no undo is available.\n"
+			"Maybe you want to reload your original data.\n\n"
+			"Sorry for any inconveniences.") );
+		makeTmpDirs();	
+	}							
+}
+
 LinkableMapObj* MapEditor::pasteNoSave()
 {
 	// Finish open lineEdits
@@ -1309,7 +1343,7 @@
 void MapEditor::paste()
 {   
 	setChanged();
-	saveState(PartOfMap,selection);
+	saveState(selection);
 	pasteNoSave();
 	mapCenter->reposition();
 	adjustCanvasSize();
@@ -1318,7 +1352,7 @@
 void MapEditor::cut()
 {
 	setChanged();
-	saveState(PartOfMap,selection->getParObj());
+	saveState(selection->getParObj());
 	copy();
 	cutNoSave();
 	mapCenter->reposition();
@@ -1335,7 +1369,7 @@
 	if (typeid(*selection) == typeid(BranchObj)  ) 
 	{
 		setChanged();
-		saveState(PartOfMap,selection,"moveBranchDown ()");
+		saveState("moveBranchDown ()");
 		bo=(BranchObj*)(selection);
 		par=(BranchObj*)(bo->getParObj());
 		selection->unselect();
@@ -1356,7 +1390,7 @@
 	if (typeid(*selection) == typeid(BranchObj)  ) 
 	{
 		setChanged();
-		saveState(PartOfMap,selection,"moveBranchUp ()");
+		saveState("moveBranchUp ()");
 		bo=(BranchObj*)(selection);
 		par=(BranchObj*)(bo->getParObj());
 		selection->unselect(); 
@@ -1377,7 +1411,7 @@
 		  typeid(*selection) == typeid(MapCenterObj) ) ) 
 	{
 		setChanged();
-		saveState(PartOfMap,selection);
+		saveState("setHeading (\""+((BranchObj*)(selection))->getHeading()+"\")");
 
 		ensureSelectionVisible();
 		editingBO=(BranchObj*)(selection);
@@ -1395,6 +1429,20 @@
 	}				
 }
 
+void MapEditor::setHeading(const QString &s)
+{
+	// Internal function, no saveState needed
+	if (selection  &&  
+		 (typeid(*selection) == typeid(BranchObj) || 
+		  typeid(*selection) == typeid(MapCenterObj) ) ) 
+	{
+		((BranchObj*)(selection))->setHeading(s);
+		mapCenter->reposition();
+		adjustCanvasSize();
+		ensureSelectionVisible();
+	}
+}
+
 void MapEditor::addNewBranch(int pos)
 {
 	// Finish open lineEdits
@@ -1405,7 +1453,7 @@
 		  typeid(*selection) == typeid(MapCenterObj) ) ) 
 	{
 		setChanged();
-		saveState(PartOfMap,selection);
+		saveState(selection);
 
 		BranchObj* bo1 = (BranchObj*) (selection);
 		bool wasScrolled=false;
@@ -1471,7 +1519,7 @@
 		 (typeid(*selection) == typeid(BranchObj) ) )
 	{
 		setChanged();
-		saveState(PartOfMap,selection);
+		saveState(selection);
 
 		BranchObj* bo1 = (BranchObj*) (selection);
 		bool wasScrolled=false;
@@ -1520,7 +1568,7 @@
 	if (selection  && typeid(*selection) ==typeid(BranchObj) ) 
 	{
 		setChanged();
-		saveState(PartOfMap,selection->getParObj());
+		saveState(selection->getParObj());
 		BranchObj* bo=dynamic_cast <BranchObj*> (selection);
 		BranchObj* par=(BranchObj*)(bo->getParObj());
 		bo->unselect();
@@ -1535,7 +1583,7 @@
 	if (selection  && typeid(*selection) ==typeid(FloatImageObj) ) 
 	{
 		setChanged();
-		saveState(PartOfMap,selection->getParObj());
+		saveState(selection->getParObj());
 		FloatImageObj* fio=dynamic_cast <FloatImageObj*> (selection);
 		BranchObj* par=(BranchObj*)(fio->getParObj());
 		fio->unselect();
@@ -1556,7 +1604,7 @@
 
 bool MapEditor::select (const QString &s)
 {
-	LinkableMapObj *lmo=mapCenter->findObj(s);
+	LinkableMapObj *lmo=mapCenter->findObjBySelect(s);
 
 	// Finally select the found object
 	if (lmo)
@@ -2006,7 +2054,7 @@
 			typeid(*selection) == typeid(MapCenterObj))
 		{
 			setChanged();
-			saveState(PartOfMap,selection);
+			saveState(selection);
 			BranchObj *bo=(BranchObj*)(selection);
 			bo->setColor(actColor, false); // color links, color childs
 		}    
@@ -2021,7 +2069,7 @@
 			typeid(*selection) == typeid(MapCenterObj))
 		{
 			setChanged();
-			saveState(PartOfMap,selection);
+			saveState(selection);
 			BranchObj *bo=(BranchObj*)(selection);
 			bo->setColor(actColor, true); // color links, color childs
 		}    
@@ -2034,7 +2082,7 @@
 	if (selection)
 	{
 		setChanged();
-		saveState(PartOfMap,selection);	
+		saveState(selection);	
 		((BranchObj*)(selection))->toggleStandardFlag (f,actionSettingsUseFlagGroups);
 	}	
 }
@@ -2234,7 +2282,7 @@
 	if (selection && (typeid(*selection) == typeid(BranchObj) ))
 	{		
 		setChanged();
-		saveState(PartOfMap,selection->getParObj());
+		saveState(selection->getParObj());
 		QString sel=selection->getSelectString();
 		BranchObj* bo=(BranchObj*)(selection);
 		BranchObj* par=(BranchObj*)(bo->getParObj());
@@ -2250,7 +2298,7 @@
 	if (selection && (typeid(*selection) == typeid(BranchObj) ))
 	{		
 		setChanged();
-		saveState(PartOfMap,selection->getParObj());
+		saveState(selection->getParObj());
 		((BranchObj*)(selection))->removeChilds();
 		mapCenter->reposition();
 	}	
@@ -2555,7 +2603,7 @@
 		if (bo->countBranches()==0) return;
 		if (bo->getDepth()==0) return;
 		setChanged();
-		saveState(PartOfMap,selection);
+		saveState(selection);
 		bo->toggleScroll();
 		adjustCanvasSize();
 		canvas()->update();
@@ -2595,7 +2643,7 @@
 		if ( fd->exec() == QDialog::Accepted )
 		{
 			setChanged();
-			saveState(PartOfMap,selection);
+			saveState(selection);
 			QString fn=fd->selectedFile();
 			lastImageDir=fn.left(fn.findRev ("/"));
 			bo->addFloatImage();
@@ -2816,25 +2864,10 @@
 		(typeid(*selection) == typeid(BranchObj)) )
 	{
 		QString s=((BranchObj*)(selection))->getHeading();
-		parseTest (s);
+		parseAtom(s);
 	}
 }
 
-void MapEditor::parseTest(const QString &s)
-{
-	API api;
-	QString c,p,p0;
-	api.parseCommand (s,c,p);
-	if (c==QString("moveBranchUp"))
-		moveBranchUp();
-	else if (c=="moveBranchDown")
-		moveBranchDown();
-	else if (c=="select")
-		select (p);
-	else
-		cout << "Don't know about command \""<<s<<"\".\n";
-}
-
 void MapEditor::ensureSelectionVisible()
 {
 	if (selection)
@@ -3109,7 +3142,7 @@
 				{
 					// depth==1, mainbranch
 					setChanged();
-					saveState(PartOfMap,lmosel);
+					saveState(lmosel);
 					lmosel->move(p.x() -movingObj_start.x(), p.y()-movingObj_start.y() );		
 				} else
 				{
@@ -3326,7 +3359,7 @@
 			selection=lmo;
 			selection->select();
 			setChanged();
-			saveState(PartOfMap,selection);
+			saveState(selection);
 			editHeading();
 		}
 	}
diff -r 67a91e28b30f -r 4083860dd82e mapeditor.h
--- a/mapeditor.h	Mon Jun 06 20:27:42 2005 +0000
+++ b/mapeditor.h	Tue Jun 14 09:41:37 2005 +0000
@@ -29,11 +29,12 @@
 	void delTmpDirs();		// delete temporary directories
 	void makeSubDirs(const QString&);		
 							// create subdirs in dir
-    QString saveToDir(const QString&,const QString &,bool, const QPoint
-	&,SaveMode);
+    QString saveToDir(const QString&,const QString &,bool, const QPoint &,LinkableMapObj*);
     void saveState();		// save actual state to backup
-    void saveState(const SaveMode&, LinkableMapObj *);
+    void saveState(LinkableMapObj *);
+    void saveState(const QString &);
     void saveState(const SaveMode&, LinkableMapObj *, const QString &);
+    void parseAtom(const QString &);	
 
 private slots:
     void finishedLineEditNoSave();
@@ -63,9 +64,10 @@
     void exportASCII();
     void exportXML(const QString&);		// export to directory
     void clear();		// clear map
+    void copy();		// copy branch to clipboard
     void undo();		// undo last action
-    void copy();		// copy branch to clipboard
 private:	
+    void undoXML(const QString &);	// undo by replacing with saved data
     LinkableMapObj* pasteNoSave();		// paste clipboard to branch
     void cutNoSave();	// cut to clipboard
 public:	
@@ -73,7 +75,10 @@
     void cut();			// cut to clipboard and backup
     void moveBranchUp();
     void moveBranchDown();
-    void editHeading();
+    void editHeading();					// Start editing heading 
+private:
+	void setHeading(const QString &);	// Just set the heading for selection
+public:	
     void addNewBranch(int);			// pos allows to add above/below selection
     void addNewBranchHere();		// insert and make selection its
     void deleteSelection();
@@ -138,7 +143,6 @@
 	void followXLink (int);
 	void editXLink (int);
     void testFunction();				// FIXME just testing
-    void parseTest(const QString &);	// FIXME just testing
 
 protected:
 	void ensureSelectionVisible();		
@@ -185,7 +189,6 @@
     bool mapChanged;				// Flag if undo is possible
 	bool mapUnsaved;				// Flag if map should be saved
     QString backupXML;				// backup (XML) for undo
-	LinkableMapObj* undoSelection;	// replace this LMO with vympart from backup
 	QString undoCommand;			// FIXME testing
 									// if != NULL
 
diff -r 67a91e28b30f -r 4083860dd82e misc.h
--- a/misc.h	Mon Jun 06 20:27:42 2005 +0000
+++ b/misc.h	Tue Jun 14 09:41:37 2005 +0000
@@ -15,7 +15,7 @@
 #define Z_TEXT   100
 
 enum LoadMode {NewMap,ImportAdd,ImportReplace};
-enum SaveMode {PartOfMap,CompleteMap};
+enum SaveMode {PartOfMap,CompleteMap,UndoCommand};
 
 /////////////////////////////////////////////////////////////////////////////
 extern ostream &operator<< (ostream &stream, QPoint const &p);
diff -r 67a91e28b30f -r 4083860dd82e tex/vym.changelog
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tex/vym.changelog	Tue Jun 14 09:41:37 2005 +0000
@@ -0,0 +1,4 @@
+-------------------------------------------------------------------
+Tue Jun 14 11:43:44 CEST 2005
+
+- Bugfix: Importing map into new map now has correct (empty) filename 
diff -r 67a91e28b30f -r 4083860dd82e tex/vym.tex
--- a/tex/vym.tex	Mon Jun 06 20:27:42 2005 +0000
+++ b/tex/vym.tex	Tue Jun 14 09:41:37 2005 +0000
@@ -751,6 +751,9 @@
 \begin{longtable}{|lcp{8cm}l|} \hline
 Version	&	&	Comment								& Date	\\ \hline \hline \endhead
 	\hline \endfoot
+1.6.8	& - &	Dramatic in speedup in some operations 
+				(e.g. move branch up/down) due to extended 
+				undo engine							& 2005-06-07 \\ 
 1.6.7	& - &	Changed default pdf-reader for Mac OSX & 2005-05-27 \\ 
 		& - &	Bugfix: xLinks stopped working in 1.6.6			&\\
 		& - &	Bugfix: drawing error when using modModeCopy    &\\
@@ -805,7 +808,7 @@
       	& -	&	z-plane of floatimages can be set (manually only)& \\
 		& - &	Bugfix: Wrong ordering of branches, if mainbranch is
 				exactly left of center& \\
-1.4.7 	& -	&	New Export to HTML by Thomas Schraitle.	& 2004-09.24 \\
+1.4.7 	& -	&	New Export to XHTML by Thomas Schraitle.	& 2004-09-24 \\
 		& - &	Bugfix: vymLink&	\\
 		& - &	Bugfix: spaces and dots in filenames	& \\
 		& - &	Bugfix: Error message if xsltproc is not installed& \\
diff -r 67a91e28b30f -r 4083860dd82e texteditor.cpp
--- a/texteditor.cpp	Mon Jun 06 20:27:42 2005 +0000
+++ b/texteditor.cpp	Tue Jun 14 09:41:37 2005 +0000
@@ -114,6 +114,7 @@
 		actionSettingsFonthintDefault->setOn (false);
 		e->setCurrentFont (varFont);
 	}	
+	filenameHint="";
 }
 
 
@@ -206,6 +207,16 @@
 	return filename;
 }
 
+void TextEditor::setFilenameHint(const QString &fnh)
+{
+	filenameHint=fnh;
+}
+
+QString TextEditor::getFilenameHint()
+{
+	return filenameHint;
+}
+
 bool TextEditor::findText(const QString &t, const bool &cs)
 {
 	bool wo=false;	// word matches
@@ -693,8 +704,16 @@
 void TextEditor::textExportAsASCII()
 {
 	QString text = textConvertToASCII( e->text());
-    QString fn = QFileDialog::getSaveFileName( QString::null, "VYM Note (ASCII) (*.txt);;All files (*)",
-					       this,"export note dialog",tr("Export Note to single file (ASCII)") );
+	QString fn,s;
+	if (!filenameHint.isEmpty())
+	{
+		if (!filenameHint.contains (".txt"))
+			s=filenameHint+".txt";
+		else	
+			s=filenameHint;
+	} else	
+		s=QString::null;
+	fn = QFileDialog::getSaveFileName( s, "VYM Note (ASCII) (*.txt);;All files (*)", this,"export note dialog",tr("Export Note to single file (ASCII)") );
 	int ret=-1;
 
     if ( !fn.isEmpty() ) 
diff -r 67a91e28b30f -r 4083860dd82e texteditor.h
--- a/texteditor.h	Mon Jun 06 20:27:42 2005 +0000
+++ b/texteditor.h	Tue Jun 14 09:41:37 2005 +0000
@@ -24,6 +24,8 @@
 	QString getFontHintDefault();
 	void setFilename (const QString&);
 	QString getFilename ();
+	void setFilenameHint (const QString&);
+	QString getFilenameHint ();
 	bool findText(const QString &, const bool &); // find Text 
 
 protected:
@@ -79,6 +81,7 @@
     QTextEdit *e;
 	QPoint lastPos;			// save last position of window
     QString filename;
+    QString filenameHint;
 
 	QBrush emptyPaper;		// setting the background color
 	QBrush filledPaper;		// depending on the state
@@ -116,8 +119,6 @@
 	*actionAlignCenter,
 	*actionAlignRight,
 	*actionAlignJustify;
-
-
 };
 
 #endif
diff -r 67a91e28b30f -r 4083860dd82e version.h
--- a/version.h	Mon Jun 06 20:27:42 2005 +0000
+++ b/version.h	Tue Jun 14 09:41:37 2005 +0000
@@ -2,6 +2,6 @@
 #define VERSION_H
 
 #define __VYM_VERSION__ "1.6.8"
-#define __BUILD_DATE__ "June 06, 2005"
+#define __BUILD_DATE__ "June 14, 2005"
 
 #endif
diff -r 67a91e28b30f -r 4083860dd82e xlinkobj.cpp
--- a/xlinkobj.cpp	Mon Jun 06 20:27:42 2005 +0000
+++ b/xlinkobj.cpp	Tue Jun 14 09:41:37 2005 +0000
@@ -53,7 +53,7 @@
 
 void XLinkObj::copy (XLinkObj* other)
 {
-	// FIXME copy not used yet
+	// TODO copy not used yet
 	MapObj::copy (other);
 	setVisibility (other->visible);
 	beginBranch=other->beginBranch;
@@ -271,11 +271,8 @@
 	if (beginBranch && endBranch &&xLinkState==activeXLink)
 	{
 		if (beginBranch==endBranch && xLinkState)
-		{
-			//FIXME testing
-			//cout << "   identical ends: "<<beginBranch->getSelectString()<<endl;
 			s="";
-		} else
+		else
 		{
 			QString colAttr=attribut ("color",color.name());
 			QString widAttr=attribut ("width",QString().setNum(width,10));
diff -r 67a91e28b30f -r 4083860dd82e xml.cpp
--- a/xml.cpp	Mon Jun 06 20:27:42 2005 +0000
+++ b/xml.cpp	Tue Jun 14 09:41:37 2005 +0000
@@ -540,11 +540,11 @@
 	{
 		if (!a.value( "endBranch").isEmpty() ) 
 		{
-			LinkableMapObj *lmo=mc->findObj (a.value( "beginBranch"));
+			LinkableMapObj *lmo=mc->findObjBySelect (a.value( "beginBranch"));
 			if (lmo && typeid (*lmo)==typeid (BranchObj))
 			{
 				xlo->setBegin ((BranchObj*)(lmo));
-				lmo=mc->findObj (a.value( "endBranch"));
+				lmo=mc->findObjBySelect (a.value( "endBranch"));
 				if (lmo && typeid (*lmo)==typeid (BranchObj))
 				{
 					xlo->setEnd ((BranchObj*)(lmo));