# HG changeset patch
# User insilmaril
# Date 1243337024 0
# Node ID 340bc29da9a00268eaaf65f3514c5e427837433a
# Parent  e3f722759c7e44cb9c53567d6053da7bbb3eae4d
Various fixes and simplifications

diff -r e3f722759c7e -r 340bc29da9a0 branchitem.cpp
--- a/branchitem.cpp	Wed May 20 15:40:14 2009 +0000
+++ b/branchitem.cpp	Tue May 26 11:23:44 2009 +0000
@@ -84,7 +84,13 @@
 		idAttr="";
 
 	*/
-    s=beginElement ("branch" 
+	QString elementName;
+	if (parentItem==rootItem)
+		elementName="mapcenter";
+	else	
+		elementName="branch";
+
+    s=beginElement (elementName
 		+getAttr()
 	//	+getOrnXMLAttr() 
 		+scrolledAttr 
@@ -146,7 +152,7 @@
 	*/
 
     decIndent();
-    s+=endElement   ("branch");
+    s+=endElement   (elementName);
     return s;
 }
 
@@ -337,6 +343,15 @@
     return NULL;
 }
 
+void BranchItem::updateStyles()
+{
+	// FIXME-5 compare also MapItem::initLMO...
+
+	if (lmo)
+	{
+		lmo->setParObj (parentItem->getLMO() );
+	}
+}
 
 BranchObj* BranchItem::getBranchObj()	// FIXME-3 only for transition BO->BI
 {
@@ -345,22 +360,50 @@
 
 BranchObj* BranchItem::createMapObj(QGraphicsScene *scene)	
 {
+	BranchObj *newbo;
+	cout << "BI::createMO  "<<getHeadingStd()<<"  pI="<<parentItem<<"  rI="<<rootItem<<endl;
+	if (parentItem==rootItem)
+	{
+		// Initialize MapCenterObj, order of things is important...
+		cout << "BI::createMO  (MCO) "<<getHeadingStd()<<endl;
+		MapCenterObj* mco=new MapCenterObj(scene);
+		newbo=mco;
+		lmo=mco;
+		newbo->setParObj(NULL);
+		newbo->setTreeItem (this);
+		newbo->setDefAttr(BranchObj::NewBranch);
+	} else
+	{
 	// Initialize BranchObj, order of things is important...
-    BranchObj* newbo=new BranchObj(scene);
-	lmo=newbo;
-	BranchObj* parbo=(BranchObj*)(parentItem->getLMO());
-    newbo->setParObj(parbo);
-	newbo->setTreeItem (this);
-	newbo->setDefAttr(BranchObj::NewBranch);
-	if (((BranchItem*)parentItem)->scrolled || !parbo->isVisibleObj() )
-		newbo->setVisibility (false);
-	
+		cout << "BI::createMO  (BO) "<<getHeadingStd()<<endl;
+		newbo=new BranchObj(scene);
+		lmo=newbo;
+		BranchObj* parbo=(BranchObj*)(parentItem->getLMO());
+		newbo->setParObj(parbo);
+		newbo->setTreeItem (this);
+		newbo->setDefAttr(BranchObj::NewBranch);
+
+		if (parentItem->isBranchLikeType())
+		{
+			// Set visibility depending on parents
+			if (((BranchItem*)parentItem)->scrolled || !parbo->isVisibleObj() )
+			{
+				if (parentItem && parentItem->isBranchLikeType())
+					cout <<"  scrolled="<<((BranchItem*)parentItem)->scrolled<<endl;
+				if (parbo)
+					cout <<"  par->vis="<<parbo->isVisibleObj()<<endl;
+				newbo->setVisibility (false);
+			}	
+		} else
+			cout <<"   pI=no branch!\n";
+
+	}
 	initLMO();
 
 	if (!getHeading().isEmpty() ) 
 	{
-		newbo->updateData();	//FIXME-3 maybe better model->emitDataHasChanged()?
-		newbo->setColor (headingColor);
+		((BranchObj*)lmo)->updateData();	//FIXME-3 maybe better model->emitDataHasChanged()?
+		((BranchObj*)lmo)->setColor (headingColor);
 	}	
 
 		
diff -r e3f722759c7e -r 340bc29da9a0 branchitem.h
--- a/branchitem.h	Wed May 20 15:40:14 2009 +0000
+++ b/branchitem.h	Tue May 26 11:23:44 2009 +0000
@@ -41,8 +41,9 @@
 	virtual void resetTmpUnscroll();		// scroll all tmp scrolled parents again e.g. when unselecting
 
 	TreeItem* findMapItem (QPointF p,TreeItem* excludeTI);	//! search map for branches or images. Ignore excludeTI, where search is started 
-	virtual TreeItem* findID (QString sid);		//! search map for object with ID string
+	virtual TreeItem* findID (QString sid);	//! search map for object with ID string
 
+	virtual void updateStyles ();			//! update related fonts, parObjects, links, ...
 	virtual BranchObj* getBranchObj();	
 	virtual BranchObj* createMapObj(QGraphicsScene *scene);		//! Create classic object in GraphicsView
 };
diff -r e3f722759c7e -r 340bc29da9a0 branchobj.cpp
--- a/branchobj.cpp	Wed May 20 15:40:14 2009 +0000
+++ b/branchobj.cpp	Tue May 26 11:23:44 2009 +0000
@@ -33,7 +33,7 @@
 //    cout << "Const BranchObj (s,p)\n";
     scene=s;
     setParObj (p);	
-	if (treeItem->depth()==1)
+	if (treeItem->depth()==1)	// FIXME-3 needed to recursively calc depth?
 		// Calc angle to mapCenter if I am a mainbranch
 		// needed for reordering the mainbranches clockwise 
 		// around mapcenter 
@@ -50,6 +50,7 @@
 	if (anim.isAnimated() )
 	{
 		anim.setAnimated (false);
+		VymModel *model=treeItem->getModel();
 		model->stopAnimation (this);
 	}
 
@@ -86,8 +87,6 @@
 		absPos+=parObj->getChildPos();
 	}
 
-    setChildObj(this);
-
 	includeImagesVer=false;
 	includeImagesHor=false;
 }
@@ -153,7 +152,7 @@
 	// Usually the positioning would be done by reposition(),
 	// but then also the destination branch would "Jump" around...
 	// Better just do it approximately
-	if (treeItem->depth()==1)
+	if (treeItem->depth()==1)	// FIXME-3 needed to recursively calc depth?
 	{	// new parent is the mapcenter itself
 
 		QPointF p= normalise ( QPointF (m.x() - o->getChildPos().x(),
@@ -245,6 +244,7 @@
 	// Overloaded from LinkableMapObj
 	// BranchObj can use color of heading
 
+	VymModel *model=treeItem->getModel();
 	if (model)
 	{
 		if (model->getMapLinkColorHint()==HeadingColor)
@@ -254,13 +254,6 @@
 	}		
 }
 
-void BranchObj::setColorSubtree(QColor col)
-{
-	setColor (col);
-	for (int i=0; i<treeItem->branchCount(); ++i)
-		treeItem->getBranchObjNum(i)->setColorSubtree(col);
-}
-
 void BranchObj::updateContentSize()
 {
 	calcBBoxSize();
@@ -663,7 +656,7 @@
 void BranchObj::alignRelativeTo (QPointF ref,bool alignSelf)
 {
 	qreal th = bboxTotal.height();	
-	int depth=treeItem->depth();
+	int depth=treeItem->depth();	// FIXME-3 needed to recursively calc depth?
 // TODO testing
 /*
 
@@ -918,7 +911,11 @@
 
 QString BranchObj::getSelectString()
 {
-	return model->getSelectString (this);
+	VymModel *model=treeItem->getModel();
+	if (model)
+		return model->getSelectString (this);
+	else
+		return QString();
 }
 
 void BranchObj::setAnimation(const AnimPoint &ap)
diff -r e3f722759c7e -r 340bc29da9a0 branchobj.h
--- a/branchobj.h	Wed May 20 15:40:14 2009 +0000
+++ b/branchobj.h	Tue May 26 11:23:44 2009 +0000
@@ -34,7 +34,6 @@
 	virtual void setVisibility(bool,int);	// set visibility
     virtual void setVisibility(bool);	    // set vis. for w
 	virtual void setLinkColor();			// set the color of link
-	virtual void setColorSubtree(QColor);	// set the color of heading
 
 	virtual void updateContentSize();
 	virtual void positionContents();
diff -r e3f722759c7e -r 340bc29da9a0 editxlinkdialog.cpp
--- a/editxlinkdialog.cpp	Wed May 20 15:40:14 2009 +0000
+++ b/editxlinkdialog.cpp	Tue May 26 11:23:44 2009 +0000
@@ -57,19 +57,21 @@
 	}
 }
 
-void EditXLinkDialog::setColorHeadingButtonPressed()
+void EditXLinkDialog::setColorHeadingButtonPressed()	//FIXME-2
 {
+/*
 	if (xlo)
 	{	
 		if (selection && 
-			(typeid(*selection) == typeid(BranchObj) || 
-			typeid(*selection) == typeid(MapCenterObj))  )
+			(typid(*selection) == typid(BranchObj) || 
+			typid(*selection) == typid(MapCenterObj))  )
 		{
 			QColor col=((BranchObj*)(selection))->getColor();
 			xlo->setColor(col);
 			ui.colorButton->setPaletteBackgroundColor (col);
 		}
 	}
+	*/
 }
 
 bool EditXLinkDialog::useSettingsGlobal ()
diff -r e3f722759c7e -r 340bc29da9a0 exports.cpp
--- a/exports.cpp	Wed May 20 15:40:14 2009 +0000
+++ b/exports.cpp	Tue May 26 11:23:44 2009 +0000
@@ -147,10 +147,9 @@
 	int i;
 	BranchItem *cur=NULL;
 	BranchItem *prev=NULL;
-	int d;
 
 	BranchObj *bo;	//FIXME-3 still needed?
-	cur=model->next (cur,prev,d);
+	cur=model->next (cur,prev);
 	while (cur) 
 	{
 		if (cur->getType()==TreeItem::Branch || cur->getType()==TreeItem::MapCenter)
@@ -199,7 +198,7 @@
 				}
 			}
 		}
-		cur=model->next(cur,prev,d);
+		cur=model->next(cur,prev);
 	}
 	file.close();
 }
