# HG changeset patch
# User insilmaril
# Date 1113805020 0
# Node ID f688a9913724df3138558299d687cc7dfe63e5ce
# Parent  6783e13bb05d622b02ab17b1b0388d16c1cba3e8
added basic xLink functions

diff -r 6783e13bb05d -r f688a9913724 branchobj.cpp
--- a/branchobj.cpp	Sat Apr 09 22:50:08 2005 +0000
+++ b/branchobj.cpp	Mon Apr 18 06:17:00 2005 +0000
@@ -87,7 +87,7 @@
 {
     branch.setAutoDelete (false);
     floatimage.setAutoDelete (true);
-    link.setAutoDelete (false);
+    xlink.setAutoDelete (false);
 
 	if (parObj)
 	{
@@ -141,8 +141,8 @@
 void BranchObj::clear() 
 {
 	floatimage.clear();
-	while (!link.isEmpty())
-		deleteLink (link.first() );
+	while (!xlink.isEmpty())
+		deleteXLink (xlink.first() );
 
 	BranchObj *bo;
 	while (!branch.isEmpty())
@@ -163,7 +163,12 @@
 
 int BranchObj::getNum(BranchObj *bo)
 {
-	return branch.findRef (bo);
+	// keep current pointer in branch, 
+	// otherwise save might fail
+	int cur=branch.at();
+	int ind=branch.findRef (bo);
+	branch.at(cur);
+	return ind;
 }
 
 int BranchObj::getFloatImageNum(FloatImageObj *fio)
@@ -181,9 +186,9 @@
 	return floatimage.count();
 }
 
-int BranchObj::countLinks()
+int BranchObj::countXLinks()
 {
-	return link.count();
+	return xlink.count();
 }
 
 void BranchObj::setParObjTmp(LinkableMapObj* lmo, QPoint m, int off)
@@ -380,9 +385,9 @@
 			FloatImageObj *fio;
 			for (fio=floatimage.first(); fio; fio=floatimage.next())
 				fio->setVisibility (v);
-			LinkObj* lo;
-			for (lo=link.first(); lo;lo=link.next() ) 
-				lo->setVisibility ();	
+			XLinkObj* xlo;
+			for (xlo=xlink.first(); xlo;xlo=xlink.next() ) 
+				xlo->setVisibility ();	
 		}
     } // depth <= toDepth	
 	requestReposition();
@@ -599,9 +604,9 @@
 	frame->setRect(QRect(bbox.x(),bbox.y(),bbox.width(),bbox.height() ) );
 
 	// Update links to other branches
-	LinkObj *l;
-    for (l=link.first(); l; l=link.next() )
-		l->updateLink();
+	XLinkObj *xlo;
+    for (xlo=xlink.first(); xlo; xlo=xlink.next() )
+		xlo->updateXLink();
 }
 
 void BranchObj::calcBBoxSize()
@@ -783,53 +788,55 @@
     BranchObj *bo;
     for (bo=branch.first(); bo; bo=branch.next() )
 		s+=bo->saveToDir(tmpdir,prefix,offset);
-    decIndent();
 
 	// Save FloatImages
 	FloatImageObj *fio;
 	for (fio=floatimage.first(); fio; fio=floatimage.next() )
 		s+=fio->saveToDir (tmpdir,prefix);
 
+	// Save XLinks
+	XLinkObj *xlo;
+    for (xlo=xlink.first(); xlo; xlo=xlink.next() )
+		s+=xlo->saveToDir();
+
+    decIndent();
     s+=endElement   ("branch");
     return s;
 }
 
-void BranchObj::addLink (LinkObj *lo)
+void BranchObj::addXLink (XLinkObj *xlo)
 {
-	link.append (lo);
+	xlink.append (xlo);
 	
 }
 
-void BranchObj::removeLinkRef (LinkObj *lo)
+void BranchObj::removeXLinkRef (XLinkObj *xlo)
 {
-	link.remove (lo);
+	xlink.remove (xlo);
 }
 
-void BranchObj::deleteLink(LinkObj *lo)
+void BranchObj::deleteXLink(XLinkObj *xlo)
 {
-	lo->deactivate();
-	if (!lo->isUsed()) delete (lo);
+	xlo->deactivate();
+	if (!xlo->isUsed()) delete (xlo);
 }
 
-void BranchObj::deleteLinkAt (int i)
+void BranchObj::deleteXLinkAt (int i)
 {
-	LinkObj *lo=link.at(i);
-	lo->deactivate();
-	if (!lo->isUsed()) 
-	{
-		delete(lo);
-	}	
+	XLinkObj *xlo=xlink.at(i);
+	xlo->deactivate();
+	if (!xlo->isUsed()) delete(xlo);
 }
 
-int BranchObj::countLink()
+int BranchObj::countXLink()
 {
-	return link.count();
+	return xlink.count();
 }
 
-BranchObj* BranchObj::linkTargetAt (int i)
+BranchObj* BranchObj::XLinkTargetAt (int i)
 {
-	if (link.at(i))
-		return link.at(i)->otherBranch (this);
+	if (xlink.at(i))
+		return xlink.at(i)->otherBranch (this);
 	else
 		return NULL;
 }
@@ -1312,15 +1319,12 @@
 	QString s;
 	if (parObj)
 	{
-		if (parObj->getDepth()==0)
+		if (depth==1)
 			s= "bo:" + QString("%1").arg(getNum());
 		else	
 			s= ((BranchObj*)(parObj))->getSelectString() + ",bo:" + QString("%1").arg(getNum());
 	} else
-	{
 		s="mc:";
-	}
-	
 	return s;
 }
 
