# HG changeset patch
# User insilmaril
# Date 1241030791 0
# Node ID 59614eaf5fbb7ef7220bc4ddc1eb95e036a87e31
# Parent  bf3ea1f1520b053a751a771e11cb1c935b303793
started to save data like positions outside of MapObj & Co

diff -r bf3ea1f1520b -r 59614eaf5fbb branchitem.cpp
--- a/branchitem.cpp	Tue Apr 28 20:53:44 2009 +0000
+++ b/branchitem.cpp	Wed Apr 29 18:46:31 2009 +0000
@@ -13,6 +13,7 @@
 
 	scrolled=false;
 	tmpUnscrolled=false;
+	type=Branch;
 }
 
 BranchItem::~BranchItem()
@@ -44,15 +45,16 @@
 	branchCounter++;
 }
 
-QString BranchItem::saveToDir (const QString &tmpdir,const QString &prefix, const QPointF& offset)
+QString BranchItem::saveToDir (const QString &tmpdir,const QString &prefix, const QPointF& offset) //FIXME-1
 {
+		cout << "BI::saveToDir: "<<getHeadingStd()<<endl;
 	// Cloudy stuff can be hidden during exports
 	if (hidden) return QString();
 
     QString s,a;
 	BranchObj *bo=(BranchObj*)lmo;
 
-	/* FIXME-1
+	/* 
 	// Update of note is usually done while unselecting a branch
 	if (isNoteInEditor) getNoteFromTextEditor();
 	
@@ -114,10 +116,14 @@
 		s+=note.saveToDir();
 	
 	// Save branches
-	TreeItem *ti=getFirstBranch();
-	TreeItem *last=getLastBranch();
-	while (ti && ti!=last) 
-		s+=ti->saveToDir(tmpdir,prefix,offset);
+	int i=0;
+	TreeItem *ti=getBranchNum(i);
+	while (ti)
+	{
+		s+=getBranchNum(i)->saveToDir(tmpdir,prefix,offset);
+		i++;
+		ti=getBranchNum(i);
+	}	
 
 	/*
 	// Save XLinks
@@ -334,10 +340,12 @@
 {
 	// Initialize BranchObj, order of things is important...
     BranchObj* newbo=new BranchObj(scene);
+	lmo=newbo;
     newbo->setParObj(parent()->getLMO() );
 	newbo->setTreeItem (this);
 	newbo->setDefAttr(BranchObj::NewBranch);
 	
+	initLMO();
 
 	if (!getHeading().isEmpty() ) 
 	{
@@ -348,7 +356,6 @@
 		
 	//newbo->updateLink();	//FIXME-3
 
-	lmo=newbo;
 	return newbo;
 }
 
diff -r bf3ea1f1520b -r 59614eaf5fbb branchitem.h
--- a/branchitem.h	Tue Apr 28 20:53:44 2009 +0000
+++ b/branchitem.h	Wed Apr 29 18:46:31 2009 +0000
@@ -19,7 +19,6 @@
 
 	QString saveToDir (const QString &tmpdir,const QString &prefix, const QPointF& offset);
 
-	
 	virtual void updateVisibility();
 
 protected:
@@ -44,8 +43,8 @@
 	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
 
-	BranchObj* getBranchObj();	
-	BranchObj* createMapObj(QGraphicsScene *scene);		//! Create classic object in GraphicsView
+	virtual BranchObj* getBranchObj();	
+	virtual BranchObj* createMapObj(QGraphicsScene *scene);		//! Create classic object in GraphicsView
 };
 
 #endif
diff -r bf3ea1f1520b -r 59614eaf5fbb branchobj.cpp
--- a/branchobj.cpp	Tue Apr 28 20:53:44 2009 +0000
+++ b/branchobj.cpp	Wed Apr 29 18:46:31 2009 +0000
@@ -100,14 +100,6 @@
 {
     OrnamentedObj::copy(other);
 
-/* FIXME-3 not needed
-	for (int i=0; i<other->treeItem->branchCount(); ++i)
-		// Make deep copy of b
-		// Because addBranch again calls copy for the children,
-		// Those will get a deep copy, too
-		addBranch(other->branch.at(i) );	
-*/		
-
 	for (int i=0; i<other->floatimage.size(); ++i)
 		addFloatImage  (other->floatimage.at(i));
 	
@@ -682,92 +674,11 @@
 	heading->setFont(font );
 
 	if (mod==NewBranch)
-		setColor (((BranchObj*)(parObj))->getColor());
-	
+		setColor (treeItem->getHeadingColor() );
 	calcBBoxSize();
 }
 
