# HG changeset patch
# User insilmaril
# Date 1246271262 0
# Node ID 8acac4fade1b8b9395adb42900276d9cd0b5b3b1
# Parent  25e634a7e1dc260e998163b1428a1f05b9fa9e6e
more fixes

diff -r 25e634a7e1dc -r 8acac4fade1b branchitem.cpp
--- a/branchitem.cpp	Mon Jun 08 11:36:56 2009 +0000
+++ b/branchitem.cpp	Mon Jun 29 10:27:42 2009 +0000
@@ -7,7 +7,7 @@
 
 using namespace std;
 
-BranchItem::BranchItem(const QList<QVariant> &data, MapItem *parent):MapItem (data,parent)
+BranchItem::BranchItem(const QList<QVariant> &data, TreeItem *parent):TreeItem (data,parent)
 {
 	//cout << "Constr. BranchItem\n";
 
@@ -105,11 +105,9 @@
     s+=valueElement("heading", getHeading(),
 		attribut ("textColor",QColor( bo->getColor()).name()));
 
-/*	
-	// Save frame  //FIXME-2
-	if (frame->getFrameType()!=FrameObj::NoFrame) 
-		s+=frame->saveToDir ();
-*/		
+	// Save frame  //FIXME-4 not saved if there is no LMO
+	if (lmo && ((OrnamentedObj*)lmo)->getFrame()->getFrameType()!=FrameObj::NoFrame) 
+		s+=((OrnamentedObj*)lmo)->getFrame()->saveToDir ();
 
 	// save names of flags set
 	s+=standardFlags.saveToDir(tmpdir,prefix,0);
@@ -354,7 +352,7 @@
 
 	if (lmo)
 	{
-		lmo->setParObj ( ((MapItem*)parentItem)->getLMO() );
+		lmo->setParObj ( parentItem->getLMO() );
 	}
 }
 
@@ -376,9 +374,9 @@
 		newbo->setFrameType (FrameObj::Rectangle);
 	} else
 	{
-		newbo->setParObj( ((MapItem*)parentItem)->getLMO() );
+		newbo->setParObj( parentItem->getLMO() );
 		// Set visibility depending on parents
-		if (((BranchItem*)parentItem)->scrolled || !((MapItem*)parentItem)->getLMO()->isVisibleObj() )
+		if (((BranchItem*)parentItem)->scrolled || !parentItem->getLMO()->isVisibleObj() )
 			newbo->setVisibility (false);
 	}
 	newbo->setDefAttr(BranchObj::NewBranch);
diff -r 25e634a7e1dc -r 8acac4fade1b branchitem.h
--- a/branchitem.h	Mon Jun 08 11:36:56 2009 +0000
+++ b/branchitem.h	Mon Jun 29 10:27:42 2009 +0000
@@ -1,17 +1,17 @@
 #ifndef BRANCHITEM_H
 #define BRANCHITEM_H
 
-#include "mapitem.h"
+#include "treeitem.h"
 
 
 class QString;
 class BranchObj;
 class QGraphicsScene;
 
-class BranchItem:public MapItem
+class BranchItem:public TreeItem
 {
 public:
-    BranchItem(const QList<QVariant> &data, MapItem *parent = 0);
+    BranchItem(const QList<QVariant> &data, TreeItem *parent = 0);
     virtual ~BranchItem();
 	void copy (BranchItem *item);
 
diff -r 25e634a7e1dc -r 8acac4fade1b branchpropwindow.cpp
--- a/branchpropwindow.cpp	Mon Jun 08 11:36:56 2009 +0000
+++ b/branchpropwindow.cpp	Mon Jun 29 10:27:42 2009 +0000
@@ -57,12 +57,13 @@
 	settings.setValue( "/satellite/propertywindow/showWithMain",isVisible() );
 }
 