@@ -233,8 +232,7 @@
 	BranchObj *bo;  //FIXME-3 still needed?
 	BranchItem *cur=NULL;
 	BranchItem *prev=NULL;
-	int d;
-	cur=model->next (cur,prev,d);
+	cur=model->next (cur,prev);
 	while (cur) 
 	{
 		bo=(BranchObj*)(cur->getLMO());
@@ -257,7 +255,7 @@
 			ts << curIndent << "\"" << cur->getHeading()<<"\""<<endl;
 		}
 		
-		cur=model->next(cur,prev,d);
+		cur=model->next(cur,prev);
 		curIndent="";
 	}
 	file.close();
@@ -393,8 +391,7 @@
   BranchObj *bo;
   BranchItem *cur=NULL;
   BranchItem *prev=NULL;
-  int d;  //FIXME-3 still needed?
-  model->next(cur,prev,d);
+  model->next(cur,prev);
   while (cur) 
   {
 	bo=(BranchObj*)(cur->getLMO());
@@ -426,7 +423,7 @@
 		  ts << ("\n");
 		}
 	}
-    cur=model->next(cur,prev,d);
+    cur=model->next(cur,prev);
    }
   file.close();
 }
diff -r e3f722759c7e -r 340bc29da9a0 floatobj.cpp
--- a/floatobj.cpp	Wed May 20 15:40:14 2009 +0000
+++ b/floatobj.cpp	Tue May 26 11:23:44 2009 +0000
@@ -34,7 +34,6 @@
 
 void FloatObj::init () 
 {
-    setChildObj(this);
 	floatExport=true;
 	zPlane=Z_ICON;
 	setLinkStyle (LinkableMapObj::Parabel);
diff -r e3f722759c7e -r 340bc29da9a0 linkablemapobj.cpp
--- a/linkablemapobj.cpp	Wed May 20 15:40:14 2009 +0000
+++ b/linkablemapobj.cpp	Tue May 26 11:23:44 2009 +0000
@@ -57,9 +57,6 @@
 
 void LinkableMapObj::init ()
 {
-	model=NULL;
-
-    childObj=NULL;
     parObj=NULL;
     parObjTmpBuf=NULL;
     parPos=QPointF(0,0);
@@ -103,7 +100,6 @@
 void LinkableMapObj::copy (LinkableMapObj* other)
 {
     MapObj::copy(other);
-	model=other->model;
 	bboxTotal=other->bboxTotal;
     setLinkStyle(other->style);
     setLinkColor (other->linkcolor);
@@ -122,25 +118,9 @@
 	return treeItem;
 }
 
-void LinkableMapObj::setModel (VymModel *vm)
-{
-	model=vm;
-}
-
-VymModel* LinkableMapObj::getModel()
-{
-	return model;
-}
-
-void LinkableMapObj::setChildObj(LinkableMapObj* o)
-{
-    childObj=o;
-}
-
 void LinkableMapObj::setParObj(LinkableMapObj* o)
 {
     parObj=o;
-	if (parObj) model=parObj->getModel();
 }
 
 void LinkableMapObj::setParObjTmp(LinkableMapObj*,QPointF,int)	// FIXME-3 make pure virtual
@@ -205,6 +185,7 @@
 
 LinkableMapObj::Style LinkableMapObj::getDefLinkStyle ()
 {
+	VymModel *model=treeItem->getModel();
 	if (!model)
 	{
 		qWarning ("LMO::getDefLinkStyle   model=NULL");
@@ -246,7 +227,7 @@
 		
 	style=newstyle;
 
-    if (childObj!=NULL && parObj != NULL)
+    if (parObj != NULL)
     {
 		QGraphicsLineItem *cl;
 		switch (style)
@@ -332,6 +313,7 @@
 {
 	// Overloaded in BranchObj and children
 	// here only set default color
+	VymModel *model=treeItem->getModel();
 	if (model)
 		setLinkColor (model->getMapDefLinkColor());
 }
@@ -554,11 +536,6 @@
 	} // switch (style)	
 }
 	
-LinkableMapObj* LinkableMapObj::getChildObj()
-{
-    return childObj;
-}
-
 LinkableMapObj* LinkableMapObj::getParObj()
 {
     return parObj;
@@ -621,6 +598,7 @@
 	// we want to block expensive repositioning, but just do it once at
 	// the end, thus check first:
 
+	VymModel *model=treeItem->getModel();
 	if (model->isRepositionBlocked()) return;	
 	
 	// Pass on the request to parent objects, if this hasn't been done yet
diff -r e3f722759c7e -r 340bc29da9a0 linkablemapobj.h
--- a/linkablemapobj.h	Wed May 20 15:40:14 2009 +0000
+++ b/linkablemapobj.h	Tue May 26 11:23:44 2009 +0000
@@ -59,8 +59,6 @@
 
 	virtual void setTreeItem(TreeItem *);
 	virtual TreeItem* getTreeItem() const;
-	virtual void setModel (VymModel *vm);
-	virtual VymModel* getModel ();
 
     void setChildObj (LinkableMapObj*);
     virtual void setParObj (LinkableMapObj*);
@@ -110,7 +108,7 @@
 
 	virtual void calcBBoxSizeWithChildren()=0;// calc size of  BBox including children recursivly
 
-    virtual void select();
+    virtual void select();					// FIXME-3  show/hide links...
     virtual void unselect();
 
 protected:
@@ -121,13 +119,11 @@
     QPointF parPos;
 	bool link2ParPos;				// While moving around, sometimes link to parent
 
-	VymModel* model;												
     Orientation orientation;     
     qreal linkwidth;				// width of a link
 	QRectF bboxTotal;				// bounding box including children
 
-    LinkableMapObj* childObj;
-    LinkableMapObj* parObj;		// FIXME-2 really still needed? Better get from TreeItem
+    LinkableMapObj* parObj;		
     LinkableMapObj* parObjTmpBuf;	// temporary buffer the original parent
     qreal bottomlineY;              // vertical offset of dockpos to pos
 
@@ -152,7 +148,6 @@
 		leftPad, rightPad;          // padding within bbox
 
 	QPointF	 relPos;				// position relative to childPos of parent
-	//AnimPoint relPos;				// position relative to childPos of parent
 	bool useRelPos;
 	bool useOrientation;
 
diff -r e3f722759c7e -r 340bc29da9a0 mainwindow.cpp
--- a/mainwindow.cpp	Wed May 20 15:40:14 2009 +0000
+++ b/mainwindow.cpp	Tue May 26 11:23:44 2009 +0000
@@ -1451,10 +1451,7 @@
 	a->setToggleAction(true);
 	a->setOn (settings.value("/animation/use",false).toBool() );
     connect( a, SIGNAL( triggered() ), this, SLOT( settingsToggleAnimation() ) );
-	if (settings.value( "/mainwindow/showTestMenu",false).toBool() )
-	{
-		settingsMenu->addAction (a);
-	}	
+	settingsMenu->addAction (a);
 	actionSettingsUseAnimation=a;
 }
 
diff -r e3f722759c7e -r 340bc29da9a0 mapcenteritem.cpp
--- a/mapcenteritem.cpp	Wed May 20 15:40:14 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,143 +0,0 @@
-#include "mapcenteritem.h"
-#include "mapcenterobj.h"
-
-#include <iostream>
-using namespace std;
-
-MapCenterItem::MapCenterItem(const QList<QVariant> &data, TreeItem *parent):BranchItem (data,parent)
-{
-	//cout << "Constr. MapCenterItem\n";
-	type=MapCenter;
-}
-
-MapCenterItem::~MapCenterItem()
-{
-//	cout << "Destr. MapCenterItem\n";
-    qDeleteAll(childItems);
-}
-
-QString MapCenterItem::saveToDir (const QString &tmpdir,const QString &prefix, const QPointF& offset)	//FIXME-3 Check if everything is saved...
-{
-	// Cloudy stuff can be hidden during exports
-	if (hidden) return QString();
-
-    QString s,a;
-	BranchObj *bo=(BranchObj*)lmo;
-
-	QString scrolledAttr;
-	if (scrolled) 
-		scrolledAttr=attribut ("scrolled","yes");
-	else
-		scrolledAttr="";
-
-	/* 
-	// save area, if not scrolled
-	QString areaAttr;
-	if (!((BranchObj*)(parObj))->isScrolled() )
-	{
-		areaAttr=
-			attribut("x1",QString().setNum(absPos.x()-offset.x())) +
-			attribut("y1",QString().setNum(absPos.y()-offset.y())) +
-			attribut("x2",QString().setNum(absPos.x()+width()-offset.x())) +
-			attribut("y2",QString().setNum(absPos.y()+height()-offset.y()));
-
-	} else
-		areaAttr="";
-	
-	// Providing an ID for a branch makes export to XHTML easier
-	QString idAttr;
-	if (countXLinks()>0)
-		idAttr=attribut ("id",model->getSelectString(this)); //TODO directly access model
-	else
-		idAttr="";
-
-	*/
-    s=beginElement ("mapcenter" 
-		+getAttr()
-	//	+getOrnXMLAttr() 
-		+scrolledAttr 
-	//	+areaAttr 
-	//	+idAttr 
-	//	+getIncludeImageAttr() 
-		);
-    incIndent();
-
-	// save heading
-    s+=valueElement("heading", getHeading(),
-		attribut ("textColor",QColor( bo->getColor()).name()));
-
-/*
-	// Save frame
-	if (frame->getFrameType()!=FrameObj::NoFrame) 
-		s+=frame->saveToDir ();
-
-	// save names of flags set
-	s+=standardFlags->saveToDir(tmpdir,prefix,0);
-	
-	// Save FloatImages
-	for (int i=0; i<floatimage.size(); ++i)
-		s+=floatimage.at(i)->saveToDir (tmpdir,prefix);
-*/
-
-	// save note
-	if (!note.isEmpty() )
-		s+=note.saveToDir();
-	
-	// Save branches
-	int i=0;
-	TreeItem *ti=getBranchNum(i);
-	while (ti)
-	{
-		s+=getBranchNum(i)->saveToDir(tmpdir,prefix,offset);
-		i++;
-		ti=getBranchNum(i);
-	}	
-
-
-	/*
-	// Save XLinks
-	QString ol;	// old link
-	QString cl;	// current link
-	for (int i=0; i<xlink.size(); ++i)
-	{
-		cl=xlink.at(i)->saveToDir();
-		if (cl!=ol)
-		{
-			s+=cl;
-			ol=cl;
-		} else
-		{
-			qWarning (QString("Ignoring of duplicate xLink in %1").arg(getHeading()));
-		}
-	}	
-	*/
-
-    decIndent();
-    s+=endElement   ("mapcenter");
-    return s;
-}
-
-BranchObj* MapCenterItem::createMapObj(QGraphicsScene *scene)	
-{
-	// Initialize MapCenterObj, order of things is important...
-    MapCenterObj* mco=new MapCenterObj(scene);
-	lmo=mco;
-    mco->setParObj(NULL);
-	mco->setModel (model);
-	mco->setTreeItem (this);
-	mco->setDefAttr(BranchObj::NewBranch);
-
-	initLMO();
-
-	if (!getHeading().isEmpty() ) 
-	{
-		mco->updateData();	//FIXME-3 better call model->emitDataHasChanged(treeItem);
-		mco->setColor (headingColor);
-	}	
-		
-	//mco->updateLink();	//FIXME-3
-
-	return mco;
-}
-
-
diff -r e3f722759c7e -r 340bc29da9a0 mapcenteritem.h
--- a/mapcenteritem.h	Wed May 20 15:40:14 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,17 +0,0 @@
-#ifndef MAPCENTERITEM_H
-#define MAPCENTERITEM_H
-
-#include "branchitem.h"
-
-
-class MapCenterItem:public BranchItem
-{
-public:
-    MapCenterItem(const QList<QVariant> &data, TreeItem *parent = 0);
-    virtual ~MapCenterItem();
-
-	QString saveToDir (const QString &tmpdir,const QString &prefix, const QPointF& offset);
-	virtual BranchObj* createMapObj (QGraphicsScene *scene);
-};
-
-#endif
diff -r e3f722759c7e -r 340bc29da9a0 mapcenterobj.cpp
--- a/mapcenterobj.cpp	Wed May 20 15:40:14 2009 +0000
+++ b/mapcenterobj.cpp	Tue May 26 11:23:44 2009 +0000
@@ -19,13 +19,6 @@
     init();
 }
 
-MapCenterObj::MapCenterObj(QGraphicsScene* s,VymModel *m) : BranchObj (s)
-{
-//    cout << "Const MapCenterObj   canvas="<<s<<"\n";
-	model=m;
-    init();
-}
-
 MapCenterObj::~MapCenterObj() 
 {
 //    cout << "Destr MapCenterObj\n";
@@ -45,41 +38,11 @@
 	// TODO this should be done in TextObj later...
 	//QFont font ("Sans Serif,16,-1,5,50,0,0,0,0,0");		
 	//heading->setFont(font);
-	//FIXME-2 no treeitem yet:  setDefAttr(MovedBranch);
+	//FIXME-2 no treeitem yet:  setDefAttr(MovedBranch); and already in BI::createMapObj ?!?
 
 	frame->setFrameType (FrameObj::Rectangle);
 }
 
-void MapCenterObj::move (double x, double y)
-{
-	BranchObj::move(x,y);
-}
-
-void MapCenterObj::move (QPointF absPos)
-{
-	BranchObj::move(absPos);
-}
-
-void MapCenterObj::moveBy (double x, double y)
-{
-	BranchObj::moveBy(x,y);
-}
-
-void MapCenterObj::moveAll (double x, double y)
-{
-	// Get rel. position
-	double dx=x-absPos.x();
-	double dy=y-absPos.y();
-
-	// Move myself and branches
-	moveAllBy (dx,dy);
-}
-
-void MapCenterObj::moveAllBy (double dx, double dy)
-{
-	// Move myself and children
-	BranchObj::moveBy(dx,dy);
-}
 
 void MapCenterObj::updateLink()
 {
diff -r e3f722759c7e -r 340bc29da9a0 mapcenterobj.h
--- a/mapcenterobj.h	Wed May 20 15:40:14 2009 +0000
+++ b/mapcenterobj.h	Tue May 26 11:23:44 2009 +0000
@@ -16,15 +16,9 @@
 public:
     MapCenterObj ();
     MapCenterObj (QGraphicsScene *);
-    MapCenterObj (QGraphicsScene *, VymModel *);
     ~MapCenterObj ();
     void clear();
     void init();
-    virtual void move      (double,double);
-    virtual void move      (QPointF absPos);
-    virtual void moveBy    (double,double);
-    virtual void moveAll   (double,double);
-    virtual void moveAllBy (double,double);
     virtual void updateLink();
     virtual void updateRelPositions();
 };
diff -r e3f722759c7e -r 340bc29da9a0 mapeditor.cpp
--- a/mapeditor.cpp	Wed May 20 15:40:14 2009 +0000
+++ b/mapeditor.cpp	Tue May 26 11:23:44 2009 +0000
@@ -560,7 +560,7 @@
 	}
 	BranchObj *bo=model->getSelectedBranchObj();
 	BranchItem *bi=model->getSelectedBranchItem();
-	if (bo)	//FIXME-3
+	if (bo)	
 	{
 		model->setSelectionBlocked(true);
 
@@ -680,14 +680,13 @@
     QPointF p = mapToScene(e->pos());
     TreeItem *ti=findMapItem (p, NULL);
     LinkableMapObj* lmo=NULL;
-	if (ti) lmo=ti->getLMO();	//FIXME-2 get rid of lmo...
+	if (ti) lmo=ti->getLMO();	//FIXME-3 get rid of lmo...
 	
 	e->accept();
 
 	//Take care of  system flags _or_ modifier modes
 	//
-	if (lmo && (typeid(*lmo)==typeid(BranchObj) ||
-		typeid(*lmo)==typeid(MapCenterObj) ))
+	if (lmo && ti->isBranchLikeType() )
 	{
 		QString foname=((BranchObj*)lmo)->getSystemFlagName(p);
 		if (!foname.isEmpty())
@@ -866,27 +865,23 @@
 			if ( (e->modifiers()==Qt::ShiftModifier) && dst && ( dst != fio->getParObj())  
 				)
 			{
-				if (typeid(*fio) == typeid(FloatImageObj) )  
-				{
+				// Also save the move which was done so far
+				QString pold=qpointfToString(movingObj_orgRelPos);
+				QString pnow=qpointfToString(fio->getRelPos());
+				model->saveState(
+					fio->getTreeItem(),  // FIXME-3 
+					"moveRel "+pold,
+					fio->getTreeItem(),
+					"moveRel "+pnow,
+					QString("Move %1 to relative position %2").arg(model->getObjectName(fio)).arg(pnow));
+				fio->getParObj()->requestReposition();
+				model->reposition();
 
-					// Also save the move which was done so far
-					QString pold=qpointfToString(movingObj_orgRelPos);
-					QString pnow=qpointfToString(fio->getRelPos());
-					model->saveState(
-						fio->getTreeItem(),  // FIXME-3 
-						"moveRel "+pold,
-						fio->getTreeItem(),
-						"moveRel "+pnow,
-						QString("Move %1 to relative position %2").arg(model->getObjectName(fio)).arg(pnow));
-					fio->getParObj()->requestReposition();
-					model->reposition();
+				model->linkFloatImageTo (model->getSelectString(dst));
+				//movingObj=lmosel;
+				//movingObj_orgRelPos=lmosel->getRelPos();	
 
-					model->linkFloatImageTo (model->getSelectString(dst));
-					//movingObj=lmosel;
-					//movingObj_orgRelPos=lmosel->getRelPos();	
-
-					model->reposition();
-				}	
+				model->reposition();
 			}
 		} else	
 		{	// selection != a FloatObj
@@ -894,7 +889,9 @@
 			{
 				// Move MapCenter
 				if (e->buttons()== Qt::LeftButton && e->modifiers()==Qt::ShiftModifier) 
-					((MapCenterObj*)lmosel)->moveAll(p.x() -movingObj_start.x(), p.y()-movingObj_start.y() );		
+					((BranchObj*)lmosel)->moveBy(
+						QPointF(p.x() -movingObj_start.x(), 
+						p.y()-movingObj_start.y()) );		
 				else	
 					lmosel->move   (p.x() -movingObj_start.x(), p.y()-movingObj_start.y() );		
 				model->updateRelPositions();
@@ -1051,7 +1048,7 @@
             }
 		}
 	
-		if (seli->getType() == TreeItem::Branch )
+		if (seli->isBranchLikeType() ) //(seli->getType() == TreeItem::Branch )
 		{	// A branch was moved
 			LinkableMapObj* lmosel=NULL;		//FIXME-2 get rid of lmosel
 			lmosel=seli->getLMO();
@@ -1063,7 +1060,7 @@
 			lmosel->unsetParObjTmp();
 
 			// For Redo we may need to save original selection
-			QString preSelStr=model->getSelectString(lmosel);
+			QString preSelStr=model->getSelectString(seli);
 
 			copyingObj=false;	
 			if (dsti)
diff -r e3f722759c7e -r 340bc29da9a0 ornamentedobj.cpp
--- a/ornamentedobj.cpp	Wed May 20 15:40:14 2009 +0000
+++ b/ornamentedobj.cpp	Tue May 26 11:23:44 2009 +0000
@@ -62,6 +62,8 @@
 
 void OrnamentedObj::setLinkColor()
 {
+	VymModel *model=treeItem->getModel();
+	if (!model) return;
 	if (model->getMapLinkColorHint()==HeadingColor)
 		LinkableMapObj::setLinkColor (heading->getColor());
 	else	
@@ -261,7 +263,7 @@
 }
 */
 
-QString OrnamentedObj::getOrnXMLAttr()	//FIXME-2
+QString OrnamentedObj::getOrnXMLAttr()	//FIXME-2 still needed?
 {
 	QString posAttr;
 
@@ -271,7 +273,8 @@
 			attribut("absPosY",QString().setNum(absPos.y())); 
 	else
 	{
-		if (treeItem->depth()==1 || typeid (*this)==typeid (FloatImageObj))
+	/* FIXME-2
+		if (treeItem->depth()==1 || typid (*this)==typid (FloatImageObj))
 		{
 			if (relPos.x()==0 && relPos.y()==0)
 				setRelPos();
@@ -280,6 +283,7 @@
 				attribut("relPosY",QString().setNum(relPos.y())); 
 		} else
 			posAttr="";
+	*/		
 	}	
 
 /* FIXME-2 QString hideExpAttr;
diff -r e3f722759c7e -r 340bc29da9a0 selection.cpp
--- a/selection.cpp	Wed May 20 15:40:14 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,189 +0,0 @@
-#include <typeinfo>
-#include <iostream>
-using namespace std;
-
-#include "selection.h"
-
-#include "mainwindow.h"
-#include "vymmodel.h"
-
-
-
-extern Main *mainWindow;
-
-Selection::Selection()
-{
-	blocked=false;
-	model=NULL;
-}
-
-Selection::~Selection()
-{
-}
-
-void Selection::setModel (VymModel *m)
-{
-	model=m;
-}
-
-void Selection::update() // FIXME-2 VM emit signal in VM instead and get rid of this
-{
-/*
-	QRectF bbox;
-	//int w=0;
-	for (int i=0; i< selectList.count(); ++i) 
-	{
-		bbox=selectList.at(i)->getBBox();
-		selboxList.at(i)->setRect (
-			bbox.x()-w,bbox.y()-w, 
-			bbox.width()+2*w, bbox.height()+2*w);
-		selboxList.at(i)->setPen (color);	
-		selboxList.at(i)->setBrush (color);	
-	}	
-*/
-}
-bool Selection::select(LinkableMapObj *lmo)// FIXME-2 VM emit signal in VM instead and get rid of this
-
-{
-	return model->select (lmo);
-	/*
-	if (!selectList.isEmpty()) unselect();
-	selectList.append (lmo);
-	lmo->select();
-	update();
-	mainWindow->updateSatellites (model);	
-	cout << "Sel::select lmo e\n";
-	return true;
-	*/
-}
-
-bool Selection::select (const QString &s)// FIXME-2 VM emit signal in VM instead and get rid of this
-
-{
-	return model->select (s);
-	/*
-	cout << "Sel::select s=\n";
-	LinkableMapObj *lmo=model->findObjBySelect(s);
-
-	// Finally select the found object
-	if (lmo)
-	{
-		unselect();
-		select (lmo);
-		return true;
-	} 
-	return false;
-	*/
-}
-
-bool Selection::reselect ()	// TODO no multiselections yet
-{
-	if (!lastSelectList.isEmpty())
-	{
-		select (lastSelectList.first());
-		return true;
-	}
-	return false;
-
-}
-
-void Selection::unselect()
-{
-	model->unselect();
-}
-
-bool Selection::isBlocked()
-{
-	return blocked;
-}
-
-void Selection::block()
-{
-	blocked=true;
-}
-
-void Selection::unblock()
-{
-	blocked=false;
-}
-
-bool Selection::isEmpty()
-{
-	return selectList.isEmpty();
-}
-
-/*
-uint Selection::count()
-{
-	return selectList.count();
-}
-*/
-
-/*
-Selection::Type Selection::type() // TODO no multiselections yet
-{
-	if (!selectList.isEmpty())
-	{
-		LinkableMapObj *sel=selectList.first();
-		if (typeid (*sel)==typeid (BranchObj)) return Branch;
-		if (typeid (*sel)==typeid (MapCenterObj)) return MapCenter;
-		if (typeid (*sel)==typeid (FloatImageObj)) return FloatImage;
-	}
-	return Undefined;
-}
-*/
-
-/*
-LinkableMapObj* Selection::first()
-{
-	if (!selectList.isEmpty())
-		return selectList.first();
-	else	
-		return NULL;
-}
-
-LinkableMapObj* Selection::single()
-{
-	if (selectList.count() == 1)
-		return selectList.first();
-	else	
-		return NULL;
-}
-
-TreeItem* Selection::getBranchItem()
-{
-	BranchObj* bo=getBranch();
-	if (bo) return bo->getTreeItem(); //  VM get directly from treemodl
-	return NULL;
-}
-
-QModelIndex Selection::getBranchIndex()
-{
-	return model->getSelectionModel()->selectedIndexes().first();	// TODO no multiselections yet
-
-}
-*/
-
-FloatImageObj* Selection::getFloatImage()
-{
-	if (!selectList.isEmpty())
-	{
-		LinkableMapObj *sel=selectList.first();
-		if (typeid (*sel)==typeid (FloatImageObj)) 
-			return (FloatImageObj*)sel;
-	}
-		return NULL;
-}
-
-QString Selection::getSelectString() // FIXME-2 VM this is also in VM ?! clean up here...
-// TODO no multiselections yet
-{
-	if (selectList.count()==1)
-	{
-		return model->getSelectString (selectList.first() );
-	}
-	else
-		return"";
-}
-
-
diff -r e3f722759c7e -r 340bc29da9a0 selection.h
--- a/selection.h	Wed May 20 15:40:14 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,56 +0,0 @@
-#ifndef SELECTION_H
-#define SELECTION_H
-
-#include <QString>
-#include <QList>
-#include <QGraphicsScene>
-#include <QItemSelectionModel>
-
-#include "treeitem.h"
-
-class BranchObj;
-class FloatImageObj;
-class MapCenterObj;
-class LinkableMapObj;
-class VymModel;
-
-
-class Selection 
-{
-public:
-	enum Type {Undefined,Branch,MapCenter,FloatImage};
-	Selection ();
-	~Selection();
-	void setModel (VymModel *);
-	void update();      
-	bool select (LinkableMapObj*);
-	bool select (const QString &);
-	bool reselect ();
-	void unselect ();
-	bool isBlocked ();
-	void block();
-	void unblock();
-	bool isEmpty();
-//	uint count();
-//	Type type();
-//	LinkableMapObj * first();		// first in selection list
-//	LinkableMapObj * single();		// NULL, if multiple selected
-//	BranchObj* getBranch();
-//	TreeItem* getBranchItem();		
-//	QModelIndex getBranchIndex();	//!< Returns index of first selected branch or mapcenter
-	FloatImageObj* getFloatImage();
-
-	QString getSelectString();
-
-private:
-	QList <LinkableMapObj*> selectList;
-	QList <LinkableMapObj*> lastSelectList;
-
-	VymModel *model;
-
-	QColor color;
-	bool blocked;					//!< if true, no new selection possible
-};
-
-#endif
-
diff -r e3f722759c7e -r 340bc29da9a0 treeitem.cpp
--- a/treeitem.cpp	Wed May 20 15:40:14 2009 +0000
+++ b/treeitem.cpp	Tue May 26 11:23:44 2009 +0000
@@ -5,7 +5,6 @@
 
 #include "branchobj.h"
 #include "branchitem.h"
-#include "mapcenteritem.h"
 #include "vymmodel.h"
 
 using namespace std;
@@ -14,10 +13,14 @@
 
 TreeItem::TreeItem(const QList<QVariant> &data, TreeItem *parent):MapItem()
 {
-	//cout << "Constructor TreeItem "<<endl;
+	//cout << "Constructor TreeItem this="<<this<<"  parent="<<parent<<endl;
 	init();
     parentItem = parent;
     itemData = data;
+	
+	rootItem=this;
+	if (parentItem )
+		rootItem=parentItem->rootItem;
 }
 
 TreeItem::~TreeItem()
@@ -30,7 +33,7 @@
 		switch (ti->getType() )
 		{
 			case TreeItem::MapCenter:
-				delete (MapCenterItem*)ti;
+				delete (BranchItem*)ti;
 				break;
 			case TreeItem::Branch:
 				delete (BranchItem*)ti;
@@ -69,12 +72,6 @@
 	standardFlags.setMasterRow (standardFlagsMaster);
 }
 
-QString TreeItem::saveToDir (const QString &tmpdir,const QString &prefix, const QPointF& offset)
-{
-	cout<< "TreeItem::saveToDir called directly for ("<<getHeadingStd()<<"), instead of inherited type...\n";
-	return QString();
-}
-
 
 /*
 void TreeItem::copy (OrnamentedObj* other)	//FIXME-2	probably need deep copy of branches and data!
@@ -101,6 +98,7 @@
 {
     childItems.append(item);
 	item->parentItem=this;
+	item->rootItem=rootItem;
 	item->setModel (model);
 
 	if (item->type == Branch || item->type ==MapCenter)
diff -r e3f722759c7e -r 340bc29da9a0 treeitem.h
--- a/treeitem.h	Wed May 20 15:40:14 2009 +0000
+++ b/treeitem.h	Tue May 26 11:23:44 2009 +0000
@@ -25,10 +25,6 @@
     ~TreeItem();
 	void init();
 
-	virtual QString saveToDir (const QString &tmpdir=QString(),const
-	QString &prefix=QString(), const QPointF& offset=QPointF());
-
-
 	// General housekeeping
 	virtual void setModel (VymModel *m);
 	virtual VymModel* getModel();
@@ -166,6 +162,10 @@
     QList<TreeItem*> childItems;
     QList<QVariant> itemData;
     TreeItem *parentItem;
+
+	/*!  Set rootItem (does not change, needed for quick check 
+	     if some branch is mapCenter */
+	TreeItem *rootItem;
  
 	int branchOffset;
 	int branchCounter;
diff -r e3f722759c7e -r 340bc29da9a0 treemodel.cpp
--- a/treemodel.cpp	Wed May 20 15:40:14 2009 +0000
+++ b/treemodel.cpp	Tue May 26 11:23:44 2009 +0000
@@ -106,7 +106,7 @@
         return rootItem->columnCount();
 }
 
-BranchItem* TreeModel::next(BranchItem* &current, BranchItem* &previous, int &d0)
+BranchItem* TreeModel::next(BranchItem* &current, BranchItem* &previous, BranchItem* start)
 {
 	// Walk through map beginning at current with previous==0
 	// Start at root, if current==NULL
@@ -115,8 +115,8 @@
 	// Are we just beginning to walk the map?
 	if (!previous)
 	{
+		if (!start) start=current;
 		previous=current;
-		d0=current->depth();
 		current=current->getFirstBranch();
 		return current;
 	}
@@ -138,7 +138,8 @@
 		// turn around and go up again
 	}	
 
-	// Coming from below,
+	// Coming from below
+
 	// Trying to go down again to siblings
 
 	BranchItem *sibling=current->getBranchNum (previous->num()+1);
@@ -151,6 +152,9 @@
 		return current;
 	} 
 
+	// If we only needed to go through subtree, we are done now
+	if (start==current) return NULL;
+
 	// Go up and try to find siblings of current
 	previous=current;
 	current=(BranchItem*)current->parent();
@@ -159,27 +163,11 @@
 	if (!current) return current;
 	
 	while (current && current->depth() < previous->depth() )
-		next (current,previous,d0);
+		current=next (current,previous,start);
 		
 	return current;
 }
 
