# HG changeset patch
# User insilmaril
# Date 1246959264 0
# Node ID 1fb50e79661c4cd663e92f79d22c183fbbc88dda
# Parent  7b4e73ac247e26448296e7423f97250ac46338c3
Hiding of links works again

diff -r 7b4e73ac247e -r 1fb50e79661c branchitem.cpp
--- a/branchitem.cpp	Mon Jun 29 10:28:28 2009 +0000
+++ b/branchitem.cpp	Tue Jul 07 09:34:24 2009 +0000
@@ -7,7 +7,7 @@
 
 using namespace std;
 
-BranchItem::BranchItem(const QList<QVariant> &data, TreeItem *parent):TreeItem (data,parent)
+BranchItem::BranchItem(const QList<QVariant> &data, TreeItem *parent):MapItem (data,parent)
 {
 	//cout << "Constr. BranchItem\n";
 
@@ -93,7 +93,8 @@
 		elementName="branch";
 
     s=beginElement (elementName
-		+getAttr()
+		+getMapAttr()
+		+getGeneralAttr()
 		+scrolledAttr 
 	//	+areaAttr 
 	//	+idAttr 
@@ -249,10 +250,11 @@
 	// find out, if we are scrolled at all.
 	// But ignore myself, just look at parents.
 
+	//cout << "BI::hasScrolledParent this="<<this<<"  "<<getHeadingStd()<<endl;
 	if (this !=start && scrolled) return true;
 
 	BranchItem* bi=(BranchItem*)parentItem;
-	if (bi && bi->isBranchLikeType() ) 
+	if (bi && bi!=rootItem && bi->isBranchLikeType() ) 
 		return bi->hasScrolledParent(start);
 	else
 		return false;
@@ -350,9 +352,9 @@
 {
 	// FIXME-5 compare also MapItem::initLMO...
 
-	if (lmo)
+	if (lmo && parentItem != rootItem)
 	{
-		lmo->setParObj ( parentItem->getLMO() );
+		lmo->setParObj ( ((MapItem*)parentItem)->getLMO() );
 	}
 }
 
@@ -374,9 +376,9 @@
 		newbo->setFrameType (FrameObj::Rectangle);
 	} else
 	{
-		newbo->setParObj( parentItem->getLMO() );
+		newbo->setParObj( ((MapItem*)parentItem)->getLMO() );
 		// Set visibility depending on parents
-		if (((BranchItem*)parentItem)->scrolled || !parentItem->getLMO()->isVisibleObj() )
+		if (((BranchItem*)parentItem)->scrolled || !((MapItem*)parentItem)->getLMO()->isVisibleObj() )
 			newbo->setVisibility (false);
 	}
 	newbo->setDefAttr(BranchObj::NewBranch);
@@ -388,7 +390,7 @@
 		newbo->setColor (headingColor);
 	}	
 		
-	//newbo->updateLink();	//FIXME-3
+	//newbo->updateLinkGeometry();	//FIXME-3
 
 	return newbo;
 }
diff -r 7b4e73ac247e -r 1fb50e79661c branchitem.h
--- a/branchitem.h	Mon Jun 29 10:28:28 2009 +0000
+++ b/branchitem.h	Tue Jul 07 09:34:24 2009 +0000
@@ -1,23 +1,24 @@
 #ifndef BRANCHITEM_H
 #define BRANCHITEM_H
 
-#include "treeitem.h"
+//#include "treeitem.h"
+#include "mapitem.h"
 
 
 class QString;
 class BranchObj;
 class QGraphicsScene;
 
-class BranchItem:public TreeItem
+class BranchItem:public MapItem
 {
 public:
     BranchItem(const QList<QVariant> &data, TreeItem *parent = 0);
     virtual ~BranchItem();
-	void copy (BranchItem *item);
+	virtual void copy (BranchItem *item);
 
-	void insertBranch (int pos,BranchItem *branch);
+	virtual void insertBranch (int pos,BranchItem *branch);
 
-	QString saveToDir (const QString &tmpdir,const QString &prefix, const QPointF& offset);
+	virtual QString saveToDir (const QString &tmpdir,const QString &prefix, const QPointF& offset);
 
 	virtual void updateVisibility();
 
diff -r 7b4e73ac247e -r 1fb50e79661c branchobj.cpp
--- a/branchobj.cpp	Mon Jun 29 10:28:28 2009 +0000
+++ b/branchobj.cpp	Tue Jul 07 09:34:24 2009 +0000
@@ -146,7 +146,7 @@
 
 	// FIXME-2 depth=parObj->getDepth()+1;
 
-	// setLinkStyle calls updateLink, only set it once
+	// setLinkStyle calls updateLinkGeometry, only set it once
 	if (style!=getDefLinkStyle() ) setLinkStyle (getDefLinkStyle());
 
 	// Move temporary to new position at destination
@@ -190,7 +190,7 @@
 			move (o->getChildPos().x() + linkwidth, y );
 	}	
 
-	// updateLink is called implicitly in move
+	// updateLinkGeometry is called implicitly in move
 	requestReposition();	
 }
 