-void BranchPropertyWindow::setBranch (BranchObj *bo)	//FIXME-2 maybe do this via signals emitted anyway from model?
+void BranchPropertyWindow::setBranch (BranchObj *bo)	
 {
 	disconnectSignals();
 	branch=bo;
 	if (bo) 
 	{
+		qWarning ("BPW::setBranch");
 		ui.tabWidget->setEnabled (true);
 
 		// Frame
diff -r 25e634a7e1dc -r 8acac4fade1b exports.cpp
--- a/exports.cpp	Mon Jun 08 11:36:56 2009 +0000
+++ b/exports.cpp	Mon Jun 29 10:27:42 2009 +0000
@@ -131,7 +131,7 @@
 	caption=vymName+ " -" +QObject::tr("Export as ASCII")+" "+QObject::tr("(still experimental)");
 }
 
-void ExportASCII::doExport()	//FIXME-1 segfaults...
+void ExportASCII::doExport()	
 {
 	QFile file (outputFile);
 	if ( !file.open( QIODevice::WriteOnly ) )
diff -r 25e634a7e1dc -r 8acac4fade1b floatobj.cpp
--- a/floatobj.cpp	Mon Jun 08 11:36:56 2009 +0000
+++ b/floatobj.cpp	Mon Jun 29 10:27:42 2009 +0000
@@ -35,7 +35,8 @@
 	floatExport=true;
 	zPlane=Z_ICON;
 	setLinkStyle (LinkableMapObj::Parabel);
-	setHideLinkUnselected(true);
+	setHideLinkUnselected(false);
+	//FIXME-2 setHideLinkUnselected(true);
 }
 
 void FloatObj::copy (FloatObj* other)
diff -r 25e634a7e1dc -r 8acac4fade1b mainwindow.cpp
--- a/mainwindow.cpp	Mon Jun 08 11:36:56 2009 +0000
+++ b/mainwindow.cpp	Mon Jun 29 10:27:42 2009 +0000
@@ -3249,7 +3249,7 @@
 
 void Main::changeSelection (VymModel *model, const QItemSelection &newsel, const QItemSelection &oldsel)
 {
-	//branchPropertyWindow->setModel (model ); //FIXME-2 this used to be called from BranchObj::select(). Maybe use signal now...
+	branchPropertyWindow->setModel (model ); //FIXME-2 this used to be called from BranchObj::select(). Maybe use signal now...
 
 	if (model && model==currentModel() )
 	{
diff -r 25e634a7e1dc -r 8acac4fade1b mapeditor.cpp
--- a/mapeditor.cpp	Mon Jun 08 11:36:56 2009 +0000
+++ b/mapeditor.cpp	Mon Jun 29 10:27:42 2009 +0000
@@ -189,7 +189,7 @@
 		LinkableMapObj* lmo=NULL;
 		TreeItem *ti= static_cast<TreeItem*>(index.internalPointer());
 		if (ti->getType()==TreeItem::Image ||ti->isBranchLikeType() )
-			lmo=((MapItem*)ti)->getLMO();
+			lmo=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=((MapItem*)ti)->getLMO();
+	if (ti) lmo=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=((MapItem*)ti)->getLMO();
+	if (ti) lmo=ti->getLMO();
 	
 	e->accept();
 
@@ -763,8 +763,6 @@
 		// Left Button	    Move Branches
 		if (e->button() == Qt::LeftButton )
 		{
-			//movingObj_start.setX( p.x() - selection->x() );// TODO replaced selection->lmo here	
-			//movingObj_start.setY( p.y() - selection->y() );	
 			movingObj_start.setX( p.x() - lmo->x() );	
 			movingObj_start.setY( p.y() - lmo->y() );	
 			movingObj_orgPos.setX (lmo->x() );
@@ -818,9 +816,9 @@
 {
     QPointF p = mapToScene(e->pos());
 	TreeItem *seli=model->getSelectedItem();
-	LinkableMapObj* lmosel=NULL;		//FIXME-2 get rid of lmosel
+	LinkableMapObj* lmosel=NULL;	
 	if (seli && (seli->isBranchLikeType() ||seli->getType()==TreeItem::Image))
-		lmosel=((MapItem*)seli)->getLMO();
+		lmosel=seli->getLMO();
 
     // Move the selected MapObj
     if ( lmosel && movingObj) 
@@ -840,15 +838,18 @@
 		// of selection back to absPos)
 		
 		// Check if we could link 
-		TreeItem *dsti=findMapItem (p, seli);
+		TreeItem *ti=findMapItem (p, seli);
+		BranchItem *dsti=NULL;
 		LinkableMapObj* dst=NULL;
-		if (dsti && dsti!=seli && dsti->isBranchLikeType())
-			dst=((MapItem*)dsti)->getLMO(); 
-		else
+		if (ti && ti!=seli && ti->isBranchLikeType())
+		{
+			dsti=(BranchItem*)ti;
+			dst=dsti->getLMO(); 
+		} else
 			dsti=NULL;
 		
 
-		if (lmosel && seli->getType()==TreeItem::Image)
+		if (lmosel && seli->getType()==TreeItem::Image)	
 		{
 			FloatObj *fio=(FloatImageObj*)lmosel;
 			fio->move   (p.x() -movingObj_start.x(), p.y()-movingObj_start.y() );		
@@ -858,23 +859,23 @@
 
 			// Relink float to new mapcenter or branch, if shift is pressed	
 			// Only relink, if selection really has a new parent
-			if ( (e->modifiers()==Qt::ShiftModifier) && dst && ( dst != fio->getParObj())  
-				)
+			if ( e->modifiers()==Qt::ShiftModifier && dsti &&  dsti != seli->parent()  )
 			{
 				// 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 
+					seli,
 					"moveRel "+pold,
-					fio->getTreeItem(),
+					seli,
 					"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;
+				model->relinkImage ((ImageItem*) seli,dsti);
+				model->select (seli);
+				//movingObj=lmosel;	//FIXME-3
 				//movingObj_orgRelPos=lmosel->getRelPos();	
 
 				model->reposition();
@@ -967,7 +968,7 @@
 	if (seli) dsti=findMapItem(p, seli);
 	LinkableMapObj* dst=NULL;
 	if (dsti && dsti->isBranchLikeType ()) 
-		dst=((MapItem*)dsti)->getLMO();	
+		dst=dsti->getLMO();	
 	else
 		dsti=NULL;
 
@@ -1012,7 +1013,7 @@
     {	
 		if (seli->getType()==TreeItem::Image)
 		{
-			FloatImageObj *fio=(FloatImageObj*)(((MapItem*)seli)->getLMO());
+			FloatImageObj *fio=(FloatImageObj*)(seli->getLMO());
 			if(fio)
 			{
 				// Moved FloatObj. Maybe we need to reposition
@@ -1049,8 +1050,8 @@
 	
 		if (seli->isBranchLikeType() ) //(seli->getType() == TreeItem::Branch )
 		{	// A branch was moved
-			LinkableMapObj* lmosel=NULL;		//FIXME-2 get rid of lmosel
-			lmosel=((MapItem*)seli)->getLMO();
+			LinkableMapObj* lmosel=NULL;		
+			lmosel=seli->getLMO();
 				
 			// save the position in case we link to mapcenter
 			QPointF savePos=QPointF (lmosel->getAbsPos()  );
@@ -1343,7 +1344,7 @@
 	{
 		index=newsel.indexes().at(i);
 		ti= static_cast<TreeItem*>(index.internalPointer());
-		lmo=((MapItem*)ti)->getLMO();
+		lmo=ti->getLMO();
 		bbox=lmo->getBBox();
 		sb->setRect (
 			bbox.x(),bbox.y(), 
@@ -1369,7 +1370,7 @@
 	
 	if (ti->isBranchLikeType())
 	{
-		BranchObj *bo=(BranchObj*) ((MapItem*)ti)->getLMO();
+		BranchObj *bo=(BranchObj*) (ti->getLMO());
 		bo->updateData();
 	}
 
diff -r 25e634a7e1dc -r 8acac4fade1b mapitem.cpp
--- a/mapitem.cpp	Mon Jun 08 11:36:56 2009 +0000
+++ b/mapitem.cpp	Mon Jun 29 10:27:42 2009 +0000
@@ -3,20 +3,11 @@
 #include "linkablemapobj.h"
 #include "ornamentedobj.h"
 
-#include <iostream>
-using namespace std;
-#include "misc.h"	//cout << QPointF
-
 MapItem::MapItem()
 {
 	init();
 }
 
-MapItem::MapItem(const QList<QVariant> &data, TreeItem *parent):TreeItem (data,parent)
-{
-	init();
-}
-
 void MapItem::init()
 {
 	lmo=NULL;
@@ -72,35 +63,3 @@
 	}
 }
 
-QString MapItem::getAttr()
-{
-	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 (hideExport)
-		return s+attribut("hideInExport","true");
-	else	
-		return s;
-}
-
diff -r 25e634a7e1dc -r 8acac4fade1b mapitem.h
--- a/mapitem.h	Mon Jun 08 11:36:56 2009 +0000
+++ b/mapitem.h	Mon Jun 29 10:27:42 2009 +0000
@@ -3,11 +3,9 @@
 
 #include <QPointF>
 
-#include "treeitem.h"
 #include "xmlobj.h"
 
 class LinkableMapObj;
-class TreeItem;
 
 /*! /brief MapItem is used to store information of MapObj and inherited
    classes.
@@ -17,7 +15,7 @@
 	but just a treeview instead.
 */
 
-class MapItem:public TreeItem, public XMLObj
+class MapItem:public XMLObj
 {
 public:
 	enum PositionMode {Unused,Absolute,Relative};
@@ -27,7 +25,6 @@
 
 public:
 	MapItem();
-	MapItem (const QList<QVariant> &data, TreeItem *parent = 0);
 	void init();
 
 	/*! Used to save relative position while map is not in QGraphicsView */
@@ -52,8 +49,6 @@
 	/*! Initialize LinkableMapObj with data in MapItem */
 	virtual void initLMO();
 
-	/*! Return data as attributes for saving in XML */
-	virtual QString getAttr();
 };
 
 
diff -r 25e634a7e1dc -r 8acac4fade1b ornamentedobj.cpp
--- a/ornamentedobj.cpp	Mon Jun 08 11:36:56 2009 +0000
+++ b/ornamentedobj.cpp	Mon Jun 29 10:27:42 2009 +0000
@@ -76,6 +76,11 @@
     return heading->getColor();
 }
 
+FrameObj* OrnamentedObj::getFrame()
+{
+	return frame;
+}
+
 FrameObj::FrameType OrnamentedObj::getFrameType()
 {
 	return frame->getFrameType();
diff -r 25e634a7e1dc -r 8acac4fade1b ornamentedobj.h
--- a/ornamentedobj.h	Mon Jun 08 11:36:56 2009 +0000
+++ b/ornamentedobj.h	Mon Jun 29 10:27:42 2009 +0000
@@ -30,6 +30,7 @@
 	virtual void setColor(QColor);			// set the color of text and link
 	QColor getColor ();						// get color of heading
 
+	virtual FrameObj* getFrame();
 	virtual FrameObj::FrameType getFrameType ();
 	virtual QString getFrameTypeName ();
 	virtual void setFrameType (const FrameObj::FrameType &);
diff -r 25e634a7e1dc -r 8acac4fade1b treeitem.cpp
--- a/treeitem.cpp	Mon Jun 08 11:36:56 2009 +0000
+++ b/treeitem.cpp	Mon Jun 29 10:27:42 2009 +0000
@@ -13,6 +13,7 @@
 
 TreeItem::TreeItem()
 {
+	//cout << "Constr. TI\n";
 	init();
 	itemData.clear();
 	rootItem=this;
@@ -60,6 +61,9 @@
 
     parentItem = NULL;
     itemData.clear();
+	QList<QVariant> cData;
+	itemData<< "VM:addMapCenter" << "undef"<<"undef";
+
 
 	branchOffset=0;
 	branchCounter=0;
@@ -120,6 +124,10 @@
 	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);
@@ -665,11 +673,10 @@
 	if (type==Branch || type==Image)
 	{
 		hideExport=b;
-		// FIXME-1 call setVis and updateContentsSize...
 		if (b)
-			systemFlags.activate("hideInExport");
+			systemFlags.activate("system-hideInExport");
 		else	
-			systemFlags.deactivate("hideInExport");
+			systemFlags.deactivate("system-hideInExport");
 	}
 }	
 
@@ -683,5 +690,37 @@
 	return hidden;
 }	
 
+QString TreeItem::getAttr()
+{
+	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 (hideExport)
+		return s+attribut("hideInExport","true");
+	else	
+		return s;
+}
 
 
+
diff -r 25e634a7e1dc -r 8acac4fade1b treeitem.h
--- a/treeitem.h	Mon Jun 08 11:36:56 2009 +0000
+++ b/treeitem.h	Mon Jun 29 10:27:42 2009 +0000
@@ -6,6 +6,7 @@
 #include <QVariant>
 
 #include "flagrow.h"
+#include "mapitem.h"
 #include "noteobj.h"
 #include "xmlobj.h"
 
@@ -16,10 +17,10 @@
 class ImageItem;
 class VymModel;
 
-class TreeItem
+class TreeItem:public MapItem
 {
 public:
-	enum Type {Undefined,MapCenter,Branch,Image};
+	enum Type {Undefined,MapCenter,Branch,Image};	//FIXME-3 MapCenter still needed?
 	enum HideTmpMode {HideNone, HideExport};
 
     TreeItem();
@@ -164,6 +165,7 @@
 	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
 
 	
 protected:
diff -r 25e634a7e1dc -r 8acac4fade1b version.h
--- a/version.h	Mon Jun 08 11:36:56 2009 +0000
+++ b/version.h	Mon Jun 29 10:27:42 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-08"
+#define __VYM_BUILD_DATE "2009-06-29"
 
 
 bool checkVersion(const QString &);
diff -r 25e634a7e1dc -r 8acac4fade1b vymmodel.cpp
--- a/vymmodel.cpp	Mon Jun 08 11:36:56 2009 +0000
+++ b/vymmodel.cpp	Mon Jun 29 10:27:42 2009 +0000
@@ -1609,162 +1609,154 @@
 	return urls;
 }
 
-void VymModel::linkFloatImageTo(const QString &dstString)	// FIXME-0
-{
-	//FIXME-0 FloatImageObj *fio=selection.getFloatImage();
-	FloatImageObj *fio=NULL;
-	if (fio)
+
+void VymModel::setFrameType(const FrameObj::FrameType &t)	//FIXME-4 not saved if there is no LMO
+{
+	BranchItem *bi=getSelectedBranchItem();
+	if (bi)
 	{
-		TreeItem *dst=findBySelectString (dstString);
-		if (dst && dst->isBranchLikeType() )
-		{			
-			TreeItem *dstPar=dst->parent();
-			QString parString=getSelectString(dstPar);
-			QString fioPreSelectString=getSelectString(fio);
-			QString fioPreParentSelectString=getSelectString (fio->getParObj());
-			// FIXME-0 ((BranchObj*)dst)->addFloatImage (fio);
-			unselect();
-			// ((BranchObj*)(fio->getParObj()))->removeFloatImage (fio);
-			fio=((BranchObj*)dst)->getLastFloatImage();
-			fio->setRelPos();
-			fio->reposition();
-			// select (fio);
-			saveState(
-				getSelectString(fio),
-				QString("linkTo (\"%1\")").arg(fioPreParentSelectString), 
-				fioPreSelectString, 
-				QString ("linkTo (\"%1\")").arg(dstString),
-				QString ("Link floatimage to %1").arg(getObjectName(dst)));
+		BranchObj *bo=(BranchObj*)(bi->getLMO());
+		if (bo)
+		{
+			QString s=bo->getFrameTypeName();
+			bo->setFrameType (t);
+			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();
 		}
 	}
 }
 
-
-void VymModel::setFrameType(const FrameObj::FrameType &t)	//FIXME-2
+void VymModel::setFrameType(const QString &s)	//FIXME-4 not saved if there is no LMO
+{
+	BranchItem *bi=getSelectedBranchItem();
+	if (bi)
+	{
+		BranchObj *bo=(BranchObj*)(bi->getLMO());
+		if (bo)
+		{
+			saveState (bi, QString("setFrameType (\"%1\")").arg(bo->getFrameTypeName()),
+				bi, QString ("setFrameType (\"%1\")").arg(s),QString ("set type of frame to %1").arg(s));
+			bo->setFrameType (s);
+			reposition();
+			bo->updateLink();
+		}
+	}
+}
+
+void VymModel::setFramePenColor(const QColor &c)	//FIXME-4 not saved if there is no LMO
+
+{
+	BranchItem *bi=getSelectedBranchItem();
+	if (bi)
+	{
+		BranchObj *bo=(BranchObj*)(bi->getLMO());
+		if (bo)
+		{
+			saveState (bi, QString("setFramePenColor (\"%1\")").arg(bo->getFramePenColor().name() ),
+				bi, QString ("setFramePenColor (\"%1\")").arg(c.name() ),QString ("set pen color of frame to %1").arg(c.name() ));
+			bo->setFramePenColor (c);
+		}	
+	}	
+}
+
+void VymModel::setFrameBrushColor(const QColor &c)	//FIXME-4 not saved if there is no LMO
+{
+	BranchItem *bi=getSelectedBranchItem();
+	if (bi)
+	{
+		BranchObj *bo=(BranchObj*)(bi->getLMO());
+		if (bo)
+		{
+			saveState (bi, QString("setFrameBrushColor (\"%1\")").arg(bo->getFrameBrushColor().name() ),
+				bi, QString ("setFrameBrushColor (\"%1\")").arg(c.name() ),QString ("set brush color of frame to %1").arg(c.name() ));
+			bo->setFrameBrushColor (c);
+		}	
+	}	
+}
+
+void VymModel::setFramePadding (const int &i) //FIXME-4 not saved if there is no LMO
+{
+	BranchItem *bi=getSelectedBranchItem();
+	if (bi)
+	{
+		BranchObj *bo=(BranchObj*)(bi->getLMO());
+		if (bo)
+		{
+			saveState (bi, QString("setFramePadding (\"%1\")").arg(bo->getFramePadding() ),
+				bi, QString ("setFramePadding (\"%1\")").arg(i),QString ("set brush color of frame to %1").arg(i));
+			bo->setFramePadding (i);
+			reposition();
+			bo->updateLink();
+		}	
+	}	
+}
+
+void VymModel::setFrameBorderWidth(const int &i) //FIXME-4 not saved if there is no LMO
+{
+	BranchItem *bi=getSelectedBranchItem();
+	if (bi)
+	{
+		BranchObj *bo=(BranchObj*)(bi->getLMO());
+		if (bo)
+		{
+			saveState (bi, QString("setFrameBorderWidth (\"%1\")").arg(bo->getFrameBorderWidth() ),
+				bi, QString ("setFrameBorderWidth (\"%1\")").arg(i),QString ("set border width of frame to %1").arg(i));
+			bo->setFrameBorderWidth (i);
+			reposition();
+			bo->updateLink();
+		}	
+	}	
+}
+
+void VymModel::setIncludeImagesVer(bool b)	//FIXME-2
 {
 /*
-	BranchObj *bo=getSelectedBranch();
-	if (bo)
+	BranchItem *bi=getSelectedBranchItem();
+	if (ti)
 	{
-		QString s=bo->getFrameTypeName();
-		bo->setFrameType (t);
-		saveState (bo, QString("setFrameType (\"%1\")").arg(s),
-			bo, QString ("setFrameType (\"%1\")").arg(bo->getFrameTypeName()),QString ("set type of frame to %1").arg(s));
-		reposition();
-		bo->updateLink();
-	}
-*/	
-}
-
-void VymModel::setFrameType(const QString &s)	//FIXME-2
-{
-/*
-	BranchObj *bo=getSelectedBranch();
-	if (bo)
-	{
-		saveState (bo, QString("setFrameType (\"%1\")").arg(bo->getFrameTypeName()),
-			bo, QString ("setFrameType (\"%1\")").arg(s),QString ("set type of frame to %1").arg(s));
-		bo->setFrameType (s);
-		reposition();
-		bo->updateLink();
-	}
-*/
-}
-
-void VymModel::setFramePenColor(const QColor &c)	//FIXME-2
-{
-/*
-	BranchObj *bo=getSelectedBranch();
-	if (bo)
-	{
-		saveState (bo, QString("setFramePenColor (\"%1\")").arg(bo->getFramePenColor().name() ),
-			bo, QString ("setFramePenColor (\"%1\")").arg(c.name() ),QString ("set pen color of frame to %1").arg(c.name() ));
-		bo->setFramePenColor (c);
-	}	
-*/	
-}
-
-void VymModel::setFrameBrushColor(const QColor &c)	//FIXME-2
-{
-/*
-	BranchObj *bo=getSelectedBranch();
-	if (bo)
-	{
-		saveState (bo, QString("setFrameBrushColor (\"%1\")").arg(bo->getFrameBrushColor().name() ),
-			bo, QString ("setFrameBrushColor (\"%1\")").arg(c.name() ),QString ("set brush color of frame to %1").arg(c.name() ));
-		bo->setFrameBrushColor (c);
+		BranchObj *bo=bi->getLMO();
+		if (bo)
+		{
+			QString u= b ? "false" : "true";
+			QString r=!b ? "false" : "true";
+			
+			saveState(
+				bo,
+				QString("setIncludeImagesVertically (%1)").arg(u),
+				bo, 
+				QString("setIncludeImagesVertically (%1)").arg(r),
+				QString("Include images vertically in %1").arg(getObjectName(bo))
+			);	
+			bo->setIncludeImagesVer(b);
+			reposition();
+		}	
 	}	
 */}
 
-void VymModel::setFramePadding (const int &i) //FIXME-2
+void VymModel::setIncludeImagesHor(bool b)	//FIXME-2
 {
 /*
-	BranchObj *bo=getSelectedBranch();
-	if (bo)
+	TreeItem *bi=getSelectedBranchItem();
+	if (ti)
 	{
-		saveState (bo, QString("setFramePadding (\"%1\")").arg(bo->getFramePadding() ),
-			bo, QString ("setFramePadding (\"%1\")").arg(i),QString ("set brush color of frame to %1").arg(i));
-		bo->setFramePadding (i);
-		reposition();
-		bo->updateLink();
-	}	
-	*/
-}
-
-void VymModel::setFrameBorderWidth(const int &i) //FIXME-2
-{
-/*
-	BranchObj *bo=getSelectedBranch();
-	if (bo)
-	{
-		saveState (bo, QString("setFrameBorderWidth (\"%1\")").arg(bo->getFrameBorderWidth() ),
-			bo, QString ("setFrameBorderWidth (\"%1\")").arg(i),QString ("set border width of frame to %1").arg(i));
-		bo->setFrameBorderWidth (i);
-		reposition();
-		bo->updateLink();
-	}	
-*/	
-}
-
-void VymModel::setIncludeImagesVer(bool b)	//FIXME-2
-{
-/*
-	BranchObj *bo=getSelectedBranch();
-	if (bo)
-	{
-		QString u= b ? "false" : "true";
-		QString r=!b ? "false" : "true";
-		
-		saveState(
-			bo,
-			QString("setIncludeImagesVertically (%1)").arg(u),
-			bo, 
-			QString("setIncludeImagesVertically (%1)").arg(r),
-			QString("Include images vertically in %1").arg(getObjectName(bo))
-		);	
-		bo->setIncludeImagesVer(b);
-		reposition();
-	}	
-*/}
-
-void VymModel::setIncludeImagesHor(bool b)	//FIXME-2
-{
-/*
-	BranchObj *bo=getSelectedBranch();
-	if (bo)
-	{
-		QString u= b ? "false" : "true";
-		QString r=!b ? "false" : "true";
-		
-		saveState(
-			bo,
-			QString("setIncludeImagesHorizontally (%1)").arg(u),
-			bo, 
-			QString("setIncludeImagesHorizontally (%1)").arg(r),
-			QString("Include images horizontally in %1").arg(getObjectName(bo))
-		);	
-		bo->setIncludeImagesHor(b);
-		reposition();
+		BranchObj *bo=bi->getLMO();
+		if (bo)
+		{
+			QString u= b ? "false" : "true";
+			QString r=!b ? "false" : "true";
+			
+			saveState(
+				bo,
+				QString("setIncludeImagesHorizontally (%1)").arg(u),
+				bo, 
+				QString("setIncludeImagesHorizontally (%1)").arg(r),
+				QString("Include images horizontally in %1").arg(getObjectName(bo))
+			);	
+			bo->setIncludeImagesHor(b);
+			reposition();
+		}	
 	}	
 	*/
 }
@@ -1795,22 +1787,22 @@
 
 void VymModel::setHideExport(bool b)
 {
-	MapItem *mi=(MapItem*)getSelectedItem();
-	if (mi && 
-		(mi->getType()==TreeItem::Image ||mi->isBranchLikeType()))
+	TreeItem *ti=getSelectedItem();
+	if (ti && 
+		(ti->getType()==TreeItem::Image ||ti->isBranchLikeType()))
 	{
-		mi->setHideInExport (b);
+		ti->setHideInExport (b);
 		QString u= b ? "false" : "true";
 		QString r=!b ? "false" : "true";
 		
 		saveState(
-			mi,
+			ti,
 			QString ("setHideExport (%1)").arg(u),
-			mi,
+			ti,
 			QString ("setHideExport (%1)").arg(r),
-			QString ("Set HideExport flag of %1 to %2").arg(getObjectName(mi)).arg (r)
+			QString ("Set HideExport flag of %1 to %2").arg(getObjectName(ti)).arg (r)
 		);	
-			emitDataHasChanged(mi);
+			emitDataHasChanged(ti);
 			emitSelectionChanged();
 		updateActions();
 		reposition();
@@ -1962,11 +1954,12 @@
 	{
 		QModelIndex parix;
 		int n;
+
 		QList<QVariant> cData;
-		cData << "VM::createImage" << "undef"<<"undef";
-
-		ImageItem *newii=new ImageItem (cData);	
-		newii->setHeading (QApplication::translate("Heading of new image in map", "new image"));
+		cData << "new" << "undef"<<"undef";
+
+		ImageItem *newii=new ImageItem(cData) ;	
+		//newii->setHeading (QApplication::translate("Heading of new image in map", "new image"));
 
 		emit (layoutAboutToBeChanged() );
 
@@ -2187,6 +2180,43 @@
 	return false;
 }
 
+bool VymModel::relinkImage (ImageItem *image, BranchItem *dst)
+{
+	if (image && dst)
+	{
+		emit (layoutAboutToBeChanged() );
+
+		BranchItem *pi=(BranchItem*)(image->parent());
+		QString oldParString=getSelectString (pi);
+		// Remove at current position
+		int n=image->childNum();
+		beginRemoveRows (index(pi),n,n);
+		pi->removeChild (n);
+		endRemoveRows();
+
+		// Add at dst
+		QModelIndex dstix=index(dst);
+		n=dst->getRowNumAppend (image);
+		beginInsertRows (dstix,n,n+1);	
+		dst->appendChild (image);	
+		endInsertRows ();
+
+		// Set new parent also for lmo
+		if (image->getLMO() && dst->getLMO() )
+			image->getLMO()->setParObj (dst->getLMO() );
+
+		emit (layoutChanged() );
+		saveState(
+			image,
+			QString("relinkTo (\"%1\")").arg(oldParString), 
+			image,
+			QString ("relinkTo (\"%1\")").arg(getSelectString (dst)),
+			QString ("Relink floatimage to %1").arg(getObjectName(dst)));
+		return true;	
+	}
+	return false;
+}
+
 void VymModel::deleteSelection()
 {
 	BranchItem *selbi=getSelectedBranchItem();
@@ -2436,7 +2466,7 @@
 	}
 }
 
-void VymModel::addFloatImage (const QPixmap &img) //FIXME-0
+void VymModel::addFloatImage (const QPixmap &img) //FIXME-2 drag & drop
 {
 /*
 	BranchObj *bo=getSelectedBranch();
@@ -3067,10 +3097,8 @@
 				TreeItem *dst=findBySelectString (s);
 				if (dst)
 				{	
-					/* FIXME-0 relink img
 					if (dst->isBranchLikeType())
-						linkFloatImageTo (getSelectString(dst));
-					*/	
+						relinkImage ( ((ImageItem*)selti),(BranchItem*)dst);
 				} else	
 					parser.setError (Aborted,"Destination is not a branch");
 			}		
@@ -3871,7 +3899,6 @@
 
 void VymModel::updateRelPositions()		//FIXME-3 VM should have no need to updateRelPos
 {
-	cout << "VM::updateRelPos...\n";
 	/* FIXME-3 ???
 	for (int i=0; i<rootItem->branchCount(); i++)
 		((MapCenterObj*)rootItem->getBranchObjNum(i))->updateRelPositions();
@@ -4927,7 +4954,7 @@
 		TreeItem::Type type=ti->getType();
 		if (type ==TreeItem::Branch || type==TreeItem::MapCenter || type==TreeItem::Image)
 		{
-			return ((MapItem*)ti)->getLMO();
+			return ti->getLMO();
 		}	
 	}
 	return NULL;
@@ -4937,7 +4964,7 @@
 {
 	TreeItem *ti = getSelectedBranchItem();
 	if (ti)
-		return (BranchObj*)((MapItem*)ti)->getLMO();
+		return (BranchObj*)(ti->getLMO());
 	else	
 		return NULL;
 }
@@ -4996,28 +5023,22 @@
 	return getSelectString (lmo->getTreeItem() );
 }
 
-QString VymModel::getSelectString (TreeItem *ti)
+QString VymModel::getSelectString (TreeItem *ti) //FIXME-1 does not return "mc:"
 {
 	QString s;
 	if (!ti) return s;
-	if (ti->isBranchLikeType())
-	{	
-		TreeItem *par=ti->parent();
-		if (par)
-		{
-			if (ti->depth() ==1)
-				// Mainbranch, return 
-				s= "bo:" + QString("%1").arg(ti->num() );
-			else	
-				// Branch, call myself recursively
-				s= getSelectString(par) + ",bo:" + QString("%1").arg(ti->num());
-		} else
-		{
-			// MapCenter
-			int i=rootItem->num(ti);
-			if (i>=0) s=QString("mc:%1").arg(i);
-		}	
-	}	
+	switch (ti->getType())
+	{
+		case TreeItem::MapCenter: s="mc:"; break;
+		case TreeItem::Branch: s="bo:";break;
+		case TreeItem::Image: s="fi:";break;
+		default:break;
+	}
+	s=  s + QString("%1").arg(ti->num());
+	if (ti->depth() >0)
+		// call myself recursively
+		s= getSelectString(ti->parent()) +","+s;
+			
 	return s;
 }
 
diff -r 25e634a7e1dc -r 8acac4fade1b vymmodel.h
--- a/vymmodel.h	Mon Jun 08 11:36:56 2009 +0000
+++ b/vymmodel.h	Mon Jun 29 10:27:42 2009 +0000
@@ -250,7 +250,6 @@
 	QString getURL();						// returns URL of selection or ""
 	QStringList getURLs();					// returns URLs of subtree
 
-	void linkFloatImageTo(const QString &);
 
 	void setFrameType(const FrameObj::FrameType &);
 	void setFrameType(const QString &);
@@ -322,6 +321,7 @@
 		Returns true if relinking was successful.
 	*/	
 	bool relinkBranch (BranchItem* branch, BranchItem* dst, int pos =-1);	
+	bool relinkImage  (ImageItem* image, BranchItem* dst);	
 
     void deleteSelection();				//!< Delete selection
 	void deleteKeepChildren();			//!< remove branch, but keep children
diff -r 25e634a7e1dc -r 8acac4fade1b vymview.cpp
--- a/vymview.cpp	Mon Jun 08 11:36:56 2009 +0000
+++ b/vymview.cpp	Mon Jun 29 10:27:42 2009 +0000
@@ -105,7 +105,9 @@
 void VymView::changeSelection (const QItemSelection &newsel, const QItemSelection &oldsel)
 {
 	// Notify mainwindow to update satellites like NoteEditor, if needed (model==currenModel...)
-	mainWindow->changeSelection (model,newsel,oldsel);	// FIXME-3 maybe connect VymModel <-> MainWindow directly?
+	mainWindow->changeSelection (model,newsel,oldsel);	// FIXME-5 maybe connect VymModel <-> MainWindow directly?
+	// would require to also get current model in mainWindow
+
 	//showSelection();
 }
 
diff -r 25e634a7e1dc -r 8acac4fade1b xml-vym.cpp
--- a/xml-vym.cpp	Mon Jun 08 11:36:56 2009 +0000
+++ b/xml-vym.cpp	Mon Jun 29 10:27:42 2009 +0000
@@ -279,13 +279,13 @@
 			mainWindow->removeProgressBar();
 			break;
         case StateMapCenter: 
-			model->selectParent();
+			model->selectParent();	// FIXME-3 really needed to "select"? Maybe optimize...
 			model->emitDataHasChanged (lastBranch);
 			lastBranch=(BranchItem*)(lastBranch->parent());
 			lastBranch->setLastSelectedBranch (0);	// Reset last selected to first child branch
             break;
         case StateBranch: 
-			model->selectParent();
+			model->selectParent();// FIXME-3 really needed to "select"? Maybe optimize...
 			model->emitDataHasChanged (lastBranch);
 			lastBranch=(BranchItem*)(lastBranch->parent());
 			lastBranch->setLastSelectedBranch (0);	// Reset last selected to first child branch
@@ -382,36 +382,42 @@
 	return true;	
 }
 
-bool parseVYMHandler::readFrameAttr (const QXmlAttributes& a)
+bool parseVYMHandler::readFrameAttr (const QXmlAttributes& a)	// FIXME-4 does not work if there is no lmo for treeitem
 {
-	bool ok;
-	int x;
-	/* FIXME-2 if (lastOO)
+	if (lastMI)
 	{
-		if (!a.value( "frameType").isEmpty() ) 
-			lastOO->setFrameType (a.value("frameType"));
-		if (!a.value( "penColor").isEmpty() ) 
-			lastOO->setFramePenColor (a.value("penColor"));
-		if (!a.value( "brushColor").isEmpty() ) 
-			lastOO->setFrameBrushColor (a.value("brushColor"));
-		if (!a.value( "padding").isEmpty() ) 
+		OrnamentedObj* oo=(OrnamentedObj*)(lastMI->getLMO()); 
+		if (oo)
 		{
-			x=a.value("padding").toInt(&ok);
-			if (ok) lastOO->setFramePadding(x);
-		}	
-		if (!a.value( "borderWidth").isEmpty() ) 
-		{
-			x=a.value("borderWidth").toInt(&ok);
-			if (ok) lastOO->setFrameBorderWidth(x);
-		}	
-	}		
-	*/
-	return true;
+			bool ok;
+			int x;
+			{
+				if (!a.value( "frameType").isEmpty() ) 
+					oo->setFrameType (a.value("frameType"));
+				if (!a.value( "penColor").isEmpty() ) 
+					oo->setFramePenColor (a.value("penColor"));
+				if (!a.value( "brushColor").isEmpty() ) 
+					oo->setFrameBrushColor (a.value("brushColor"));
+				if (!a.value( "padding").isEmpty() ) 
+				{
+					x=a.value("padding").toInt(&ok);
+					if (ok) oo->setFramePadding(x);
+				}	
+				if (!a.value( "borderWidth").isEmpty() ) 
+				{
+					x=a.value("borderWidth").toInt(&ok);
+					if (ok) oo->setFrameBorderWidth(x);
+				}	
+			}		
+			return true;
+		}
+	}
+	return false;
 }
 
 bool parseVYMHandler::readOOAttr (const QXmlAttributes& a)
 {
-	if (lastMI)
+	if (lastMI)	//FIXME-1  below lastBranch is used, not lastMI. So it might not work for images
 	{
 		bool okx,oky;
 		float x,y;
@@ -516,7 +522,6 @@
 		{
 			QMessageBox::warning( 0, "Warning: " ,
 				"Couldn't load image\n"+parseHREF(a.value ("href") ));
-			//FIXME-0 lastBranch->removeFloatImage(((FloatImageObj*)(lastFloat)));
 			lastImage=NULL;
 			return true;
 		}
@@ -534,19 +539,14 @@
 			x=a.value("relPosX").toFloat (&okx);
 			y=a.value("relPosY").toFloat (&oky);
 			if (okx && oky) 
-				
-				{
-					lastImage->setRelPos (QPointF (x,y) );
-					// make sure floats in mapcenter are repositioned to relative pos
-					//FIXME-0 if (lastBranch->depth()==0) lastBranch->positionContents();
-				}
+				lastImage->setRelPos (QPointF (x,y) );
 			else
 				// Couldn't read relPos
 				return false;  
 		}           
 	}	
 	
-	if (!readOOAttr(a)) return false;
+	//FIXME-3 if (!readOOAttr(a)) return false;
 
 	if (!a.value ("originalName").isEmpty() )
 	{