-/*
-bool TreeModel::insertRows ( int row, int count, const QModelIndex & parent)
-{
-	std::cout << "TreeModel insertRows()\n";
-	int last=row+count-1;
-	beginInsertRows (parent,row,last);
-
-	for (int i=row; i<=last; i++)
-	{
-		std::cout << "TreeModel::insertRows inserting i="<<i<<std::endl;
-	}
-	endInsertRows ();
-	return true;
-}
-*/
-
 bool TreeModel::removeRows ( int row, int count, const QModelIndex & parent)
 {
 	int last=row+count-1;
diff -r e3f722759c7e -r 340bc29da9a0 treemodel.h
--- a/treemodel.h	Wed May 20 15:40:14 2009 +0000
+++ b/treemodel.h	Tue May 26 11:23:44 2009 +0000
@@ -28,12 +28,8 @@
     int rowCount(const QModelIndex &parent = QModelIndex()) const;
     int columnCount(const QModelIndex &parent = QModelIndex()) const;
 
-	BranchItem* next(BranchItem* &current, BranchItem* &previous, int &d0);
+	BranchItem* next(BranchItem* &current, BranchItem* &previous, BranchItem* start=NULL);
 
-/*
-	bool insertRows ( int row, int count, 
-				const QModelIndex & parent = QModelIndex() ); 
-*/				
 	bool removeRows ( int row, int count, 
 				const QModelIndex & parent = QModelIndex() ); 
 
diff -r e3f722759c7e -r 340bc29da9a0 version.h
--- a/version.h	Wed May 20 15:40:14 2009 +0000
+++ b/version.h	Tue May 26 11:23:44 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-05-18"
+#define __VYM_BUILD_DATE "2009-05-26"
 
 
 bool checkVersion(const QString &);
diff -r e3f722759c7e -r 340bc29da9a0 vym.pro
--- a/vym.pro	Wed May 20 15:40:14 2009 +0000
+++ b/vym.pro	Tue May 26 11:23:44 2009 +0000
@@ -64,7 +64,6 @@
 	linkablemapobj.h \
 	mainwindow.h \
 	mapcenterobj.h \
-	mapcenteritem.h \
 	mapeditor.h \
 	mapitem.h \
 	mapobj.h \
@@ -74,7 +73,6 @@
 	ornamentedobj.h \
 	parser.h \
 	process.h \
-	selection.h \
 	showtextdialog.h\
 	simplescripteditor.h\
 	texteditor.h \
@@ -126,7 +124,6 @@
 	linkablemapobj.cpp \
 	main.cpp \
 	mainwindow.cpp \
-	mapcenteritem.cpp \
 	mapcenterobj.cpp \
 	mapeditor.cpp \
 	mapitem.cpp \
@@ -137,7 +134,6 @@
 	ornamentedobj.cpp \
 	parser.cpp \
 	process.cpp \
-	selection.cpp \
 	showtextdialog.cpp \
 	simplescripteditor.cpp \
 	texteditor.cpp \
diff -r e3f722759c7e -r 340bc29da9a0 vymmodel.cpp
--- a/vymmodel.cpp	Wed May 20 15:40:14 2009 +0000
+++ b/vymmodel.cpp	Tue May 26 11:23:44 2009 +0000
@@ -5,7 +5,6 @@
 
 #include "treeitem.h"
 #include "branchitem.h"
-#include "mapcenteritem.h"
 #include "editxlinkdialog.h"
 #include "exports.h"
 #include "exportxhtmldialog.h"
@@ -15,8 +14,6 @@
 #include "mapcenterobj.h"
 #include "misc.h"
 #include "parser.h"
-#include "selection.h"
-
 
 #include "warningdialog.h"
 #include "xml-freemind.h"
@@ -121,6 +118,7 @@
 
 	// selections
 	selModel=NULL;
+	selectionBlocked=false;
 
 	// find routine
 	findCurrent=NULL;				
@@ -245,9 +243,9 @@
 		s+=saveTreeToDir(tmpdir,prefix,writeflags,offset);
 	else
 	{
-		if (saveSel->getType()==TreeItem::Branch)
+		if (saveSel->isBranchLikeType())
 			// Save Subtree
-			s+=saveSel->saveToDir(tmpdir,prefix,offset);
+			s+=((BranchItem*)saveSel)->saveToDir(tmpdir,prefix,offset);
 		//FIXME-2 else if (saveSel->getType()==TreeItem::Image)
 			// Save image
 			//s+=((FloatImageObj*)(saveSel))->saveToDir(tmpdir,prefix);
@@ -272,7 +270,7 @@
     QString s;
 
 	for (int i=0; i<rootItem->branchCount(); i++)
-		s+=((MapCenterItem*)rootItem->getBranchNum(i))->saveToDir (tmpdir,prefix,offset);
+		s+=rootItem->getBranchNum(i)->saveToDir (tmpdir,prefix,offset);
     return s;
 }
 
@@ -465,7 +463,7 @@
 		if ( ok ) 
 		{
 			reposition();	// FIXME-2 VM reposition the view instead...
-			selection.update();
+			updateSelection();
 			if (lmode==NewMap)
 			{
 				mapDefault=false;
@@ -585,7 +583,7 @@
 	makeSubDirs (fileDir);
 
 	QString saveFile;
-	if (savemode==CompleteMap || selection.isEmpty())
+	if (savemode==CompleteMap || selModel->selection().isEmpty())
 	{
 		// Save complete map
 		saveFile=saveToDir (fileDir,mapName+"-",true,QPointF(),NULL);
@@ -770,7 +768,8 @@
 
 void VymModel::saveFloatImage ()
 {
-	FloatImageObj *fio=selection.getFloatImage();
+	//FIXME-1 FloatImageObj *fio=selection.getFloatImage();
+	FloatImageObj *fio=NULL;
 	if (fio)
 	{
 		QFileDialog *fd=new QFileDialog( NULL);
@@ -998,15 +997,15 @@
 	QString s;
 	if (!lmo) return QString("Error: NULL has no name!");
 
-	if ((typeid(*lmo) == typeid(BranchObj) ||
-				      typeid(*lmo) == typeid(MapCenterObj))) 
+	TreeItem *ti=lmo->getTreeItem();
+	if (ti->isBranchLikeType() )
 	{
 		
 		s=lmo->getTreeItem()->getHeading();
 		if (s=="") s="unnamed";
 		return QString("branch (%1)").arg(s);
 	}	
-	if ((typeid(*lmo) == typeid(FloatImageObj) ))
+	if (ti->getType()==TreeItem::Image)
 		return QString ("floatimage [%1]").arg(((FloatImageObj*)lmo)->getOriginalFilename());
 	return QString("Unknown type has no name!");
 }
@@ -1180,8 +1179,7 @@
 
 	mainWindow->updateHistory (undoSet);
 	updateActions();
-	selection.update();
-	emitShowSelection();
+	updateSelection();
 }
 
 bool VymModel::isUndoAvailable()
@@ -1487,12 +1485,11 @@
 	int c=0;
 	BranchItem *cur=NULL;
 	BranchItem *prev=NULL;
-	int d;
-	next(cur,prev,d);
+	next(cur,prev);
 	while (cur) 
 	{
 		c++;
-		next(cur,prev,d);
+		next(cur,prev);
 	}
 	return c;
 }
@@ -1512,14 +1509,12 @@
 		emitDataHasChanged ( selbi);	//FIXME-3 maybe emit signal from TreeItem? 
 
 		reposition();
-//		selection.update();	//FIXME-4
 		updateSelection();
 	}
 }
 
 BranchItem* VymModel::findText (QString s, bool cs)   
 {
-	int d=0;
 	QTextDocument::FindFlags flags=0;
 	if (cs) flags=QTextDocument::FindCaseSensitively;
 
@@ -1530,7 +1525,7 @@
 			EOFind=false;
 		findCurrent=NULL;	
 		findPrevious=NULL;	
-		next (findCurrent,findPrevious,d);
+		next (findCurrent,findPrevious);
 	}	
 	bool searching=true;
 	bool foundNote=false;
@@ -1564,7 +1559,7 @@
 		}	
 		if (!foundNote)
 		{
-			if (!next(findCurrent,findPrevious,d) )
+			if (!next(findCurrent,findPrevious) )
 				EOFind=true;
 		}
 	//cout <<"still searching...  "<<qPrintable( itFind->getHeading())<<endl;
