# HG changeset patch
# User insilmaril
# Date 1156940185 0
# Node ID 557239819c4584990e2655a82474233914ad95cf
# Parent  41c3d7f9f53215fcede98fbdd5b468cda0742713
Fixed editing of headings. Undo debug output still enabled

diff -r 41c3d7f9f532 -r 557239819c45 branchobj.cpp
--- a/branchobj.cpp	Tue Aug 29 08:31:42 2006 +0000
+++ b/branchobj.cpp	Wed Aug 30 12:16:25 2006 +0000
@@ -14,6 +14,7 @@
 /////////////////////////////////////////////////////////////////
 
 BranchObj* BranchObj::itLast=NULL;
+BranchObj* BranchObj::itFirst=NULL;
 
 
 BranchObj::BranchObj () :OrnamentedObj()
@@ -406,6 +407,7 @@
 BranchObj* BranchObj::first()
 {
 	itLast=NULL;	
+	itFirst=this;
 	return this; 
 }
 	
@@ -416,15 +418,17 @@
 	BranchObj *po=(BranchObj*)(parObj);
 
 	if (!itLast)
-	{	// We are just beginning at the mapCenter
+	{
 		if (bo) 
-		{
+		{	// We are just beginning, 
+			// return first child  
 			itLast=this;
 			return bo;
 		}	
 		else
 		{
-			itLast=NULL;
+			// No childs
+			itLast=this;
 			return NULL;
 		}	
 	}
@@ -457,7 +461,7 @@
 		}
 	}
 
-	// Try to find last child, we came from, in my own childs
+	// Try to find last child, where we came from, in my own childs
 	bool searching=true;
 	while (bo && searching)
 	{
@@ -476,6 +480,7 @@
 		{
 			if (po)
 			{
+				if (this==itFirst) return NULL;	// Stop at starting point
 				// go up
 				itLast=this;
 				lmo=po->next();
diff -r 41c3d7f9f532 -r 557239819c45 branchobj.h
--- a/branchobj.h	Tue Aug 29 08:31:42 2006 +0000
+++ b/branchobj.h	Wed Aug 30 12:16:25 2006 +0000
@@ -124,6 +124,7 @@
 
 protected:
 	static BranchObj* itLast;		// iterator for first(), next()
+	static BranchObj* itFirst;		// first iterator for first(), next()
     BranchObjPtrList branch;		// all child branches
 	Q3PtrList<FloatImageObj> floatimage;	// child images
 	Q3PtrList<XLinkObj> xlink;		// xlinks to other branches
diff -r 41c3d7f9f532 -r 557239819c45 demos/todo.vym
Binary file demos/todo.vym has changed
diff -r 41c3d7f9f532 -r 557239819c45 main.cpp
--- a/main.cpp	Tue Aug 29 08:31:42 2006 +0000
+++ b/main.cpp	Wed Aug 30 12:16:25 2006 +0000
@@ -52,6 +52,7 @@
 QAction *actionEditBugzilla2URL;
 QAction *actionEditFATE2URL;
 QAction *actionEditOpenVymLink;
+QAction *actionEditOpenMultipleVymLinks;
 QAction *actionEditVymLink;
 QAction *actionEditToggleHideExport;
 QAction *actionEditDeleteVymLink;
@@ -112,8 +113,9 @@
 QMenu* branchContextMenu;
 QMenu* branchAddContextMenu;
 QMenu* branchRemoveContextMenu;
-QMenu* branchLinksContextMenuEdit;
-QMenu* branchLinksContextMenuFollow;
+QMenu* branchLinksContextMenu;
+QMenu* branchXLinksContextMenuEdit;
+QMenu* branchXLinksContextMenuFollow;
 QMenu* floatimageContextMenu;
 QMenu* canvasContextMenu;
 QMenu* fileLastMapsMenu;
diff -r 41c3d7f9f532 -r 557239819c45 mainwindow.cpp
--- a/mainwindow.cpp	Tue Aug 29 08:31:42 2006 +0000
+++ b/mainwindow.cpp	Wed Aug 30 12:16:25 2006 +0000
@@ -69,6 +69,7 @@
 extern QAction* actionEditBugzilla2URL;
 extern QAction* actionEditFATE2URL;
 extern QAction *actionEditOpenVymLink;
+extern QAction *actionEditOpenMultipleVymLinks;
 extern QAction *actionEditVymLink;
 extern QAction *actionEditDeleteVymLink;
 extern QAction *actionEditToggleHideExport;
@@ -129,8 +130,9 @@
 extern QMenu* branchContextMenu;
 extern QMenu* branchAddContextMenu;
 extern QMenu* branchRemoveContextMenu;
-extern QMenu* branchLinksContextMenuEdit;
-extern QMenu* branchLinksContextMenuFollow;
+extern QMenu* branchLinksContextMenu;
+extern QMenu* branchXLinksContextMenuEdit;
+extern QMenu* branchXLinksContextMenuFollow;
 extern QMenu* floatimageContextMenu;
 extern QMenu* canvasContextMenu;
 extern QMenu* fileLastMapsMenu;
@@ -259,10 +261,10 @@
 	settings.setValue( "/version/version", __VYM_VERSION );
 	settings.setValue( "/version/builddate", __BUILD_DATE );
 
-	settings.setValue( "/mapeditor/editmode/autoselectheading",actionSettingsAutoselectHeading->isOn() );
-	settings.setValue( "/mapeditor/editmode/autoselecttext",actionSettingsAutoselectText->isOn() );
-	settings.setValue( "/mapeditor/editmode/pastenewheading",actionSettingsPasteNewHeading->isOn() );
-	settings.setValue( "/mapeditor/editmode/autoedit",actionSettingsAutoedit->isOn() );
+	settings.setValue( "/mapeditor/editmode/autoSelectHeading",actionSettingsAutoselectHeading->isOn() );
+	settings.setValue( "/mapeditor/editmode/autoSelectText",actionSettingsAutoselectText->isOn() );
+	settings.setValue( "/mapeditor/editmode/pasteNewHeading",actionSettingsPasteNewHeading->isOn() );
+	settings.setValue( "/mapeditor/editmode/autoEdit",actionSettingsAutoedit->isOn() );
 	settings.setValue( "/mapeditor/editmode/useDelKey",actionSettingsUseDelKey->isOn() );
 	settings.setValue( "/mapeditor/editmode/useFlagGroups",actionSettingsUseFlagGroups->isOn() );
 	settings.setValue( "/export/useHideExport",actionSettingsUseHideExport->isOn() );
@@ -680,8 +682,8 @@
 
 	a = new QAction( tr( "Open all URLs in subtree" ), this);
 	a->setStatusTip (tr( "Open all URLs in subtree" ));
-	a->setShortcut (Qt::CTRL+Qt::Key_U );
 	addAction(a);
+	actionListBranches.append(a);
     connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleURLTabs() ) );
 	actionEditOpenMultipleURLTabs=a;
 
@@ -716,13 +718,21 @@
     connect( a, SIGNAL( triggered() ), this, SLOT( editFATE2URL() ) );
 	actionEditFATE2URL=a;
 	
-    a = new QAction(QPixmap(flagsPath+"flag-vymlink.png"), tr( "Jump to map" ), this);
+    a = new QAction(QPixmap(flagsPath+"flag-vymlink.png"), tr( "Open xlinked map" ), this);
 	a->setStatusTip ( tr( "Jump to another vym map, if needed load it first" ));
     tb->addAction (a);
 	a->setEnabled (false);
     connect( a, SIGNAL( triggered() ), this, SLOT( editOpenVymLink() ) );
 	actionEditOpenVymLink=a;
 	
+    a = new QAction(QPixmap(), tr( "Open all vym links in subtree" ), this);
+	a->setStatusTip ( tr( "Open all vym links in subtree" ));
+	a->setEnabled (false);
+	actionListBranches.append(a);
+    connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleVymLinks() ) );
+	actionEditOpenMultipleVymLinks=a;
+	
+
     a = new QAction(tr( "Edit vym link"+QString("...") ), this);
 	a->setEnabled (false);
 	a->setStatusTip ( tr( "Edit link to another vym map" ));