diff -r 6783e13bb05d -r f688a9913724 branchobj.h
--- a/branchobj.h	Sat Apr 09 22:50:08 2005 +0000
+++ b/branchobj.h	Mon Apr 18 06:17:00 2005 +0000
@@ -4,7 +4,7 @@
 #include "floatimageobj.h"
 #include "linkablemapobj.h"
 #include "ornamentedobj.h"
-#include "linkobj.h"
+#include "xlinkobj.h"
 
 class BranchObjPtrList : public QPtrList<BranchObj>
 {
@@ -28,7 +28,7 @@
 	virtual int getFloatImageNum(FloatImageObj*);		
 	virtual int countBranches();		
 	virtual int countFloatImages();		
-	virtual int countLinks();		
+	virtual int countXLinks();		
     virtual void setParObjTmp (LinkableMapObj*,QPoint,int);// Only for moving Obj around
 	virtual void unsetParObjTmp();			// reuse original ParObj
 
@@ -63,12 +63,12 @@
     virtual void setVymLink (QString);
     virtual QString getVymLink ();
 	virtual QString saveToDir (const QString&,const QString&, const QPoint&);// Save data recursivly to tempdir
-	virtual void addLink (LinkObj*);
-	virtual void removeLinkRef (LinkObj*);	// Remove ref in list
-	virtual void deleteLink (LinkObj*);		// remove references and delete LinkObj 
-	virtual void deleteLinkAt (int);		// remove references and delete LinkObj 
-	virtual int countLink ();
-	virtual BranchObj* linkTargetAt (int);
+	virtual void addXLink (XLinkObj*);
+	virtual void removeXLinkRef (XLinkObj*);	// Remove ref in list
+	virtual void deleteXLink (XLinkObj*);		// remove references and delete XLinkObj 
+	virtual void deleteXLinkAt (int);		// remove references and delete XLinkObj 
+	virtual int countXLink ();
+	virtual BranchObj* XLinkTargetAt (int);
 	virtual LinkableMapObj* addFloatImage();
 	virtual LinkableMapObj* addFloatImage(FloatImageObj*);
 	virtual void removeFloatImage(FloatImageObj*);
@@ -109,7 +109,7 @@
 	static BranchObj* itLast;		// iterator for first(), next()
     BranchObjPtrList branch;		// all child branches
 	QPtrList<FloatImageObj> floatimage;	// child images
-	QPtrList<LinkObj> link;			// links to other branches
+	QPtrList<XLinkObj> xlink;		// xlinks to other branches
 public:	
 	float angle;					// used in mainbranch to reorder mainbranches
 protected:	
diff -r 6783e13bb05d -r f688a9913724 demos/todo.vym
Binary file demos/todo.vym has changed
diff -r 6783e13bb05d -r f688a9913724 editxlinkdialog.ui
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/editxlinkdialog.ui	Mon Apr 18 06:17:00 2005 +0000
@@ -0,0 +1,100 @@
+<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
+<class>EditXLinkDialog</class>
+<widget class="QDialog">
+    <property name="name">
+        <cstring>EditXLinkDialog</cstring>
+    </property>
+    <property name="geometry">
+        <rect>
+            <x>0</x>
+            <y>0</y>
+            <width>570</width>
+            <height>91</height>
+        </rect>
+    </property>
+    <property name="caption">
+        <string>Edit Link</string>
+    </property>
+    <grid>
+        <property name="name">
+            <cstring>unnamed</cstring>
+        </property>
+        <widget class="QPushButton" row="0" column="0">
+            <property name="name">
+                <cstring>deleteButton</cstring>
+            </property>
+            <property name="text">
+                <string>Delete XLink</string>
+            </property>
+        </widget>
+        <spacer row="0" column="1">
+            <property name="name">
+                <cstring>spacer11</cstring>
+            </property>
+            <property name="orientation">
+                <enum>Horizontal</enum>
+            </property>
+            <property name="sizeType">
+                <enum>Expanding</enum>
+            </property>
+            <property name="sizeHint">
+                <size>
+                    <width>180</width>
+                    <height>20</height>
+                </size>
+            </property>
+        </spacer>
+        <widget class="QPushButton" row="0" column="3">
+            <property name="name">
+                <cstring>okButton</cstring>
+            </property>
+            <property name="text">
+                <string>Ok</string>
+            </property>
+        </widget>
+        <widget class="QPushButton" row="0" column="2">
+            <property name="name">
+                <cstring>cancelButton</cstring>
+            </property>
+            <property name="text">
+                <string>Cancel</string>
+            </property>
+        </widget>
+    </grid>
+</widget>
+<connections>
+    <connection>
+        <sender>okButton</sender>
+        <signal>clicked()</signal>
+        <receiver>EditXLinkDialog</receiver>
+        <slot>accept()</slot>
+    </connection>
+    <connection>
+        <sender>cancelButton</sender>
+        <signal>clicked()</signal>
+        <receiver>EditXLinkDialog</receiver>
+        <slot>reject()</slot>
+    </connection>
+    <connection>
+        <sender>deleteButton</sender>
+        <signal>clicked()</signal>
+        <receiver>EditXLinkDialog</receiver>
+        <slot>deleteButtonPressed()</slot>
+    </connection>
+</connections>
+<includes>
+    <include location="local" impldecl="in implementation">editxlinkdialog.ui.h</include>
+</includes>
+<variables>
+    <variable access="private">bool delink;</variable>
+</variables>
+<slots>
+    <slot access="protected">deleteButtonPressed()</slot>
+</slots>
+<functions>
+    <function access="private" specifier="non virtual">init()</function>
+    <function returnType="bool">deleteXLink()</function>
+</functions>
+<pixmapinproject/>
+<layoutdefaults spacing="6" margin="11"/>
+</UI>
diff -r 6783e13bb05d -r f688a9913724 editxlinkdialog.ui.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/editxlinkdialog.ui.h	Mon Apr 18 06:17:00 2005 +0000
@@ -0,0 +1,23 @@
+/****************************************************************************
+** ui.h extension file, included from the uic-generated form implementation.
+**
+** If you wish to add, delete or rename functions or slots use
+** Qt Designer which will update this file, preserving your code. Create an
+** init() function in place of a constructor, and a destroy() function in
+** place of a destructor.
+*****************************************************************************/
+void EditXLinkDialog::init()
+{
+	delink=false;
+}
+
+void EditXLinkDialog::deleteButtonPressed()
+{
+	delink=true;
+	accept();
+}
+
+bool EditXLinkDialog::deleteXLink()
+{
+	return delink;
+}	
diff -r 6783e13bb05d -r f688a9913724 linkablemapobj.cpp
--- a/linkablemapobj.cpp	Sat Apr 09 22:50:08 2005 +0000
+++ b/linkablemapobj.cpp	Mon Apr 18 06:17:00 2005 +0000
@@ -1,4 +1,4 @@
-//#include <math.h>
+#include <cmath>
 
 #include "linkablemapobj.h"
 #include "branchobj.h"
@@ -535,6 +535,40 @@
     return parObj;
 }
 