@@ -1621,21 +1616,21 @@
 QStringList VymModel::getURLs()	
 {
 	QStringList urls;
-	BranchItem *cur=getSelectedBranchItem();
+	BranchItem *selbi=getSelectedBranchItem();
+	BranchItem *cur=selbi;
 	BranchItem *prev=NULL;
-	int d=0;
-	next (cur,prev,d);
 	while (cur) 
 	{
 		if (!cur->getURL().isEmpty()) urls.append( cur->getURL());
-		cur=next (cur,prev,d);
+		cur=next (cur,prev,selbi);
 	}	
 	return urls;
 }
 
-void VymModel::linkFloatImageTo(const QString &dstString)	// FIXME-2
-{
-	FloatImageObj *fio=selection.getFloatImage();
+void VymModel::linkFloatImageTo(const QString &dstString)	// FIXME-1
+{
+	//FIXME-1 FloatImageObj *fio=selection.getFloatImage();
+	FloatImageObj *fio=NULL;
 	if (fio)
 	{
 		TreeItem *dst=findBySelectString (dstString);
@@ -1645,7 +1640,7 @@
 			QString parString=getSelectString(dstPar);
 			QString fioPreSelectString=getSelectString(fio);
 			QString fioPreParentSelectString=getSelectString (fio->getParObj());
-			// FIXME-2 ((BranchObj*)dst)->addFloatImage (fio);
+			// FIXME-1 ((BranchObj*)dst)->addFloatImage (fio);
 			unselect();
 			// ((BranchObj*)(fio->getParObj()))->removeFloatImage (fio);
 			fio=((BranchObj*)dst)->getLastFloatImage();
@@ -1834,7 +1829,7 @@
 		);	
 		updateActions();
 		reposition();
-		// selection.update();
+		// updateSelection();
 		// FIXME-3 VM needed? scene()->update();
 	}
 }