@@ -1413,28 +1423,28 @@
     a = new QAction( tr( "Edit branch after adding it" ), this );
     a->setStatusTip( tr( "Edit branch after adding it" ));
 	a->setToggleAction(true);
-	a->setOn ( settings.value ("/mapeditor/editmode/autoedit",true).toBool());
+	a->setOn ( settings.value ("/mapeditor/editmode/autoEdit",true).toBool());
 	settingsMenu->addAction (a);
 	actionSettingsAutoedit=a;
 
     a= new QAction( tr( "Select branch after adding it" ), this );
     a->setStatusTip( tr( "Select branch after adding it" ));
 	a->setToggleAction(true);
-	a->setOn ( settings.value ("/mapeditor/editmode/autoselect",false).toBool() );
+	a->setOn ( settings.value ("/mapeditor/editmode/autoSelectHeading",false).toBool() );
 	settingsMenu->addAction (a);
 	actionSettingsAutoselectHeading=a;
 	
     a= new QAction(tr( "Select existing heading" ), this);
     a->setStatusTip( tr( "Select heading before editing" ));
 	a->setToggleAction(true);
-	a->setOn ( settings.value ("/mapeditor/editmode/autoselectexistingtext",true).toBool() );
+	a->setOn ( settings.value ("/mapeditor/editmode/autoSelectText",true).toBool() );
 	settingsMenu->addAction (a);
 	actionSettingsAutoselectText=a;
 	
     a= new QAction(tr( "pasting into new branch" ), this );
     a->setStatusTip( tr( "Pasting into new branch" ));
 	a->setToggleAction(true);
-	a->setOn ( settings.value ("/mapeditor/editmode/newheadingisempty",true).toBool() );
+	a->setOn ( settings.value ("/mapeditor/editmode/newHeadingIsEmpty",true).toBool() );
 	settingsMenu->addAction (a);
 	actionSettingsPasteNewHeading=a;
 	