-BranchObj* BranchObj::addBranch()	// FIXME-3 still needed?
-{
-    BranchObj* newbo=new BranchObj(scene,this);
-    newbo->setParObj(this);
-	newbo->setDefAttr(NewBranch);
-	/* FIXME-2 treeItem not set yet!!!
-	if ( ((BranchItem*)treeItem)->isScrolled() )
-		newbo->setVisibility (false);
-	else	
-		newbo->setVisibility(visible);
-	*/	
-	newbo->updateLink();	
-	requestReposition();
-	return newbo;
-}
-
-BranchObj* BranchObj::addBranch(BranchObj* bo)
-{
-    BranchObj* newbo=new BranchObj(scene,this);
-    //FIXME-1 branch.append (newbo);
-    newbo->copy(bo);
-    newbo->setParObj(this);
-	newbo->setDefAttr(MovedBranch);
-	if ( ((BranchItem*)treeItem)->isScrolled() )
-		newbo->setVisibility (false);
-	else	
-		newbo->setVisibility(bo->visible);
-	newbo->updateLink();	
-	requestReposition();
-	return newbo;
-}
-
-BranchObj* BranchObj::addBranchPtr(BranchObj* bo)
-{
-	//FIXME-1 branch.append (bo);
-	bo->setParObj (this);
-	//FIXME-2 bo->depth=depth+1;
-	bo->setDefAttr(MovedBranch);
-	BranchItem *bi=(BranchItem*)treeItem;
-	if ( bi->isScrolled() ) bi->tmpUnscroll();
-	//setLastSelectedBranch (bo);	//FIXME-3 needed?
-	return bo;
-}
-
-BranchObj* BranchObj::insertBranch(int pos)
-{
-	savePosInAngle();
-	// Add new bo and resort branches
-	BranchObj *newbo=addBranch ();
-	newbo->angle=pos-0.5;
-	//FIXME-1 qSort (branch.begin(),branch.end(), isAbove);
-	return newbo;
-}
-
-BranchObj* BranchObj::insertBranch(BranchObj* bo, int pos)
-{
-	savePosInAngle();
-	// Add new bo and resort branches
-	bo->angle=pos-0.5;
-	BranchObj *newbo=addBranch (bo);
-	//FIXME-1 qSort (branch.begin(),branch.end(), isAbove);
-	return newbo;
-}
-
-BranchObj* BranchObj::insertBranchPtr (BranchObj* bo, int pos)
-{
-	savePosInAngle();
-	// Add new bo and resort branches
-	bo->angle=pos-0.5;
-	//FIXME-4 branch.append (bo);
-	bo->setParObj (this);
-	//FIXME-2 bo->depth=depth+1;
-	bo->setDefAttr (MovedBranch);
-	BranchItem *bi=(BranchItem*)treeItem;
-	if ( bi->isScrolled() ) bi->tmpUnscroll();
-	//setLastSelectedBranch (bo); //FIXME-3 needed?
-	//FIXME-2 qSort (branch.begin(),branch.end(), isAbove);
-	return bo;
-}
-
-void BranchObj::removeBranchHere(BranchObj* borem)	// FIXME-1 getNum no longer available
+void BranchObj::removeBranchHere(BranchObj* borem)	// FIXME-2 getNum no longer available
 {
 /*
 	// This removes the branch bo from list, but 
@@ -789,7 +700,7 @@
 	clear();
 }
 
-void BranchObj::removeBranch(BranchObj* bo)	// FIXME-1 not needed here
+void BranchObj::removeBranch(BranchObj* bo)	// FIXME-2 not needed here
 {
 /*
     // if bo is not in branch remove returns false, we
@@ -806,7 +717,7 @@
 	*/
 }
 
-void BranchObj::removeBranchPtr(BranchObj* bo)	// FIXME-1 not needed here
+void BranchObj::removeBranchPtr(BranchObj* bo)	// FIXME-3 not needed here
 {
 /*
 	int i=branch.indexOf(bo);
@@ -819,9 +730,9 @@
 */	
 }
 
-bool BranchObj::canMoveBranchUp() 
+bool BranchObj::canMoveBranchUp() // FIXME-1 move to BranchItem
 {
-	/* FIXME-1 move to BranchItem
+/*
 	if (!parObj || depth==1) return false;
 	BranchObj* par=(BranchObj*)parObj;
 	if (this==par->getTreeItem()->getFirstBranch())
@@ -848,9 +759,9 @@
 		return NULL;
 }
 
-bool BranchObj::canMoveBranchDown() 
+bool BranchObj::canMoveBranchDown() //FIXME-1 move to BranchItem
 {
-	/* FIXME-1 move to BranchItem
+	/* 
 	if (!parObj|| depth==1) return false;
 	BranchObj* par=(BranchObj*)parObj;
 	if (this==par->getTreeItem()->getLastBranch())
@@ -879,7 +790,7 @@
 		return NULL;
 }
 
-void BranchObj::sortChildren() //FIXME-1  
+void BranchObj::sortChildren() //FIXME-2  
 {
 /*
 	int childCount=branch.count(); 
@@ -901,42 +812,6 @@
 */
 }
 
