# HG changeset patch
# User insilmaril
# Date 1260785875 0
# Node ID b486ffd0fa1152b762f6149a4ceaa01531e90a16
# Parent  3086ee01554a85bb3cee4389bf717051261989ed
Bugfix for relinking mainbranches

diff -r 3086ee01554a -r b486ffd0fa11 branchobj.cpp
--- a/branchobj.cpp	Thu Dec 10 17:04:48 2009 +0000
+++ b/branchobj.cpp	Mon Dec 14 10:17:55 2009 +0000
@@ -69,16 +69,6 @@
 	clear();
 }
 
-bool BranchObj::operator< ( const BranchObj & other )
-{
-    return  angle < other.angle;
-}
-
-bool BranchObj::operator== ( const BranchObj & other )
-{
-    return angle == other.angle;
-}
-
 void BranchObj::init () 
 {
 	if (parObj)
@@ -94,8 +84,6 @@
 
 	setVisibility (other->visible);
 
-	angle=other->angle;
-
     positionBBox();
 }
 
@@ -107,14 +95,6 @@
 		delete xlink.takeFirst();
 }
 
-bool isAbove (BranchObj* a, BranchObj *b)
-{
-	if (a->angle < b->angle)
-		return true;
-	else	
-		return false;
-}
-
 void BranchObj::setParObjTmp(LinkableMapObj* dst, QPointF m, int off)	//FIXME-1 when moving a mainbranch to a branch it still has relPos, not moved as child
 {
 	// Temporary link to dst
@@ -146,7 +126,6 @@
 	// Usually the positioning would be done by reposition(),
 	// but then also the destination branch would "Jump" around...
 	// Better just do it approximately
-	cout << "BO::setTmp ";
 	if (dsti->depth()==0)	
 	{	// new parent is a mapcenter
 		Vector v= ( m - bodst->getChildPos());
@@ -154,7 +133,6 @@
 		v.normalize();
 		v.scale (100);
 		move2RelPos (v.toQPointF());
-		cout << "  v="<<v<<endl;
 	} else
 	{	
 		qreal y;
@@ -168,8 +146,6 @@
 				y=t.y();
 
 			y=t.bottom();
-			cout << "  y="<<y;		
-			cout << "  t.h="<<t.height();
 
 		} else
 		{
@@ -183,7 +159,6 @@
 				// Don't try to find that branch, guess 12 pixels
 				y=bodst->getChildPos().y()  -height() + 12; 
 		}	
-		cout << "  pos="<<getAbsPos()<<" cPos="<<bodst->getChildPos()<<endl;
 		if (bodst->getOrientation()==LinkableMapObj::LeftOfCenter)
 			move ( bodst->getChildPos().x() - linkwidth, y );
 		else	
@@ -480,13 +455,6 @@
 	updateContentSize();
 }
 