@@ -1527,22 +1537,6 @@
 	actionEditSaveBranch->addTo( branchContextMenu );
 
 	branchContextMenu->addSeparator();	
-	branchContextMenu->addAction ( actionEditOpenURL );
-	branchContextMenu->addAction ( actionEditOpenURLTab );
-	branchContextMenu->addAction ( actionEditOpenMultipleURLTabs );
-	branchContextMenu->addAction ( actionEditURL );
-	branchContextMenu->addAction ( actionEditHeading2URL );
-	branchContextMenu->addAction ( actionEditBugzilla2URL );
-    if (settings.value( "/mainwindow/showTestMenu",true).toBool() )
-	{
-		branchContextMenu->addAction ( actionEditFATE2URL );
-	}	
-	branchContextMenu->addSeparator();	
-	branchContextMenu->addAction ( actionEditOpenVymLink );
-	branchContextMenu->addAction ( actionEditVymLink );
-	branchContextMenu->addAction ( actionEditDeleteVymLink );
-	
-	branchContextMenu->addSeparator();	
 	branchContextMenu->addAction ( actionFormatFrameNone );
 	branchContextMenu->addAction ( actionFormatFrameRectangle);
 
@@ -1551,13 +1545,36 @@
 	branchContextMenu->addAction ( actionFormatIncludeImagesHor );
 	branchContextMenu->addAction ( actionFormatHideLinkUnselected );
 
-	// Context Menu for links in a branch menu
+	// Submenu for Links (URLs, vymLinks)
+	branchLinksContextMenu =new QMenu (this);
+
+		branchContextMenu->addSeparator();	
+		branchLinksContextMenu=branchContextMenu->addMenu(tr("URLs and vymLinks"));	
+		branchLinksContextMenu->addAction ( actionEditOpenURL );
+		branchLinksContextMenu->addAction ( actionEditOpenURLTab );
+		branchLinksContextMenu->addAction ( actionEditOpenMultipleURLTabs );
+		branchLinksContextMenu->addAction ( actionEditURL );
+		branchLinksContextMenu->addAction ( actionEditHeading2URL );
+		branchLinksContextMenu->addAction ( actionEditBugzilla2URL );
+		if (settings.value( "/mainwindow/showTestMenu",true).toBool() )
+		{
+			branchLinksContextMenu->addAction ( actionEditFATE2URL );
+		}	
+		branchLinksContextMenu->addSeparator();	
+		branchLinksContextMenu->addAction ( actionEditOpenVymLink );
+		branchLinksContextMenu->addAction ( actionEditOpenMultipleVymLinks );
+		branchLinksContextMenu->addAction ( actionEditVymLink );
+		branchLinksContextMenu->addAction ( actionEditDeleteVymLink );
+		
+
+	// Context Menu for XLinks in a branch menu
 	// This will be populated "on demand" in MapEditor::updateActions
 	branchContextMenu->addSeparator();	
-	branchLinksContextMenuEdit =branchContextMenu->addMenu (tr ("Edit XLink"));
-	branchLinksContextMenuFollow =branchContextMenu->addMenu (tr ("Follow XLink"));
-	connect( branchLinksContextMenuFollow, SIGNAL( triggered(QAction *) ), this, SLOT( editFollowXLink(QAction * ) ) );
-	connect( branchLinksContextMenuEdit, SIGNAL( triggered(QAction *) ), this, SLOT( editEditXLink(QAction * ) ) );
+	branchXLinksContextMenuEdit =branchContextMenu->addMenu (tr ("Edit XLink"));
+	branchXLinksContextMenuFollow =branchContextMenu->addMenu (tr ("Follow XLink"));
+	connect( branchXLinksContextMenuFollow, SIGNAL( triggered(QAction *) ), this, SLOT( editFollowXLink(QAction * ) ) );
+	connect( branchXLinksContextMenuEdit, SIGNAL( triggered(QAction *) ), this, SLOT( editEditXLink(QAction * ) ) );
+ 	
 	
 	// Context menu for floatimage
 	floatimageContextMenu =new QMenu (this);
@@ -2368,6 +2385,9 @@
 		if ( fd->exec() == QDialog::Accepted )
 		{
 			QString fn=fd->selectedFile();
+			if (!fn.contains (".odp"))
+				fn +=".odp";
+
 			//lastImageDir=fn.left(fn.findRev ("/"));
 			if (currentMapEditor())
 				currentMapEditor()->exportOOPresentation(fn,fd->selectedConfig());	
@@ -2623,10 +2643,7 @@
 	if (currentMapEditor())
 	{	
 	    QStringList urls;
-		urls.append ("www.suse.de");
-		urls.append ("www.google.de");
-		urls.append ("www.heise.de");
-		urls.append ("www.insilmaril.de");
+		urls=currentMapEditor()->getURLs();
 		openTabs (urls);
 	}	
 }