-
-BranchObj* BranchObj::linkTo (BranchObj* dst, int pos)
-{
-	// Find current parent and 
-	// remove pointer to myself there
-	if (!dst) return NULL;
-	BranchObj *par=(BranchObj*)parObj;
-	if (par)
-		par->removeBranchPtr (this);
-	else
-		return NULL;
-
-/* FIXME-1
-	// Create new pointer to myself at dst
-	if (pos<0||dst->getDepth()==0)
-	{	
-		// links myself as last branch at dst
-		dst->addBranchPtr (this);
-		updateLink();
-		return this;
-	} else
-	{
-		// inserts me at pos in parent of dst
-		if (par)
-		{
-			BranchObj *bo=dst->insertBranchPtr (this,pos);
-			bo->setDefAttr(MovedBranch);
-			updateLink();
-			return bo;
-
-		} else
-			return NULL;
-	}	
-*/	
-}
-
 void BranchObj::alignRelativeTo (QPointF ref,bool alignSelf)
 {
 	qreal th = bboxTotal.height();	
diff -r bf3ea1f1520b -r 59614eaf5fbb branchobj.h
--- a/branchobj.h	Tue Apr 28 20:53:44 2009 +0000
+++ b/branchobj.h	Wed Apr 29 18:46:31 2009 +0000
@@ -73,13 +73,8 @@
 	virtual void savePosInAngle();					// write pos in angle for resorting			
 public:	
 	virtual void setDefAttr (BranchModification);	// set default attributes (font, size, ...)
-    virtual BranchObj* addBranch();
-    virtual BranchObj* addBranch(BranchObj*);		// makes deep copy of BranchObj
-    virtual BranchObj* addBranchPtr(BranchObj*);	// just adds pointer
-    virtual BranchObj* insertBranch(int);
-    virtual BranchObj* insertBranch(BranchObj*,int);
-    virtual BranchObj* insertBranchPtr (BranchObj*,int);
-    virtual void removeBranchHere(BranchObj*);  
+
+    virtual void removeBranchHere(BranchObj*);  //FIXME-3
     virtual void removeChildren();  
     virtual void removeBranch(BranchObj*);  
     virtual void removeBranchPtr (BranchObj*);  
@@ -90,7 +85,6 @@
     virtual BranchObj* moveBranchDown(BranchObj*);
 
     virtual void sortChildren();
-    virtual BranchObj* linkTo (BranchObj*, int);
     virtual void alignRelativeTo(const QPointF, bool alignSelf=false );
 	virtual void reposition();
 	virtual void unsetAllRepositionRequests();
diff -r bf3ea1f1520b -r 59614eaf5fbb linkablemapobj.cpp
--- a/linkablemapobj.cpp	Tue Apr 28 20:53:44 2009 +0000
+++ b/linkablemapobj.cpp	Wed Apr 29 18:46:31 2009 +0000
@@ -140,7 +140,7 @@
 void LinkableMapObj::setParObj(LinkableMapObj* o)
 {
     parObj=o;
-	model=parObj->getModel();	
+	if (parObj) model=parObj->getModel();
 }
 
 void LinkableMapObj::setParObjTmp(LinkableMapObj*,QPointF,int)	// FIXME-3 make pure virtual
diff -r bf3ea1f1520b -r 59614eaf5fbb mapcenteritem.cpp
--- a/mapcenteritem.cpp	Tue Apr 28 20:53:44 2009 +0000
+++ b/mapcenteritem.cpp	Wed Apr 29 18:46:31 2009 +0000
@@ -6,8 +6,7 @@
 
 MapCenterItem::MapCenterItem(const QList<QVariant> &data, TreeItem *parent):BranchItem (data,parent)
 {
-	scrolled=false;
-	tmpUnscrolled=false;
+	type=MapCenter;
 }
 
 MapCenterItem::~MapCenterItem()
@@ -16,15 +15,17 @@
     qDeleteAll(childItems);
 }
 
-QString MapCenterItem::saveToDir (const QString &tmpdir,const QString &prefix, const QPointF& offset)
+QString MapCenterItem::saveToDir (const QString &tmpdir,const QString &prefix, const QPointF& offset)	//FIXME-1
 {
+	cout << "MCI::saveToDir: "<<getHeadingStd()<<endl;
+
 	// Cloudy stuff can be hidden during exports
 	if (hidden) return QString();
 
     QString s,a;
 	BranchObj *bo=(BranchObj*)lmo;
 
-	/* FIXME-1
+	/* 
 	// Update of note is usually done while unselecting a branch
 	if (isNoteInEditor) getNoteFromTextEditor();
 	
@@ -55,7 +56,7 @@
 		idAttr="";
 
 	*/
-    s=beginElement ("branch" 
+    s=beginElement ("mapcenter" 
 	//	+getOrnXMLAttr() 
 	//	+scrolledAttr 
 	//	+areaAttr 
@@ -86,10 +87,15 @@
 		s+=note.saveToDir();
 	
 	// Save branches
-	TreeItem *ti=getFirstBranch();
-	TreeItem *last=getLastBranch();
-	while (ti && ti!=last) 
-		s+=ti->saveToDir(tmpdir,prefix,offset);
+	int i=0;
+	TreeItem *ti=getBranchNum(i);
+	while (ti)
+	{
+		s+=getBranchNum(i)->saveToDir(tmpdir,prefix,offset);
+		i++;
+		ti=getBranchNum(i);
+	}	
+
 
 	/*
 	// Save XLinks
@@ -110,9 +116,32 @@
 	*/
 
     decIndent();
-    s+=endElement   ("branch");
+    s+=endElement   ("mapcenter");
     return s;
 }
 
+BranchObj* MapCenterItem::createMapObj(QGraphicsScene *scene)	
+{
+	cout <<"MCI  parent->model="<<parent()->getModel()<<endl;
+	// 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->updateHeading();
+		mco->setColor (headingColor);
+	}	
+		
+	//mco->updateLink();	//FIXME-3
+
+	return mco;
+}
+
+
diff -r bf3ea1f1520b -r 59614eaf5fbb mapcenteritem.h
--- a/mapcenteritem.h	Tue Apr 28 20:53:44 2009 +0000
+++ b/mapcenteritem.h	Wed Apr 29 18:46:31 2009 +0000
@@ -11,6 +11,7 @@
     virtual ~MapCenterItem();
 
 	QString saveToDir (const QString &tmpdir,const QString &prefix, const QPointF& offset);
+	virtual BranchObj* createMapObj (QGraphicsScene *scene);
 };
 
 #endif