@@ -203,7 +203,7 @@
 		parObjTmpBuf=NULL;
 		//FIXME-2 depth=parObj->getDepth()+1;
 		setLinkStyle (getDefLinkStyle() );
-		updateLink();
+		updateLinkGeometry();
 	}		
 }
 
@@ -397,7 +397,7 @@
 		childPos.setY( clickBox.topLeft().y() + clickBox.height()/2 );
 		parPos=childPos;		
 		for (int i=0; i<treeItem->branchCount(); ++i)
-			treeItem->getBranchObjNum(i)->updateLink();
+			treeItem->getBranchObjNum(i)->updateLinkGeometry();
 
 	} else
 	{
@@ -702,7 +702,7 @@
 */
 
 	setOrientation();
-	//updateLink();
+	//updateLinkGeometry();
 
 	if (depth==1 && parObj)
 	{
@@ -788,7 +788,7 @@
 		// changes its height,
 		// all upper LMOs have to change, too.
 		calcBBoxSizeWithChildren();
-		updateLink();	// This update is needed if the scene is resized 
+		updateLinkGeometry();	// This update is needed if the scene is resized 
 						// due to excessive moving of a FIO
 
 	    alignRelativeTo ( QPointF (absPos.x(),
diff -r 7b4e73ac247e -r 1fb50e79661c branchpropwindow.cpp
--- a/branchpropwindow.cpp	Mon Jun 29 10:28:28 2009 +0000
+++ b/branchpropwindow.cpp	Tue Jul 07 09:34:24 2009 +0000
@@ -2,6 +2,7 @@
 
 #include <QColorDialog>
 
+#include "branchitem.h"
 #include "frameobj.h"
 #include "settings.h"
 
@@ -63,7 +64,7 @@
 	branch=bo;
 	if (bo) 
 	{
-		qWarning ("BPW::setBranch");
+		BranchItem *bi=(BranchItem*)(bo->getTreeItem());
 		ui.tabWidget->setEnabled (true);
 
 		// Frame
@@ -109,7 +110,7 @@
 		}	
 		
 		// Link
-		if (branch->getHideLinkUnselected())
+		if (bi->getHideLinkUnselected())
 			ui.hideLinkIfUnselected->setCheckState (Qt::Checked);
 		else	
 			ui.hideLinkIfUnselected->setCheckState (Qt::Unchecked);
diff -r 7b4e73ac247e -r 1fb50e79661c floatobj.cpp
--- a/floatobj.cpp	Mon Jun 29 10:28:28 2009 +0000
+++ b/floatobj.cpp	Tue Jul 07 09:34:24 2009 +0000
@@ -30,13 +30,15 @@
 //   cout << "Destr FloatObj\n";
 }
 
+#include <iostream>
+using namespace std;
 void FloatObj::init () 
 {
 	floatExport=true;
 	zPlane=Z_ICON;
 	setLinkStyle (LinkableMapObj::Parabel);
-	setHideLinkUnselected(false);
 	//FIXME-2 setHideLinkUnselected(true);
+	cout << "FO::init  tI="<<treeItem<<endl;
 }
 
 void FloatObj::copy (FloatObj* other)
@@ -84,7 +86,7 @@
 void FloatObj::reposition()
 {
 	move2RelPos (relPos);
-	updateLink();	
+	updateLinkGeometry();	
 }
 
 QRectF FloatObj::getTotalBBox()
diff -r 7b4e73ac247e -r 1fb50e79661c imageitem.cpp
--- a/imageitem.cpp	Mon Jun 29 10:28:28 2009 +0000
+++ b/imageitem.cpp	Tue Jul 07 09:34:24 2009 +0000
@@ -14,7 +14,7 @@
 	init();
 }
 
-ImageItem::ImageItem (const QList<QVariant> &data, TreeItem *parent):TreeItem (data,parent)
+ImageItem::ImageItem (const QList<QVariant> &data, TreeItem *parent):MapItem (data,parent)
 {
 	init();
 }
@@ -29,6 +29,7 @@
 {
 	type=Image;
 	imageType=Undefined;
+	hideLinkUnselected=true;
 	originalFilename="no original name available";
 	zValue=Z_FLOATIMG;
 	posMode=Relative;
@@ -56,8 +57,8 @@
 	FloatImageObj *fio=new FloatImageObj (scene);
 	fio->setTreeItem (this);
 	lmo=fio;
-	fio->setParObj ( parentItem->getLMO());
-	if (((BranchItem*)parentItem)->isScrolled() || !parentItem->getLMO()->isVisibleObj() )
+	fio->setParObj ( ((MapItem*)parentItem)->getLMO());
+	if (((BranchItem*)parentItem)->isScrolled() || !((MapItem*)parentItem)->getLMO()->isVisibleObj() )
 			fio->setVisibility (false);
 	initLMO();
 	fio->setZValue(zValue);
@@ -136,7 +137,8 @@
 	QString nameAttr=attribut ("originalName",originalFilename);
 
     return singleElement ("floatimage",  
-		getAttr() 
+		getMapAttr() 
+		+getGeneralAttr()
 //		+useOrientAttr 
 //		+saveInMapAttr 
 //		+exportAttr  
diff -r 7b4e73ac247e -r 1fb50e79661c imageitem.h
--- a/imageitem.h	Mon Jun 29 10:28:28 2009 +0000
+++ b/imageitem.h	Tue Jul 07 09:34:24 2009 +0000
@@ -6,10 +6,11 @@
 #include <QVariant>
 
 #include "floatimageobj.h"
-#include "treeitem.h"
+//#include "treeitem.h"
+#include "mapitem.h"
 
 
-class ImageItem: public TreeItem
+class ImageItem: public MapItem
 {
 public:
 	enum ImageType {Undefined,Pixmap,SVG};
diff -r 7b4e73ac247e -r 1fb50e79661c linkablemapobj.cpp
--- a/linkablemapobj.cpp	Mon Jun 29 10:28:28 2009 +0000
+++ b/linkablemapobj.cpp	Tue Jul 07 09:34:24 2009 +0000
@@ -79,11 +79,6 @@
     bottomline->setZValue(Z_LINK);
     bottomline->show();
 
-    // Prepare showing the selection of a MapObj
-    selected=false;
-
-	hideLinkUnselected=false;
-
 	topPad=botPad=leftPad=rightPad=0;
 
 	repositionRequest=false;
@@ -287,16 +282,10 @@
 	return style;
 }
 
-void LinkableMapObj::setHideLinkUnselected(bool b)
+void LinkableMapObj::setHideLinkUnselected()
 {
-	hideLinkUnselected=b;
 	setVisibility (visible);
-	updateLink();
-}
-
-bool LinkableMapObj::getHideLinkUnselected()
-{
-	return hideLinkUnselected;
+	updateLinkGeometry();
 }
 
 void LinkableMapObj::setLinkPos(Position lp)
@@ -353,10 +342,40 @@
 void LinkableMapObj::setVisibility (bool v)
 {
 	MapObj::setVisibility (v);
+	updateVisibility();
+}
+
+void LinkableMapObj::setOrientation()
+{
+	Orientation orientOld=orientation;
+
+	if (!parObj) 
+	{
+		orientation=UndefinedOrientation;
+		return;
+	}
+		
+    // Set orientation, first look for orientation of parent
+    if (parObj->getOrientation() != UndefinedOrientation ) 
+		// use the orientation of the parent:
+		orientation=parObj->getOrientation();
+    else
+    {
+		// calc orientation depending on position rel to parent
+		if (absPos.x() < QPointF(parObj->getChildPos() ).x() )
+			orientation=LeftOfCenter; 
+		else
+			orientation=RightOfCenter;
+    }
+	if (orientOld!=orientation) requestReposition();
+}
+
+void LinkableMapObj::updateVisibility()
+{
 	bool visnow=visible;
 
-	// We can hide the link, while object is not selected
-	if (hideLinkUnselected && !selected)
+	if (((MapItem*)treeItem)->getHideLinkUnselected()
+		&& treeItem->getModel()->getSelectedLMO() !=this)
 		visnow=false;
 
 	if (visnow) 
@@ -372,11 +391,11 @@
 					segment.at(i)->show();
 				break;	
 			case PolyLine:
-				if (!p) cout << "LMO::setVis p==0 (PolyLine)\n"; //FIXME-3
+				if (!p) cout << "LMO::updateVis p==0 (PolyLine)\n"; //FIXME-3
 				if (p) p->show();
 				break;
 			case PolyParabel:	
-				if (!p) cout << "LMO::setVis p==0 (PolyParabel) "<<treeItem->getHeading().toStdString()<<endl; //FIXME-3
+				if (!p) cout << "LMO::updateVis p==0 (PolyParabel) "<<treeItem->getHeading().toStdString()<<endl; //FIXME-3
 				if (p) p->show();
 				break;
 			default:
@@ -406,32 +425,7 @@
 	}	
 }
 
-void LinkableMapObj::setOrientation()
-{
-	Orientation orientOld=orientation;
-
-	if (!parObj) 
-	{
-		orientation=UndefinedOrientation;
-		return;
-	}
-		
-    // Set orientation, first look for orientation of parent
-    if (parObj->getOrientation() != UndefinedOrientation ) 
-		// use the orientation of the parent:
-		orientation=parObj->getOrientation();
-    else
-    {
-		// calc orientation depending on position rel to parent
-		if (absPos.x() < QPointF(parObj->getChildPos() ).x() )
-			orientation=LeftOfCenter; 
-		else
-			orientation=RightOfCenter;
-    }
-	if (orientOld!=orientation) requestReposition();
-}
-
-void LinkableMapObj::updateLink()
+void LinkableMapObj::updateLinkGeometry()
 {
     // needs:
     //	childPos of parent
@@ -445,7 +439,7 @@
 	//  bottomlineY
     //	drawing of the link itself
 
-	// updateLink is called from move, but called from constructor we don't
+	// updateLinkGeometry is called from move, but called from constructor we don't
 	// have parents yet...
 
 	if (!parObj)	
@@ -456,7 +450,7 @@
 		parPos=childPos;		
 		// Redraw links to children
 		for (int i=0; i<treeItem->branchCount(); ++i)
-			treeItem->getBranchObjNum(i)->updateLink();
+			treeItem->getBranchObjNum(i)->updateLinkGeometry();
 		return;	
 	}
 
@@ -511,7 +505,6 @@
 	switch (style)
 	{
 		case Line:
-			//l->prepareGeometryChange();
 			l->setLine( QLine(qRound (parPos.x()),
 				qRound(parPos.y()),
 				qRound(p2x),
@@ -520,17 +513,13 @@
 		case Parabel:	
 			parabel (pa0, p1x,p1y,p2x,p2y);
 			for (int i=0; i<segment.size(); ++i)
-			{
-				//segment.at(i)->prepareGeometryChange();
 				segment.at(i)->setLine(QLineF( pa0.at(i).x(), pa0.at(i).y(),pa0.at(i+1).x(),pa0.at(i+1).y()));
-			}	
 			break;
 		case PolyLine:
 			pa0.clear();
 			pa0<<QPointF (qRound(p2x+tp.x()), qRound(p2y+tp.y()));
 			pa0<<QPointF (qRound(p2x-tp.x()), qRound(p2y-tp.y()));
 			pa0<<QPointF (qRound (parPos.x()), qRound(parPos.y()) );
-			//p->prepareGeometryChange();
 			p->setPolygon(QPolygonF (pa0));
 			break;
 		case PolyParabel:	
@@ -541,12 +530,11 @@
 				pa0 << QPointF (pa1.at(i));
 			for (int i=0;i<=arcsegs;i++)
 				pa0 << QPointF (pa2.at(arcsegs-i));
-			//p->prepareGeometryChange();
 			p->setPolygon(QPolygonF (pa0));
 			break;
 		default:
 			break;
-	} // switch (style)	
+	} 
 }
 	
 LinkableMapObj* LinkableMapObj::getParObj()
@@ -626,23 +614,6 @@
 	return repositionRequest;
 }
 
-
-void LinkableMapObj::select()
-{
-	// select and unselect are still needed to
-	// handle hiding of links
-    selected=true;
-	setVisibility (visible);
-}
-
-
-void LinkableMapObj::unselect()
-{
-    selected=false;
-	// Maybe we have to hide the link:
-	setVisibility (visible);
-}
-
 void LinkableMapObj::parabel (QPolygonF &ya, double p1x, double p1y, double p2x, double p2y)
 
 {
@@ -672,12 +643,3 @@
 	}	
 }
 
-QString LinkableMapObj::getLinkAttr ()
-{
-	if (hideLinkUnselected)
-		return attribut ("hideLink","true");
-	else
-		return attribut ("hideLink","false");
-	
-}
-
diff -r 7b4e73ac247e -r 1fb50e79661c linkablemapobj.h
--- a/linkablemapobj.h	Mon Jun 29 10:28:28 2009 +0000
+++ b/linkablemapobj.h	Tue Jul 07 09:34:24 2009 +0000
@@ -79,19 +79,23 @@
 	Style getDefLinkStyle();
     void setLinkStyle(Style);            
 	Style getLinkStyle();
-	void setHideLinkUnselected(bool);
-	bool getHideLinkUnselected();
+
+	void setHideLinkUnselected();
 	void setLinkPos (Position);
 	Position getLinkPos ();
 
-	virtual void setLinkColor();					// sets color according to colorhint, overloaded
+	virtual void setLinkColor();			// sets color according to colorhint, overloaded
 	virtual void setLinkColor(QColor);
 	QColor getLinkColor();
 	virtual void setVisibility (bool);
 	virtual void setOrientation();
-    virtual void updateLink();				// update parPos and childPos
-											// depending on pos
-											// redraw link with given style
+    virtual void updateVisibility();		//! hides/unhides link depending on selection
+
+    /*! update parPos, childPos 
+		depending on pos
+		redraw link with given style */
+    virtual void updateLinkGeometry();		
+
     LinkableMapObj* getChildObj();			// returns pointer to fromObj
     LinkableMapObj* getParObj();			// returns pointer to toObj
 	virtual void setDockPos()=0;				// sets childPos and parPos
@@ -108,12 +112,8 @@
 
 	virtual void calcBBoxSizeWithChildren()=0;// calc size of  BBox including children recursivly
 
-    virtual void select();					// FIXME-3  show/hide links...
-    virtual void unselect();
-
 protected:
 	void parabel(QPolygonF &,double,double,double,double);	// Create Parabel connecting two points
-	QString getLinkAttr();
 
     QPointF childPos;
     QPointF parPos;
@@ -142,8 +142,6 @@
     QGraphicsLineItem* bottomline;  // on bottom of BBox
 	bool repositionRequest;			// 
 
-	bool selected;					// Used for marking the selection
-	bool hideLinkUnselected;		// to hide links if unselected
 	qreal topPad, botPad,
 		leftPad, rightPad;          // padding within bbox
 
diff -r 7b4e73ac247e -r 1fb50e79661c mapeditor.cpp
--- a/mapeditor.cpp	Mon Jun 29 10:28:28 2009 +0000
+++ b/mapeditor.cpp	Tue Jul 07 09:34:24 2009 +0000
@@ -189,7 +189,7 @@
 		LinkableMapObj* lmo=NULL;
 		TreeItem *ti= static_cast<TreeItem*>(index.internalPointer());
 		if (ti->getType()==TreeItem::Image ||ti->isBranchLikeType() )
-			lmo=ti->getLMO();
+			lmo=((MapItem*)ti)->getLMO();
 		if (lmo) setScrollBarPosTarget (lmo->getBBox() );
 	}
 }