@@ -1962,11 +1957,11 @@
 */
 }
 
-MapCenterItem* VymModel::createMapCenter()
-{
-	MapCenterItem *mci=addMapCenter (QPointF (0,0) );
-	select (mci);
-	return mci;
+BranchItem* VymModel::createMapCenter()
+{
+	BranchItem *newbi=addMapCenter (QPointF (0,0) );
+	select (newbi);
+	return newbi;
 }
 
 BranchItem* VymModel::createBranch()	
@@ -1978,8 +1973,9 @@
 		return NULL;
 }
 
-TreeItem* VymModel::createImage()	//FIXME-2
-{
+TreeItem* VymModel::createImage()	//FIXME-1
+{
+	return NULL;
 /*
 	BranchObj *bo=getSelectedBranch();
 	if (bo)
@@ -2002,26 +1998,25 @@
 			return ti;
 		}
 	}
-	return NULL;
 */
 }
 
-MapCenterItem* VymModel::addMapCenter ()
-{
-	MapCenterItem *mci=addMapCenter (contextPos);
+BranchItem* VymModel::addMapCenter ()
+{
+	BranchItem *bi=addMapCenter (contextPos);
 	updateActions();
 	emitShowSelection();
 	saveState (
-		mci,
+		bi,
 		"delete()",
 		NULL,
 		QString ("addMapCenter (%1,%2)").arg (contextPos.x()).arg(contextPos.y()),
 		QString ("Adding MapCenter to (%1,%2)").arg (contextPos.x()).arg(contextPos.y())
 	);	
-	return mci;	
+	return bi;	
 }
 
-MapCenterItem* VymModel::addMapCenter(QPointF absPos)
+BranchItem* VymModel::addMapCenter(QPointF absPos)	//FIXME-2 absPos not used in context menu?!
 {
 
 	// Create TreeItem
@@ -2034,17 +2029,17 @@
 
 	QList<QVariant> cData;
 	cData << "VM:addMapCenter" << "undef"<<"undef";
-	MapCenterItem *mci=new MapCenterItem (cData);
-	mci->setHeading (QApplication::translate("Heading of mapcenter in new map", "New map"));
-	rootItem->appendChild (mci);
+	BranchItem *newbi=new BranchItem (cData);
+	newbi->setHeading (QApplication::translate("Heading of mapcenter in new map", "New map"));
+	rootItem->appendChild (newbi);
 
 	endInsertRows();
 	emit (layoutChanged() );
 
 	// Create MapObj
-	BranchObj *newbo=mci->createMapObj(mapScene);
+	newbi->createMapObj(mapScene);
 		
-	return mci;
+	return newbi;
 }
 
 BranchItem* VymModel::addNewBranchInt(BranchItem *dst,int num)	//FIXME-4 simplify...
@@ -2121,7 +2116,7 @@
 				QString ("Add new branch to %1").arg(getObjectName(selbi)));	
 
 			reposition();
-			// selection.update(); FIXME-3
+			// updateSelection(); FIXME-3
 			latestAddedItem=newbi;
 			// In Network mode, the client needs to know where the new branch is,
 			// so we have to pass on this information via saveState.
@@ -2161,7 +2156,7 @@
 				QString ("Add branch before %1").arg(getObjectName(selbi)));
 
 			// FIXME-3 needed? reposition();