diff -r bf3ea1f1520b -r 59614eaf5fbb mapcenterobj.cpp
--- a/mapcenterobj.cpp	Tue Apr 28 20:53:44 2009 +0000
+++ b/mapcenterobj.cpp	Wed Apr 29 18:46:31 2009 +0000
@@ -45,7 +45,7 @@
 	// TODO this should be done in TextObj later...
 	//QFont font ("Sans Serif,16,-1,5,50,0,0,0,0,0");		
 	//heading->setFont(font);
-	setDefAttr(MovedBranch);
+	//FIXME-2 no treeitem yet:  setDefAttr(MovedBranch);
 
 	frame->setFrameType (FrameObj::Rectangle);
 }
@@ -108,29 +108,6 @@
 	if (repositionRequest) reposition();
 }
 
-LinkableMapObj* MapCenterObj::findMapObj(QPointF p, LinkableMapObj *excludeLMO)
-	{
-	/* FIXME-1 should not be necessary
-	LinkableMapObj *lmo;
-
-	// Search through child branches
-	for (int i=0; i<treeItem->branchCount(); ++i)
-	{	
-		lmo = treeItem->getBranchObjNum(i)->findMapObj(p, excludeLMO);
-		if (lmo!= NULL) return lmo;
-	}
-	// is p in MapCenter?
-	if (inBox (p,clickBox) && (this != excludeLMO) ) return this;
-
-	// Search float images
-	for (int i=0; i<floatimage.size(); ++i)
-		if (inBox(p,floatimage.at(i)->getClickBox()) && (floatimage.at(i) != excludeLMO) && floatimage.at(i)->getParObj()!= excludeLMO) return floatimage.at(i);
-
-	// nothing found
-	*/
-	return NULL;
-}
-
 QString MapCenterObj::saveToDir (const QString &tmpdir,const QString &prefix, int verbose, const QPointF &offset)
 {
     QString s,a;
diff -r bf3ea1f1520b -r 59614eaf5fbb mapcenterobj.h
--- a/mapcenterobj.h	Tue Apr 28 20:53:44 2009 +0000
+++ b/mapcenterobj.h	Wed Apr 29 18:46:31 2009 +0000
@@ -27,7 +27,6 @@
     virtual void moveAllBy (double,double);
     virtual void updateLink();
     virtual void updateRelPositions();
-    LinkableMapObj* findMapObj(QPointF,LinkableMapObj*);	// find MapObj 
 	virtual QString saveToDir (const QString&,const QString&,int, const QPointF&);// Save data recursivly to tempdir
 	void setVersion(const  QString &);
 	void setAuthor  (const QString &);
diff -r bf3ea1f1520b -r 59614eaf5fbb mapeditor.cpp
--- a/mapeditor.cpp	Tue Apr 28 20:53:44 2009 +0000
+++ b/mapeditor.cpp	Wed Apr 29 18:46:31 2009 +0000
@@ -798,7 +798,6 @@
 {
     QPointF p = mapToScene(e->pos());
 	TreeItem *seli=model->getSelectedItem();
-	LinkableMapObj *lmosel=seli->getLMO();	// FIXME-2 get rid of lmosel
 
 	TreeItem *dsti=findMapItem(p, seli);
 	LinkableMapObj* dst=NULL;
@@ -811,7 +810,7 @@
 		pickingColor=false;
 		setCursor (Qt::ArrowCursor);
 		// Check if we are over another branch
-		if (dsti && lmosel) 
+		if (dsti && seli) 
 		{	
 			if (e->state() & Qt::ShiftModifier)
 				model->colorBranch (((BranchObj*)dst)->getColor());
@@ -826,7 +825,7 @@
 	{
 		drawingLink=false;
 		// Check if we are over another branch
-		if (dsti && lmosel && dsti->isBranchLikeType() ) 
+		if (dsti && seli && dsti->isBranchLikeType() ) 
 		{	
 			tmpXLink->setEnd ( ((BranchObj*)(dst)) );
 			tmpXLink->updateXLink();
@@ -893,7 +892,9 @@
 	
 		if (seli->getType() == TreeItem::Branch )
 		{	// A branch was moved
-			
+			LinkableMapObj* lmosel=NULL;		//FIXME-2 get rid of lmosel
+			lmosel=seli->getLMO();
+				
 			// save the position in case we link to mapcenter
 			QPointF savePos=QPointF (lmosel->getAbsPos()  );
 
@@ -918,19 +919,16 @@
 				if (e->state() & Qt::ShiftModifier && dst->getParObj())
 				{	// Link above dst
 					preDstParStr=model->getSelectString (dst->getParObj());
-					bsel->linkTo ( (BranchObj*)(bdst->getParObj()), seli->num());	//FIXME-2 not needed
 					model->relinkBranch ((BranchItem*)seli,(BranchItem*)dsti->parent(),((BranchItem*)dsti)->num());
 				} else 
 				if (e->state() & Qt::ControlModifier && dst->getParObj())
 				{
 					// Link below dst
 					preDstParStr=model->getSelectString (dst->getParObj());
-					bsel->linkTo ( (BranchObj*)(bdst->getParObj()), seli->num()+1);//FIXME-2 not needed
 					model->relinkBranch ((BranchItem*)seli,(BranchItem*)dsti->parent(),((BranchItem*)seli)->num()+1);
 				} else	
 				{	// Append to dst
 					preDstParStr=model->getSelectString(dst);
-					bsel->linkTo (bdst,-1);//FIXME-2 not needed
 					model->relinkBranch ((BranchItem*)seli,(BranchItem*)dsti);
 					if (dsti->depth()==0) bsel->move (savePos);
 				} 
diff -r bf3ea1f1520b -r 59614eaf5fbb mapitem.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mapitem.cpp	Wed Apr 29 18:46:31 2009 +0000
@@ -0,0 +1,58 @@
+#include "mapitem.h"
+
+#include "linkablemapobj.h"
+#include "ornamentedobj.h"
+
+#include <iostream>
+using namespace std;
+
+MapItem::MapItem()
+{
+	lmo=NULL;
+	posMode=Unused;
+}
+
+void MapItem::setRelPos (const QPointF &p)
+{
+	posMode=Relative;
+	pos=p;
+	if (lmo)
+	{
+		((OrnamentedObj*)lmo)->setUseRelPos (true);
+		((OrnamentedObj*)lmo)->move2RelPos(p);
+	}
+}
+
+void MapItem::setAbsPos (const QPointF &p)
+{
+	posMode=Absolute;
+	pos=p;
+	if (lmo) lmo->move (p);
+}
+
+LinkableMapObj* MapItem::getLMO()
+{
+	return lmo;
+}
+
+void MapItem::setLMO(LinkableMapObj *l)
+{
+	lmo=l;
+}
+
+void MapItem::initLMO()
+{
+	if (!lmo) return;
+	switch (posMode)
+	{
+		case Relative:	
+			lmo->setRelPos (pos);
+			break;
+		case Absolute:	
+			lmo->move (pos);
+			break;
+		default:
+			break;
+	}
+}
+
diff -r bf3ea1f1520b -r 59614eaf5fbb mapitem.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mapitem.h	Wed Apr 29 18:46:31 2009 +0000
@@ -0,0 +1,45 @@
+#ifndef MAPITEM_H
+#define MAPITEM_H
+
+#include <QPointF>
+
+class LinkableMapObj;
+
+/*! /brief MapItem is used to store information of MapObj and inherited
+   classes.
+ 
+	This is done even while no QGraphicsView is availabe, e.g. on a
+	mobile device.
+*/
+
+class MapItem
+{
+protected:
+	enum PositionMode {Unused,Absolute,Relative};
+	QPointF pos;
+	PositionMode posMode;
+
+public:
+	MapItem();
+
+	/*! Used to save relative position while map is not in QGraphicsView */
+	virtual void setRelPos(const QPointF&);	
+
+	/*! Used to save absolute position while map is not in QGraphicsView */
+	virtual void setAbsPos(const QPointF&);	
+
+protected:
+	LinkableMapObj *lmo;
+public:
+	/*! Returns pointer to related LinkableMapObj in QGraphicsView */
+	virtual LinkableMapObj* getLMO();
+
+	/*! Set pointer to related LinkableMapObj in QGraphicsView */
+	virtual void setLMO (LinkableMapObj*);
+
+	/*! Initialize LinkableMapObj with data in MapItem */
+	virtual void initLMO();
+};
+
+
+#endif
diff -r bf3ea1f1520b -r 59614eaf5fbb noteobj.cpp
--- a/noteobj.cpp	Tue Apr 28 20:53:44 2009 +0000
+++ b/noteobj.cpp	Wed Apr 29 18:46:31 2009 +0000
@@ -95,7 +95,7 @@
 	r.replace (rx,indent);
 	r=indent + r;	// Don't forget first line
 
-/* FIXME-2	wrap text at width
+/* FIXME-5	wrap text at width
 	if (fonthint !="fixed")
 	{
 	}
diff -r bf3ea1f1520b -r 59614eaf5fbb ornamentedobj.h
--- a/ornamentedobj.h	Tue Apr 28 20:53:44 2009 +0000
+++ b/ornamentedobj.h	Wed Apr 29 18:46:31 2009 +0000
@@ -72,7 +72,7 @@
 	virtual void updateSystemFlags();
 	virtual void updateFlagsToolbar();
 
-	//virtual void getNoteFromTextEditor ();// FIXME should move to vymview?!
+	//virtual void getNoteFromTextEditor ();// FIXME-3 should move to vymview?!
 	virtual QString getOrnXMLAttr();		// get attributes for saveToDir
 
 protected:
@@ -82,7 +82,7 @@
 	FrameObj *frame;				// frame around object
 	QRectF ornamentsBBox;			// bbox of flags and heading
 	QString url;					// url to external doc
-	QString vymLink;				// path to another map  // FIXME-1 remove this
+	QString vymLink;				// path to another map  // FIXME-3 remove this
 	QList <Attribute> attributes;	// List with attributes
 };
 
diff -r bf3ea1f1520b -r 59614eaf5fbb treeitem.cpp
--- a/treeitem.cpp	Tue Apr 28 20:53:44 2009 +0000
+++ b/treeitem.cpp	Wed Apr 29 18:46:31 2009 +0000
@@ -5,12 +5,13 @@
 
 #include "branchobj.h"
 #include "branchitem.h"
+#include "mapcenteritem.h"
 #include "vymmodel.h"
 
 using namespace std;
 
 
-TreeItem::TreeItem(const QList<QVariant> &data, TreeItem *parent)
+TreeItem::TreeItem(const QList<QVariant> &data, TreeItem *parent):MapItem()
 {
 	init();
     parentItem = parent;
@@ -46,7 +47,6 @@
 
     parentItem = NULL;
     itemData.clear();
-	lmo=NULL;	
 
 	branchOffset=0;
 	branchCounter=0;
@@ -60,8 +60,6 @@
 
 	// Reset ID
 	objID="";
-
-
 }
 
 QString TreeItem::saveToDir (const QString &tmpdir,const QString &prefix, const QPointF& offset)
@@ -377,41 +375,6 @@
 		parentItem->lastSelectedBranchNum=parentItem->childItems.indexOf(this);
 }
 
-TreeItem* TreeItem::findBySelectString (const QString &s)  //FIXME-1
-{
-/*
-	LinkableMapObj *lmo=this;
-	QString part;
-	QString typ;
-	QString num;
-	while (!s.isEmpty() )
-	{
-		part=s.section(",",0,0);
-		typ=part.left (3);
-		num=part.right(part.length() - 3);
-		if (typ=="mc:")
-		{
-			if (depth>0)
-				return false;	// in a subtree there is no center
-			else
-				break;
-		} else
-			if (typ=="bo:")
-				lmo=lmo->getTreeItem()->getBranchObjNum (num.toInt());
-			else
-				if (typ=="fi:")
-					lmo=((BranchObj*)lmo)->getFloatImageNum (num.toUInt());
-		if (!lmo) break;
-		
-		if (s.contains(","))
-			s=s.right(s.length() - part.length() -1 );
-		else	
-			break;
-	}
-	*/
-	return NULL;
-}
-
 void TreeItem::setLastSelectedBranch(int i)
 {
 		lastSelectedBranchNum=i;
@@ -510,13 +473,4 @@
 }	
 
 
-LinkableMapObj* TreeItem::getLMO()	// FIXME-3  VM should be unnecessary in the end
-{
-	return lmo;
-}
 
-void TreeItem::setLMO(LinkableMapObj *l)
-{
-	lmo=l;
-}
-
diff -r bf3ea1f1520b -r 59614eaf5fbb treeitem.h
--- a/treeitem.h	Tue Apr 28 20:53:44 2009 +0000
+++ b/treeitem.h	Wed Apr 29 18:46:31 2009 +0000
@@ -5,17 +5,16 @@
 #include <QList>
 #include <QVariant>
 
+#include "mapitem.h"
 #include "noteobj.h"
 #include "xmlobj.h"
 
 class LinkableMapObj;
 class BranchObj;
 class BranchItem;
-
-
 class VymModel;
 
-class TreeItem:public XMLObj
+class TreeItem:public XMLObj, public MapItem
 {
 public:
 	enum Type {Undefined,MapCenter,Branch,Image};
@@ -77,7 +76,6 @@
     virtual QString getNoteASCII();			// returns note	(ASCII)
     virtual QString getNoteOpenDoc();		// returns note	(OpenDoc)
 
-
 protected:
 	Type type;
 public:	
@@ -101,7 +99,6 @@
 	virtual void setLastSelectedBranch();		//! Set myself as last selected in parent
 	virtual void setLastSelectedBranch(int i);	//! Set last selected branch directly
 	virtual TreeItem* getLastSelectedBranch();
-	virtual TreeItem* findBySelectString (const QString &);	
 
 	virtual void setHideTmp (HideTmpMode);
 	virtual bool hasHiddenExportParent ();
@@ -110,10 +107,6 @@
 	virtual bool isHidden ();		
 
 	
-	// Relation to map objects in graphicsscene	// FIXME-4 should be obsolete
-	virtual LinkableMapObj* getLMO();
-	virtual void setLMO (LinkableMapObj*);
-
 protected:
 	VymModel *model;
 
@@ -121,8 +114,6 @@
     QList<QVariant> itemData;
     TreeItem *parentItem;
  
-	LinkableMapObj *lmo;
-
 	int branchOffset;
 	int branchCounter;
 	int lastSelectedBranchNum;
diff -r bf3ea1f1520b -r 59614eaf5fbb treemodel.cpp
--- a/treemodel.cpp	Tue Apr 28 20:53:44 2009 +0000
+++ b/treemodel.cpp	Wed Apr 29 18:46:31 2009 +0000
@@ -183,7 +183,6 @@
 	int last=row+count-1;
     TreeItem *pi= getItem (parent);
 	TreeItem *ti;
-	beginRemoveRows (parent,row,last);
 
 	for (int i=row; i<=last; i++)
 	{
@@ -202,7 +201,6 @@
 				break;
 		}
 	}
-	endRemoveRows ();
 	return true;
 }
 
diff -r bf3ea1f1520b -r 59614eaf5fbb vym.pro
--- a/vym.pro	Tue Apr 28 20:53:44 2009 +0000
+++ b/vym.pro	Wed Apr 29 18:46:31 2009 +0000
@@ -58,6 +58,7 @@
 	mapcenterobj.h \
 	mapcenteritem.h \
 	mapeditor.h \
+	mapitem.h \
 	mapobj.h \
 	misc.h \
 	noteobj.h \
@@ -117,6 +118,7 @@
 	mapcenteritem.cpp \
 	mapcenterobj.cpp \
 	mapeditor.cpp \
+	mapitem.cpp \
 	mapobj.cpp \
 	misc.cpp \
 	noteobj.cpp \
diff -r bf3ea1f1520b -r 59614eaf5fbb vymmodel.cpp
--- a/vymmodel.cpp	Tue Apr 28 20:53:44 2009 +0000
+++ b/vymmodel.cpp	Wed Apr 29 18:46:31 2009 +0000
@@ -240,6 +240,7 @@
 	// TODO constr. of FIO creates lots of objects, better do this in some other way...
 	FloatImageObj (mapScene).resetSaveCounter();// FIXME-2 this can be done local to vymmodel maybe...
 
+	cout << "VM::saveToDir 0 " <<saveSel<<endl;
 	// Build xml recursivly
 	if (!saveSel || saveSel->getType()==TreeItem::MapCenter)
 		// Save all mapcenters as complete map, if saveSel not set
@@ -254,9 +255,11 @@
 			//s+=((FloatImageObj*)(saveSel))->saveToDir(tmpdir,prefix);
 	}
 
+	cout << "VM::saveToDir 1 \n";
 	// Save local settings
 	s+=settings.getDataXML (destPath);
 
+	cout << "VM::saveToDir 2 \n";
 	// Save selection
 	if (getSelectedItem() && !saveSel ) 
 		s+=xml.valueElement("select",getSelectString());
@@ -1232,7 +1235,7 @@
 
 	if (blockSaveState) return;
 
-	if (debug) cout << "ME::saveState() for  "<<qPrintable (mapName)<<endl;
+	if (debug) cout << "VM::saveState() for  "<<qPrintable (mapName)<<endl;
 	
 	// Find out current undo directory
 	if (undosAvail<stepsTotal) undosAvail++;
@@ -1263,6 +1266,7 @@
 		undoCommand.replace ("PATH",bakMapPath);
 	}
 
+
 	if (!backupXML.isEmpty())
 		// Write XML Data to disk
 		saveStringToDisk (bakMapPath,backupXML);
@@ -1329,7 +1333,7 @@
 		undoSel);
 }
 