@@ -599,7 +599,7 @@
     QPointF p = mapToScene(e->pos());
     TreeItem *ti=findMapItem (p, NULL);
     LinkableMapObj* lmo=NULL;
-	if (ti) lmo=ti->getLMO();
+	if (ti) lmo=((MapItem*)ti)->getLMO();
 	
     if (lmo) 
 	{	// MapObj was found
@@ -683,7 +683,7 @@
     QPointF p = mapToScene(e->pos());
     TreeItem *ti=findMapItem (p, NULL);
     LinkableMapObj* lmo=NULL;
-	if (ti) lmo=ti->getLMO();
+	if (ti) lmo=((MapItem*)ti)->getLMO();
 	
 	e->accept();
 
@@ -818,7 +818,7 @@
 	TreeItem *seli=model->getSelectedItem();
 	LinkableMapObj* lmosel=NULL;	
 	if (seli && (seli->isBranchLikeType() ||seli->getType()==TreeItem::Image))
-		lmosel=seli->getLMO();
+		lmosel=((MapItem*)seli)->getLMO();
 
     // Move the selected MapObj
     if ( lmosel && movingObj) 
@@ -854,7 +854,7 @@
 			FloatObj *fio=(FloatImageObj*)lmosel;
 			fio->move   (p.x() -movingObj_start.x(), p.y()-movingObj_start.y() );		
 			fio->setRelPos();
-			fio->updateLink(); //no need for reposition, if we update link here
+			fio->updateLinkGeometry(); //no need for reposition, if we update link here
 			model->emitSelectionChanged();	// position has changed
 
 			// Relink float to new mapcenter or branch, if shift is pressed	
@@ -968,7 +968,7 @@
 	if (seli) dsti=findMapItem(p, seli);
 	LinkableMapObj* dst=NULL;
 	if (dsti && dsti->isBranchLikeType ()) 
-		dst=dsti->getLMO();	
+		dst=((MapItem*)dsti)->getLMO();	
 	else
 		dsti=NULL;
 
@@ -1013,7 +1013,7 @@
     {	
 		if (seli->getType()==TreeItem::Image)
 		{
-			FloatImageObj *fio=(FloatImageObj*)(seli->getLMO());
+			FloatImageObj *fio=(FloatImageObj*)( ((MapItem*)seli)->getLMO());
 			if(fio)
 			{
 				// Moved FloatObj. Maybe we need to reposition
@@ -1051,7 +1051,7 @@
 		if (seli->isBranchLikeType() ) //(seli->getType() == TreeItem::Branch )
 		{	// A branch was moved
 			LinkableMapObj* lmosel=NULL;		
-			lmosel=seli->getLMO();
+			lmosel=((MapItem*)seli)->getLMO();
 				
 			// save the position in case we link to mapcenter
 			QPointF savePos=QPointF (lmosel->getAbsPos()  );
@@ -1272,6 +1272,9 @@
 
 void MapEditor::updateSelection(QItemSelection newsel,QItemSelection oldsel)
 {
+	// Note: Here we are prepared for multiple selections, though this 
+	// is not yet implemented elsewhere
+
 	// Here in MapEditor we can only select Branches and Images
 	QModelIndex ix;
 	foreach (ix,newsel.indexes() )
@@ -1281,6 +1284,7 @@
 			newsel.indexes().removeOne (ix);
 	}
 
+	// Trim list of selection rectangles 
 	while (newsel.indexes().count() < selboxList.count() )
 		delete selboxList.takeFirst();
 
@@ -1291,10 +1295,17 @@
 		if (ix.isValid() )
 		{
 			TreeItem *ti= static_cast<TreeItem*>(ix.internalPointer());
-			if (ti && ti->isBranchLikeType() )
+			if (ti)
 			{
-				BranchItem *bi=(BranchItem*)ti;
-				bi->resetTmpUnscroll();
+				if (ti->isBranchLikeType() )
+				{
+					// reset tmp scrolled branches
+					BranchItem *bi=(BranchItem*)ti;
+					bi->resetTmpUnscroll();
+				}
+				if (ti->isBranchLikeType() || ti->getType()==TreeItem::Image)
+					// Hide link if not needed
+					((MapItem*)ti)->getLMO()->updateVisibility();
 			}
 		}
 	}
@@ -1313,6 +1324,9 @@
 					bi->tmpUnscroll();
 			}
 			scrollTo (ix);
+			if (ti->isBranchLikeType() || ti->getType()==TreeItem::Image)
+				// Show link if needed
+				((MapItem*)ti)->getLMO()->updateVisibility();
 		}
 	}
 
@@ -1344,7 +1358,7 @@
 	{
 		index=newsel.indexes().at(i);
 		ti= static_cast<TreeItem*>(index.internalPointer());
-		lmo=ti->getLMO();
+		lmo=((MapItem*)ti)->getLMO();
 		bbox=lmo->getBBox();
 		sb->setRect (
 			bbox.x(),bbox.y(), 
@@ -1370,7 +1384,7 @@
 	
 	if (ti->isBranchLikeType())
 	{
-		BranchObj *bo=(BranchObj*) (ti->getLMO());
+		BranchObj *bo=(BranchObj*) ( ((MapItem*)ti)->getLMO());
 		bo->updateData();
 	}
 
diff -r 7b4e73ac247e -r 1fb50e79661c mapitem.cpp
--- a/mapitem.cpp	Mon Jun 29 10:28:28 2009 +0000
+++ b/mapitem.cpp	Tue Jul 07 09:34:24 2009 +0000
@@ -8,10 +8,32 @@
 	init();
 }
 
+MapItem::MapItem(const QList<QVariant> &data, TreeItem *parent):TreeItem (data,parent)
+{
+	init();
+}
+
 void MapItem::init()
 {
 	lmo=NULL;
 	posMode=Unused;
+	hideLinkUnselected=false;
+}
+
+void MapItem::appendChild (TreeItem *item)
+{
+	TreeItem::appendChild (item);
+
+	// FIXME-4 maybe access parent in MapObjs directly via treeItem
+	// and remove this here...
+
+	// If lmo exists, also set parObj there
+	if (lmo && (item->isBranchLikeType() || item->getType()==TreeItem::Image) )
+	{
+		LinkableMapObj *itemLMO=((MapItem*)item)->lmo;
+		if (itemLMO)
+			itemLMO->setParObj (lmo);
+	}
 }
 
 void MapItem::setRelPos (const QPointF &p)
@@ -37,6 +59,51 @@
 	posMode=mode;
 }
 
+void MapItem::setHideLinkUnselected (bool b)
+{
+	hideLinkUnselected=b;
+	if (lmo) lmo->setHideLinkUnselected();
+}
+
+bool MapItem::getHideLinkUnselected()
+{
+	return hideLinkUnselected;
+}	
+
+QString MapItem::getMapAttr ()	
+{
+	QString s;
+
+	if (parentItem==rootItem)
+		posMode=Absolute;
+	else
+	{
+		if (type==TreeItem::Image ||depth()==1)
+			posMode=Relative;
+		else
+			posMode=Unused;
+	}
+	switch (posMode)
+	{
+		case Relative:	
+			if (lmo) pos=lmo->getRelPos();
+			s= attribut("relPosX",QString().setNum(pos.x())) +
+			   attribut("relPosY",QString().setNum(pos.y())); 
+			break;
+		case Absolute:	
+			if (lmo) pos=lmo->getAbsPos();
+			s=attribut("absPosX",QString().setNum(pos.x())) +
+			  attribut("absPosY",QString().setNum(pos.y())); 
+			break;
+		default: break;
+	}
+	if (hideLinkUnselected)
+		s+=attribut ("hideLink","true");
+	else
+		s+=attribut ("hideLink","false");
+	return s;
+}
+
 LinkableMapObj* MapItem::getLMO()
 {
 	return lmo;
diff -r 7b4e73ac247e -r 1fb50e79661c mapitem.h
--- a/mapitem.h	Mon Jun 29 10:28:28 2009 +0000
+++ b/mapitem.h	Tue Jul 07 09:34:24 2009 +0000
@@ -3,7 +3,8 @@
 
 #include <QPointF>
 
-#include "xmlobj.h"
+//#include "xmlobj.h"
+#include "treeitem.h"
 
 class LinkableMapObj;
 
@@ -15,7 +16,7 @@
 	but just a treeview instead.
 */
 
-class MapItem:public XMLObj
+class MapItem:public TreeItem
 {
 public:
 	enum PositionMode {Unused,Absolute,Relative};
@@ -25,8 +26,13 @@
 
 public:
 	MapItem();
+	MapItem(const QList<QVariant> &data, TreeItem *parent = 0);
+
 	void init();
 
+	/*! Overloaded from TreeItem. Used to set parObj in LinkableMapObj */
+	virtual void appendChild (TreeItem *item);
+
 	/*! Used to save relative position while map is not in QGraphicsView */
 	virtual void setRelPos(const QPointF&);	
 
@@ -37,6 +43,20 @@
 	    Defaulst is MapItem::Unused */
 	void setPositionMode (PositionMode mode);
 
+
+protected:
+	bool hideLinkUnselected;
+public:
+	/*! Hide link if item is not selected */
+	virtual void setHideLinkUnselected(bool);
+
+	/*! Check if link is hidden for unselected items */
+	virtual bool getHideLinkUnselected();
+
+	virtual QString getMapAttr();	//! Get attributes for saving as XML
+
+
+
 protected:
 	LinkableMapObj *lmo;
 public:
diff -r 7b4e73ac247e -r 1fb50e79661c ornamentedobj.cpp
--- a/ornamentedobj.cpp	Mon Jun 29 10:28:28 2009 +0000
+++ b/ornamentedobj.cpp	Tue Jul 07 09:34:24 2009 +0000
@@ -190,7 +190,7 @@
 {
 	MapObj::move (x,y);
 	positionContents();
-	updateLink();
+	updateLinkGeometry();
 	requestReposition();
 }
 
@@ -207,7 +207,7 @@
     systemFlags->moveBy (x,y);
     standardFlags->moveBy (x,y);
     heading->moveBy (x,y);
-	updateLink();
+	updateLinkGeometry();
 	requestReposition();
 }
 
diff -r 7b4e73ac247e -r 1fb50e79661c treeitem.cpp
--- a/treeitem.cpp	Mon Jun 29 10:28:28 2009 +0000
+++ b/treeitem.cpp	Tue Jul 07 09:34:24 2009 +0000
@@ -124,10 +124,6 @@
 	item->rootItem=rootItem;
 	item->setModel (model);
 
-	// If lmo exists, also set parObj there
-	if (lmo && item->lmo)
-		item->lmo->setParObj (lmo);
-
 	if (item->type == Image)
 	{
 		childItems.insert (imageCounter,item);
@@ -609,6 +605,7 @@
 		return NULL;
 }
 
+
 void TreeItem::setHideTmp (HideTmpMode mode)
 {
 	if (isBranchLikeType() )
@@ -690,37 +687,12 @@
 	return hidden;
 }	
 
-QString TreeItem::getAttr()
+QString TreeItem::getGeneralAttr()
 {
-	QString s;
-	if (parentItem==rootItem)
-		posMode=Absolute;
+	if (hideExport)
+		 return attribut("hideInExport","true");
 	else
-	{
-		if (type==TreeItem::Image ||depth()==1)
-			posMode=Relative;
-		else
-			posMode=Unused;
-	}
-	switch (posMode)
-	{
-		case Relative:	
-			if (lmo) pos=lmo->getRelPos();
-			s= attribut("relPosX",QString().setNum(pos.x())) +
-			   attribut("relPosY",QString().setNum(pos.y())); 
-			break;
-		case Absolute:	
-			if (lmo) pos=lmo->getAbsPos();
-			s=attribut("absPosX",QString().setNum(pos.x())) +
-			  attribut("absPosY",QString().setNum(pos.y())); 
-			break;
-		default: break;
-	}
-	if (hideExport)
-		return s+attribut("hideInExport","true");
-	else	
-		return s;
+		return QString();
 }
 
 
-
diff -r 7b4e73ac247e -r 1fb50e79661c treeitem.h
--- a/treeitem.h	Mon Jun 29 10:28:28 2009 +0000
+++ b/treeitem.h	Tue Jul 07 09:34:24 2009 +0000
@@ -6,7 +6,7 @@
 #include <QVariant>
 
 #include "flagrow.h"
-#include "mapitem.h"
+//#include "mapitem.h"
 #include "noteobj.h"
 #include "xmlobj.h"
 
@@ -17,7 +17,7 @@
 class ImageItem;
 class VymModel;
 
-class TreeItem:public MapItem
+class TreeItem:public XMLObj
 {
 public:
 	enum Type {Undefined,MapCenter,Branch,Image};	//FIXME-3 MapCenter still needed?
@@ -157,6 +157,7 @@
 
 	virtual ImageItem* getImageNum(const int &n);
 	virtual FloatImageObj* getImageObjNum(const int &n);
+
 protected:
 	bool hideExport;							//! Hide this item in export
 public:
@@ -165,8 +166,8 @@
 	virtual void setHideInExport(bool);		// set export of object (and children)
 	virtual bool hideInExport();
 	virtual bool isHidden ();		
-	virtual QString getAttr();				//! Get attributes for saving as XML
 
+	virtual QString getGeneralAttr();
 	
 protected:
 	VymModel *model;
diff -r 7b4e73ac247e -r 1fb50e79661c version.h
--- a/version.h	Mon Jun 29 10:28:28 2009 +0000
+++ b/version.h	Tue Jul 07 09:34:24 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-06-29"
+#define __VYM_BUILD_DATE "2009-07-07"
 
 
 bool checkVersion(const QString &);
diff -r 7b4e73ac247e -r 1fb50e79661c vymmodel.cpp
--- a/vymmodel.cpp	Mon Jun 29 10:28:28 2009 +0000
+++ b/vymmodel.cpp	Tue Jul 07 09:34:24 2009 +0000
@@ -1623,7 +1623,7 @@
 			saveState (bi, QString("setFrameType (\"%1\")").arg(s),
 				bi, QString ("setFrameType (\"%1\")").arg(bo->getFrameTypeName()),QString ("set type of frame to %1").arg(s));
 			reposition();
-			bo->updateLink();
+			bo->updateLinkGeometry();
 		}
 	}
 }