-			// selection.update(); FIXME-3 
+			// updateSelection(); FIXME-3 
 		}
 	}	
 	//FIXME-3 needed? latestSelectionString=selection.getSelectString();
@@ -2172,6 +2167,10 @@
 {
 	if (branch && dst)
 	{
+		if (branch->depth()==0) 
+		{
+			cout <<"VM::relinkBranch  d=0 for "<<branch->getHeadingStd()<<endl;
+		}
 		emit (layoutAboutToBeChanged() );
 		BranchItem *branchpi=(BranchItem*)branch->parent();
 		// Remove at current position
@@ -2191,7 +2190,9 @@
 		dst->insertBranch (pos,branch);
 		endInsertRows();
 
-		branch->getLMO()->setParObj(dst->getLMO());	//FIXME-5 update parObj in View
+		// reset parObj, fonts, frame, etc in related LMO or other view-objects
+		branch->updateStyles();
+
 		emit (layoutChanged() );
 		reposition();	// both for moveUp/Down and relinking
 		select (branch);
@@ -2449,49 +2450,50 @@
 }
 
 
-void VymModel::colorBranch (QColor c)	//FIXME-2
-{
-/*
-	BranchObj *bo=getSelectedBranch();
-	if (bo)
+void VymModel::colorBranch (QColor c)	
+{
+	BranchItem *selbi=getSelectedBranchItem();
+	if (selbi)
 	{
 		saveState(
-			bo, 
-			QString ("colorBranch (\"%1\")").arg(bo->getColor().name()),
-			bo,
+			selbi, 
+			QString ("colorBranch (\"%1\")").arg(selbi->getHeadingColor().name()),
+			selbi,
 			QString ("colorBranch (\"%1\")").arg(c.name()),
-			QString("Set color of %1 to %2").arg(getObjectName(bo)).arg(c.name())
+			QString("Set color of %1 to %2").arg(getObjectName(selbi)).arg(c.name())
 		);	
-		bo->setColor(c); // color branch
+		selbi->setHeadingColor(c); // color branch
 	}
-*/
 }
 
-void VymModel::colorSubtree (QColor c) //FIXME-2
-{
-/*
-	BranchObj *bo=getSelectedBranch();
-	if (bo) 
+void VymModel::colorSubtree (QColor c) 
+{
+	BranchItem *selbi=getSelectedBranchItem();
+	if (selbi)
 	{
 		saveStateChangingPart(
-			bo, 
-			bo,
+			selbi,
+			selbi,
 			QString ("colorSubtree (\"%1\")").arg(c.name()),
-			QString ("Set color of %1 and children to %2").arg(getObjectName(bo)).arg(c.name())
+			QString ("Set color of %1 and children to %2").arg(getObjectName(selbi)).arg(c.name())
 		);	
-		bo->setColorSubtree (c); // color links, color children
+		BranchItem *prev=NULL;
+		BranchItem *cur=selbi;
+		while (cur) 
+		{
+			cur->setHeadingColor(c); // color links, color children
+			cur=next (cur,prev,selbi);
+		}	
+
 	}
-*/	
 }
 
-QColor VymModel::getCurrentHeadingColor()	//FIXME-2
-{
-/*
-	BranchObj *bo=getSelectedBranch();
-	if (bo) return bo->getColor(); 
-	
+QColor VymModel::getCurrentHeadingColor()	
+{
+	BranchItem *selbi=getSelectedBranchItem();
+	if (selbi)	return selbi->getHeadingColor();
+		
 	QMessageBox::warning(0,"Warning","Can't get color of heading,\nthere's no branch selected");
-	*/
 	return Qt::black;
 }
 
@@ -2615,8 +2617,7 @@
 		bi->setVymLink(s);
 		reposition();
 		updateActions();
-		//selection.update();
-		emitShowSelection();
+		//updateSelection();
 	}
 }
 