@@ -2661,7 +2678,13 @@
 	if (lineedit->isVisible())
 	{
 		if (currentMapEditor())
-			currentMapEditor()->setHeading(lineedit->text());
+		{	
+			MapEditor *me=currentMapEditor();
+			QString oldSel=me->getSelectString();
+			if (me->select (editSel))
+				me->setHeading(lineedit->text());
+			me->select (oldSel);
+		}	
 		lineedit->releaseKeyboard();
 		lineedit->hide();
 		setFocus();
@@ -2697,6 +2720,8 @@
 				lineedit->show();
 				lineedit->grabKeyboard();
 				lineedit->setFocus();
+
+				editSel=currentMapEditor()->getSelectString();
 #endif
 
 			}
@@ -2704,13 +2729,10 @@
 	}
 }
 
-void Main::editOpenVymLink()
+void Main::openVymLinks(const QStringList &vl)
 {
-	// Get current path to map
-	QString currentVymLink;
-	if (currentMapEditor())
+	for (int j=0; j<vl.size(); j++)
 	{
-		currentVymLink=currentMapEditor()->getVymLink();	
 		// compare path with already loaded maps
 		int index=-1;
 		int i;
@@ -2718,7 +2740,7 @@
 		for (i=0;i<=tabWidget->count() -1;i++)
 		{
 			me=(MapEditor*)tabWidget->page(i);
-			if (currentVymLink==me->getFilePath() )
+			if (vl.at(j)==me->getFilePath() )
 			{
 				index=i;
 				break;
@@ -2727,12 +2749,12 @@
 		if (index<0)
 		// Load map
 		{
-			if (!QFile(currentVymLink).exists() )
+			if (!QFile(vl.at(j)).exists() )
 				QMessageBox::critical( 0, tr( "Critical Error" ),
-				   tr("Couldn't open map %1").arg(currentVymLink));
+				   tr("Couldn't open map %1").arg(vl.at(j)));
 			else
 			{
-				fileLoad (currentVymLink, NewMap);
+				fileLoad (vl.at(j), NewMap);
 				tabWidget->setCurrentPage (tabWidget->count()-1);	
 			}
 		} else
@@ -2741,6 +2763,26 @@
 	}
 }
 
+void Main::editOpenVymLink()
+{
+	if (currentMapEditor())
+	{
+		QStringList vl;
+		vl.append(currentMapEditor()->getVymLink());	
+		openVymLinks (vl);
+	}
+}
+
+void Main::editOpenMultipleVymLinks()
+{
+	QString currentVymLink;
+	if (currentMapEditor())
+	{
+		QStringList vl=currentMapEditor()->getVymLinks();
+		openVymLinks (vl);
+	}
+}
+
 void Main::editVymLink()
 {
 	if (currentMapEditor())
@@ -2903,13 +2945,13 @@
 {
 
 	if (currentMapEditor())
-		currentMapEditor()->followXLink(branchLinksContextMenuFollow->actions().indexOf(a));
+		currentMapEditor()->followXLink(branchXLinksContextMenuFollow->actions().indexOf(a));
 }
 
 void Main::editEditXLink(QAction *a)
 {
 	if (currentMapEditor())
-		currentMapEditor()->editXLink(branchLinksContextMenuEdit->actions().indexOf(a));
+		currentMapEditor()->editXLink(branchXLinksContextMenuEdit->actions().indexOf(a));
 }
 
 void Main::formatSelectColor()
diff -r 41c3d7f9f532 -r 557239819c45 mainwindow.h
--- a/mainwindow.h	Tue Aug 29 08:31:42 2006 +0000
+++ b/mainwindow.h	Wed Aug 30 12:16:25 2006 +0000
@@ -100,7 +100,9 @@
 	void editHeading2URL();
 	void editBugzilla2URL();
 	void editFATE2URL();
+	void openVymLinks(const QStringList &);
 	void editVymLink();
+	void editOpenMultipleVymLinks();
 public slots:
     void editHeading();
 	void editOpenVymLink();
@@ -191,6 +193,8 @@
 	QStringList imageTypes;
 
 	QLineEdit *lineedit;	// to enter headings of branches
+	QString editSel;
+	
 };
 
 
diff -r 41c3d7f9f532 -r 557239819c45 mapeditor.cpp
--- a/mapeditor.cpp	Tue Aug 29 08:31:42 2006 +0000
+++ b/mapeditor.cpp	Wed Aug 30 12:16:25 2006 +0000
@@ -129,8 +129,9 @@
 extern QMenu* branchContextMenu;
 extern QMenu* branchAddContextMenu;
 extern QMenu* branchRemoveContextMenu;
-extern QMenu* branchLinksContextMenuEdit;
-extern QMenu* branchLinksContextMenuFollow;
+extern QMenu* branchLinksContextMenu;
+extern QMenu* branchXLinksContextMenuEdit;
+extern QMenu* branchXLinksContextMenuFollow;
 extern QMenu* floatimageContextMenu;
 extern QMenu* saveImageFormatMenu;
 extern QMenu* canvasContextMenu;
@@ -376,7 +377,7 @@
 	d.mkdir (tmpMapDir,true);
 }
 