@@ -1640,7 +1640,7 @@
 				bi, QString ("setFrameType (\"%1\")").arg(s),QString ("set type of frame to %1").arg(s));
 			bo->setFrameType (s);
 			reposition();
-			bo->updateLink();
+			bo->updateLinkGeometry();
 		}
 	}
 }
@@ -1688,7 +1688,7 @@
 				bi, QString ("setFramePadding (\"%1\")").arg(i),QString ("set brush color of frame to %1").arg(i));
 			bo->setFramePadding (i);
 			reposition();
-			bo->updateLink();
+			bo->updateLinkGeometry();
 		}	
 	}	
 }
@@ -1705,7 +1705,7 @@
 				bi, QString ("setFrameBorderWidth (\"%1\")").arg(i),QString ("set border width of frame to %1").arg(i));
 			bo->setFrameBorderWidth (i);
 			reposition();
-			bo->updateLink();
+			bo->updateLinkGeometry();
 		}	
 	}	
 }
@@ -1763,26 +1763,21 @@
 
 void VymModel::setHideLinkUnselected (bool b)//FIXME-2
 {
-/*
-	LinkableMapObj *sel=getSelectedLMO();
-	if (sel &&
-		(selectionType() == TreeItem::Branch || 
-		selectionType() == TreeItem::MapCenter  ||
-		selectionType() == TreeItem::Image ))
+	TreeItem *ti=getSelectedItem();
+	if (ti && (ti->getType()==TreeItem::Image ||ti->isBranchLikeType()))
 	{
 		QString u= b ? "false" : "true";
 		QString r=!b ? "false" : "true";
 		
 		saveState(
-			sel,
+			ti,
 			QString("setHideLinkUnselected (%1)").arg(u),
-			sel, 
+			ti, 
 			QString("setHideLinkUnselected (%1)").arg(r),
-			QString("Hide link of %1 if unselected").arg(getObjectName(sel))
+			QString("Hide link of %1 if unselected").arg(getObjectName(ti))
 		);	
-		sel->setHideLinkUnselected(b);
+		((MapItem*)ti)->setHideLinkUnselected(b);
 	}
-*/
 }
 
 void VymModel::setHideExport(bool b)
