# HG changeset patch
# User insilmaril
# Date 1183110233 0
# Node ID ce2abdbd0b655e90ee3c33b60862a5b4e47bb0d4
# Parent  36d14034989779957223fa0fc91611589adfd6d7
1.8.76 - Extended fileformat to ease tomboy export to vym

diff -r 36d140349897 -r ce2abdbd0b65 branchobj.cpp
--- a/branchobj.cpp	Mon Jun 25 12:54:19 2007 +0000
+++ b/branchobj.cpp	Fri Jun 29 09:43:53 2007 +0000
@@ -697,6 +697,31 @@
     return NULL;
 }
 
+LinkableMapObj* BranchObj::findID (QString sid)
+{
+	// Search branches
+    LinkableMapObj *lmo;
+	for (int i=0; i<branch.size(); ++i)
+    {	
+		lmo=branch.at(i)->findID (sid);
+		if (lmo != NULL) return lmo;
+    }
+	
+	// Search myself
+	if (sid==id) return this;
+
+/*
+	// Search float images
+    for (int i=0; i<floatimage.size(); ++i )
+		if (floatimage.at(i)->inBox(p) && 
+			(floatimage.at(i) != excludeLMO) && 
+			floatimage.at(i)->getParObj()!= excludeLMO &&
+			floatimage.at(i)->isVisibleObj() 
+		) return floatimage.at(i);
+*/
+    return NULL;
+}
+
 void BranchObj::setHeading(QString s)
 {
     heading->setText(s);	// set new heading
diff -r 36d140349897 -r ce2abdbd0b65 branchobj.h
--- a/branchobj.h	Mon Jun 25 12:54:19 2007 +0000
+++ b/branchobj.h	Fri Jun 29 09:43:53 2007 +0000
@@ -64,6 +64,7 @@
     virtual void calcBBoxSize();
 	virtual void setDockPos();
     virtual LinkableMapObj* findMapObj(QPointF,LinkableMapObj*);	// find MapObj 
+    virtual LinkableMapObj* findID (QString sid);	// find Obj by ID string
     virtual void setHeading (QString);
 
 	virtual void setHideTmp (HideTmpMode);
@@ -139,6 +140,7 @@
 	bool tmpUnscrolled;				// can only be true (temporary) for a scrolled subtree
 	bool includeImagesVer;			// include floatimages in bbox vertically
 	bool includeImagesHor;			// include floatimages in bbox horizontally
+	QString id;						// IDstring, needed for xlinks (tomboy)
 
 };
 
diff -r 36d140349897 -r ce2abdbd0b65 xml.cpp
--- a/xml.cpp	Mon Jun 25 12:54:19 2007 +0000
+++ b/xml.cpp	Fri Jun 29 09:43:53 2007 +0000
@@ -479,6 +479,8 @@
 					return false;   // Couldn't read absPos
 			}           
 		}           
+		if (!a.value( "id").isEmpty() ) 
+			lastOO->setID (a.value ("id"));
 		if (!a.value( "url").isEmpty() ) 
 			lastOO->setURL (a.value ("url"));
 		if (!a.value( "vymLink").isEmpty() ) 
@@ -614,6 +616,7 @@
 		xlo->setWidth(a.value ("width").toInt (&okx, 10));
 	}
 
+	// Connecting by select string for compatibility with version < 1.8.76
 	if (!a.value( "beginBranch").isEmpty() ) 
 	{ 
 		if (!a.value( "endBranch").isEmpty() ) 
@@ -632,6 +635,26 @@
 			success=true; // Not all branches there yet, no error
 		}           
 	}	
+
+	// object ID is used starting in version 1.8.76
+	if (!a.value( "beginID").isEmpty() ) 
+	{ 
+		if (!a.value( "endID").isEmpty() ) 
+		{
+			LinkableMapObj *lmo=mc->findID (a.value( "beginBranch"));
+			if (lmo && typeid (*lmo)==typeid (BranchObj))
+			{
+				xlo->setBegin ((BranchObj*)lmo);
+				lmo=mc->findID (a.value( "endID"));
+				if (lmo && typeid (*lmo)==typeid (BranchObj))
+				{
+					xlo->setEnd ((BranchObj*)(lmo));
+					xlo->activate();
+				}
+			}
+			success=true; // Not all branches there yet, no error
+		}           
+	}	
 	if (!success) delete (xlo);
 	return success;
 }