-QString MapEditor::saveToDir(const QString &tmpdir, const QString &prefix, bool writeflags, const QPoint &offset, LinkableMapObj *saveSelection)
+QString MapEditor::saveToDir(const QString &tmpdir, const QString &prefix, bool writeflags, const QPoint &offset, LinkableMapObj *saveSel)
 {
 	// tmpdir		temporary directory to which data will be written
 	// prefix		mapname, which will be appended to images etc.
@@ -408,7 +409,7 @@
 		colhint=attribut("linkColorHint","HeadingColor");
 
 	QString mapAttr=attribut("version",__VYM_VERSION);
-	if (!saveSelection)
+	if (!saveSel)
 		mapAttr+= attribut("author",mapCenter->getAuthor()) +
 				  attribut("comment",mapCenter->getComment()) +
 			      attribut("date",mapCenter->getDate()) +
@@ -428,25 +429,28 @@
 	FloatImageObj (mapCanvas).resetSaveCounter();
 
 	// Build xml recursivly
-	if (!saveSelection)
+	if (!saveSel)
+		// Save complete map, if saveSel not set
 		s+=mapCenter->saveToDir(tmpdir,prefix,writeflags,offset);
 	else
 	{
-		if ( typeid(*saveSelection) == typeid(BranchObj) )
-			s+=((BranchObj*)(saveSelection))->saveToDir(tmpdir,prefix,offset);
-		else if ( typeid(*saveSelection) == typeid(FloatImageObj) )
-			s+=((FloatImageObj*)(saveSelection))->saveToDir(tmpdir,prefix,offset);
+		if ( typeid(*saveSel) == typeid(BranchObj) )
+			// Save Subtree
+			s+=((BranchObj*)(saveSel))->saveToDir(tmpdir,prefix,offset);
+		else if ( typeid(*saveSel) == typeid(FloatImageObj) )
+			// Save image
+			s+=((FloatImageObj*)(saveSel))->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);
+			// Save selected branch is saved from mainwindow		//FIXME maybe use "subtree" above?
+			s+=((BranchObj*)selection)->saveToDir(tmpdir,prefix,offset);
 	}
 
 	// Save local settings
 	s+=settings.getXMLData (destPath);
 
 	// Save selection
-	if (selection && !saveSelection ) 
+	if (selection && !saveSel ) 
 		s+=valueElement("select",selection->getSelectString());
 
 	decIndent();
@@ -459,14 +463,22 @@
 
 void MapEditor::saveStateComplete(const QString &comment)
 {
-	// Save complete map
-	saveState (CompleteMap,"",NULL,"",NULL, comment);
+	// Save complete map, Undo will replace whole map
+	saveState (CompleteMap,
+		NULL, "",
+		NULL, "", 
+		comment, 
+		mapCenter);
 }
 
 void MapEditor::saveStatePart(LinkableMapObj *undoSel, const QString &comment)
 {
-	// save the selected part of the map 
-	saveState (PartOfMap,"",undoSel,"",NULL, comment);
+	// save the selected part of the map, Undo will replace part of map 
+	saveState (PartOfMap,
+		undoSel, "",
+		NULL, "", 
+		comment, 
+		undoSel);
 }
 
 void MapEditor::saveStateConstSelection(const QString &uc, const QString &rc, const QString &comment)
@@ -474,16 +486,33 @@
 	// selection does not change during action,
 	// so just save commands for undo and redo
 	// and use current selection
-	saveState (UndoCommand,uc,selection,rc,selection, comment);
+	saveState (UndoCommand,
+		selection, uc,
+		selection, rc, 
+		comment, 
+		NULL);
 }
 
-void MapEditor::saveStateX(LinkableMapObj *unsel, const QString &uncom, const QString &comment) 
+void MapEditor::saveStateX(LinkableMapObj *unsel, const QString &uc, const QString &comment) 
 {
-	// 
-	saveState (UndoCommand,uncom,unsel,"FIXME-redoCom",NULL, comment);
+	// TODO Is this still needed?
+	saveState (UndoCommand,
+		unsel, uc,
+		NULL, "FIXME-redoCom",	//FIXME
+		comment, 
+		NULL);
 }
 