-void VymModel::saveStateRemovingPart(TreeItem*redoSel, const QString &comment)
+void VymModel::saveStateRemovingPart(TreeItem* redoSel, const QString &comment)
 {
 	if (!redoSel)
 	{
@@ -1397,8 +1401,9 @@
 	return mapScene;
 }
 
-TreeItem* VymModel::findBySelectString(const QString &s)
-{
+TreeItem* VymModel::findBySelectString(const QString &s)	//FIXME-0
+{
+	return NULL;
 	if (!s.isEmpty() )
 	{
 		QString part;
@@ -1414,7 +1419,7 @@
 	TreeItem *ti;
 	for (int i=0; i<rootItem->branchCount(); i++)
 	{
-		ti=rootItem->getBranchNum(i)->findBySelectString(s);
+		// ti=rootItem->getBranchNum(i)->findBySelectString(s);
 		if (ti) return ti;
 	}	
 	return NULL;
@@ -2066,8 +2071,7 @@
 
 	QList<QVariant> cData;
 	cData << "VM:addMapCenter" << "undef"<<"undef";
-	MapCenterItem *mci=new MapCenterItem (cData,rootItem);
-	mci->setType (TreeItem::MapCenter);
+	MapCenterItem *mci=new MapCenterItem (cData);
 	mci->setHeading (QApplication::translate("Heading of mapcenter in new map", "New map"));
 	rootItem->appendChild (mci);
 
@@ -2076,7 +2080,20 @@
 	emit (layoutChanged() );
 
 	// Create MapObj
-	MapCenterObj *mapCenter = new MapCenterObj(mapScene,this);
+	BranchObj *newbo=mci->createMapObj(mapScene);
+		
+	/*
+
+	if (!mci->getHeading().isEmpty() ) 
+	{
+		newbo->updateHeading();
+		newbo->setColor (headingColor);
+	}	
+*/
+		
+	//newbo->updateLink();	//FIXME-3
+
+/*
 	//mapCenter->setMapEditor(mapEditor);		//FIXME-3 VM needed to get defLinkStyle, mapLinkColorHint ... for later added objects
 	mapCenter->setTreeItem (mci);	// TreeItem needs to exist before setVisibility
 	mci->setLMO (mapCenter);
@@ -2084,39 +2101,10 @@
 	mapCenter->move (absPos);
     mapCenter->setVisibility (true);
 	//mapCenter->setHeading (QApplication::translate("Heading of mapcenter in new map", "New map"));
-	// Testing
-/*
-	qWarning ("MW::insertRow a");
-    if (!insertRow(0, parix))
-	{
-		std::cout << "  war nix...\n";
-	}	
-	qWarning ("MW::insertRow b");
 */
-
 	return mci;
 }
 
-MapCenterItem* VymModel::removeMapCenter(MapCenterItem* mci) //FIXME-2
-{
-/*
-	int i=mapCenters.indexOf (mco);
-	if (i>=0)
-	{
-		mapCenters.removeAt (i);
-		delete (mco);
-		if (i>0) return rootItem->getBranchNum(i-1);	// Return previous MCO
-	}
-*/	
-	return NULL;
-}
-
-MapCenterObj* VymModel::getLastMapCenter()		// FIXME-3 still needed?
-{
-	return (MapCenterObj*)rootItem->getLastBranch();
-}
-
-
 BranchItem* VymModel::addNewBranchInt(int num)
 {
 	// Depending on pos:
@@ -2142,7 +2130,6 @@
 			emit (layoutAboutToBeChanged() );
 			beginInsertRows (parix,n,n+1);	//FIXME-1 check if n is correct: should be index below _last_ branch...
 			bi=new BranchItem (cData);	
-			bi->setType (TreeItem::Branch);
 			bi->setHeading (QApplication::translate("Heading of new branch in map", "new"));
 
 			parbi->appendChild (bi);	
@@ -2286,60 +2273,21 @@
 
 	if (!selbi) return;
 
-	QModelIndex ix=index (selbi);
-	if (!ix.isValid() ) return;
-
-	QModelIndex parentIndex=parent(ix);
-/*
-	if (!parentIndex.isValid()) 
-	{
-	cout << "VM::delete no valid parent ix\n";
-	return;
-	}
-*/	
+	TreeItem *pi=selbi->parent();
+	QModelIndex parentIndex=index(pi);
 	
-	/*
-	if (selbi->getType()==TreeItem::MapCenter)	
-	{
-	//	BranchObj* par=(BranchObj*)(bo->getParObj());
-		//selection.unselect();
-		// FIXME-1 VM Note:  does saveStateRemovingPart work for MCO? (No parent!)
-		//saveStateRemovingPart (bo, QString ("Delete %1").arg(getObjectName(bo)));
-		emit (layoutAboutToBeChanged() );
-
-		parentIndex=parent(index(selbi));
-		cout << "VM::delete  selbi="<<selbi<<"  row="<<ix.row()<<"  parIndex.valid="<<parentIndex.isValid()<<endl;
-		int n=ix.row();
-		beginRemoveRows (parentIndex,n,n);
-		removeRows (n,1,parentIndex);
-		MapCenterItem *mci=removeMapCenter (selbi);
-		endRemoveRows();
-		if (mci) 
-		{
-			select (mci);
-			ensureSelectionVisible();
-			reposition();
-		}	
-
-		emit (layoutChanged() );
-	}
-	if (selbi->getType()==TreeItem::Branch)
-	*/
 	if (selbi->isBranchLikeType() )
 	{
-
-		BranchObj* par=(BranchObj*)bo->getParObj();
 		unselect();
-		saveStateRemovingPart (selbi, QString ("Delete %1").arg(getObjectName(bo)));
+		saveStateRemovingPart (selbi, QString ("Delete %1").arg(getObjectName(selbi)));
 
 		emit (layoutAboutToBeChanged() );
 
-		parentIndex=parent(index(selbi));
-		int n=ix.row();
+		int n=selbi->childNum();
 		beginRemoveRows (parentIndex,n,n);
 		removeRows (n,1,parentIndex);
 		endRemoveRows();
-		select (par);
+		select (pi);
 		ensureSelectionVisible();
 		reposition();
 
@@ -3971,7 +3919,7 @@
 
 void VymModel::updateRelPositions()		//FIXME-2 VM should have no need to updateRelPos
 {
-	cout << "VM::updateRelPos...\n";
+	//cout << "VM::updateRelPos...\n";
 	for (int i=0; i<rootItem->branchCount(); i++)
 		((MapCenterObj*)rootItem->getBranchObjNum(i))->updateRelPositions();
 }
diff -r bf3ea1f1520b -r 59614eaf5fbb vymmodel.h
--- a/vymmodel.h	Tue Apr 28 20:53:44 2009 +0000
+++ b/vymmodel.h	Wed Apr 29 18:46:31 2009 +0000
@@ -293,8 +293,6 @@
 	MapCenterItem* addMapCenter();
 private:	
 	MapCenterItem* addMapCenter(QPointF absPos);
-public:	
-	MapCenterItem* removeMapCenter(MapCenterItem *mci);
 
 	/*! \brief Add new branch
 
@@ -306,7 +304,6 @@
 		0..n	insert at a specific position in selections parent
 		(needed for free relinking)
 	*/	
-	MapCenterObj* getLastMapCenter();		//!< get last added MapCenter, used for context menu
 
 private:	
     BranchItem* addNewBranchInt(int);		// pos allows to add above/below selection
diff -r bf3ea1f1520b -r 59614eaf5fbb xml-base.cpp
--- a/xml-base.cpp	Tue Apr 28 20:53:44 2009 +0000
+++ b/xml-base.cpp	Wed Apr 29 18:46:31 2009 +0000
@@ -72,7 +72,7 @@
 		QStringList sl=QStringList::split ("\n",s);
 		int i=1;
 		QStringList::Iterator it = sl.begin();
-		while (i<exception.lineNumber()-1)
+		while (i<exception.lineNumber())
 		{
 			it++;
 			i++;
diff -r bf3ea1f1520b -r 59614eaf5fbb xml-vym.cpp
--- a/xml-vym.cpp	Tue Apr 28 20:53:44 2009 +0000
+++ b/xml-vym.cpp	Wed Apr 29 18:46:31 2009 +0000
@@ -410,8 +410,7 @@
 
 bool parseVYMHandler::readOOAttr (const QXmlAttributes& a)
 {
-	BranchObj *bo=(BranchObj*)lastBranchItem->getLMO();
-	if (bo)
+	if (lastBranchItem)
 	{
 		bool okx,oky;
 		float x,y;
@@ -422,10 +421,7 @@
 				x=a.value("relPosX").toFloat (&okx);
 				y=a.value("relPosY").toFloat (&oky);
 				if (okx && oky  )
-				{
-					bo->setUseRelPos (true);
-					bo->move2RelPos (x,y);
-				}	
+					lastBranchItem->setRelPos (QPointF(x,y));
 				else
 					return false;   // Couldn't read relPos
 			}           
@@ -437,7 +433,7 @@
 				x=a.value("absPosX").toFloat (&okx);
 				y=a.value("absPosY").toFloat (&oky);
 				if (okx && oky  )
-					bo->move(x,y);
+					lastBranchItem->setAbsPos (QPointF(x,y));
 				else
 					return false;   // Couldn't read absPos
 			}