+LinkableMapObj* LinkableMapObj::findObj (QString s)
+{
+	LinkableMapObj *lmo=this;
+	QString part;
+	QString typ;
+	QString num;
+	while (!s.isEmpty() )
+	{
+		part=s.section(",",0,0);
+		typ=part.left (3);
+		num=part.right(part.length() - 3);
+		
+		if (typ=="mc:")
+		{
+			if (depth>0)
+				return false;	// in a subtree there is no center
+			else
+				break;
+		} else
+			if (typ=="bo:")
+				lmo=((BranchObj*)(lmo))->getBranchNum (num.toUInt());
+			else
+				if (typ=="fi:")
+					lmo=((BranchObj*)(lmo))->getFloatImageNum (num.toUInt());
+		if (!lmo) break;
+		
+		if (s.contains(","))
+			s=s.right(s.length() - part.length() -1 );
+		else	
+			break;
+	}
+	return lmo;
+}
+
 QPoint LinkableMapObj::getChildPos()
 {
     return childPos;
@@ -584,6 +618,8 @@
 
 void LinkableMapObj::alignRelativeTo (QPoint ref)
 {
+	cout << "LMO::alignRelTo   ref="<<ref<<endl;
+	//FIXME 
 }
 
 void LinkableMapObj::reposition()
diff -r 6783e13bb05d -r f688a9913724 linkablemapobj.h
--- a/linkablemapobj.h	Sat Apr 09 22:50:08 2005 +0000
+++ b/linkablemapobj.h	Mon Apr 18 06:17:00 2005 +0000
@@ -51,6 +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
     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 6783e13bb05d -r f688a9913724 mainwindow.cpp
--- a/mainwindow.cpp	Sat Apr 09 22:50:08 2005 +0000
+++ b/mainwindow.cpp	Mon Apr 18 06:17:00 2005 +0000
@@ -16,7 +16,7 @@
 
 
 #include <iostream>
-#include <stdlib.h>
+#include <cstdlib>
 #include <typeinfo>
 
 #include "version.h"
@@ -842,9 +842,9 @@
 	branchContextMenu->insertSeparator();	
 	actionEditLoadImage->addTo( branchContextMenu );
 	branchContextMenu->insertSeparator();	
-	actionEditCopy->addTo( branchContextMenu );
-	actionEditCut->addTo( branchContextMenu );
-	actionEditPaste->addTo( branchContextMenu );
+	//actionEditCopy->addTo( branchContextMenu );
+	//actionEditCut->addTo( branchContextMenu );
+	//actionEditPaste->addTo( branchContextMenu );
 	branchContextMenu->insertSeparator();	
 	actionGroupFormatFrameTypes->addTo( branchContextMenu );
 
@@ -852,12 +852,12 @@
 	// This will be populated "on demand" in MapEditor::updateActions
 	branchContextMenu->insertSeparator();	
 	branchLinksContextMenu =new QPopupMenu (this);
-	branchContextMenu->insertItem (tr("Goto Link"),branchLinksContextMenu);
-	connect( branchLinksContextMenu, SIGNAL( activated(int) ), this, SLOT( editFollowLink(int ) ) );
+	branchContextMenu->insertItem (tr("Goto XLink"),branchLinksContextMenu);
+	connect( branchLinksContextMenu, SIGNAL( activated(int) ), this, SLOT( editFollowXLink(int ) ) );
 	
 	branchLinksContextMenuDup =new QPopupMenu (this);
-	branchContextMenu->insertItem (tr("Edit Link"),branchLinksContextMenuDup);
-	connect( branchLinksContextMenuDup, SIGNAL( activated(int) ), this, SLOT( editEditLink(int ) ) );
+	branchContextMenu->insertItem (tr("Edit XLink"),branchLinksContextMenuDup);
+	connect( branchLinksContextMenuDup, SIGNAL( activated(int) ), this, SLOT( editEditXLink(int ) ) );
 
 	// Context menu for floatimage
 	floatimageContextMenu =new QPopupMenu (this);
@@ -1135,8 +1135,7 @@
 		if (!QFile(fn).exists() )
 		{
 			QMessageBox mb( "VYM",
-				tr("The map") + fn + 
-				tr(" does not exist.\n Do you want to create a new one?"),
+				tr("This map does not exist:\n  ")+fn+tr("\nDo you want to create a new one?"),
 				QMessageBox::Question,
 				QMessageBox::Yes ,
 				QMessageBox::Cancel | QMessageBox::Default,
@@ -1994,16 +1993,16 @@
 		currentMapEditor()->toggleFloatExport();
 }
 
-void Main::editFollowLink(int item)
+void Main::editFollowXLink(int item)
 {
 	if (currentMapEditor())
-		currentMapEditor()->followLink(branchLinksContextMenu->indexOf(item));
+		currentMapEditor()->followXLink(branchLinksContextMenu->indexOf(item));
 }
 
-void Main::editEditLink(int item)
+void Main::editEditXLink(int item)
 {
 	if (currentMapEditor())
-		currentMapEditor()->editLink(branchLinksContextMenuDup->indexOf(item));
+		currentMapEditor()->editXLink(branchLinksContextMenuDup->indexOf(item));
 }
 
 void Main::formatSelectColor()
diff -r 6783e13bb05d -r f688a9913724 mainwindow.h
--- a/mainwindow.h	Sat Apr 09 22:50:08 2005 +0000
+++ b/mainwindow.h	Mon Apr 18 06:17:00 2005 +0000
@@ -115,8 +115,8 @@
     void editLoadImage();
     void editSaveImage(int);
     void editToggleFloatExport();
-    void editFollowLink (int);
-    void editEditLink (int);
+    void editFollowXLink (int);
+    void editEditXLink (int);
 
     void formatSelectColor();
     void formatPickColor();
diff -r 6783e13bb05d -r f688a9913724 mapcenterobj.cpp
--- a/mapcenterobj.cpp	Sat Apr 09 22:50:08 2005 +0000
+++ b/mapcenterobj.cpp	Mon Apr 18 06:17:00 2005 +0000
@@ -151,15 +151,20 @@
 	if (!note.isEmpty() )
 		s+=note.saveToDir();
 	
+	// Save branches
+    BranchObj *bo;
+    for (bo=branch.first(); bo; bo=branch.next() )
+		s+=bo->saveToDir(tmpdir,prefix, offset);
+
 	// Save FloatImages
 	FloatImageObj *fio;
 	for (fio=floatimage.first(); fio; fio=floatimage.next() )
 		s+=fio->saveToDir (tmpdir,prefix);
 
-	// Save branches
-    BranchObj *bo;
-    for (bo=branch.first(); bo; bo=branch.next() )
-		s+=bo->saveToDir(tmpdir,prefix, offset);
+	// Save XLinks
+	XLinkObj *xlo;
+    for (xlo=xlink.first(); xlo; xlo=xlink.next() )
+		s+=xlo->saveToDir();
 
     decIndent();
     s+=endElement   ("mapcenter");
diff -r 6783e13bb05d -r f688a9913724 mapcenterobj.h
--- a/mapcenterobj.h	Sat Apr 09 22:50:08 2005 +0000
+++ b/mapcenterobj.h	Mon Apr 18 06:17:00 2005 +0000
@@ -2,7 +2,7 @@
 #define MAPCENTEROBJ_H
 
 #include "branchobj.h"
-#include "linkobj.h"
+#include "xlinkobj.h"
 #include "version.h"
 
 /////////////////////////////////////////////////////////////////////////////
diff -r 6783e13bb05d -r f688a9913724 mapeditor.cpp
--- a/mapeditor.cpp	Sat Apr 09 22:50:08 2005 +0000
+++ b/mapeditor.cpp	Mon Apr 18 06:17:00 2005 +0000
@@ -17,7 +17,7 @@
 #include <qinputdialog.h>
 
 #include <iostream>
-#include <stdlib.h>
+#include <cstdlib>
 #include <typeinfo>
 
 #include "version.h"
@@ -29,7 +29,7 @@
 #include "misc.h"
 #include "mainwindow.h"
 #include "extrainfodialog.h"
-#include "editlinkdialog.h"
+#include "editxlinkdialog.h"
 #include "settings.h"
 
 #include "icons/flag-note.xpm"
@@ -1449,43 +1449,9 @@
 	return selection;
 }
 
-LinkableMapObj* MapEditor::findObj (QString s)
-{
-	LinkableMapObj *lmo=mapCenter;
-	QString part;
-	QString typ;
-	QString num;
-	while (!s.isEmpty() )
-	{
-		part=s.section(",",0,0);
-		typ=part.left (3);
-		num=part.right(part.length() - 3);
-		
-		if (typ=="mc:")
-		{
-			if (num=="")
-				break;
-			else
-				lmo=mapCenter->getBranchNum (num.toUInt());
-		} else
-			if (typ=="bo:")
-				lmo=((BranchObj*)(lmo))->getBranchNum (num.toUInt());
-			else
-				if (typ=="fi:")
-					lmo=((BranchObj*)(lmo))->getFloatImageNum (num.toUInt());
-		if (!lmo) break;
-		
-		if (s.contains(","))
-			s=s.right(s.length() - part.length() -1 );
-		else	
-			break;
-	}
-	return lmo;
-}
-
 bool MapEditor::select (const QString &s)
 {
-	LinkableMapObj *lmo=findObj(s);
+	LinkableMapObj *lmo=mapCenter->findObj(s);
 
 	// Finally select the found object
 	if (lmo)
@@ -2104,8 +2070,7 @@
 			typeid(*selection) == typeid(MapCenterObj)) )
 	{		
 		BranchObj *b=(BranchObj*)(selection);
-		b->setURL ("http://bugzilla.suse.de/show_bug.cgi?id="+b->getHeading());
-		b->setURL ("https://bugzilla.innerweb.novell.com/show_bug.cgi?id="+b->getHeading());
+		b->setURL ("https://bugzilla.novell.com/show_bug.cgi?id="+b->getHeading());
 		updateActions();
 		setChanged();
 	}