@@ -4283,7 +4278,7 @@
                 QString("Move %1 to relative position %2").arg(getObjectName(bo)).arg(ps));
             ((OrnamentedObj*)bo)->move2RelPos (x,y);
             reposition();
-            bo->updateLink();
+            bo->updateLinkGeometry();
             emitSelectionChanged();
         }
 	}
@@ -4953,9 +4948,7 @@
 		TreeItem *ti = getItem (list.first() );
 		TreeItem::Type type=ti->getType();
 		if (type ==TreeItem::Branch || type==TreeItem::MapCenter || type==TreeItem::Image)
-		{
-			return ti->getLMO();
-		}	
+			return ((MapItem*)ti)->getLMO();
 	}
 	return NULL;
 }
@@ -4964,7 +4957,7 @@
 {
 	TreeItem *ti = getSelectedBranchItem();
 	if (ti)
-		return (BranchObj*)(ti->getLMO());
+		return (BranchObj*)(  ((MapItem*)ti)->getLMO());
 	else	
 		return NULL;
 }
diff -r 7b4e73ac247e -r 1fb50e79661c xml-vym.cpp
--- a/xml-vym.cpp	Mon Jun 29 10:28:28 2009 +0000
+++ b/xml-vym.cpp	Tue Jul 07 09:34:24 2009 +0000
@@ -359,7 +359,8 @@
 	if (!readOOAttr(a)) return false;
 
 	if (!a.value( "scrolled").isEmpty() )
-		lastBranch->toggleScroll();
+		lastBranch->toggleScroll();	//FIXME-3 in endElement unscroll again, if branch is still empty 
+		// (interesting for import of KDE bookmarks)
 /*
 	if (!a.value( "frameType").isEmpty() ) 
 		lastOO->setFrameType (a.value("frameType")); //Compatibility 1.8.1
@@ -456,15 +457,13 @@
 			if (a.value("hideInExport")=="true")
 				lastBranch->setHideInExport(true);
 
-		/* FIXME-2
 		if (!a.value( "hideLink").isEmpty()) 
 		{
 			if (a.value ("hideLink") =="true")
-				lastOO->setHideLinkUnselected(true);
+				lastMI->setHideLinkUnselected(true);
 			else	
-				lastOO->setHideLinkUnselected(false);
+				lastMI->setHideLinkUnselected(false);
 		}	
-		*/
 	}
 	return true;	
 }