@@ -2651,14 +2652,13 @@
 QStringList VymModel::getVymLinks()	
 {
 	QStringList links;
-	BranchItem *cur=getSelectedBranchItem();
+	BranchItem *selbi=getSelectedBranchItem();
+	BranchItem *cur=selbi;
 	BranchItem *prev=NULL;
-	int d=0;
-	next (cur,prev,d);
 	while (cur) 
 	{
 		if (!cur->getVymLink().isEmpty()) links.append( cur->getVymLink());
-		cur=next (cur,prev,d);
+		cur=next (cur,prev,selbi);
 	}	
 	return links;
 }
@@ -3027,16 +3027,16 @@
 				LinkableMapObj *dst=findObjBySelect (s);
 				if (dst)
 				{	
-					if (typeid(*dst) == typeid(BranchObj) ) 
+					if (typid(*dst) == typid(BranchObj) ) 
 					{
 						// Get number in parent
 						n=parser.parInt (ok,1);
 						if (ok)
 						{
 							selb->linkTo ((BranchObj*)(dst),n);
-							selection.update();
+							updateSelection();
 						}	
-					} else if (typeid(*dst) == typeid(MapCenterObj) ) 
+					} else if (typid(*dst) == typid(MapCenterObj) ) 
 					{
 						selb->linkTo ((BranchObj*)(dst),-1);
 						// Get coordinates of mainbranch
@@ -3047,7 +3047,7 @@
 							if (ok) 
 							{
 								selbi->move (x,y);
-								selection.update();
+								updateSelection();
 							}
 						}
 					}	
@@ -3062,8 +3062,8 @@
 				LinkableMapObj *dst=findObjBySelect (s);
 				if (dst)
 				{	
-					if (typeid(*dst) == typeid(BranchObj) ||
-						typeid(*dst) == typeid(MapCenterObj)) 
+					if (typid(*dst) == typid(BranchObj) ||
+						typid(*dst) == typid(MapCenterObj)) 
 						linkFloatImageTo (getSelectString(dst));
 				} else	
 					parser.setError (Aborted,"Destination is not a branch");
@@ -3236,7 +3236,8 @@
 	/////////////////////////////////////////////////////////////////////
 	} else if (com=="saveImage")
 	{
-		FloatImageObj *fio=selection.getFloatImage();
+		//FIXME-2 FloatImageObj *fio=selection.getFloatImage();
+		FloatImageObj* fio=NULL;
 		if (!fio)
 		{
 			parser.setError (Aborted,"Type of selection is not an image");
@@ -3879,9 +3880,10 @@
 		rootItem->getBranchObjNum(i)->reposition();	//	for positioning heading
 }
 
+/*
 QPolygonF VymModel::shape(BranchObj *bo)	//FIXME-4
 {
-/*
+	return QPolygonF ();
 	// Creating (arbitrary) shapes
 
 	QPolygonF p;
@@ -3911,9 +3913,10 @@
 			<<rb.bottomLeft()
 			<<QPointF (rb.bottomRight().x(), ra.bottomRight().y() ) ;
 	return p;		
-	*/
 }
-
+*/
+
+/*
 void VymModel::moveAway(LinkableMapObj *lmo)	//FIXME-5
 {
 	// Autolayout:
@@ -3921,7 +3924,6 @@
 	// Move all branches and MapCenters away from lmo 
 	// to avoid collisions 
 
-		/*
 	QPolygonF pA;
 	QPolygonF pB;
 
@@ -3941,8 +3943,8 @@
 			<<r.willIntersect 
 			<<"  minT="<<r.minTranslation<<endl<<endl;
 	}
-			*/
 }
+*/
 
 QPixmap VymModel::getPixmap()
 {
@@ -3953,14 +3955,14 @@
 	pp.setRenderHints(mapEditor->renderHints());
 
 	// Don't print the visualisation of selection
-	selection.unselect();
+	unselect();
 
 	mapScene->render (	&pp, 
 		QRectF(0,0,mapRect.width()+2,mapRect.height()+2),
 		QRectF(mapRect.x(),mapRect.y(),mapRect.width(),mapRect.height() ));
 
 	// Restore selection
-	selection.reselect();
+	reselect();
 	
 	return pix;
 }
@@ -4007,14 +4009,13 @@
 
 	BranchItem *cur=NULL;
 	BranchItem *prev=NULL;
-	int d=0;
 	BranchObj *bo;
-	next (cur,prev,d);
+	next (cur,prev);
 	while (cur) 
 	{
 		bo=(BranchObj*)(cur->getLMO() );
 		bo->setLinkStyle(bo->getDefLinkStyle());
-		cur=next(cur,prev,d);
+		cur=next(cur,prev);
 	}
 	reposition();
 }
@@ -4036,14 +4037,13 @@
 	defLinkColor=col;
 	BranchItem *cur=NULL;
 	BranchItem *prev=NULL;
-	int d=0;
 	BranchObj *bo;
-	cur=next(cur,prev,d);
+	cur=next(cur,prev);
 	while (cur) 
 	{
 		bo=(BranchObj*)(cur->getLMO() );
 		bo->setLinkColor();
-		next(cur,prev,d);
+		next(cur,prev);
 	}
 	updateActions();
 }
@@ -4053,14 +4053,13 @@
 	// called from setMapLinkColorHint(lch) or at end of parse
 	BranchItem *cur=NULL;
 	BranchItem *prev=NULL;
-	int d=0;
 	BranchObj *bo;
-	cur=next(cur,prev,d);
+	cur=next(cur,prev);
 	while (cur) 
 	{
 		bo=(BranchObj*)(cur->getLMO() );
 		bo->setLinkColor();
-		cur=next(cur,prev,d);
+		cur=next(cur,prev);
 	}
 }
 