@@ -2241,7 +2206,7 @@
 		{
 			BranchObj *bo=(BranchObj*)(selection);
 			// Take care of links
-			if (bo->countLinks()==0)
+			if (bo->countXLinks()==0)
 			{
 				branchLinksContextMenu->clear();
 				branchLinksContextMenu->insertItem ("No link available");
@@ -2254,9 +2219,9 @@
 				QString s;
 				branchLinksContextMenu->clear();
 				branchLinksContextMenuDup->clear();
-				for (int i=0; i<=bo->countLinks();i++)
+				for (int i=0; i<=bo->countXLinks();i++)
 				{
-					bot=bo->linkTargetAt(i);
+					bot=bo->XLinkTargetAt(i);
 					if (bot)
 					{
 						s=bot->getHeading();
@@ -2682,9 +2647,9 @@
 	}	
 }
 
-void MapEditor::followLink(int i)
+void MapEditor::followXLink(int i)
 {
-	BranchObj *bo=((BranchObj*)(selection))->linkTargetAt(i);
+	BranchObj *bo=((BranchObj*)(selection))->XLinkTargetAt(i);
 	if (bo) 
 	{
 		selection->unselect();
@@ -2694,16 +2659,16 @@
 	}
 }
 
-void MapEditor::editLink(int i)
+void MapEditor::editXLink(int i)
 {
-	BranchObj *bo=((BranchObj*)(selection))->linkTargetAt(i);
+	BranchObj *bo=((BranchObj*)(selection))->XLinkTargetAt(i);
 	if (bo) 
 	{
-		EditLinkDialog dia;
+		EditXLinkDialog dia;
 		if (dia.exec() == QDialog::Accepted)
 		{
-			if (dia.deleteLink())
-				((BranchObj*)(selection))->deleteLinkAt(i);
+			if (dia.deleteXLink())
+				((BranchObj*)(selection))->deleteXLinkAt(i);
 			setChanged();
 		}
 	}	
@@ -2712,40 +2677,9 @@
 void MapEditor::testFunction()
 {
 	cout << "MapEditor::testFunction() called\n";
-	if (selection  &&  
-		 (typeid(*selection) == typeid(BranchObj) || 
-		  typeid(*selection) == typeid(MapCenterObj) ) ) 
-	{
-		BranchObj *bo=(BranchObj*)(selection);
-		QPoint p = worldMatrix().map(QPoint (bo->x(),bo->y()));
-		//	lineedit->setGeometry(p.x()-contentsX(),p.y()-contentsY(),200,25);
-		QPopupMenu *popupLinks=new QPopupMenu (this);
-		if (bo->countLinks()==0)
-		{
-			popupLinks->clear();
-			popupLinks->insertItem ("No link available");
-			
-		} else
-		{
-			BranchObj *bot;
-			QString s;
-			popupLinks->clear();
-			for (int i=0; i<=bo->countLinks();i++)
-			{
-				bot=bo->linkTargetAt(i);
-				if (bot)
-				{
-					s=bot->getHeading();
-					if (s.length()>25)
-						s=s.left(25)+"...";
-					popupLinks->insertItem (s);
-				}	
-			}
-		}
-		popupLinks->move(p);
-		popupLinks->exec();
-		
-	}
+	//cout <<((BranchObj*)(selection))->getSelectString()<<endl;
+	QString tmpdir,prefix;
+	cout << saveToDir(tmpdir,prefix,true,QPoint(0,0),CompleteMap)<<endl;
 }
 
 void MapEditor::ensureSelectionVisible()
@@ -2847,11 +2781,11 @@
 			{
 				drawingLink=true;
 				linkingObj_src=bo_begin;
-				tmpLink=new LinkObj (mapCanvas);
-				tmpLink->setBegin (bo_begin);
-				tmpLink->setEnd   (p);
-				tmpLink->updateLink();
-				tmpLink->setVisibility (true);
+				tmpXLink=new XLinkObj (mapCanvas);
+				tmpXLink->setBegin (bo_begin);
+				tmpXLink->setEnd   (p);
+				tmpXLink->updateXLink();
+				tmpXLink->setVisibility (true);
 				return;
 			} 
 		}	
@@ -3071,8 +3005,8 @@
 	// Draw a link from one branch to another
 	if (drawingLink)
 	{
-		 tmpLink->setEnd (p);
-		 tmpLink->updateLink();
+		 tmpXLink->setEnd (p);
+		 tmpXLink->updateXLink();
 	}	 
 	
     // Move CanvasView 
@@ -3123,15 +3057,15 @@
 		dst=mapCenter->findMapObj(inverseWorldMatrix().map(e->pos() ), NULL);
 		if (dst && selection) 
 		{	
-			tmpLink->setEnd ( ((BranchObj*)(dst)) );
-			tmpLink->updateLink();
-			tmpLink->activate();
+			tmpXLink->setEnd ( ((BranchObj*)(dst)) );
+			tmpXLink->updateXLink();
+			tmpXLink->activate();
 			setChanged();
 			
 		} else
 		{
-			delete(tmpLink);
-			tmpLink=NULL;
+			delete(tmpXLink);
+			tmpXLink=NULL;
 		}
 		return;
 	}
diff -r 6783e13bb05d -r f688a9913724 mapeditor.h
--- a/mapeditor.h	Sat Apr 09 22:50:08 2005 +0000
+++ b/mapeditor.h	Mon Apr 18 06:17:00 2005 +0000
@@ -76,7 +76,6 @@
     void addNewBranch(int);			// pos allows to add above/below selection
     void deleteSelection();
 	LinkableMapObj* getSelection();	// returns selection
-	LinkableMapObj* findObj (QString);
 	bool select(const QString &);	// Select 
 	void unselect();				// before changing current noteedit
 	void reselect();				// after  changing current noteedit
@@ -128,8 +127,8 @@
     void importDir(BranchObj *,QDir);
 public:	
     void importDir();
-	void followLink (int);
-	void editLink (int);
+	void followXLink (int);
+	void editXLink (int);
     void testFunction();				// FIXME just testing
 
 protected:
@@ -159,7 +158,7 @@
 	bool pickingColor;
 	bool drawingLink;			// true while creating a link
 	bool copyingObj;			// true while creating a link
-	LinkObj* tmpLink;
+	XLinkObj* tmpXLink;
 	
     LinkableMapObj* selection;		// select a LinkableMapObj
     LinkableMapObj* selectionLast;	// last selection 
diff -r 6783e13bb05d -r f688a9913724 misc.cpp
--- a/misc.cpp	Sat Apr 09 22:50:08 2005 +0000
+++ b/misc.cpp	Mon Apr 18 06:17:00 2005 +0000
@@ -1,7 +1,7 @@
 #include <qregexp.h>
 #include <qpoint.h>
 
-#include <math.h>
+#include <cmath>
 
 #include "misc.h"
 
diff -r 6783e13bb05d -r f688a9913724 tex/vym.tex
--- a/tex/vym.tex	Sat Apr 09 22:50:08 2005 +0000
+++ b/tex/vym.tex	Mon Apr 18 06:17:00 2005 +0000
@@ -713,6 +713,8 @@
 \begin{longtable}{|lcp{8cm}l|} \hline
 Version	&	&	Comment								& Date	\\ \hline \hline \endhead
 	\hline \endfoot
+1.6.4	& -	&	xLinks (arbitrary connection between 2 branches) works
+				in a basic version (straight line)	& 2005-04-15\\
 1.6.3	& -	&	Bugfix: Saving of selection to a vym part (.vyp)	&2005-03-30\\
 		& - &	Bugfix: Closing the noteeditor by closing its window now
 				also toggles the responding toolbar button. &\\
diff -r 6783e13bb05d -r f688a9913724 texteditor.cpp
--- a/texteditor.cpp	Sat Apr 09 22:50:08 2005 +0000
+++ b/texteditor.cpp	Mon Apr 18 06:17:00 2005 +0000
@@ -25,7 +25,7 @@
 #include <qsimplerichtext.h>
 
 #include <iostream>
-#include <stdlib.h>
+#include <cstdlib>
 #include <typeinfo>
 
 #include "icons/fileopen.xpm"
diff -r 6783e13bb05d -r f688a9913724 version.h
--- a/version.h	Sat Apr 09 22:50:08 2005 +0000
+++ b/version.h	Mon Apr 18 06:17:00 2005 +0000
@@ -1,7 +1,7 @@
 #ifndef VERSION_H 
 #define VERSION_H
 
-#define __VYM_VERSION__ "1.6.3"
-#define __BUILD_DATE__ "April 11, 2005"
+#define __VYM_VERSION__ "1.6.4"
+#define __BUILD_DATE__ "April 15, 2005"
 
 #endif
diff -r 6783e13bb05d -r f688a9913724 vym.pro
--- a/vym.pro	Sat Apr 09 22:50:08 2005 +0000
+++ b/vym.pro	Mon Apr 18 06:17:00 2005 +0000
@@ -22,23 +22,6 @@
 INSTALLS += demo
 
 
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
 TEMPLATE	= app
 LANGUAGE	= C++
 
@@ -56,7 +39,7 @@
 	headingobj.h \
 	imageobj.h \
 	linkablemapobj.h \
-	linkobj.h \
+	xlinkobj.h \
 	mainwindow.h \
 	mapcenterobj.h \
 	mapeditor.h \
@@ -82,7 +65,7 @@
 	headingobj.cpp \
 	imageobj.cpp \
 	linkablemapobj.cpp \
-	linkobj.cpp \
+	xlinkobj.cpp \
 	main.cpp \
 	mainwindow.cpp \
 	mapcenterobj.cpp \
@@ -101,5 +84,5 @@
 	exportxhtmldialog.ui \
 	showtextdialog.ui \
 	extrainfodialog.ui \
-	editlinkdialog.ui
+	editxlinkdialog.ui
 
diff -r 6783e13bb05d -r f688a9913724 xlinkobj.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xlinkobj.cpp	Mon Apr 18 06:17:00 2005 +0000
@@ -0,0 +1,261 @@
+#include "xlinkobj.h"
+#include "branchobj.h"
+
+
+/////////////////////////////////////////////////////////////////
+// XLinkObj
+/////////////////////////////////////////////////////////////////
+
+int XLinkObj::arrowSize=10;						// make instances 
+QColor XLinkObj::defXLinkColor=QColor(180,180,180); 
+
+XLinkObj::XLinkObj ():MapObj() 
+{
+	//	cout << "Const XLinkObj ()\n";
+	init();
+}
+
+XLinkObj::XLinkObj (QCanvas* c):MapObj(c)
+{
+	//	cout << "Const XLinkObj (c)  called from MapCenterObj (c)\n";
+	init();
+}
+
+
+XLinkObj::~XLinkObj ()
+{
+	//	cout << "Destr XLinkObj\n";
+	if (xLinkState!=undefinedXLink)
+		deactivate();
+	delete (line);
+	delete (poly);
+}
+
+void XLinkObj::init () 
+{
+	beginBranch=NULL;
+	endBranch=NULL;
+	visBranch=NULL;
+	xLinkState=undefinedXLink;
+
+	xLinkColor=defXLinkColor;
+	line=new QCanvasLine (canvas);
+	line->setPoints (0,0,200,200);
+	line->setPen (QPen(xLinkColor, 1));
+
+	poly=new QCanvasPolygon (canvas);
+	poly->setBrush( xLinkColor );
+
+	setVisibility (false);
+}
+
+void XLinkObj::copy (XLinkObj* other)
+{
+	// FIXME copy not used yet
+	cout << "LO::copy called\n";
+	MapObj::copy (other);
+	setVisibility (other->visible);
+	beginBranch=other->beginBranch;
+	endBranch=other->endBranch;
+}
+
+void XLinkObj::setBegin (BranchObj *bo)
+{
+	if (bo) 
+	{
+		xLinkState=initXLink;
+		beginBranch=bo;
+		beginPos=beginBranch->getChildPos();
+	}	
+}
+
+void XLinkObj::setEnd (BranchObj *bo)
+{
+	if (bo) 
+	{
+		xLinkState=initXLink;
+		endBranch=bo;
+		endPos=endBranch->getChildPos();
+	}		
+}
+
+void XLinkObj::setColor(QColor c)
+{
+	xLinkColor=c;
+}
+
+void XLinkObj::setEnd (QPoint p)
+{
+	endPos=p;
+}
+
+bool XLinkObj::activate ()
+{
+	if (beginBranch && endBranch)
+	{
+		xLinkState=activeXLink;
+		beginBranch->addXLink (this);
+		endBranch->addXLink (this);
+		setVisibility (true);
+		return true;
+	} else
+		return false;
+}
+
+void XLinkObj::deactivate ()
+{
+	if (beginBranch)
+		beginBranch->removeXLinkRef (this);
+	beginBranch=NULL;	
+	if (endBranch)
+		endBranch->removeXLinkRef (this);
+	endBranch=NULL;	
+	visBranch=NULL;
+	xLinkState=undefinedXLink;
+
+	line->hide();
+}
+
+bool XLinkObj::isUsed()
+{
+	if (beginBranch || endBranch || xLinkState!=undefinedXLink)
+		return true;
+	else
+		return false;
+}
+
+void XLinkObj::updateXLink()
+{
+	QPoint a,b;
+	QPointArray pa (3);
+	if (visBranch)
+	{
+		// Only one of the linked branches is visible
+		a=b=visBranch->getChildPos();
+		if (visBranch->getOrientation()==OrientRightOfCenter)
+		{
+			b.setX (b.x()+25);
+			pa.putPoints (0,3,
+				b.x(),b.y(),
+				b.x()-arrowSize,b.y()-arrowSize,
+				b.x()-arrowSize,b.y()+arrowSize
+			);
+			poly->setPoints (pa);
+		} else
+		{
+			b.setX (b.x()-25);
+			pa.putPoints (0,3,
+				b.x(),b.y(),
+				b.x()+arrowSize,b.y()-arrowSize,
+				b.x()+arrowSize,b.y()+arrowSize);
+			poly->setPoints (pa);
+		}	
+	} else
+	{
+		// Both linked branches are visible
+		if (beginBranch)
+			// If a link is just drawn in the editor,
+			// we have already a beginBranch
+			a=beginBranch->getChildPos();
+		else
+			// This shouldn't be reached normally...
+			a=beginPos;
+		if (xLinkState==activeXLink && endBranch)
+			b=endBranch->getChildPos();
+		else
+			b=endPos;
+	}
+
+
+	if (line->startPoint()==a && line->endPoint()==b && !visBranch)
+	{
+		// update is called from both branches, so only
+		// update if something has changed
+		return;
+	}	
+	else
+	{
+		beginPos=a;
+		endPos=b;
+		line->setPoints (a.x(), a.y(), b.x(), b.y());
+	}
+}
+
+BranchObj* XLinkObj::otherBranch(BranchObj* thisBranch)
+{
+	if (!beginBranch && !endBranch)
+		return NULL;
+	if (thisBranch==beginBranch)
+		return endBranch;
+	else	
+		return beginBranch;
+}
+
+void XLinkObj::positionBBox()
+{
+}
+
+void XLinkObj::calcBBoxSize()
+{
+}
+
+void XLinkObj::setVisibility (bool b)
+{
+	MapObj::setVisibility (b);
+	if (b)
+	{
+		line->show();
+		if (visBranch) 
+			poly->show();
+		else	
+			poly->hide();
+	}	
+	else
+	{
+		line->hide();
+		poly->hide();
+	}	
+}
+
+void XLinkObj::setVisibility ()
+{
+	if (beginBranch && endBranch)
+	{
+		if(beginBranch->isVisibleObj() && endBranch->isVisibleObj())
+		{	// Both ends are visible
+			visBranch=NULL;
+			setVisibility (true);
+		} else
+		{
+			if(!beginBranch->isVisibleObj() && !endBranch->isVisibleObj())
+			{	//None of the ends is visible
+				visBranch=NULL;
+				setVisibility (false);
+			} else
+			{	// Just one end is visible, draw a symbol that shows
+				// that there is a link to a scrolled branch
+				if (beginBranch->isVisibleObj())
+					visBranch=beginBranch;
+				else
+					visBranch=endBranch;
+				setVisibility (true);
+			}
+		}
+	}
+}
+
+QString XLinkObj::saveToDir ()
+{
+	QString s;
+	if (beginBranch && endBranch)
+	{
+		QString colAttr=attribut ("color",xLinkColor.name());
+		QString begSelAttr=attribut ("beginBranch",beginBranch->getSelectString());
+		QString endSelAttr=attribut ("endBranch",  endBranch->getSelectString());
+		s=beginElement ("xlink", colAttr +begSelAttr +endSelAttr);
+
+		s+=endElement ("xlink");
+	}
+	return s;
+}
+
diff -r 6783e13bb05d -r f688a9913724 xlinkobj.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xlinkobj.h	Mon Apr 18 06:17:00 2005 +0000
@@ -0,0 +1,45 @@
+#ifndef XLINKOBJ_H
+#define XLINKOBJ_H
+
+#include "linkablemapobj.h"
+
+enum XLinkState {undefinedXLink,initXLink,activeXLink,deleteXLink};
+
+/////////////////////////////////////////////////////////////////////////////
+class XLinkObj:public MapObj {
+public:
+    XLinkObj ();
+    XLinkObj (QCanvas*);
+    ~XLinkObj ();
+    virtual void init ();
+    virtual void copy (XLinkObj*);
+	void setBegin (BranchObj*);
+	void setEnd   (BranchObj*);
+	void setEnd   (QPoint);
+	void setColor(QColor);
+	bool activate ();			// Sets pointers in branchObjects
+	void deactivate();			// removes those pointers
+	bool isUsed();				// true, if at least on branch uses it
+	void updateXLink();
+	BranchObj* otherBranch (BranchObj*);
+	void positionBBox();
+	void calcBBoxSize();
+	void setVisibility (bool);
+	void setVisibility ();
+	QString saveToDir ();
+
+private:
+	static int arrowSize;
+	static QColor defXLinkColor;
+	QColor xLinkColor;
+	QCanvasLine *line;
+	QCanvasPolygon *poly;
+	BranchObj *beginBranch;
+	BranchObj *endBranch;
+	BranchObj *visBranch;	// the "visible" part of a partially scrolled link
+	XLinkState xLinkState;	// init during drawing or active
+	QPoint beginPos;
+	QPoint   endPos;
+};
+
+#endif
diff -r 6783e13bb05d -r f688a9913724 xml.cpp
--- a/xml.cpp	Sat Apr 09 22:50:08 2005 +0000
+++ b/xml.cpp	Mon Apr 18 06:17:00 2005 +0000
@@ -7,6 +7,7 @@
 
 #include "misc.h"
 #include "settings.h"
+#include "linkablemapobj.h"
 
 #include "version.h"
 
@@ -228,6 +229,10 @@
         lastBranch->addFloatImage();
 		lastFloat=lastBranch->getLastFloatImage();
 		if (!readFloatImageAttr(atts)) return false;
+    } else if ( eName == "xlink" && state == StateBranch ) 
+	{
+		state=StateBranchXLink;
+		if (!readXLinkAttr (atts)) return false;
     } else if ( eName == "branch" && state == StateBranch ) 
 	{
         lastBranch->addBranch();
@@ -282,6 +287,7 @@
         case StateBranchHeading: state=StateBranch;  return true;
         case StateBranchNote: state=StateBranch; return true;
         case StateBranchFloatImage: state=StateBranch;  return true;
+        case StateBranchXLink: state=StateBranch;  return true;
         case StateHtmlNote: state=laststate; return true;
         case StateHtml: 
 			htmldata+="</"+eName+">";
@@ -504,6 +510,38 @@
 	return true;
 }
 