-void MapEditor::saveState(const SaveMode &savemode, const QString &undoCom, LinkableMapObj *undoSel, const QString &redoCom, LinkableMapObj *redoSel, const QString &comment)
+void MapEditor::saveStateComData(LinkableMapObj *unSel, const QString &uc, LinkableMapObj *redoSel, const QString &rc, const QString &comment, LinkableMapObj *saveSel) 
+{
+	saveState (UndoCommand,
+		unSel, uc,
+		NULL, "FIXME-redoCom",	//FIXME
+		comment, 
+		saveSel);
+}
+
+void MapEditor::saveState(const SaveMode &savemode, LinkableMapObj *undoSel, const QString &undoCom, LinkableMapObj *redoSel, const QString &redoCom, const QString &comment, LinkableMapObj *saveSel)
 {
 	// Main saveState
 
@@ -491,10 +520,7 @@
 
 	/* TODO remove after testing
 	*/
-	cout << "ME::saveState()  begin\n"<<endl;
-	cout << "    undosTotal="<<undosTotal<<endl;
-	cout << "    ---------------------------"<<endl;
-
+	cout << "ME::saveState()  begin"<<endl;
 	historyWindow->append (comment);
 	
 	setChanged();
@@ -526,21 +552,22 @@
 		undoSelection=undoSel->getSelectString();
 		
 	// Save depending on how much needs to be saved	
+	if (!saveSel)
+		backupXML="";
+	else 
+		backupXML=saveToDir (bakMapDir,mapName+"-",false, QPoint (),saveSel);
+		
 	QString undoCommand="";
 	if (savemode==UndoCommand)
 	{
 		undoCommand=undoCom;
-		backupXML="";
 	}	
 	else if (savemode==PartOfMap && undoSel)
 	{
 		undoCommand="undoPart (\""+ undoSelection+"\",\""+bakMapPath+"\")";
-		backupXML=saveToDir (bakMapDir,mapName+"-",false, QPoint (),undoSel);
 	} else
 	{
 		undoCommand="undoMap (\""+bakMapPath+"\")";
-		backupXML=saveToDir (bakMapDir,mapName+"-",false, QPoint (),NULL);
-		undoSelection="";
 	}
 	if (!backupXML.isEmpty())
 		// Write XML Data to disk
@@ -557,16 +584,17 @@
 
 	/* TODO remove after testing
 	*/
-	cout << "          into="<< histPath.toStdString()<<endl;
-	cout << "    undosAvail="<<undosAvail<<endl;
-	cout << "       curStep="<<curStep<<endl;
+	//cout << "          into="<< histPath.toStdString()<<endl;
+	cout << "    undosTotal="<<undosTotal<<
+	", undosAvail="<<undosAvail<<
+	", curStep="<<curStep<<endl;
 	cout << "    ---------------------------"<<endl;
 	cout << "    comment="<<comment.toStdString()<<endl;
 	cout << "    undoCom="<<undoCommand.toStdString()<<endl;
 	cout << "    undoSel="<<undoSelection.toStdString()<<endl;
 	cout << "    redoCom="<<redoCom.toStdString()<<endl;
 	cout << "    redoSel="<<redoSelection.toStdString()<<endl;
-	cout << "    ---------------------------"<<endl<<endl;
+	cout << "    ---------------------------"<<endl;
 }
 
 void MapEditor::parseAtom(const QString &atom)
@@ -692,8 +720,8 @@
 	{
 		if (api.checkParamCount(2))
 		{
-			s=api.parString (ok,0);
-			t=api.parString (ok,1);
+			s=api.parString (ok,0);	// undo selection
+			t=api.parString (ok,1);	// backup dir
 			undoXML(s,t);	
 		}
 	} else if (com=="select")
@@ -711,6 +739,7 @@
 	// Any errors?
 	if (api.error())
 	{
+		// TODO Error handling
 		qWarning("MapEditor::parseAtom: Error!");
 		qWarning(api.errorDesc());
 	}	
@@ -1467,43 +1496,6 @@
 	}	
 }
 