@@ -4078,14 +4077,13 @@
 		linkcolorhint=LinkableMapObj::HeadingColor;
 	BranchItem *cur=NULL;
 	BranchItem *prev=NULL;
-	int d=0;
 	BranchObj *bo;
-	cur=next(cur,prev,d);
+	cur=next(cur,prev);
 	while (cur) 
 	{
 		bo=(BranchObj*)(cur->getLMO() );
 		bo->setLinkColor();
-		next(cur,prev,d);
+		next(cur,prev);
 	}
 }
 
@@ -4203,7 +4201,7 @@
                 QString("Move %1 to %2").arg(getObjectName(bo)).arg(ps));
             bo->move(x,y);
             reposition();
-            selection.update();
+            updateSelection();
         }
 	}
 */	
@@ -4234,7 +4232,7 @@
             ((OrnamentedObj*)bo)->move2RelPos (x,y);
             reposition();
             bo->updateLink();
-            selection.update();
+            updateSelection();
         }
 	}
 */	
@@ -4294,7 +4292,7 @@
 void VymModel::sendSelection()
 {
 	if (netstate!=Server) return;
-	sendData (QString("select (\"%1\")").arg(selection.getSelectString()) );
+	sendData (QString("select (\"%1\")").arg(getSelectString()) );
 }
 
 void VymModel::newServer()
@@ -4522,15 +4520,12 @@
 
 void VymModel::setSelectionBlocked (bool b)
 {
-	if (b)
-		selection.block();
-	else	
-		selection.unblock();
+	selectionBlocked=b;
 }
 
 bool VymModel::isSelectionBlocked()
 {
-	return selection.isBlocked();
+	return selectionBlocked;
 }
 
 bool VymModel::select ()
@@ -4582,12 +4577,13 @@
 
 void VymModel::unselect()
 {
+	lastSelectString=getSelectString();
 	selModel->clearSelection();
 }	
 
 void VymModel::reselect()
 {
-	selection.reselect();
+	select (lastSelectString);
 }	
 
 void VymModel::emitShowSelection()	
@@ -4614,8 +4610,7 @@
 {
 	if (selection.select(lmo))
 	{
-		//selection.update();
-		sendSelection ();	// FIXME-4 VM use signal
+		//updateSelection();
 	}
 }
 
@@ -4623,8 +4618,7 @@
 {
 	if (selection.select(lmo))
 	{
-		//selection.update();
-		sendSelection ();	// FIXME-4 VM use signal
+		//updateSelection();
 	}
 }
 */
@@ -4747,8 +4741,6 @@
 
 void VymModel::selectUpperBranch()
 {
-	if (selection.isBlocked() ) return;
-
 	BranchItem *bi=getSelectedBranchItem();
 	if (bi && bi->isBranchLikeType())
 		selectAboveBranchInt();
@@ -4756,8 +4748,6 @@
 
 void VymModel::selectLowerBranch()
 {
-	if (selection.isBlocked() ) return;
-
 	BranchItem *bi=getSelectedBranchItem();
 	if (bi && bi->isBranchLikeType())
 		selectBelowBranchInt();
@@ -4766,8 +4756,6 @@
 
 void VymModel::selectLeftBranch()
 {
-	if (selection.isBlocked() ) return;
-
 	QItemSelection oldsel=selModel->selection();
 
 	BranchItem* par;
@@ -4806,8 +4794,6 @@
 
 void VymModel::selectRightBranch()
 {
-	if (selection.isBlocked() ) return;
-
 	QItemSelection oldsel=selModel->selection();
 
 	BranchItem* par;
@@ -4854,9 +4840,7 @@
 		TreeItem *ti2=par->getFirstBranch();
 		if (ti2) {
 			select(ti2);
-			selection.update();
-			emitShowSelection();
-			sendSelection();
+			updateSelection();
 		}
 	}		
 }
@@ -4871,9 +4855,7 @@
 		TreeItem *ti2=par->getLastBranch();
 		if (ti2) {
 			select(ti2);
-			selection.update();
-			emitShowSelection();
-			sendSelection();
+			updateSelection();
 		}
 	}		
 }
@@ -4897,9 +4879,7 @@
 		par=ti->parent();
 		if (!par) return;
 		select(par);
-		selection.update();
-		emitShowSelection();
-		sendSelection();
+		updateSelection();
 	}		
 }
 
@@ -4969,7 +4949,8 @@
 
 FloatImageObj* VymModel::getSelectedFloatImage()
 {
-	return selection.getFloatImage();	
+	//FIXME-2 return selection.getFloatImage();	
+	return NULL;
 }
 
 QString VymModel::getSelectString ()
diff -r e3f722759c7e -r 340bc29da9a0 vymmodel.h
--- a/vymmodel.h	Wed May 20 15:40:14 2009 +0000
+++ b/vymmodel.h	Tue May 26 11:23:44 2009 +0000
@@ -8,12 +8,10 @@
 #include "mapcenterobj.h"
 #include "mapeditor.h"
 #include "parser.h"
-#include "selection.h"
 #include "treeitem.h"
 #include "treemodel.h"
 
 class BranchItem;
-class MapCenterItem;
 class MapEditor;
 
 class VymModel : public TreeModel {		
@@ -282,7 +280,7 @@
 	void sortChildren();	//!< Sort children lexically
 
 	// The create methods are used to quickly parse a XML file
-	MapCenterItem* createMapCenter();	//!< Create and select MapCenter
+	BranchItem* createMapCenter();	//!< Create and select MapCenter // FIXME-3 maybe join this also with createBranch
 	BranchItem* createBranch();			//!< Create and select Branch
 	TreeItem* createImage();			//!< Create and select image
 
@@ -290,9 +288,9 @@
 
 	    Disclaimer: Still experimental, not fully supported yet.
 	*/	
-	MapCenterItem* addMapCenter();
+	BranchItem* addMapCenter();
 private:	
-	MapCenterItem* addMapCenter(QPointF absPos);
+	BranchItem* addMapCenter(QPointF absPos);
 
 	/*! \brief Add new branch
 
@@ -425,8 +423,8 @@
 	void reposition();					//!< Call reposition for all MCOs
 	void setHideTmpMode (TreeItem::HideTmpMode mode);	
 
-	QPolygonF shape(BranchObj *bo);		//!< Returns arbitrary shape of subtree
-	void moveAway (LinkableMapObj *lmo);//!< Autolayout: Move all out of the way
+	//FIXME-5 QPolygonF shape(BranchObj *bo);		//!< Returns arbitrary shape of subtree
+	//FIXME-5 void moveAway (LinkableMapObj *lmo);//!< Autolayout: Move all out of the way
 
 	void emitNoteHasChanged (TreeItem *ti);
 	void emitDataHasChanged (TreeItem *ti);
@@ -539,7 +537,6 @@
 // Selection related 
 ////////////////////////////////////////////
 private:
-	Selection selection;
 	TreeItem *latestAddedItem;				// latest added object, reset on setChanged()
 
 signals:
@@ -607,6 +604,8 @@
 private:	
     void setSelectionColorInt(QColor);
 	QItemSelectionModel *selModel;
+	QString lastSelectString;
+	bool selectionBlocked;		//! Used to block changes of selection while editing a heading
 
 public:	
     void setSelectionColor(QColor);
diff -r e3f722759c7e -r 340bc29da9a0 xml-vym.cpp
--- a/xml-vym.cpp	Wed May 20 15:40:14 2009 +0000
+++ b/xml-vym.cpp	Tue May 26 11:23:44 2009 +0000
@@ -186,8 +186,8 @@
 				(state == StateMapCenter ||state==StateBranch)) 
 	{
 		state=StateFloatImage;
-        //FIXME-2lastBranch->addFloatImage();
-		//FIXME-2lastFloat=lastBranch->getLastFloatImage();
+        //FIXME-2 lastBranch->addFloatImage();
+		//FIXME-2 lastFloat=lastBranch->getLastFloatImage();
 		if (!readFloatImageAttr(atts)) return false;
 	} else if ( (eName == "branch"||eName=="floatimage") && state == StateMap) 
 	{
@@ -591,7 +591,7 @@
 			/* FIXME-2 xLinks
 				xlo->setBegin ((BranchObj*)lmo);
 				lmo=model->findBySelectString (a.value( "endBranch"));
-				if (lmo && typeid (*lmo)==typeid (BranchObj))
+				if (lmo && typid (*lmo)==typid (BranchObj))
 				{
 					xlo->setEnd ((BranchObj*)(lmo));
 					xlo->activate();
@@ -609,11 +609,11 @@
 		if (!a.value( "endID").isEmpty() ) 
 		{
 			LinkableMapObj *lmo=model->findID (a.value( "beginID"));
-			if (lmo && typeid (*lmo)==typeid (BranchObj))
+			if (lmo && typid (*lmo)==typid (BranchObj))
 			{
 				xlo->setBegin ((BranchObj*)lmo);
 				lmo=model->findID (a.value( "endID"));
-				if (lmo && typeid (*lmo)==typeid (BranchObj))
+				if (lmo && typid (*lmo)==typid (BranchObj))
 				{
 					xlo->setEnd ((BranchObj*)(lmo));
 					xlo->activate();