+bool mapBuilderHandler::readXLinkAttr (const QXmlAttributes& a)
+{
+	QColor col;
+	XLinkObj *xlo=new XLinkObj (mc->getCanvas());
+	if (!a.value( "xLinkColor").isEmpty() ) 
+	{
+		col.setNamedColor(a.value("xLinkColor"));
+		xlo->setColor (col);
+	}
+
+	if (!a.value( "beginBranch").isEmpty() ) 
+	{
+		if (!a.value( "endBranch").isEmpty() ) 
+		{
+			LinkableMapObj *lmo=mc->findObj (a.value( "beginBranch"));
+			if (lmo && typeid (*lmo)==typeid (BranchObj))
+			{
+				xlo->setBegin ((BranchObj*)(lmo));
+				lmo=mc->findObj (a.value( "endBranch"));
+				if (lmo && typeid (*lmo)==typeid (BranchObj))
+				{
+					xlo->setEnd ((BranchObj*)(lmo));
+					xlo->activate();
+					return true;
+				}
+			}
+			return true;	// Not all branches there yet, no error
+		}           
+	}	
+	return false; 
+}
+
 bool mapBuilderHandler::readHtmlAttr (const QXmlAttributes& a)
 {
 	for (int i=1; i<=a.count(); i++)
diff -r 6783e13bb05d -r f688a9913724 xml.h
--- a/xml.h	Sat Apr 09 22:50:08 2005 +0000
+++ b/xml.h	Mon Apr 18 06:17:00 2005 +0000
@@ -29,6 +29,7 @@
 	bool readBranchAttr (const QXmlAttributes&);
 	bool readNoteAttr (const QXmlAttributes&);
 	bool readFloatImageAttr (const QXmlAttributes&);
+	bool readXLinkAttr (const QXmlAttributes&);
 	bool readHtmlAttr (const QXmlAttributes&);
 	bool readSettingAttr (const QXmlAttributes&);
 
@@ -44,7 +45,7 @@
 		
 		StateBranch, StateBranchStandardFlag,
 		StateBranchHeading, StateBranchNote, 
-		StateBranchFloatImage, 
+		StateBranchFloatImage, StateBranchXLink,
 		StateHtmlNote, StateHtml 
 	 };