-void BranchObj::savePosInAngle ()
-{
-	// Save position in angle
-	for (int i=0; i<treeItem->branchCount(); ++i)
-		treeItem->getBranchObjNum(i)->angle=i;
-}
-
 void BranchObj::setDefAttr (BranchModification mod)
 {
 	int fontsize;
@@ -527,21 +495,23 @@
 void BranchObj::alignRelativeTo (QPointF ref,bool alignSelf)
 {
 	qreal th = bboxTotal.height();	
-	int depth=treeItem->depth();	// FIXME-3 needed to recursively calc depth?
+	int depth=0;
+	if (parObj)	depth=1 + parObj->getTreeItem()->depth();
 // TODO testing
 /*
-
-	QString h=QString (depth,' ');
+	QString h=QString (depth+1,' ');
 	h+=treeItem->getHeading();
 	h+=QString (15,' ');
 	h.truncate (15);
-	QPointF pp; if (parObj) pp=parObj->getChildPos();
+	QPointF pp; 
+	if (parObj) pp=parObj->getChildPos();
 	cout << "BO::alignRelTo ";
 	cout<<h.toStdString();
-	cout << "    d="<<depth<<
+	cout << "    d="<<depth;
+	cout <<"  parO="<<parObj;
 //cout<<  "  ref="<<ref<<
-      	"  bbox.tL="<<bboxTotal.topLeft()<<
-		"  absPos="<<absPos<<
+//cout <<	"  bbox.tL="<<bboxTotal.topLeft();
+cout<<	"  absPos="<<absPos<<
 		"  relPos="<<relPos<<
 //		"  parPos="<<pp<<
 //		"  w="<<bbox.width()<<
@@ -551,24 +521,13 @@
 //		"  scrolled="<<((BranchItem*)treeItem)->isScrolled()<<
 //		"  pad="<<topPad<<","<<botPad<<","<<leftPad<<","<<rightPad<<
 //		"  hidden="<<hidden<<
-		"  th="<<th<<
+//		"  th="<<th<<
 		endl;
 */
 
 	setOrientation();
 	//updateLinkGeometry();
 
-	if (depth==1 && parObj)
-	{
-		// Position relatively, if needed
-		//if (useRelPos) move2RelPos (relPos.x(), relPos.y());
-
-		// Calc angle to mapCenter if I am a mainbranch
-		// needed for reordering the mainbranches clockwise 
-		// around mapcenter 
-		angle=getAngle (QPointF ((int)(x() - parObj->getChildPos().x() ), 
-								(int)(y() - parObj->getChildPos().y() ) ) );
-	}							
 	if (depth==1)
 	{
 		move2RelPos (getRelPos() );
@@ -651,7 +610,6 @@
 
 	    alignRelativeTo ( QPointF (absPos.x(),
 			absPos.y()-(bboxTotal.height()-bbox.height())/2) );
-		//FIXME-2 qSort (branch.begin(),branch.end(), isAbove);
 		positionBBox();	// Reposition bbox and contents
 	} else
 	{
diff -r 3086ee01554a -r b486ffd0fa11 branchobj.h
--- a/branchobj.h	Thu Dec 10 17:04:48 2009 +0000
+++ b/branchobj.h	Mon Dec 14 10:17:55 2009 +0000
@@ -6,8 +6,6 @@
 #include "ornamentedobj.h"
 #include "xlinkobj.h"
 
-bool isAbove(BranchObj*,BranchObj*);
-
 /*! \brief A branch visible in the map */
 
 /////////////////////////////////////////////////////////////////////////////
@@ -18,8 +16,6 @@
 
     BranchObj (QGraphicsScene*,TreeItem *ti=NULL);
     ~BranchObj ();
-	bool operator< ( const BranchObj & );
-	bool operator== ( const BranchObj & );
     virtual void init ();
     virtual void copy (BranchObj*);
     void clear();
@@ -43,8 +39,6 @@
     
     virtual void updateData();	//! Update represantatio of heading, flags, etc.
 
-protected:	
-	virtual void savePosInAngle();					// write pos in angle for resorting			
 public:	
 	virtual void setDefAttr (BranchModification);	// set default attributes (font, size, ...)
 
@@ -65,9 +59,6 @@
 	QList<XLinkObj*> xlink;			// xlinks to other branches
 
 	AnimPoint anim;
-
-public:	
-	float angle;					// used in mainbranch to reorder mainbranches
 };
 
 
diff -r 3086ee01554a -r b486ffd0fa11 mapeditor.cpp
--- a/mapeditor.cpp	Thu Dec 10 17:04:48 2009 +0000
+++ b/mapeditor.cpp	Mon Dec 14 10:17:55 2009 +0000
@@ -1051,10 +1051,11 @@
 			// Take care of xLink
 			if (ti->xlinkCount()>0 && lmo->getBBox().width()>30)
 			{
-				if ((lmo->getOrientation()==LinkableMapObj::RightOfCenter && p.x() > lmo->getBBox().right()-20)  ||
-				    (lmo->getOrientation()==LinkableMapObj::LeftOfCenter && p.x() < lmo->getBBox().left()+20) ) 
+				if ((lmo->getOrientation()!=LinkableMapObj::RightOfCenter && p.x() < lmo->getBBox().left()+20)  ||
+				    (lmo->getOrientation()!=LinkableMapObj::LeftOfCenter && p.x() > lmo->getBBox().right()-20) ) 
 				{
-					if (ti->xlinkCount()>1)
+					// FIXME-4 if (ti->xlinkCount()>1)
+					if (true)
 					{
 						QMenu menu;
 						QList <QAction*> alist;
diff -r 3086ee01554a -r b486ffd0fa11 tex/vym.changelog
--- a/tex/vym.changelog	Thu Dec 10 17:04:48 2009 +0000
+++ b/tex/vym.changelog	Mon Dec 14 10:17:55 2009 +0000
@@ -1,3 +1,8 @@
+-------------------------------------------------------------------
+Mon Dec 14 11:16:57 CET 2009 - vym@insilmaril.de
+
+- Bugfix: Wrong tmp position when relinking a mainbranch
+
 -------------------------------------------------------------------
 Thu Dec  7 23:17:57 CET 2009 - vym@insilmaril.de
 
diff -r 3086ee01554a -r b486ffd0fa11 version.h
--- a/version.h	Thu Dec 10 17:04:48 2009 +0000
+++ b/version.h	Mon Dec 14 10:17:55 2009 +0000
@@ -7,7 +7,7 @@
 #define __VYM_VERSION "1.13.0"
 //#define __VYM_CODENAME "Codename: RC-1"
 #define __VYM_CODENAME "Codename: development version, not for production!"
-#define __VYM_BUILD_DATE "2009-12-10"
+#define __VYM_BUILD_DATE "2009-12-14"
 
 
 bool checkVersion(const QString &);