-void MapEditor::editHeading()
-{
-/* FIXME not needed any longer
-	if (selection  &&  
-		 (typeid(*selection) == typeid(BranchObj) || 
-		  typeid(*selection) == typeid(MapCenterObj) ) ) 
-	{
-		editingBO=(BranchObj*)selection;
-		ensureSelectionVisible();
-		QPoint p = worldMatrix().map(QPoint (editingBO->x(),editingBO->y()));
-
-		QDialog *d =new QDialog(NULL);
-		QLineEdit *le=new QLineEdit (d);
-		d->setWindowFlags (Qt::FramelessWindowHint);
-		QPoint q=mapToGlobal (QPoint(0,0));
-		d->setGeometry(p.x()+q.x(),p.y()+q.y(),200,25);
-		le->resize (d->size());
-		le->setText (editingBO->getHeading());
-		le->selectAll();
-		connect (le, SIGNAL (returnPressed()), d, SLOT (accept()));
-		d->activateWindow();
-		d->exec();
-
-		saveStateConstSelection(
-			"setHeading (\""+editingBO->getHeading()+"\")", 
-			"setHeading (\""+le->text()+"\")", 
-			QString("Set heading of %1 to \"%2\"").arg(getName(editingBO)).arg(le->text()) );
-		editingBO->setHeading(le->text() );
-		editingBO=NULL;
-		mapCenter->reposition();
-		adjustCanvasSize();
-		ensureSelectionVisible();
-		activateWindow();
-	}	
-*/	
-}
-
 QString MapEditor::getHeading(bool &ok, QPoint &p)
 {
 	if (selection  &&  
@@ -1513,8 +1505,8 @@
 		ok=true;
 		ensureSelectionVisible();
 		p = ((BranchObj*)selection)->getAbsPos();
-		p.setY(p.y()+((BranchObj*)selection)->height()/2);
-//		p = mapTo(mainWindow,worldMatrix().map( p));
+		p.setX (p.x() - contentsX());
+		p.setY (p.y() - contentsY() + ((BranchObj*)selection)->height()/2);
 		return ((BranchObj*)selection)->getHeading();
 	}
 	ok=false;
@@ -1523,7 +1515,6 @@
 
 void MapEditor::setHeading(const QString &s)
 {
-	// Internal function, no saveState needed
 	if (selection  &&  
 		 (typeid(*selection) == typeid(BranchObj) || 
 		  typeid(*selection) == typeid(MapCenterObj) ) ) 
@@ -1682,7 +1673,7 @@
 				bo2->setHeading("");
 			}	
 			if (actionSettingsAutoedit->isOn() )
-				editHeading();
+				mainWindow->editHeading();
 			if (!actionSettingsAutoselectHeading->isOn()
 				&& !wasScrolled)
 			{
@@ -1698,12 +1689,13 @@
 {
 	if (selection  && typeid(*selection) ==typeid(BranchObj) ) 
 	{
-		BranchObj* bo=dynamic_cast <BranchObj*> (selection);
+		BranchObj* bo=(BranchObj*)selection;
 		BranchObj* par=(BranchObj*)(bo->getParObj());
 		bo->unselect();
 		if (selection->getDepth()>1)
 			// Normal branch, save parent with childs
 			saveStatePart(par,QString("Delete %1").arg(getName(bo)));
+		//	naveState (UndoCom, par, QString("insertBranchAt (%1)", bo, "", QString ("Delete %1").arg(getName(bo))));
 		else
 			// Mainbranch, save whole map
 			// TODO Better would be to insert mainbranch again at pos
@@ -1719,7 +1711,7 @@
 	}
 	if (selection  && typeid(*selection) ==typeid(FloatImageObj) ) 
 	{
-		FloatImageObj* fio=dynamic_cast <FloatImageObj*> (selection);
+		FloatImageObj* fio=(FloatImageObj*)selection;
 		BranchObj* par=(BranchObj*)(fio->getParObj());
 		saveStatePart(par, QString("Delete %1").arg(getName(fio)));
 		fio->unselect();
@@ -1775,6 +1767,12 @@
 	return false;
 }
 
+QString MapEditor::getSelectString()
+{
+	if (selection) return selection->getSelectString();
+	return QString();
+}
+
 void MapEditor::selectInt (LinkableMapObj *lmo)
 {
 	if (lmo && selection != lmo)
@@ -2244,7 +2242,7 @@
 BranchObj* MapEditor::findText (QString s, bool cs)
 {
 	QTextDocument::FindFlags flags=0;
-	if (cs) flags=QTextDocument::QTextDocument::FindCaseSensitively;
+	if (cs) flags=QTextDocument::FindCaseSensitively;
 
 	if (!itFind) 
 	{	// Nothing found or new find process
@@ -2336,6 +2334,24 @@
 		return "";
 }
 
+QStringList MapEditor::getURLs()
+{
+	QStringList urls;
+	if (selection && (typeid(*selection) == typeid(BranchObj) ||
+			typeid(*selection) == typeid(MapCenterObj)) )
+	{		
+		BranchObj *bo=(BranchObj*)selection;
+		bo=bo->first();	
+		while (bo) 
+		{
+			if (!bo->getURL().isEmpty()) urls.append( bo->getURL());
+			bo=bo->next();
+		}	
+	}	
+	return urls;
+}
+
+
 void MapEditor::editHeading2URL()
 {
 	if (selection && (typeid(*selection) == typeid(BranchObj) ||
@@ -2454,6 +2470,24 @@
 	
 }
 
+QStringList MapEditor::getVymLinks()
+{
+	QStringList links;
+	if (selection && (typeid(*selection) == typeid(BranchObj) ||
+			typeid(*selection) == typeid(MapCenterObj)) )
+	{		
+		BranchObj *bo=(BranchObj*)selection;
+		bo=bo->first();	
+		while (bo) 
+		{
+			if (!bo->getVymLink().isEmpty()) links.append( bo->getVymLink());
+			bo=bo->next();
+		}	
+	}	
+	return links;
+}
+
+
 void MapEditor::removeBranchKeepChilds()
 {
 	if (selection && (typeid(*selection) == typeid(BranchObj) ))
@@ -2579,14 +2613,14 @@
 			// Take care of links
 			if (bo->countXLinks()==0)
 			{
-				branchLinksContextMenuEdit->clear();
-				branchLinksContextMenuFollow->clear();
+				branchXLinksContextMenuEdit->clear();
+				branchXLinksContextMenuFollow->clear();
 			} else
 			{
 				BranchObj *bot;
 				QString s;
-				branchLinksContextMenuEdit->clear();
-				branchLinksContextMenuFollow->clear();
+				branchXLinksContextMenuEdit->clear();
+				branchXLinksContextMenuFollow->clear();
 				for (int i=0; i<=bo->countXLinks();i++)
 				{
 					bot=bo->XLinkTargetAt(i);
@@ -2595,8 +2629,8 @@
 						s=bot->getHeading();
 						if (s.length()>25)
 							s=s.left(25)+"...";
-						branchLinksContextMenuFollow->addAction (s);
-						branchLinksContextMenuEdit->addAction (s);
+						branchXLinksContextMenuFollow->addAction (s);
+						branchXLinksContextMenuEdit->addAction (s);
 					}	
 				}
 			}
@@ -3631,7 +3665,7 @@
 			if (selection) selection->unselect();
 			selection=lmo;
 			selection->select();
-			editHeading();
+			mainWindow->editHeading();
 		}
 	}
 }
diff -r 41c3d7f9f532 -r 557239819c45 mapeditor.h
--- a/mapeditor.h	Tue Aug 29 08:31:42 2006 +0000
+++ b/mapeditor.h	Wed Aug 30 12:16:25 2006 +0000
@@ -2,14 +2,14 @@
 #define MAPEDITOR_H
 
 #include <q3canvas.h>
+//#include <q3filedialog.h>
+//#include <q3process.h>
+#include <QBuffer>
+#include <QContextMenuEvent>
 #include <QCursor>
-//#include <q3filedialog.h>
+#include <QDragEnterEvent>
+#include <QDropEvent>
 #include <QEvent>
-//#include <q3process.h>
-#include <qbuffer.h>
-#include <QDragEnterEvent>
-#include <QContextMenuEvent>
-#include <QDropEvent>
 #include <QLineEdit>
 #include <QMouseEvent>
 #include <QPixmap>
@@ -46,7 +46,8 @@
     void saveStatePart           (LinkableMapObj *, const QString &);
     void saveStateConstSelection (const QString &, const QString &, const QString &);
     void saveStateX				 (LinkableMapObj *, const QString &, const QString &);
-    void saveState(const SaveMode&, const QString &, LinkableMapObj *, const QString &, LinkableMapObj *, const QString &);
+    void saveStateComData		 (LinkableMapObj *, const QString &, LinkableMapObj *, const QString &, const QString &, LinkableMapObj *);
+    void saveState(const SaveMode&, LinkableMapObj *, const QString &, LinkableMapObj *, const QString &, const QString &, LinkableMapObj *);
     void parseAtom(const QString &);	
 
     void addFloatImage(const QPixmap &img);
@@ -99,7 +100,6 @@
     void move(const int &,const int&);
     void moveBranchUp();
     void moveBranchDown();
-    void editHeading();						// Start editing heading 
 	QString getHeading (bool &,QPoint &);	// Get heading, ok if selection is branch
 	void setHeading(const QString &);
 private:
@@ -113,7 +113,8 @@
 	LinkableMapObj* getSelection();	// returns selection
 	void unselect();				// before changing current noteedit
 	void reselect();				// after  changing current noteedit
-	bool select(const QString &);	// Select 
+	bool select(const QString &);	// Select by string
+	QString getSelectString();
 private:	
 	void selectInt(LinkableMapObj*);	
 	void selectNextBranchInt();		// Increment number of branch
@@ -137,12 +138,14 @@
     void findReset();						// Reset Find 
 	void editURL();							// edit the URL
 	QString getURL();						// returns URL of selection or ""
+	QStringList getURLs();					// returns URLs of subtree
 	void editHeading2URL();					// copy heading to URL
 	void editBugzilla2URL();				// create URL to Bugzilla
 	void editFATE2URL();					// create URL to FATE
 	void editVymLink();						// edit link to another map
 	void deleteVymLink();					// delete link to another map
 	QString getVymLink();					// return path to map
+	QStringList getVymLinks();				// return paths in subtree
 	void toggleHideExport();				// toggle the export flag
 	void removeBranchKeepChilds();			// remove but keep childs
 	void removeChilds();					// remove childs
diff -r 41c3d7f9f532 -r 557239819c45 tex/vym.changelog
--- a/tex/vym.changelog	Tue Aug 29 08:31:42 2006 +0000
+++ b/tex/vym.changelog	Wed Aug 30 12:16:25 2006 +0000
@@ -1,3 +1,16 @@
+-------------------------------------------------------------------
+Wed Aug 30 14:14:56 CEST 2006 - uwedr
+
+- Version: 1.8.54
+- Bugfix: Editing headings now works both on Mac and Linux
+
+-------------------------------------------------------------------
+Mon Aug 28 13:15:35 CEST 2006 - uwe
+
+- Version: 1.8.53
+- Feature: Opening of all URLs in a subtree
+- Feature: Opening of all vymLinks in a subtree
+
 -------------------------------------------------------------------
 Tue Aug 15 13:39:42 CEST 2006 - uwedr
 
diff -r 41c3d7f9f532 -r 557239819c45 version.h
--- a/version.h	Tue Aug 29 08:31:42 2006 +0000
+++ b/version.h	Wed Aug 30 12:16:25 2006 +0000
@@ -2,7 +2,7 @@
 #define VERSION_H
 
 #define __VYM "VYM"
-#define __VYM_VERSION "1.8.53"
-#define __BUILD_DATE "August 23, 2006"
+#define __VYM_VERSION "1.8.54"
+#define __BUILD_DATE "August 30, 2006"
 
 #endif