# HG changeset patch
# User insilmaril
# Date 1242203187 0
# Node ID 6d2b32f305f94bb2017992b3771a36eaf9152394
# Parent  7a71a914afdbd6d7e8308cf177ab4ea56a829136
Started to use QtKinetic for Animation

diff -r 7a71a914afdb -r 6d2b32f305f9 aboutdialog.cpp
--- a/aboutdialog.cpp	Thu May 07 08:48:53 2009 +0000
+++ b/aboutdialog.cpp	Wed May 13 08:26:27 2009 +0000
@@ -91,7 +91,7 @@
     license->setText (
 	"<center>"
 	"<h3>VYM - View Your Mind</h3>"
-    "<p>Copyright (C) 2004-2007  Uwe Drechsel</p>"  
+    "<p>Copyright (C) 2004-2009  Uwe Drechsel</p>"  
 	"</center>"
 
     "<p>This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation.</p>"
diff -r 7a71a914afdb -r 6d2b32f305f9 animpoint.cpp
--- a/animpoint.cpp	Thu May 07 08:48:53 2009 +0000
+++ b/animpoint.cpp	Wed May 13 08:26:27 2009 +0000
@@ -115,7 +115,7 @@
 		return animated;
 	}
 
-	// Some math slow down the movement
+	// Some math to slow down the movement in the end
 	qreal f=1-n/animTicks;
 	qreal ff=1-f*f*f;
 	setX (startPos.x() + vector.x()*ff );
diff -r 7a71a914afdb -r 6d2b32f305f9 attribute.h
--- a/attribute.h	Thu May 07 08:48:53 2009 +0000
+++ b/attribute.h	Wed May 13 08:26:27 2009 +0000
@@ -6,8 +6,8 @@
 
 #include "xmlobj.h"
 
-class AttributeTable;
-class AttributeDef;
+class AttributeTable;	//FIXME-3 remove from CVS
+class AttributeDef;		//FIXME-3 remove from CVS
 
 enum AttributeType {
 	Undefined,	//!< Undefined type
diff -r 7a71a914afdb -r 6d2b32f305f9 branchitem.cpp
--- a/branchitem.cpp	Thu May 07 08:48:53 2009 +0000
+++ b/branchitem.cpp	Wed May 13 08:26:27 2009 +0000
@@ -202,38 +202,38 @@
 	if (scrolled) toggleScroll();
 }
 
-void BranchItem::toggleScroll()
+bool BranchItem::toggleScroll()	
 {
-	BranchItem *bi=getFirstBranch();
 
+	if (!branchCount()>0) return false;
 	BranchObj *bo=NULL;
 	if (scrolled)
 	{
 		scrolled=false;
-		//FIXME-1 systemFlags->deactivate("scrolledright");
-		while (bi)
+		systemFlags.deactivate("system-scrolledright");
+		if (branchCounter>0)
 		{
-			bo=(BranchObj*)(bi->getLMO());
-			if (bo) bo->setVisibility(true);
-			bi=getNextBranch(bi);
+			for (int i=0;i<branchCounter;++i)
+			{
+				bo=(BranchObj*)(getBranchNum(i)->getLMO());
+				if (bo) bo->setVisibility(true);
+			}
 		}
+		model->reposition();
 	} else
 	{
 		scrolled=true;
-		//FIXME-1 systemFlags->activate("scrolledright");
-		while (bi)
+		systemFlags.activate("system-scrolledright");
+		if (branchCounter>0)
 		{
-			bo=(BranchObj*)(bi->getLMO());
-			if (bo) bo->setVisibility(false);
-			bi=getNextBranch(bi);
+			for (int i=0;i<branchCounter;++i)
+			{
+				bo=(BranchObj*)(getBranchNum(i)->getLMO());
+				if (bo) bo->setVisibility(false);
+			}
 		}
 	}
-	if (bo)
-	{
-		bo->calcBBoxSize();
-		bo->positionBBox();	
-		bo->forceReposition();
-	}
+	return true;
 }
 
 bool BranchItem::isScrolled()
@@ -357,7 +357,7 @@
 
 	if (!getHeading().isEmpty() ) 
 	{
-		newbo->updateHeading();
+		newbo->updateData();	//FIXME-3 maybe better model->emitDataHasChanged()?
 		newbo->setColor (headingColor);
 	}	
 
diff -r 7a71a914afdb -r 6d2b32f305f9 branchitem.h
--- a/branchitem.h	Thu May 07 08:48:53 2009 +0000
+++ b/branchitem.h	Wed May 13 08:26:27 2009 +0000
@@ -34,7 +34,7 @@
 	bool tmpUnscrolled;		// can only be true (temporary) for a scrolled subtree
 public:
 	virtual void unScroll();				
-	virtual void toggleScroll();			// scroll or unscroll
+	virtual bool toggleScroll();			// scroll or unscroll
 	virtual bool isScrolled();				// returns scroll state
 	virtual bool hasScrolledParent(BranchItem*);	// true, if any of the parents is scrolled
 	virtual void tmpUnscroll();				// unscroll scrolled parents temporary e.g. during "find" process
diff -r 7a71a914afdb -r 6d2b32f305f9 branchobj.cpp
--- a/branchobj.cpp	Thu May 07 08:48:53 2009 +0000
+++ b/branchobj.cpp	Wed May 13 08:26:27 2009 +0000
@@ -6,12 +6,8 @@
 #include "mainwindow.h"
 #include "misc.h"
 
-//class TextEditor; //FIXME-3
-
-//extern TextEditor *textEditor;
-//extern Main *mainWindow;
-//extern FlagRowObj *standardFlagsDefault;
-
+extern FlagRow *standardFlagsMaster;
+extern FlagRow *systemFlagsMaster;
 
 /////////////////////////////////////////////////////////////////
 // BranchObj
@@ -325,12 +321,12 @@
     QSizeF heading_r=heading->getSize();
     qreal heading_w=(qreal) heading_r.width() ;
     qreal heading_h=(qreal) heading_r.height() ;
-    QSizeF sysflags_r; //FIXME-1 =systemFlags->getSize();
-	qreal sysflags_h=0;//sysflags_r.height();
-	qreal sysflags_w=0;//sysflags_r.width();
-    QSizeF stanflags_r; //FIXME-1 =standardFlags->getSize();
-	qreal stanflags_h=0; //stanflags_r.height();
-	qreal stanflags_w=0; //stanflags_r.width();
+    QSizeF sysflags_r=systemFlags->getSize();
+	qreal sysflags_h=sysflags_r.height();
+	qreal sysflags_w=sysflags_r.width();
+    QSizeF stanflags_r=standardFlags->getSize();
+	qreal stanflags_h=stanflags_r.height();
+	qreal stanflags_w=stanflags_r.width();
     qreal w;
     qreal h;
 
@@ -416,105 +412,67 @@
     }
 }
 
-void BranchObj::updateHeading()
+void BranchObj::updateData()
 {
+	bool changed=false;
 	if (!treeItem)
 	{
 		qWarning ("BranchObj::udpateHeading treeItem==NULL");
 		return;
 	}
-	heading->setText (treeItem->getHeading() );
-	updateContentSize();
+	QString s=treeItem->getHeading();
+	if (s!=heading->text())
+	{
+		heading->setText (s);
+		changed=true;
+	}
+	QStringList TIactiveFlags=treeItem->activeStandardFlagNames();
+
+	// Add missing standard flags active in TreeItem
+	for (int i=0;i<=TIactiveFlags.size()-1;i++)
+	{	
+		if (!standardFlags->isActive (TIactiveFlags.at(i) ))
+		{
+			Flag *f=standardFlagsMaster->getFlag(TIactiveFlags.at(i));
+			if (f) standardFlags->activate (f);
+			changed=true;
+		}
+	}
+	// Remove standard flags no longer active in TreeItem
+	QStringList BOactiveFlags=standardFlags->activeFlagNames();
+	for (int i=0;i<BOactiveFlags.size();++i)
+		if (!TIactiveFlags.contains (BOactiveFlags.at(i)))
+		{
+			standardFlags->deactivate (BOactiveFlags.at(i));
+			changed=true;
+		}	
+
+	// Add missing system flags active in TreeItem
+	TIactiveFlags=treeItem->activeSystemFlagNames();
+	for (int i=0;i<TIactiveFlags.size();++i)
+	{	
+		if (!systemFlags->isActive (TIactiveFlags.at(i) ))
+		{
+			Flag *f=systemFlagsMaster->getFlag(TIactiveFlags.at(i));
+			if (f) systemFlags->activate (f);
+			changed=true;
+		}
+	}
+	// Remove system flags no longer active in TreeItem
+	BOactiveFlags=systemFlags->activeFlagNames();
+	for (int i=0;i<BOactiveFlags.size();++i)
+	{
+		if (!TIactiveFlags.contains (BOactiveFlags.at(i)))
+		{
+			systemFlags->deactivate (BOactiveFlags.at(i));
+			changed=true;
+		}	
+	}
+
+	if (changed)
+		updateContentSize();
 }
 
-QString BranchObj::saveToDir (const QString &tmpdir,const QString &prefix, const QPointF& offset)
-{
-	// Cloudy stuff can be hidden during exports
-	// FIXME-1 if (hidden) return "";
-
-	// Update of note is usually done while unselecting a branch
-	// if (isNoteInEditor) getNoteFromTextEditor();		//FIXME-2 moved to TreeItem
-	
-    QString s,a;
-	/*
-	QString scrolledAttr;
-	if ( ((BranchItem*)treeItem)->isScrolled() ) 
-		scrolledAttr=attribut ("scrolled","yes");
-	else
-		scrolledAttr="";
-
-	// save area, if not scrolled
-	QString areaAttr;
-	if (!((BranchItem*) (treeItem->parent()) )->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 (treeItem->xlinkCount()>0)
-		idAttr=attribut ("id",model->getSelectString(this)); //TODO directly access model
-	else
-		idAttr="";
-
-    s=beginElement ("branch" 
-		+getOrnXMLAttr() 
-		+scrolledAttr 
-		+areaAttr 
-		+idAttr 
-		+getIncludeImageAttr() );
-    incIndent();
-
-	// save heading
-    s+=valueElement("heading", treeItem->getHeading(),
-		attribut ("textColor",QColor(heading->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 (!treeItem->getNoteObj().isEmpty() )
-		s+=treeItem->getNoteObj().saveToDir();
-	
-	// Save branches
-	for (int i=0; i<treeItem->branchCount(); ++i)
-		s+=treeItem->getBranchObjNum(i)->saveToDir(tmpdir,prefix,offset);
-
-	// 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(treeItem->getHeading()));
-		}
-	}	
-
-    decIndent();
-    s+=endElement   ("branch");
-    return s;
-*/	
-}
 
 void BranchObj::addXLink (XLinkObj *xlo)
 {
@@ -732,66 +690,6 @@
 */	
 }
 
-bool BranchObj::canMoveBranchUp() // FIXME-1 move to BranchItem
-{
-/*
-	if (!parObj || depth==1) return false;
-	BranchObj* par=(BranchObj*)parObj;
-	if (this==par->getTreeItem()->getFirstBranch())
-		return false;
-	else
-		return true;
-		*/
-return false;
-}
-
-BranchObj* BranchObj::moveBranchUp(BranchObj* bo1) // FIXME-1
-{
-/*
-	savePosInAngle();
-    int i=branch.indexOf(bo1);
-    if (i>0) 
-	{	// -1 if bo1 not found 
-		treeItem->getBranchObjNum(i)->angle--;
-		treeItem->getBranchObjNum(i-1)->angle++;
-		qSort (branch.begin(),branch.end(), isAbove);
-		return treeItem->getBranchObjNum(i);
-	} else
-*/	
-		return NULL;
-}
-
-bool BranchObj::canMoveBranchDown() //FIXME-1 move to BranchItem
-{
-	/* 
-	if (!parObj|| depth==1) return false;
-	BranchObj* par=(BranchObj*)parObj;
-	if (this==par->getTreeItem()->getLastBranch())
-		return false;
-	else
-		return true;
-	*/
-return false;	
-}
-
-BranchObj* BranchObj::moveBranchDown(BranchObj* bo1)// FIXME-1
-{
-/*
-	savePosInAngle();
-    int i=branch.indexOf(bo1);
-	int j;
-	if (i <treeItem->branchCount())
-	{
-		j = i+1;
-		treeItem->getBranchObjNum(i)->angle++;
-		treeItem->getBranchObjNum(j)->angle--;
-		qSort (branch.begin(),branch.end(), isAbove);
-		return treeItem->getBranchObjNum(i);
-	} else
-*/	
-		return NULL;
-}
-
 void BranchObj::sortChildren() //FIXME-2  
 {
 /*
@@ -1070,65 +968,6 @@
 	bboxTotal.setHeight(max (r.height(),  bbox.height()));
 }
 
-/*
-void BranchObj::select()	// FIXME-4 try to get rid of this in BO completely
-{
-	cout << "BO::select()\n";
-	textEditor->setText(treeItem->getNoteObj().getNote() );
-	QString fnh=treeItem->getNoteObj().getFilenameHint();
-	if (fnh!="")
-		textEditor->setFilenameHint(treeItem->getNoteObj().getFilenameHint() );
-	else	
-		textEditor->setFilenameHint(getHeading() );
-	textEditor->setFontHint (treeItem->getNoteObj().getFontHint() );
-	//isNoteInEditor=true;
-
-	// set selected and visible
-    LinkableMapObj::select();
-
-    //if (po)	po->setLastSelectedBranch(this);  needed?
-		
-	// temporary unscroll, if we have scrolled parents somewhere
-	if (parObj) ((BranchObj*)(parObj))->tmpUnscroll();
-
-	//moved to vymmodel or vymview...
-	// Show URL and link in statusbar
-	QString status;
-	if (!url.isEmpty()) status+="URL: "+url+"  ";
-	if (!vymLink.isEmpty()) status+="Link: "+vymLink;
-	if (!status.isEmpty()) mainWindow->statusMessage (status);
-
-	// Update Toolbar
-	updateFlagsToolbar();
-
-	// Update actions
-	model->updateActions();
-}
-	*/
-
-/*
-void BranchObj::unselect()	//FIXME-4 should not be needed
-{
-	cout << "BO::unselect()\n";
-	LinkableMapObj::unselect();
-	// Delete any messages like vymLink in StatusBar
-	mainWindow->statusMessage ("");		//this causes segfault, when MainWindow is already gone in global destructor on quitting vym
-
-	// Save current note
-	if (isNoteInEditor) getNoteFromTextEditor();
-	isNoteInEditor=false;
-
-	// reset temporary unscroll, if we have scrolled parents somewhere
-	if (parObj) ((BranchObj*)(parObj))->resetTmpUnscroll();
-
-	// Erase content of editor 
-	textEditor->setInactive();
-
-	// unselect all buttons in toolbar
-	standardFlagsDefault->updateToolbar();
-}
-*/	
-
 QString BranchObj::getSelectString()
 {
 	return model->getSelectString (this);
diff -r 7a71a914afdb -r 6d2b32f305f9 branchobj.h
--- a/branchobj.h	Thu May 07 08:48:53 2009 +0000
+++ b/branchobj.h	Wed May 13 08:26:27 2009 +0000
@@ -46,9 +46,7 @@
     virtual void calcBBoxSize();
 	virtual void setDockPos();
     
-    virtual void updateHeading ();
-
-	virtual QString saveToDir (const QString&,const QString&, const QPointF&);// Save data recursivly to tempdir
+    virtual void updateData();	//! Update represantatio of heading, flags, etc.
 
 	virtual void addXLink (XLinkObj*);
 	virtual void removeXLinkRef (XLinkObj*);// Remove ref in list
@@ -79,11 +77,6 @@
     virtual void removeBranch(BranchObj*);  
     virtual void removeBranchPtr (BranchObj*);  
 
-    virtual bool canMoveBranchUp();
-    virtual BranchObj* moveBranchUp(BranchObj*);
-    virtual bool canMoveBranchDown();
-    virtual BranchObj* moveBranchDown(BranchObj*);
-
     virtual void sortChildren();
     virtual void alignRelativeTo(const QPointF, bool alignSelf=false );
 	virtual void reposition();
@@ -107,8 +100,6 @@
 public:	
 	float angle;					// used in mainbranch to reorder mainbranches
 protected:	
-//	bool scrolled;					// true if all children are scrolled and thus invisible
-//	bool tmpUnscrolled;				// can only be true (temporary) for a scrolled subtree
 	bool includeImagesVer;			// include floatimages in bbox vertically
 	bool includeImagesHor;			// include floatimages in bbox horizontally
 };
diff -r 7a71a914afdb -r 6d2b32f305f9 branchpropwindow.cpp
--- a/branchpropwindow.cpp	Thu May 07 08:48:53 2009 +0000
+++ b/branchpropwindow.cpp	Wed May 13 08:26:27 2009 +0000
@@ -27,13 +27,14 @@
 	ui.framePenColorButton->setPixmap (pix);
 	ui.frameBrushColorButton->setPixmap (pix);
 
-	// Create Model and View to hold attributes
+	// Create Model and View to hold attributes 
+	/*
 	attributeModel = new QStandardItemModel (1,3,this);
 	attributeModel->setHeaderData(0, Qt::Horizontal, tr("Name","Branchprop window: Attribute name"));
 	attributeModel->setHeaderData(1, Qt::Horizontal, tr("Value","Branchprop window: Attribute value"));
 	attributeModel->setHeaderData(2, Qt::Horizontal, tr("Type","Branchprop window: Attribute type"));
 	ui.attributeTableView->setModel (attributeModel);
-	
+	*/
 
 	// Load Settings
 	resize (settings.value ( "/satellite/propertywindow/geometry/size", QSize(450,600)).toSize());
@@ -56,7 +57,7 @@
 	settings.setValue( "/satellite/propertywindow/showWithMain",isVisible() );
 }
 
-void BranchPropertyWindow::setBranch (BranchObj *bo)
+void BranchPropertyWindow::setBranch (BranchObj *bo)	//FIXME-2 maybe do this via signals emitted anyway from model?
 {
 	disconnectSignals();
 	branch=bo;
@@ -122,10 +123,10 @@
 		else	
 			ui.incImgHor->setCheckState (Qt::Unchecked);
 
+/*
 		// Attributes
 		attributeModel->removeRows(0, attributeModel->rowCount(), QModelIndex());
 
-/*
 		// FIXME-3 some samples for attribute testing
 		QStringList attrTypes=mapEditor->attributeTable()->getTypes();
 		for (int i=0; i<attrTypes.count()-1;i++)
@@ -241,6 +242,7 @@
     return;
 }
 
+/*
 void BranchPropertyWindow::addAttributeClicked()
 {
 	// Add empty line for adding attributes
@@ -265,6 +267,7 @@
 {
 	//FIXME-3 cout << "BPW::delete\n";
 }
+*/
 
 void BranchPropertyWindow::connectSignals()
 {
@@ -299,6 +302,7 @@
 		ui.incImgHor, SIGNAL (stateChanged( int)), 
 		this, SLOT (incImgHorChanged (int)));
 
+/*
 	// Attributes	
 	connect ( 
 		ui.addAttributeButton, SIGNAL (clicked()), 
@@ -306,6 +310,7 @@
 	connect ( 
 		ui.deleteAttributeButton, SIGNAL (clicked()), 
 		this, SLOT (deleteAttributeClicked()));
+*/		
 }
 
 
@@ -326,8 +331,10 @@
 	disconnect ( ui.incImgHor, 0,0,0);
 
 	// Attributes
+	/*
 	disconnect ( ui.addAttributeButton, 0,0,0);
 	disconnect ( ui.deleteAttributeButton, 0,0,0);
+	*/
 }
 
 
diff -r 7a71a914afdb -r 6d2b32f305f9 branchpropwindow.h
--- a/branchpropwindow.h	Thu May 07 08:48:53 2009 +0000
+++ b/branchpropwindow.h	Wed May 13 08:26:27 2009 +0000
@@ -8,7 +8,7 @@
 #include <QtGui>
 
 
-#include "attributedelegate.h"
+//#include "attributedelegate.h"
 #include "branchobj.h"
 #include "vymmodel.h"
 
@@ -32,8 +32,8 @@
 	void linkHideUnselectedChanged (int);
 	void incImgVerChanged (int);
 	void incImgHorChanged (int);
-	void addAttributeClicked();
-	void deleteAttributeClicked();
+//	void addAttributeClicked();
+//	void deleteAttributeClicked();
 
 signals:
 	void windowClosed();
@@ -53,9 +53,9 @@
 	QColor penColor;
 	QColor brushColor;
 
-	QAbstractItemModel *attributeModel;
+//	QAbstractItemModel *attributeModel;
 
-	AttributeDelegate delegate;
+//	AttributeDelegate delegate;
 };
 
 #endif // 
diff -r 7a71a914afdb -r 6d2b32f305f9 flagobj.cpp
--- a/flagobj.cpp	Thu May 07 08:48:53 2009 +0000
+++ b/flagobj.cpp	Wed May 13 08:26:27 2009 +0000
@@ -20,6 +20,13 @@
     copy (io);
 }
 
+FlagObj::FlagObj (Flag* f)
+{
+	init();
+	name=f->getName();
+	icon->load(f->getPixmap());
+}
+
 FlagObj::~FlagObj()
 {
 //   cout << "Destr FlagObj  this="<<this <<"  " << qPrintable(name) << "\n";
@@ -30,27 +37,20 @@
 void FlagObj::init ()
 {
 	name="undefined";
-	unsetGroup();
 
 	icon=new ImageObj (scene);
 	icon->setPos (absPos.x(), absPos.y() );
 	state=false;
-	used=false;
 	avis=true;
-	action=NULL;
 }
 
 void FlagObj::copy (FlagObj* other)
 {
     MapObj::copy(other);
 	name=other->name;
-	group=other->group;
-	tooltip=other->tooltip;
 	state=other->state;
 	avis=other->avis;
-	used=other->used;
 	icon->copy(other->icon);
-	action=other->action;
 	setVisibility (other->isVisibleObj() );
 }
 
@@ -99,51 +99,6 @@
 	return name;
 }
 
-void FlagObj::setGroup (const QString &n)
-{
-	group=n;
-}
-
-const QString FlagObj::getGroup()
-{
-	return group;
-}
-
-void FlagObj::unsetGroup()
-{
-	group="undefined";
-}
-
-void FlagObj::setToolTip(const QString &n)
-{
-	tooltip=n;
-}
-
-const QString FlagObj::getToolTip()
-{
-	return tooltip;
-}
-
-QPixmap FlagObj::getPixmap()
-{
-	return icon->pixmap();
-}
-
-void FlagObj::setAction (QAction* a)
-{
-	action=a;
-}
-
-void FlagObj::updateAction ()
-{
-	if (action) 
-	{
-		action->setChecked(state);
-		if (!avis)
-			action->setVisible(state);
-	}
-}
-
 void FlagObj::setAlwaysVisible(bool b)
 {
 	avis=b;
@@ -189,16 +144,6 @@
 	}	
 }
 
-void FlagObj::setUsed (bool b)
-{
-	used=b;
-}
-
-bool FlagObj::isUsed()
-{
-	return used;
-}
-
 void FlagObj::saveToDir (const QString &tmpdir, const QString &prefix)
 {
 	QString fn=tmpdir + prefix + name + ".png";
diff -r 7a71a914afdb -r 6d2b32f305f9 flagobj.h
--- a/flagobj.h	Thu May 07 08:48:53 2009 +0000
+++ b/flagobj.h	Wed May 13 08:26:27 2009 +0000
@@ -5,6 +5,7 @@
 #include <QAction>
 #include <QPixmap>
 
+#include "flag.h"
 #include "mapobj.h"
 #include "imageobj.h"
 
@@ -20,6 +21,7 @@
     FlagObj ();
     FlagObj (QGraphicsScene*);
     FlagObj (FlagObj*);
+    FlagObj (Flag*);
     ~FlagObj ();
     virtual void init ();
     virtual void copy (FlagObj*);
@@ -30,36 +32,24 @@
 	void load (const QPixmap&);
 	void setName (const QString&);
 	const QString getName ();
-	void setGroup (const QString&);
-	const QString getGroup();
-	void unsetGroup ();
-	void setToolTip(const QString&);
-	const QString getToolTip();
 	QPixmap getPixmap();
 	void setAction(QAction*);
-	void updateAction ();
 	void setAlwaysVisible (bool b);
 	bool isAlwaysVisible ();
 	bool isActive();
 	void toggle();
 	void activate();
 	void deactivate();
-	void setUsed (bool);
-	bool isUsed();
 	void saveToDir (const QString&, const QString&);
 	
 protected:	
 	QString name;
-	QString group;
-	QString tooltip;
 	bool state;
 	bool avis;
-	bool used;
     virtual void positionBBox();
     virtual void calcBBoxSize();
 private:
 	ImageObj* icon;
-	QAction* action;
 };
 
 #endif
diff -r 7a71a914afdb -r 6d2b32f305f9 flagrowobj.cpp
--- a/flagrowobj.cpp	Thu May 07 08:48:53 2009 +0000
+++ b/flagrowobj.cpp	Wed May 13 08:26:27 2009 +0000
@@ -3,6 +3,7 @@
 #include <iostream>
 using namespace std;
 
+#include "flag.h"
 #include "flagrowobj.h"
 
 #include "geometry.h"
@@ -31,30 +32,17 @@
 
 void FlagRowObj::init ()
 {
-	parentRow=NULL;
 	showFlags=true;
 }
 
 void FlagRowObj::copy (FlagRowObj* other)
 {
     MapObj::copy(other);
-	parentRow=other->parentRow;
 	flag.clear();
 	for (int i=0; i<flag.size(); ++i)
 		addFlag (flag.at(i));
 }
 
-void FlagRowObj::clone (FlagRowObj* pr)
-{
-	// Difference to copy:
-	// We don't copy the flags here, they
-	// are created on the fly by toggle and activate
-	// This saves lots of canvas objects.
-	MapObj::copy(pr);
-	flag.clear();
-	parentRow=pr;
-}
-
 void FlagRowObj::move(double x, double y)
 {
     MapObj::move(x,y);
@@ -89,6 +77,14 @@
 	return newfo;
 }
 
+QStringList FlagRowObj::activeFlagNames()
+{
+	QStringList list;
+	for (int i=0; i<flag.size(); ++i)
+		list.append (flag.at(i)->getName());
+	return list;
+}
+
 void FlagRowObj::positionBBox()
 {
     bbox.moveTopLeft(absPos );
@@ -124,84 +120,28 @@
 
 bool FlagRowObj::isActive (const QString &foname)
 {
+
 	FlagObj *fo=findFlag (foname);
-	if (parentRow && fo)
-		return fo->isActive();
+	if (fo) 
+		return true;
 	else
-		if (fo) return true;
-	return false;
+		return false;
 }
 
-void FlagRowObj::toggle (const QString &foname)
+void FlagRowObj::activate (Flag *flag)	
 {
-	FlagObj *fo=findFlag (foname);
-	if (fo)
+	if (flag) 
 	{
-		// FlagObj is here, it will be active, too.
-		// Deactivate it by removing it from this row.
-		flag.remove (fo);
-		delete (fo);
-	} else
-	{
-		// FlagObj is not present in this row.
-		// Copy it from parentRow
-		fo=parentRow->findFlag (foname);
-		if (fo)
-		{
-			fo=addFlag (fo);
-			fo->activate();
-			/*FIXME-0 move to VM if (exclusive) 
-			{
-				deactivateGroup (fo);
-				updateToolbar();
-			}
-			*/
-		} else
-			qWarning ("FlagRowObj ("+name+")::toggle ("+foname+")  failed - could not find it in parentRow");
-	}	
-	calcBBoxSize();
-	positionBBox();	
-}
-
-void FlagRowObj::activate (const QString &foname)
-{
-	cout << "FRO::activate  "<<foname.toStdString()<<endl;
-	// Note: "activate" is also called during loading of a map
-	// Here we do not check for exclusive flags!
-	FlagObj *fo=findFlag (foname);
-	if (parentRow)
-	{
-		if (!fo)
-		{
-			// FlagObj is not present in this row.
-			// Copy it from parentRow and activate there
-			fo=parentRow->findFlag (foname);
-			if (fo)
-			{
-				fo=addFlag (fo);
-				fo->activate();
-				if (showFlags) 
-					fo->setVisibility (visible);
-				else
-					fo->setVisibility (false);
-				calcBBoxSize();
-			} else
-				qWarning ("FlagRowObj ("+name+")::activate ("+foname+")  failed - could not find it in parentRow");
-		}	
-	} else
-	{
-		// I am the parentRow, mark flag as used
-		if (fo)
-		{
-			fo->setUsed(true);
-			fo->activate();
-		}	
+		FlagObj *fo=addFlag (new FlagObj (flag));
+		fo->activate();
+		if (showFlags)	// FIXME-3 necessary? only called from FIO::init
+			fo->setVisibility (visible);
 		else
-			qWarning ("FlagRowObj::activate no FlagObj \""+foname+"\" found in parentRow");
+			fo->setVisibility (false);
+		calcBBoxSize();
 	}
 }
 
-
 void FlagRowObj::deactivate (const QString &foname)
 {
 	FlagObj *fo=findFlag (foname);
@@ -214,116 +154,11 @@
 	positionBBox();
 }
 
-void FlagRowObj::deactivateAll ()
-{
-	if (!parentRow)
-	{
-		for (int i=0; i<flag.size(); ++i)
-			if (flag.at(i)->isActive()) flag.at(i)->deactivate();
-	} else
-	{
-		while (!flag.isEmpty())
-			delete flag.takeFirst();
-		calcBBoxSize();
-		positionBBox();
-	}
-}
-
-void FlagRowObj::deactivateGroup (FlagObj *keepfo)	//FIXME-0 move to VM
-{
-	// deactivate all flags in keepof, but keep keepfo [sic!]
-	if (keepfo)
-	{
-		QString g=keepfo->getGroup();
-		if (g!="undefined")
-		{
-			for (int i=0; i<flag.size(); ++i)
-				if (g==flag.at(i)->getGroup() && keepfo!=flag.at(i)) 
-				{
-					FlagObj *fo=flag.at(i);
-					flag.remove (fo);
-					delete (fo);
-				}	
-		}		
-	}	
-}
-
-void FlagRowObj::setToolBar(QToolBar *tb)
-{
-	toolbar=tb;
-}
-
-void FlagRowObj::setEnabled (bool b)
-{
-	if (toolbar)
-	{
-		toolbar->setEnabled (b);
-	}
-}
-
 void FlagRowObj::setShowFlags (bool b)
 {
 	showFlags=b;
 }
 
-void FlagRowObj::resetUsedCounter()
-{
-	for (int i=0; i<flag.size(); ++i)
-		flag.at(i)->setUsed (false);
-}
-
-QString FlagRowObj::saveToDir (const QString &tmpdir,const QString &prefix, bool writeflags)
-{
-	// Build xml string
-	QString s;
-	if (parentRow)
-		for (int i=0; i<flag.size(); ++i)
-		{
-			// save flag to xml, if flag is set 
-			s+=valueElement("standardflag",flag.at(i)->getName() );
-
-			// and tell parentRow, that this flag is used
-			parentRow->activate(flag.at(i)->getName() );
-		}	
-	else
-		// Save icons to dir, if verbose is set (xml export)
-		// and I am a parentRow 
-		// and this flag is really used somewhere
-		if (writeflags)
-			for (int i=0; i<flag.size(); ++i)
-				if (flag.at(i)->isUsed()) flag.at(i)->saveToDir (tmpdir,prefix);
-	return s;		
-
-}
-
-void FlagRowObj::setName (const QString &n)
-{
-	name=n;
-}
-
-void  FlagRowObj::updateToolbar()	//FIXME-2 this needs to be changed with VM
-{
-	if (parentRow)
-	{
-		// We are just a branch, not the toolbar default
-		// but state has to be copied from ourselves to parentrow!
-		parentRow->deactivateAll();
-		// In parentRow activate all existing (==active) flags
-		for (int i=0; i<flag.size(); ++i)
-			parentRow->activate(flag.at(i)->getName());
-		parentRow->updateToolbar();	
-	} else
-	{
-		// We are the toolbar default
-		if (toolbar)
-		{
-			// Update state of actions in toolbar
-			for (int i=0; i<flag.size(); ++i)
-				flag.at(i)->updateAction();
-		}	
-	}
-}
-
 FlagObj* FlagRowObj::findFlag (const QString &name)
 {
 	for (int i=0; i<flag.size(); ++i)
diff -r 7a71a914afdb -r 6d2b32f305f9 flagrowobj.h
--- a/flagrowobj.h	Thu May 07 08:48:53 2009 +0000
+++ b/flagrowobj.h	Wed May 13 08:26:27 2009 +0000
@@ -6,47 +6,35 @@
 //#include "mapobj.h"
 #include "flagobj.h"
 
-/*! \brief A collection of flags (FlagObj). 
+class Flag;
+
+/*! \brief A collection of flags (FlagObj) in a map. 
 
    The flags are aligned horizontally  in a row on the map. 
-   A toolbar can be created from the flags in this row.
  */
 
-class FlagRowObj:public MapObj {	// FIXME-0 move pixmaps to mainwindow or model in the end...
+class FlagRowObj:public MapObj {
 public:
     FlagRowObj ();
     FlagRowObj (QGraphicsScene *);
     ~FlagRowObj ();
     virtual void init ();
     virtual void copy (FlagRowObj*);
-    virtual void clone(FlagRowObj*);
     virtual void move   (double,double);
     virtual void moveBy (double,double);
     virtual void setVisibility(bool);
     virtual FlagObj* addFlag (FlagObj *fo);			// make deep copy of FlagObj
+	virtual QStringList activeFlagNames();
     virtual void positionBBox();
     virtual void calcBBoxSize();
 	virtual QString getFlagName (const QPointF &p);	// Find flag by position
 	bool isActive(const QString&);
-	void toggle (const QString &name);
-	void activate(const QString&);
+	void activate (Flag *flag);
 	void deactivate(const QString&);
-	void deactivateAll();
-	void deactivateGroup(FlagObj *);	//FIXME-0
-	void setToolBar (QToolBar *);		//FIXME-0
-	void setEnabled (bool);
 	void setShowFlags (bool);
-	void resetUsedCounter();
-	QString saveToDir (const QString &,const QString &,bool);
-	void setName (const QString&);			// prefix for exporting flags to dir
-	void makeToolbar (QMainWindow*, const QString &);	// Create Toolbar buttons FIXME-0
-	void updateToolbar();					// Update Toolbar buttons	FIXME-0
 private:	
-	FlagRowObj* parentRow;					// look for flags in this row
 	FlagObj* findFlag (const QString&);
     QList <FlagObj*> flag; 
-	QToolBar *toolbar;
-	QString name;
 	bool showFlags;							// FloatObjects want to hide their flags
 };
 #endif
diff -r 7a71a914afdb -r 6d2b32f305f9 main.cpp
--- a/main.cpp	Thu May 07 08:48:53 2009 +0000
+++ b/main.cpp	Wed May 13 08:26:27 2009 +0000
@@ -3,6 +3,7 @@
 #include <iostream>
 using namespace std;
 
+#include "flagrow.h"
 #include "flagrowobj.h"
 #include "mainwindow.h"
 #include "options.h"
@@ -36,9 +37,8 @@
 QString flagsPath;				// Pointing to flags
 bool clipboardEmpty;			
 bool debug;						// global debugging flag
-FlagRowObj *systemFlagsDefault;	// used to copy from in LinkableMapObj
-FlagRowObj *standardFlagsDefault;
-
+FlagRow *systemFlagsMaster;	
+FlagRow *standardFlagsMaster;	
 
 Settings settings ("InSilmaril","vym"); // Organization, Application name
 
@@ -158,11 +158,12 @@
 	translator.load( QString("vym_")+QTextCodec::locale(), vymBaseDir.path() + "/lang");
     app.installTranslator( &translator );
 
-	// Initializing the row of system flags
-	// is done in first call to MapEditor(),
-	// because we need at least one canvas first
-	systemFlagsDefault=NULL;
-	standardFlagsDefault=NULL;
+	// Initializing the master rows of flags
+	systemFlagsMaster=new FlagRow;
+	systemFlagsMaster->setName ("systemFlagsMaster");
+	standardFlagsMaster=new FlagRow;
+	standardFlagsMaster->setName ("standardFlagsMaster");
+
 
 	// Initialize window of TextEditor
 	textEditor = new TextEditor();
diff -r 7a71a914afdb -r 6d2b32f305f9 mainwindow.cpp
--- a/mainwindow.cpp	Thu May 07 08:48:53 2009 +0000
+++ b/mainwindow.cpp	Wed May 13 08:26:27 2009 +0000
@@ -12,7 +12,7 @@
 #include "exportoofiledialog.h"
 #include "exports.h"
 #include "file.h"
-#include "flagrowobj.h"
+#include "flagrow.h"
 #include "historywindow.h"
 #include "imports.h"
 #include "mapeditor.h"
@@ -43,8 +43,8 @@
 extern QString clipboardFile;
 extern bool clipboardEmpty;
 extern int statusbarTime;
-extern FlagRowObj* standardFlagsDefault;
-extern FlagRowObj* systemFlagsDefault;
+extern FlagRow *standardFlagsMaster;	
+extern FlagRow *systemFlagsMaster;
 extern QString vymName;
 extern QString vymVersion;
 extern QString vymBuildDate;
@@ -1187,229 +1187,217 @@
 {
 	// Create System Flags
 	QToolBar *tb=NULL;
-	bool avis=true;
-
-	systemFlagsDefault = new FlagRowObj ();
-	systemFlagsDefault->setVisibility (false);
-	systemFlagsDefault->setName ("systemFlagsDef");
-
-	FlagObj *fo = new FlagObj ();
-	fo->load(QPixmap(flagsPath+"flag-note.png"));
-	setupFlag (fo,tb,avis,"note",tr("Note","SystemFlag"));
-
-	fo->load(QPixmap(flagsPath+"flag-url.png"));
-	setupFlag (fo,tb,avis,"url",tr("URL to Document ","SystemFlag"));
+
+	Flag *flag=new Flag;;
+
+	flag->load(QPixmap(flagsPath+"flag-note.png"));
+	setupFlag (flag,tb,"system-note",tr("Note","SystemFlag"));
+
+	flag->load(QPixmap(flagsPath+"flag-url.png"));
+	setupFlag (flag,tb,"system-url",tr("URL to Document ","SystemFlag"));
 	
-	fo->load(QPixmap(flagsPath+"flag-vymlink.png"));
-	setupFlag (fo,tb,avis,"vymLink",tr("Link to another vym map","SystemFlag"));
-
-	fo->load(QPixmap(flagsPath+"flag-scrolled-right.png"));
-	setupFlag (fo,tb,avis,"scrolledright",tr("subtree is scrolled","SystemFlag"));
+	flag->load(QPixmap(flagsPath+"flag-vymlink.png"));
+	setupFlag (flag,tb,"system-vymLink",tr("Link to another vym map","SystemFlag"));
+
+	flag->load(QPixmap(flagsPath+"flag-scrolled-right.png"));
+	setupFlag (flag,tb,"system-scrolledright",tr("subtree is scrolled","SystemFlag"));
 	
-	fo->load(QPixmap(flagsPath+"flag-tmpUnscrolled-right.png"));
-	setupFlag (fo,tb,avis,"tmpUnscrolledright",tr("subtree is temporary scrolled","SystemFlag"));
-
-	fo->load(QPixmap(flagsPath+"flag-hideexport.png"));
-	setupFlag (fo,tb,avis,"hideInExport",tr("Hide object in exported maps","SystemFlag"));
+	flag->load(QPixmap(flagsPath+"flag-tmpUnscrolled-right.png"));
+	setupFlag (flag,tb,"system-tmpUnscrolledright",tr("subtree is temporary scrolled","SystemFlag"));
+
+	flag->load(QPixmap(flagsPath+"flag-hideexport.png"));
+	setupFlag (flag,tb,"system-hideInExport",tr("Hide object in exported maps","SystemFlag"));
 
 	// Create Standard Flags
 	tb=addToolBar (tr ("Standard Flags","Standard Flag Toolbar"));
 	tb->setObjectName ("standardFlagTB");
 
-	standardFlagsDefault = new FlagRowObj ();
-	standardFlagsDefault->setVisibility (false);
-	standardFlagsDefault->setName ("standardFlagsDef");
-	standardFlagsDefault->setToolBar (tb);
-
-	fo->load(flagsPath+"flag-exclamationmark.png");
-	fo->setGroup("standard-mark");
-	setupFlag (fo,tb,avis,"exclamationmark",tr("Take care!","Standardflag"));
 	
-	fo->load(flagsPath+"flag-questionmark.png");
-	fo->setGroup("standard-mark");
-	setupFlag (fo,tb,avis,"questionmark",tr("Really?","Standardflag"));
-
-	fo->load(flagsPath+"flag-hook-green.png");
-	fo->setGroup("standard-hook");
-	setupFlag (fo,tb,avis,"hook-green",tr("ok!","Standardflag"));
-
-	fo->load(flagsPath+"flag-cross-red.png");
-	fo->setGroup("standard-hook");
-	setupFlag (fo,tb,avis,"cross-red",tr("Not ok!","Standardflag"));
-	fo->unsetGroup();
-
-	fo->load(flagsPath+"flag-stopsign.png");
-	setupFlag (fo,tb,avis,"stopsign",tr("This won't work!","Standardflag"));
-
-	fo->load(flagsPath+"flag-smiley-good.png");
-	fo->setGroup("standard-smiley");
-	setupFlag (fo,tb,avis,"smiley-good",tr("Good","Standardflag"));
-
-	fo->load(flagsPath+"flag-smiley-sad.png");
-	fo->setGroup("standard-smiley");
-	setupFlag (fo,tb,avis,"smiley-sad",tr("Bad","Standardflag"));
-
-	fo->load(flagsPath+"flag-smiley-omg.png");
-	fo->setGroup("standard-smiley");
-	setupFlag (fo,tb,avis,"smiley-omb",tr("Oh no!","Standardflag"));
+	flag->load(flagsPath+"flag-exclamationmark.png");
+	flag->setGroup("standard-mark");
+	setupFlag (flag,tb,"exclamationmark",tr("Take care!","Standardflag"));
+	
+	flag->load(flagsPath+"flag-questionmark.png");
+	flag->setGroup("standard-mark");
+	setupFlag (flag,tb,"questionmark",tr("Really?","Standardflag"));
+
+	flag->load(flagsPath+"flag-hook-green.png");
+	flag->setGroup("standard-hook");
+	setupFlag (flag,tb,"hook-green",tr("ok!","Standardflag"));
+
+	flag->load(flagsPath+"flag-cross-red.png");
+	flag->setGroup("standard-hook");
+	setupFlag (flag,tb,"cross-red",tr("Not ok!","Standardflag"));
+	flag->unsetGroup();
+
+	flag->load(flagsPath+"flag-stopsign.png");
+	setupFlag (flag,tb,"stopsign",tr("This won't work!","Standardflag"));
+
+	flag->load(flagsPath+"flag-smiley-good.png");
+	flag->setGroup("standard-smiley");
+	setupFlag (flag,tb,"smiley-good",tr("Good","Standardflag"));
+
+	flag->load(flagsPath+"flag-smiley-sad.png");
+	flag->setGroup("standard-smiley");
+	setupFlag (flag,tb,"smiley-sad",tr("Bad","Standardflag"));
+
+	flag->load(flagsPath+"flag-smiley-omg.png");
+	flag->setGroup("standard-smiley");
+	setupFlag (flag,tb,"smiley-omb",tr("Oh no!","Standardflag"));
 	// Original omg.png (in KDE emoticons)
-	fo->unsetGroup();
-
-	fo->load(flagsPath+"flag-kalarm.png");
-	setupFlag (fo,tb,avis,"clock",tr("Time critical","Standardflag"));
-
-	fo->load(flagsPath+"flag-phone.png");
-	setupFlag (fo,tb,avis,"phone",tr("Call...","Standardflag"));
-
-	fo->load(flagsPath+"flag-lamp.png");
-	setupFlag (fo,tb,avis,"lamp",tr("Idea!","Standardflag"));
-
-	fo->load(flagsPath+"flag-arrow-up.png");
-	fo->setGroup("standard-arrow");
-	setupFlag (fo,tb,avis,"arrow-up",tr("Important","Standardflag"));
-
-	fo->load(flagsPath+"flag-arrow-down.png");
-	fo->setGroup("standard-arrow");
-	setupFlag (fo,tb,avis,"arrow-down",tr("Unimportant","Standardflag"));
-
-	fo->load(flagsPath+"flag-arrow-2up.png");
-	fo->setGroup("standard-arrow");
-	setupFlag (fo,tb,avis,"2arrow-up",tr("Very important!","Standardflag"));
-
-	fo->load(flagsPath+"flag-arrow-2down.png");
-	fo->setGroup("standard-arrow");
-	setupFlag (fo,tb,avis,"2arrow-down",tr("Very unimportant!","Standardflag"));
-	fo->unsetGroup();
-
-	fo->load(flagsPath+"flag-thumb-up.png");
-	fo->setGroup("standard-thumb");
-	setupFlag (fo,tb,avis,"thumb-up",tr("I like this","Standardflag"));
-
-	fo->load(flagsPath+"flag-thumb-down.png");
-	fo->setGroup("standard-thumb");
-	setupFlag (fo,tb,avis,"thumb-down",tr("I do not like this","Standardflag"));
-	fo->unsetGroup();
+	flag->unsetGroup();
+
+	flag->load(flagsPath+"flag-kalarm.png");
+	setupFlag (flag,tb,"clock",tr("Time critical","Standardflag"));
+
+	flag->load(flagsPath+"flag-phone.png");
+	setupFlag (flag,tb,"phone",tr("Call...","Standardflag"));
+
+	flag->load(flagsPath+"flag-lamp.png");
+	setupFlag (flag,tb,"lamp",tr("Idea!","Standardflag"));
+
+	flag->load(flagsPath+"flag-arrow-up.png");
+	flag->setGroup("standard-arrow");
+	setupFlag (flag,tb,"arrow-up",tr("Important","Standardflag"));
+
+	flag->load(flagsPath+"flag-arrow-down.png");
+	flag->setGroup("standard-arrow");
+	setupFlag (flag,tb,"arrow-down",tr("Unimportant","Standardflag"));
+
+	flag->load(flagsPath+"flag-arrow-2up.png");
+	flag->setGroup("standard-arrow");
+	setupFlag (flag,tb,"2arrow-up",tr("Very important!","Standardflag"));
+
+	flag->load(flagsPath+"flag-arrow-2down.png");
+	flag->setGroup("standard-arrow");
+	setupFlag (flag,tb,"2arrow-down",tr("Very unimportant!","Standardflag"));
+	flag->unsetGroup();
+
+	flag->load(flagsPath+"flag-thumb-up.png");
+	flag->setGroup("standard-thumb");
+	setupFlag (flag,tb,"thumb-up",tr("I like this","Standardflag"));
+
+	flag->load(flagsPath+"flag-thumb-down.png");
+	flag->setGroup("standard-thumb");
+	setupFlag (flag,tb,"thumb-down",tr("I do not like this","Standardflag"));
+	flag->unsetGroup();
 	
-	fo->load(flagsPath+"flag-rose.png");
-	setupFlag (fo,tb,avis,"rose",tr("Rose","Standardflag"));
-
-	fo->load(flagsPath+"flag-heart.png");
-	setupFlag (fo,tb,avis,"heart",tr("I just love...","Standardflag"));
-
-	fo->load(flagsPath+"flag-present.png");
-	setupFlag (fo,tb,avis,"present",tr("Surprise!","Standardflag"));
-
-	fo->load(flagsPath+"flag-flash.png");
-	setupFlag (fo,tb,avis,"flash",tr("Dangerous","Standardflag"));
+	flag->load(flagsPath+"flag-rose.png");
+	setupFlag (flag,tb,"rose",tr("Rose","Standardflag"));
+
+	flag->load(flagsPath+"flag-heart.png");
+	setupFlag (flag,tb,"heart",tr("I just love...","Standardflag"));
+
+	flag->load(flagsPath+"flag-present.png");
+	setupFlag (flag,tb,"present",tr("Surprise!","Standardflag"));
+
+	flag->load(flagsPath+"flag-flash.png");
+	setupFlag (flag,tb,"flash",tr("Dangerous","Standardflag"));
 	
 	// Original: xsldbg_output.png
-	fo->load(flagsPath+"flag-info.png");
-	setupFlag (fo,tb,avis,"info",tr("Info","Standardflag"));
+	flag->load(flagsPath+"flag-info.png");
+	setupFlag (flag,tb,"inflag",tr("Info","Standardflag"));
 
 	// Original khelpcenter.png
-	fo->load(flagsPath+"flag-lifebelt.png");
-	setupFlag (fo,tb,avis,"lifebelt",tr("This will help","Standardflag"));
+	flag->load(flagsPath+"flag-lifebelt.png");
+	setupFlag (flag,tb,"lifebelt",tr("This will help","Standardflag"));
 
 	// Freemind flags
 
-	avis=false;
-
-	fo->load(flagsPath+"freemind/warning.png");
-	setupFlag (fo,tb, avis, "freemind-warning",tr("Important","Freemind-Flag"));
+	flag->load(flagsPath+"freemind/warning.png");
+	setupFlag (flag,tb,  "freemind-warning",tr("Important","Freemind-Flag"));
 
 	for (int i=1; i<8; i++)
 	{
-		fo->load(flagsPath+QString("freemind/priority-%1.png").arg(i));
-		setupFlag (fo,tb, avis,QString("freemind-priority-%1").arg(i),tr("Priority","Freemind-Flag"));
+		flag->load(flagsPath+QString("freemind/priority-%1.png").arg(i));
+		setupFlag (flag,tb, QString("freemind-priority-%1").arg(i),tr("Priority","Freemind-Flag"));
 	}
 
-	fo->load(flagsPath+"freemind/back.png");
-	setupFlag (fo,tb,avis,"freemind-back",tr("Back","Freemind-Flag"));
-
-	fo->load(flagsPath+"freemind/forward.png");
-	setupFlag (fo,tb,avis,"freemind-forward",tr("Forward","Freemind-Flag"));
-
-	fo->load(flagsPath+"freemind/attach.png");
-	setupFlag (fo,tb,avis,"freemind-attach",tr("Look here","Freemind-Flag"));
-
-	fo->load(flagsPath+"freemind/clanbomber.png");
-	setupFlag (fo,tb,avis,"freemind-clanbomber",tr("Dangerous","Freemind-Flag"));
-
-	fo->load(flagsPath+"freemind/desktopnew.png");
-	setupFlag (fo,tb,avis,"freemind-desktopnew",tr("Don't forget","Freemind-Flag"));
-
-	fo->load(flagsPath+"freemind/flag.png");
-	setupFlag (fo,tb,avis,"freemind-flag",tr("Flag","Freemind-Flag"));
-
-
-	fo->load(flagsPath+"freemind/gohome.png");
-	setupFlag (fo,tb,avis,"freemind-gohome",tr("Home","Freemind-Flag"));
-
-
-	fo->load(flagsPath+"freemind/kaddressbook.png");
-	setupFlag (fo,tb,avis,"freemind-kaddressbook",tr("Telephone","Freemind-Flag"));
-
-	fo->load(flagsPath+"freemind/knotify.png");
-	setupFlag (fo,tb,avis,"freemind-knotify",tr("Music","Freemind-Flag"));
-
-	fo->load(flagsPath+"freemind/korn.png");
-	setupFlag (fo,tb,avis,"freemind-korn",tr("Mailbox","Freemind-Flag"));
-
-	fo->load(flagsPath+"freemind/mail.png");
-	setupFlag (fo,tb,avis,"freemind-mail",tr("Maix","Freemind-Flag"));
-
-	fo->load(flagsPath+"freemind/password.png");
-	setupFlag (fo,tb,avis,"freemind-password",tr("Password","Freemind-Flag"));
-
-	fo->load(flagsPath+"freemind/pencil.png");
-	setupFlag (fo,tb,avis,"freemind-pencil",tr("To be improved","Freemind-Flag"));
-
-	fo->load(flagsPath+"freemind/stop.png");
-	setupFlag (fo,tb,avis,"freemind-stop",tr("Stop","Freemind-Flag"));
-
-	fo->load(flagsPath+"freemind/wizard.png");
-	setupFlag (fo,tb,avis,"freemind-wizard",tr("Magic","Freemind-Flag"));
-
-	fo->load(flagsPath+"freemind/xmag.png");
-	setupFlag (fo,tb,avis,"freemind-xmag",tr("To be discussed","Freemind-Flag"));
-
-	fo->load(flagsPath+"freemind/bell.png");
-	setupFlag (fo,tb,avis,"freemind-bell",tr("Reminder","Freemind-Flag"));
-
-	fo->load(flagsPath+"freemind/bookmark.png");
-	setupFlag (fo,tb,avis,"freemind-bookmark",tr("Excellent","Freemind-Flag"));
-
-	fo->load(flagsPath+"freemind/penguin.png");
-	setupFlag (fo,tb,avis,"freemind-penguin",tr("Linux","Freemind-Flag"));
-
-	fo->load(flagsPath+"freemind/licq.png");
-	setupFlag (fo,tb,avis,"freemind-licq",tr("Sweet","Freemind-Flag"));
-
-	delete (fo);
+	flag->load(flagsPath+"freemind/back.png");
+	setupFlag (flag,tb,"freemind-back",tr("Back","Freemind-Flag"));
+
+	flag->load(flagsPath+"freemind/forward.png");
+	setupFlag (flag,tb,"freemind-forward",tr("forward","Freemind-Flag"));
+
+	flag->load(flagsPath+"freemind/attach.png");
+	setupFlag (flag,tb,"freemind-attach",tr("Look here","Freemind-Flag"));
+
+	flag->load(flagsPath+"freemind/clanbomber.png");
+	setupFlag (flag,tb,"freemind-clanbomber",tr("Dangerous","Freemind-Flag"));
+
+	flag->load(flagsPath+"freemind/desktopnew.png");
+	setupFlag (flag,tb,"freemind-desktopnew",tr("Don't flagrget","Freemind-Flag"));
+
+	flag->load(flagsPath+"freemind/flag.png");
+	setupFlag (flag,tb,"freemind-flag",tr("Flag","Freemind-Flag"));
+
+
+	flag->load(flagsPath+"freemind/gohome.png");
+	setupFlag (flag,tb,"freemind-gohome",tr("Home","Freemind-Flag"));
+
+
+	flag->load(flagsPath+"freemind/kaddressbook.png");
+	setupFlag (flag,tb,"freemind-kaddressbook",tr("Telephone","Freemind-Flag"));
+
+	flag->load(flagsPath+"freemind/knotify.png");
+	setupFlag (flag,tb,"freemind-knotify",tr("Music","Freemind-Flag"));
+
+	flag->load(flagsPath+"freemind/korn.png");
+	setupFlag (flag,tb,"freemind-korn",tr("Mailbox","Freemind-Flag"));
+
+	flag->load(flagsPath+"freemind/mail.png");
+	setupFlag (flag,tb,"freemind-mail",tr("Maix","Freemind-Flag"));
+
+	flag->load(flagsPath+"freemind/password.png");
+	setupFlag (flag,tb,"freemind-password",tr("Password","Freemind-Flag"));
+
+	flag->load(flagsPath+"freemind/pencil.png");
+	setupFlag (flag,tb,"freemind-pencil",tr("To be improved","Freemind-Flag"));
+
+	flag->load(flagsPath+"freemind/stop.png");
+	setupFlag (flag,tb,"freemind-stop",tr("Stop","Freemind-Flag"));
+
+	flag->load(flagsPath+"freemind/wizard.png");
+	setupFlag (flag,tb,"freemind-wizard",tr("Magic","Freemind-Flag"));
+
+	flag->load(flagsPath+"freemind/xmag.png");
+	setupFlag (flag,tb,"freemind-xmag",tr("To be discussed","Freemind-Flag"));
+
+	flag->load(flagsPath+"freemind/bell.png");
+	setupFlag (flag,tb,"freemind-bell",tr("Reminder","Freemind-Flag"));
+
+	flag->load(flagsPath+"freemind/bookmark.png");
+	setupFlag (flag,tb,"freemind-bookmark",tr("Excellent","Freemind-Flag"));
+
+	flag->load(flagsPath+"freemind/penguin.png");
+	setupFlag (flag,tb,"freemind-penguin",tr("Linux","Freemind-Flag"));
+
+	flag->load(flagsPath+"freemind/licq.png");
+	setupFlag (flag,tb,"freemind-licq",tr("Sweet","Freemind-Flag"));
 }
 
-void Main::setupFlag (FlagObj *fo, QToolBar *tb, bool aw, const QString &name, const QString &tooltip)
+void Main::setupFlag (Flag *flag, QToolBar *tb, const QString &name, const QString &tooltip)
 {
-	fo->setName(name);
-	fo->setToolTip (tooltip);
-	QAction *a=new QAction (fo->getPixmap(),fo->getName(),this);
+	flag->setName(name);
+	flag->setToolTip (tooltip);
+	QAction *a;
 	if (tb)
 	{
+		a=new QAction (flag->getPixmap(),name,this);
 		// StandardFlag
 		tb->addAction (a);
-		fo->setAction (a);
-		fo->setAlwaysVisible(aw);
 		a->setCheckable(true);
-		a->setObjectName(fo->getName());
+		a->setObjectName(name);
 		a->setToolTip(tooltip);
 		connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
-		standardFlagsDefault->addFlag (fo);	
+		standardFlagsMaster->addFlag (flag);	
 	} else
 	{
 		// SystemFlag
-		systemFlagsDefault->addFlag (fo);	
+		systemFlagsMaster->addFlag (flag);	
 	}
 }
+
 // Network Actions
 void Main::setupNetworkActions()
 {
@@ -2692,107 +2680,6 @@
 	}
 }
 
-
-void Main::editAttributeFinished()
-{
-	// only called from editHeading(), so there is a currentME
-
-	/*
-	MapEditor *me=currentMapEditor();
-	if (me)
-	{
-		me->setStateEditHeading (false);
-		QPoint p;	//Not used here, only to find out pos of branch
-		bool ok;
-		QString s=me->getHeading(ok,p);
-
-#if defined(Q_OS_MACX)
-#else
-		if (ok && s!=lineedit->text())
-			me->setHeading(lineedit->text());
-			
-		lineedit->releaseKeyboard();
-		lineedit->hide();
-		setFocus();
-#endif	
-		if (!actionSettingsAutoSelectNewBranch->isOn() && 
-			!prevSelection.isEmpty()) 
-			me->select(prevSelection);
-		prevSelection="";
-	}
-	*/
-}
-
-#include "attribute.h"
-#include "attributedialog.h"
-void Main::editAttribute()
-{
-/*
-	MapEditor *me=currentMapEditor();
-	if (me)
-	{
-		BranchObj *bo=me->getModel()->getSelectedBranch();
-		if (bo)
-		{
-			AttributeDialog dia(this);
-			dia.setTable (me->attributeTable() );
-			dia.setBranch (bo);
-			dia.setMode (Definition);
-			dia.updateTable();
-			dia.exec();
-		}
-	}	
-	*/
-	/*
-	if (currentMapEditor())
-	{
-		MapEditor *me=currentMapEditor();
-		QString oldSel=me->getSelectString();
-
-		if (lineedit->isVisible())
-			editAttributeFinished();
-		else
-		{
-			bool ok;
-			QPoint p;
-			QString s=me->getHeading(ok,p);
-
-			if (ok)
-			{
-				me->setStateEditHeading (true);
-#if defined(Q_OS_MACX)
-				p=me->mapToGlobal (p);
-				QDialog *d =new QDialog(NULL);
-				QLineEdit *le=new QLineEdit (d);
-				d->setWindowFlags (Qt::FramelessWindowHint);
-				d->setGeometry(p.x(),p.y(),230,25);
-				le->resize (d->width()-10,d->height());
-				le->setText (s);
-				le->selectAll();
-				connect (le, SIGNAL (returnPressed()), d, SLOT (accept()));
-				d->activateWindow();
-				d->exec();
-				me->setHeading (le->text());
-				delete (le);
-				delete (d);
-				editHeadingFinished();
-#else
-				p=me->mapTo (this,p);
-				lineedit->setGeometry(p.x(),p.y(),230,25);
-				lineedit->setText(s);
-				lineedit->setCursorPosition(1);
-				lineedit->selectAll();
-				lineedit->show();
-				lineedit->grabKeyboard();
-				lineedit->setFocus();
-#endif
-			}
-		} 
-	} // currentMapEditor()	
-
-	*/
-}
-
 void Main::openVymLinks(const QStringList &vl)
 {
 	for (int j=0; j<vl.size(); j++)
@@ -2912,13 +2799,13 @@
 void Main::editMoveUp()
 {
 	VymModel *m=currentModel();
-	if (m) m->moveBranchUp();
+	if (m) m->moveUp();
 }
 
 void Main::editMoveDown()
 {
 	VymModel *m=currentModel();
-	if (m) m->moveBranchDown();
+	if (m) m->moveDown();
 }
 
 void Main::editSortChildren()
@@ -3266,32 +3153,20 @@
 
 void Main::viewZoomReset()
 {
-	if (currentMapEditor())
-	{
-		QMatrix m;
-		m.reset();
-		currentMapEditor()->setMatrix( m );
-	}	
+	MapEditor *me=currentMapEditor();
+	if (me) me->setZoomFactorTarget (1);
 }
 
 void Main::viewZoomIn()
 {
-	if (currentMapEditor())
-	{
-		QMatrix m = currentMapEditor()->matrix();
-		m.scale( 1.25, 1.25 );
-		currentMapEditor()->setMatrix( m );
-	}	
+	MapEditor *me=currentMapEditor();
+	if (me) me->setZoomFactorTarget (me->getZoomFactorTarget()*1.25);
 }
 
 void Main::viewZoomOut()
 {
-	if (currentMapEditor())
-	{
-		QMatrix m = currentMapEditor()->matrix();
-		m.scale( 0.8, 0.8 );
-		currentMapEditor()->setMatrix( m );
-	}	
+	MapEditor *me=currentMapEditor();
+	if (me) me->setZoomFactorTarget (me->getZoomFactorTarget()*0.75);
 }
 
 void Main::viewCenter()
@@ -3523,7 +3398,7 @@
 		if (!status.isEmpty() ) statusMessage (status);
 */
 
-		// Update Toolbar // FIXME-1, was so far in BranchObj
+		// Update Toolbar // FIXME-0, was so far in BranchObj
 		//updateFlagsToolbar();
 
 		updateActions();
@@ -3640,15 +3515,13 @@
 			}
 			*/
 
-			standardFlagsDefault->setEnabled (true);
-
 			actionToggleScroll->setEnabled (true);
 			if ( selbi->isScrolled() )
 				actionToggleScroll->setOn(true);
 			else	
 				actionToggleScroll->setOn(false);
 
-/* FIXME-1 if ( selti->getURL().isEmpty() )
+			if ( selti->getURL().isEmpty() )
 			{
 				actionOpenURL->setEnabled (false);
 				actionOpenURLTab->setEnabled (false);
@@ -3667,16 +3540,16 @@
 				actionOpenVymLink->setEnabled (true);
 				actionDeleteVymLink->setEnabled (true);
 			}	
-*/
-/* FIXME-1  if (selbi->canMoveBranchUp()) 
+
+            if (selbi->canMoveUp()) 
 				actionMoveUp->setEnabled (true);
 			else	
 				actionMoveUp->setEnabled (false);
-			if (selbi->canMoveBranchDown()) 
+			if (selbi->canMoveDown()) 
 				actionMoveDown->setEnabled (true);
 			else	
 				actionMoveDown->setEnabled (false);
-*/
+
 			actionSortChildren->setEnabled (true);
 
 			actionToggleHideExport->setEnabled (true);	
@@ -3709,7 +3582,7 @@
 
 			actionCopy->setEnabled (true);
 			actionCut->setEnabled (true);	
-			actionPaste->setEnabled (false);
+			actionPaste->setEnabled (false);	//FIXME-4 why not allowing copy of images?
 			for (int i=0; i<actionListBranches.size(); ++i)	
 				actionListBranches.at(i)->setEnabled(false);
 			actionDelete->setEnabled (true);
@@ -3722,7 +3595,6 @@
 
 	} else
 	{
-		standardFlagsDefault->setEnabled (false);
 		actionFileSave->setEnabled (false);	
 		actionCopy->setEnabled (false);	
 		actionCut->setEnabled (false);	
@@ -3761,11 +3633,6 @@
 	return actionSettingsAutoSelectNewBranch->isOn();
 }
 
-bool Main::useFlagGroups()
-{
-	return actionSettingsUseFlagGroups->isOn();
-}
-
 void Main::windowShowNoteEditor()
 {
 	textEditor->setShowWithMain(true);
@@ -3816,13 +3683,18 @@
 void Main::standardFlagChanged()
 {
 	if (currentModel())
-		currentModel()->toggleStandardFlag(sender()->name());
+	{
+		if ( actionSettingsUseFlagGroups->isOn() )
+			currentModel()->toggleStandardFlag(sender()->name(),standardFlagsMaster);
+		else	
+			currentModel()->toggleStandardFlag(sender()->name());
+	}
 }
 
 void Main::testFunction1()
 {
-	//if (!currentMapEditor()) return;
-	//currentMapEditor()->testFunction1();
+	if (!currentMapEditor()) return;
+		currentMapEditor()->testFunction1();
 	//editAttribute();
 }
 
diff -r 7a71a914afdb -r 6d2b32f305f9 mainwindow.h
--- a/mainwindow.h	Thu May 07 08:48:53 2009 +0000
+++ b/mainwindow.h	Wed May 13 08:26:27 2009 +0000
@@ -5,6 +5,7 @@
 
 #include "branchpropwindow.h"
 #include "extrainfodialog.h"
+#include "flag.h"
 #include "file.h"
 #include "findwindow.h"
 #include "historywindow.h"
@@ -58,7 +59,7 @@
     void setupViewActions();
     void setupModeActions();
     void setupWindowActions();
-    void setupFlag(FlagObj *fo, QToolBar *tb, bool aw, const QString &name, const QString &tooltip);
+    void setupFlag(Flag *flag, QToolBar *tb, const QString &name, const QString &tooltip);
     void setupFlagActions();
     void setupNetworkActions();
     void setupSettingsActions();
@@ -133,11 +134,9 @@
 	void openVymLinks(const QStringList &);
 	void editVymLink();
 	void editOpenMultipleVymLinks();
-    void editAttributeFinished();
 public slots:
     void editHeadingFinished(VymModel *m);
 //    void editHeading();
-    void editAttribute();
 	void editOpenVymLink();
 private slots:
 	void editDeleteVymLink();
@@ -223,7 +222,6 @@
 	ModMode getModMode();
 	bool autoEditNewBranch();
 	bool autoSelectNewBranch();
-	bool useFlagGroups();
 	void setScript(const QString &);
 	void runScript(const QString &);
 	void runScriptEverywhere (const QString &);
diff -r 7a71a914afdb -r 6d2b32f305f9 mapcenteritem.cpp
--- a/mapcenteritem.cpp	Thu May 07 08:48:53 2009 +0000
+++ b/mapcenteritem.cpp	Wed May 13 08:26:27 2009 +0000
@@ -135,7 +135,7 @@
 
 	if (!getHeading().isEmpty() ) 
 	{
-		mco->updateHeading();
+		mco->updateData();	//FIXME-3 better call model->emitDataHasChanged(treeItem);
 		mco->setColor (headingColor);
 	}	
 		
diff -r 7a71a914afdb -r 6d2b32f305f9 mapcenterobj.cpp
--- a/mapcenterobj.cpp	Thu May 07 08:48:53 2009 +0000
+++ b/mapcenterobj.cpp	Wed May 13 08:26:27 2009 +0000
@@ -108,103 +108,3 @@
 	if (repositionRequest) reposition();
 }
 
-QString MapCenterObj::saveToDir (const QString &tmpdir,const QString &prefix, int verbose, const QPointF &offset)
-{
-    QString s,a;
-
-/*
-	// save area, if not scrolled
-	QString 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()));
-	
-	// Providing an ID for a branch makes export to XHTML easier
-	// FIXME-3
-	QString idAttr;
-	if (treeItem->xlinkCount()>0)
-		idAttr=attribut ("id",mapEditor->getModel()->getSelectString(this)); //TODO directly access model
-
-	else
-		idAttr="";
-	
-
-	QString linkAttr=getLinkAttr();
-
-    s=beginElement ("mapcenter" 
-		+getOrnXMLAttr() 
-		+areaAttr 
-//		+idAttr 
-		+getIncludeImageAttr() );
-    incIndent();
-    if (heading->getColor()!=QColor("black"))
-		a=attribut ("textColor",QColor(heading->getColor()).name() );
-    else	
-		a="";
-    
-	// Save flags. If verbose is set (export to xml dir), also write
-	// the flags as picture
-	s+=standardFlags->saveToDir(tmpdir+"/flags", "/standardFlag-", verbose);
-
-	// Save heading
-    s+=valueElement("heading", treeItem->getHeading(),a);
-
-	// Save frame
-	s+=frame->saveToDir ();
-
-	// Update of note is usually done while unselecting a branch
-	//if (isNoteInEditor) getNoteFromTextEditor();  FIXME-3
-
-	// save note
-	if (!treeItem->getNoteObj().isEmpty() )
-		s+=treeItem->getNoteObj().saveToDir();
-	
-	// Save branches
-	for (int i=0; i<treeItem->branchCount(); ++i)
-		s+=treeItem->getBranchObjNum(i)->saveToDir(tmpdir,prefix, offset);
-
-	// Save FloatImages
-	for (int i=0; i<floatimage.size(); ++i)
-		s+=floatimage.at(i)->saveToDir (tmpdir,prefix);
-
-	// Save XLinks
-	for (int i=0;i<xlink.size(); ++i)
-		s+=xlink.at(i)->saveToDir();
-
-    decIndent();
-    s+=endElement   ("mapcenter");
-	*/
-    return s;
-}
-
-void MapCenterObj::setVersion (const QString &s)
-{
-	version=s;
-}
-
-void MapCenterObj::setAuthor (const QString &s)
-{
-	author=s;
-}
-
-QString MapCenterObj::getAuthor()
-{
-	return author;
-}
-
-void MapCenterObj::setComment (const QString &s)
-{
-	comment=s;
-}
-
-QString MapCenterObj::getComment ()
-{
-	return comment;
-}
-
-QString MapCenterObj::getDate ()
-{
-	return QDate::currentDate().toString ("yyyy-MM-dd");
-}
-
diff -r 7a71a914afdb -r 6d2b32f305f9 mapcenterobj.h
--- a/mapcenterobj.h	Thu May 07 08:48:53 2009 +0000
+++ b/mapcenterobj.h	Wed May 13 08:26:27 2009 +0000
@@ -27,17 +27,5 @@
     virtual void moveAllBy (double,double);
     virtual void updateLink();
     virtual void updateRelPositions();
-	virtual QString saveToDir (const QString&,const QString&,int, const QPointF&);// Save data recursivly to tempdir
-	void setVersion(const  QString &);
-	void setAuthor  (const QString &);
-	QString getAuthor ();
-	void setComment (const QString &);
-	QString getComment ();
-	QString getDate();
-private:
-	QString version;	//!< version string saved in vym file
-	QString author;
-	QString comment;
-	QDate date;
 };
 #endif
diff -r 7a71a914afdb -r 6d2b32f305f9 mapeditor.cpp
--- a/mapeditor.cpp	Thu May 07 08:48:53 2009 +0000
+++ b/mapeditor.cpp	Wed May 13 08:26:27 2009 +0000
@@ -19,7 +19,6 @@
 extern QString clipboardFile;
 extern bool clipboardEmpty;
 extern bool debug;
-extern FlagRowObj *standardFlagsDefault;
 
 extern QMenu* branchContextMenu;
 extern QMenu* branchAddContextMenu;
@@ -41,6 +40,8 @@
 	mapScene= new QGraphicsScene(NULL);
 	mapScene->setBackgroundBrush (QBrush(Qt::white, Qt::SolidPattern));
 
+	zoomFactor=zoomFactorTarget=1;
+
 	model=vm;
 	model->setScene (mapScene);
 	model->registerEditor(this);
@@ -147,6 +148,105 @@
     return mapScene;
 }
 
+void MapEditor::setScrollBarPosTarget (const QRectF &rect)
+{
+	// Code copied from Qt sources
+	int xmargin=50;
+	int ymargin=50;
+
+    qreal width = viewport()->width();
+    qreal height = viewport()->height();
+    QRectF viewRect = matrix().mapRect(rect);
+
+    qreal left = horizontalScrollBar()->value();
+    qreal right = left + width;
+    qreal top = verticalScrollBar()->value();
+    qreal bottom = top + height;
+
+    if (viewRect.left() <= left + xmargin) {
+        // need to scroll from the left
+  //      if (!d->leftIndent)
+            scrollBarPosTarget.setX(int(viewRect.left() - xmargin - 0.5));
+    }
+    if (viewRect.right() >= right - xmargin) {
+        // need to scroll from the right
+//        if (!d->leftIndent)
+            scrollBarPosTarget.setX(int(viewRect.right() - width + xmargin + 0.5));
+    }
+    if (viewRect.top() <= top + ymargin) {
+        // need to scroll from the top
+   //     if (!d->topIndent)
+            scrollBarPosTarget.setY(int(viewRect.top() - ymargin - 0.5));
+    }
+    if (viewRect.bottom() >= bottom - ymargin) {
+        // need to scroll from the bottom
+//        if (!d->topIndent)
+            scrollBarPosTarget.setY(int(viewRect.bottom() - height + ymargin + 0.5));
+    }
+
+	if (scrollBarPosAnimation.state()==QtAbstractAnimation::Running)
+		scrollBarPosAnimation.stop();
+	scrollBarPosAnimation.setTargetObject (this);
+	scrollBarPosAnimation.setPropertyName ("scrollBarPos");
+	scrollBarPosAnimation.setDuration(1000);
+	scrollBarPosAnimation.setEasingCurve ( QtEasingCurve::OutQuint);
+	scrollBarPosAnimation.setStartValue(
+		QPointF (horizontalScrollBar()->value() ,
+		         verticalScrollBar()->value() ) );
+	scrollBarPosAnimation.setEndValue(scrollBarPosTarget);
+	scrollBarPosAnimation.start();
+}
+
+QPointF MapEditor::getScrollBarPosTarget()
+{
+    return scrollBarPosTarget;
+}
+
+
+void MapEditor::setScrollBarPos(const QPointF &p)
+{
+    scrollBarPos=p;
+	horizontalScrollBar()->setValue(int(p.x()));
+	verticalScrollBar()->setValue(int(p.y()));
+}
+
+QPointF MapEditor::getScrollBarPos()
+{
+    return scrollBarPos;
+}
+
+void MapEditor::setZoomFactorTarget (const qreal &zft)
+{
+	zoomFactorTarget=zft;
+	if (zoomAnimation.state()==QtAbstractAnimation::Running)
+		zoomAnimation.stop();
+	//zoomAnimation=QtPropertyAnimation(this, "zoomFactor");
+	zoomAnimation.setTargetObject (this);
+	zoomAnimation.setPropertyName ("zoomFactor");
+	zoomAnimation.setDuration(1000);
+	zoomAnimation.setEasingCurve ( QtEasingCurve::OutQuint);
+	zoomAnimation.setStartValue(zoomFactor);
+	zoomAnimation.setEndValue(zft);
+	zoomAnimation.start();
+}
+
+qreal MapEditor::getZoomFactorTarget()
+{
+    return zoomFactorTarget;
+}
+
+
+void MapEditor::setZoomFactor(const qreal &zf)
+{
+    zoomFactor=zf;
+	setMatrix (QMatrix(zf, 0, 0, zf, 0, 0),false );
+}
+
+qreal MapEditor::getZoomFactor()
+{
+    return zoomFactor;
+}
+
 void MapEditor::print()
 {
 	if ( !printer ) 
@@ -273,42 +373,70 @@
 
 void MapEditor::testFunction1()
 {
-	BranchItem *cur=NULL;
-	BranchItem *prev=NULL;
-	int d;
-	cout << "ME::testFunction1  starting to walk the map...\n";
-	while (model->next (cur,prev,d) )
-		cout << "*** " <<cur->getHeading().toStdString()<<endl;
+	
+	// Code copied from Qt sources
+	QRectF rect=model->getSelectedBranchObj()->getBBox();
+	int xmargin=50;
+	int ymargin=50;
 
+    qreal width = viewport()->width();
+    qreal height = viewport()->height();
+    QRectF viewRect = matrix().mapRect(rect);
 
-	//BranchObj *bo=model->getSelectedBranchObj();
-	//if (bo) model->moveAway (bo);
-	//if (bo) bo->setLinkStyle (LinkableMapObj::Line);
-	
+    qreal left = horizontalScrollBar()->value();
+    qreal right = left + width;
+    qreal top = verticalScrollBar()->value();
+    qreal bottom = top + height;
 
+    if (viewRect.left() <= left + xmargin) {
+        // need to scroll from the left
+  //      if (!d->leftIndent)
+            horizontalScrollBar()->setValue(int(viewRect.left() - xmargin - 0.5));
+    }
+    if (viewRect.right() >= right - xmargin) {
+        // need to scroll from the right
+//        if (!d->leftIndent)
+            horizontalScrollBar()->setValue(int(viewRect.right() - width + xmargin + 0.5));
+    }
+    if (viewRect.top() <= top + ymargin) {
+        // need to scroll from the top
+   //     if (!d->topIndent)
+            verticalScrollBar()->setValue(int(viewRect.top() - ymargin - 0.5));
+    }
+    if (viewRect.bottom() >= bottom - ymargin) {
+        // need to scroll from the bottom
+//        if (!d->topIndent)
+            verticalScrollBar()->setValue(int(viewRect.bottom() - height + ymargin + 0.5));
+    }
+	cout << "test1:  hor="<<horizontalScrollBar()->value()<<endl;
+	cout << "test1:  ver="<<verticalScrollBar()->value()<<endl;
+}
 /*
-	// Displacement and animation of all non-mainbranches
-	QPointF p;
-	QPointF q;
-	BranchObj *bo;
-	TreeItem *cur=NULL;
-	TreeItem *prev=NULL;
-	int d;
-	while (cur) 
-	{
-		bo=(BranchObj*)(cur->getLMO());
+	 QtPropertyAnimation *animation=new QtPropertyAnimation(this, "sceneRect");
+	 animation->setDuration(5000);
+	 //animation->setEasingCurve ( QtEasingCurve::OutElastic);
+	 animation->setEasingCurve ( QtEasingCurve::OutQuint);
+	 animation->setStartValue(sceneRect() );
+	 animation->setEndValue(QRectF(50, 50, 1000, 1000));
 
-		if (cur->depth() >0 && !bo->hasScrolledParent(bo) )
-		{
-			p=QPointF (qrand() %600-300, qrand () %600-300);
-			bo->setRelPos();
-			q=bo->getRelPos();
-			model->startAnimation (bo,p, q);
-		}
-		model->next(cur,prev,d);
-	}
-*/
+	 animation->start();
+*/	 
+/*
+	QDialog *dia= new QDialog (this);
+	dia->setGeometry (50,50,10,10);
 
+     dia->show();
+     dia ->raise();
+
+	 QtPropertyAnimation *animation=new QtPropertyAnimation(dia, "geometry");
+	 animation->setDuration(1000);
+	 //animation->setEasingCurve ( QtEasingCurve::OutElastic);
+	 animation->setEasingCurve ( QtEasingCurve::OutQuint);
+	 animation->setStartValue(QRect(50, 50, 10, 10));
+	 animation->setEndValue(QRect(250, 250, 100, 100));
+
+	 animation->start();
+ */
 
 /* TODO Hide hidden stuff temporary, maybe add this as regular function somewhere
 	if (hidemode==HideNone)
@@ -335,7 +463,6 @@
 	}	
 	cout <<"  hidemode="<<hidemode<<endl;
 	*/
-}	
 	
 void MapEditor::testFunction2()
 {
@@ -885,40 +1012,43 @@
 				QString preParStr=model->getSelectString (bsel->getParObj());
 				QString preNum=QString::number (seli->num(),10);
 				QString preDstParStr;
+				bool relinked;
 
 				if (e->state() & Qt::ShiftModifier && dst->getParObj())
 				{	// Link above dst
 					preDstParStr=model->getSelectString (dst->getParObj());
-					model->relinkBranch ((BranchItem*)seli,(BranchItem*)dsti->parent(),((BranchItem*)dsti)->num());
+					relinked=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());
-					model->relinkBranch ((BranchItem*)seli,(BranchItem*)dsti->parent(),((BranchItem*)seli)->num()+1);
+					relinked=model->relinkBranch ((BranchItem*)seli,(BranchItem*)dsti->parent(),((BranchItem*)dsti)->num()+1);
 				} else	
 				{	// Append to dst
 					preDstParStr=model->getSelectString(dst);
-					model->relinkBranch ((BranchItem*)seli,(BranchItem*)dsti);
+					relinked=model->relinkBranch ((BranchItem*)seli,(BranchItem*)dsti);
 					if (dsti->depth()==0) bsel->move (savePos);
 				} 
-				QString postSelStr=model->getSelectString(lmosel);
-				QString postNum=QString::number (seli->num(),10);
+				if (relinked)
+				{
+					QString postSelStr=model->getSelectString(lmosel);
+					QString postNum=QString::number (seli->num(),10);
 
-				QString undoCom="linkTo (\""+ 
-					preParStr+ "\"," + preNum  +"," + 
-					QString ("%1,%2").arg(movingObj_orgPos.x()).arg(movingObj_orgPos.y())+ ")";
+					QString undoCom="linkTo (\""+ 
+						preParStr+ "\"," + preNum  +"," + 
+						QString ("%1,%2").arg(movingObj_orgPos.x()).arg(movingObj_orgPos.y())+ ")";
 
-				QString redoCom="linkTo (\""+ 
-					preDstParStr + "\"," + postNum + "," +
-					QString ("%1,%2").arg(savePos.x()).arg(savePos.y())+ ")";
+					QString redoCom="linkTo (\""+ 
+						preDstParStr + "\"," + postNum + "," +
+						QString ("%1,%2").arg(savePos.x()).arg(savePos.y())+ ")";
 
-				model->saveState (
-					postSelStr,undoCom,
-					preSelStr, redoCom,
-					QString("Relink %1 to %2").arg(model->getObjectName(bsel)).arg(model->getObjectName(dst)) );
+					model->saveState (
+						postSelStr,undoCom,
+						preSelStr, redoCom,
+						QString("Relink %1 to %2").arg(model->getObjectName(bsel)).arg(model->getObjectName(dst)) );
 
-				model->reposition();	// not necessary if we undo temporary move  below
+				}
 			} else
 			{
 				// No destination, undo  temporary move
@@ -1135,7 +1265,7 @@
 	if (ti->isBranchLikeType())
 	{
 		BranchObj *bo=(BranchObj*)ti->getLMO();
-		bo->updateHeading();
+		bo->updateData();
 	}
 
 }
diff -r 7a71a914afdb -r 6d2b32f305f9 mapeditor.h
--- a/mapeditor.h	Thu May 07 08:48:53 2009 +0000
+++ b/mapeditor.h	Wed May 13 08:26:27 2009 +0000
@@ -4,6 +4,8 @@
 #include <QGraphicsView>
 #include <QItemSelectionModel>
 
+#include <QtPropertyAnimation>	//! Not yet officially in Qt!
+
 #include "attribute.h"
 #include "ornamentedobj.h"
 #include "settings.h"
@@ -12,8 +14,11 @@
 
 /*! \brief Main widget in vym to display and edit a map */
 
-class MapEditor : public QGraphicsView  {	
+
+class MapEditor : public QGraphicsView {	
     Q_OBJECT
+	Q_PROPERTY(qreal zoomFactor READ getZoomFactor WRITE setZoomFactor)
+	Q_PROPERTY(QPointF scrollBarPos READ getScrollBarPos WRITE setScrollBarPos)
 
 public:
     MapEditor(VymModel *vm);
@@ -21,6 +26,26 @@
 	VymModel* getModel();
 	QGraphicsScene * getScene();
 
+protected:
+	QPointF scrollBarPos;
+	QPointF scrollBarPosTarget;
+	QtPropertyAnimation scrollBarPosAnimation;
+public:
+	void setScrollBarPosTarget (const QRectF &rect);	//!  ensureVisible of rect
+	QPointF getScrollBarPosTarget ();
+	void setScrollBarPos (const QPointF &p);
+	QPointF getScrollBarPos();
+
+protected:
+	qreal zoomFactor;
+	qreal zoomFactorTarget;
+	QtPropertyAnimation zoomAnimation;
+public:
+	void setZoomFactorTarget (const qreal &zf);
+	qreal getZoomFactorTarget();
+	void setZoomFactor (const qreal &zf);
+	qreal getZoomFactor();
+
 public:
     void print();				//!< Print the map
 	void setAntiAlias (bool);	//!< Set or unset antialiasing
diff -r 7a71a914afdb -r 6d2b32f305f9 ornamentedobj.cpp
--- a/ornamentedobj.cpp	Thu May 07 08:48:53 2009 +0000
+++ b/ornamentedobj.cpp	Wed May 13 08:26:27 2009 +0000
@@ -6,9 +6,6 @@
 #include "linkablemapobj.h"
 
 extern TextEditor *textEditor;
-extern FlagRowObj *systemFlagsDefault;
-extern FlagRowObj *standardFlagsDefault;
-
 
 /////////////////////////////////////////////////////////////////
 // OrnamentedObj
@@ -46,20 +43,9 @@
 	heading->move (absPos.x(), absPos.y());
 
 	systemFlags=new FlagRowObj(scene);
-	systemFlags->clone(systemFlagsDefault);
-	systemFlags->setName ("systemFlags");
-	
 	standardFlags=new FlagRowObj(scene);
-	standardFlags->clone(standardFlagsDefault);
-	standardFlags->setName ("standardFlags");
-
-	attributes.clear();
 
 	frame = new FrameObj (scene);
-
-	url="";
-	vymLink="";
-	
 }
 
 void OrnamentedObj::copy (OrnamentedObj* other)
@@ -72,9 +58,6 @@
 	standardFlags->copy (other->standardFlags);
 
 	ornamentsBBox=other->ornamentsBBox;
-
-	url=other->url;
-	vymLink=other->vymLink;
 }
 
 void OrnamentedObj::setLinkColor()
@@ -246,90 +229,9 @@
 	move2RelPos (p.x(),p.y());
 }
 
-void OrnamentedObj::setURL(QString s)
+void OrnamentedObj::activateStandardFlag(Flag *flag)
 {
-	url=s;
-	if (!url.isEmpty())
-		systemFlags->activate("url");
-	else	
-		systemFlags->deactivate("url");
-	calcBBoxSize();			// recalculate bbox
-    positionBBox();			// rearrange contents
-	forceReposition();
-}
-
-QString OrnamentedObj::getURL()
-{
-	return url;
-}
-
-void OrnamentedObj::setVymLink(QString s)
-{
-	if (!s.isEmpty())
-	{
-		// We need the relative (from loading) 
-		// or absolute path (from User event)
-		// and build the absolute path.
-		// Note: If we have relative, use path of
-		// current map to build absolute path
-		QDir d(s);
-		if (!d.path().startsWith ("/"))
-		{
-			QString p=model->getDestPath();
-			int i=p.findRev("/",-1);
-			d.setPath(p.left(i)+"/"+s);
-			d.convertToAbs();
-		}
-		vymLink=d.path();
-		systemFlags->activate("vymLink");
-	}	
-	else	
-	{
-		systemFlags->deactivate("vymLink");
-		vymLink="";
-	}	
-	calcBBoxSize();			// recalculate bbox
-    positionBBox();			// rearrange contents
-	forceReposition();
-}
-
-QString OrnamentedObj::getVymLink()
-{
-	return vymLink;
-}
-
-
-void OrnamentedObj::setAttributes (const QList <Attribute> &al)
-{
-	attributes=al;
-}
-
-QList <Attribute> OrnamentedObj::getAttributes()
-{
-	return attributes;
-}
-
-void OrnamentedObj::clearStandardFlags()
-{
-	standardFlags->deactivateAll();
-	calcBBoxSize();
-	positionBBox();
-	move (absPos.x(), absPos.y() );
-	forceReposition();
-}
-
-void OrnamentedObj::toggleStandardFlag(const QString &name)
-{
-	standardFlags->toggle(name);
-	calcBBoxSize();
-	positionBBox();
-	move (absPos.x(), absPos.y() );
-	forceReposition();
-}
-
-void OrnamentedObj::activateStandardFlag(const QString &name)
-{
-	standardFlags->activate(name);
+	standardFlags->activate(flag);
 	calcBBoxSize();
 	positionBBox();
 	move (absPos.x(), absPos.y() );
@@ -345,22 +247,12 @@
 	forceReposition();
 }
 
-bool OrnamentedObj::isSetStandardFlag (const QString &name)
-{
-	return standardFlags->isActive(name);
-}
 
 QString OrnamentedObj::getSystemFlagName(const QPointF &p)
 {
 	return systemFlags->getFlagName(p);	
 }
 
-bool OrnamentedObj::isActiveFlag (const QString &name)
-{
-	if (standardFlags->isActive (name) ) return true;
-	return false;
-}
-
 /* FIXME-3 should move to VymView ?!  void OrnamentedObj::getNoteFromTextEditor ()
 {
 	note.setFilenameHint (textEditor->getFilename());
@@ -369,41 +261,7 @@
 }
 */
 
-void OrnamentedObj::updateSystemFlags()
-{
-	// FIXME-3 check if note here and text in editor are still in sync!!	
-	// Best would be to always have current text here...
-	bool noteEmpty=treeItem->getNoteObj().isEmpty();
-	/*
-	if (isNoteInEditor)
-		noteEmpty=textEditor->isEmpty();
-	else	
-		noteEmpty=note.isEmpty();
-	*/	
-
-	if (!noteEmpty)
-	{	
-		if (systemFlags->isActive ("note")) return;
-		systemFlags->activate("note");
-	}	
-	else		
-	{	
-		if (!systemFlags->isActive ("note")) return;
-		systemFlags->deactivate("note");
-	}	
-	//model->setChanged();
-	calcBBoxSize();
-	positionBBox();	
-	move (absPos.x(), absPos.y() );
-	forceReposition();
-}	
-
-void OrnamentedObj::updateFlagsToolbar()
-{
-	standardFlags->updateToolbar();
-}
-
-QString OrnamentedObj::getOrnXMLAttr()
+QString OrnamentedObj::getOrnXMLAttr()	//FIXME-2
 {
 	QString posAttr;
 
@@ -424,20 +282,12 @@
 			posAttr="";
 	}	
 
-	QString urlAttr;
-	if (!url.isEmpty())
-		urlAttr=attribut ("url",url);
-
-	QString vymLinkAttr;
-	if (!vymLink.isEmpty())
-		vymLinkAttr=attribut ("vymLink",convertToRel(model->getDestPath(),vymLink) );
-
 /* FIXME-2 QString hideExpAttr;
 	if (hideExport)
 		hideExpAttr= attribut("hideInExport","true");
 	else	
 		hideExpAttr="";
 */
-	return posAttr +urlAttr +vymLinkAttr +getLinkAttr() ;//+hideExpAttr;
+	return posAttr +getLinkAttr() ;//+hideExpAttr;
 }
 
diff -r 7a71a914afdb -r 6d2b32f305f9 ornamentedobj.h
--- a/ornamentedobj.h	Thu May 07 08:48:53 2009 +0000
+++ b/ornamentedobj.h	Wed May 13 08:26:27 2009 +0000
@@ -11,8 +11,6 @@
 	- frame
 	- note
 	- references
-		- URL
-		-vymLink
 	- flags
 		- standard flags
 		- system flags
@@ -53,24 +51,9 @@
     virtual void move2RelPos (QPointF);		// move relativly to parent^
     virtual void move2RelPos (double,double);
 
-    virtual void setURL (QString);
-    virtual QString getURL ();
-
-    virtual void setVymLink (QString);
-    virtual QString getVymLink ();
-
-	virtual void setAttributes (const QList <Attribute> &al);
-	virtual QList <Attribute> getAttributes ();
-
-	virtual void clearStandardFlags();
-	virtual void toggleStandardFlag(const QString &name);
-	virtual void activateStandardFlag(const QString &name);
+	virtual void activateStandardFlag(Flag *flag);
 	virtual void deactivateStandardFlag(const QString &name);
-	virtual bool isSetStandardFlag(const QString &name);
 	virtual QString getSystemFlagName (const QPointF &p);
-	virtual bool isActiveFlag(const QString&);	// check if flag is set
-	virtual void updateSystemFlags();
-	virtual void updateFlagsToolbar();
 
 	//virtual void getNoteFromTextEditor ();// FIXME-3 should move to vymview?!
 	virtual QString getOrnXMLAttr();		// get attributes for saveToDir
@@ -81,9 +64,6 @@
 	FlagRowObj *standardFlags;		// Standard Flags
 	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-3 remove this
-	QList <Attribute> attributes;	// List with attributes
 };
 
 #endif
diff -r 7a71a914afdb -r 6d2b32f305f9 treeitem.cpp
--- a/treeitem.cpp	Thu May 07 08:48:53 2009 +0000
+++ b/treeitem.cpp	Wed May 13 08:26:27 2009 +0000
@@ -278,20 +278,72 @@
 	return headingColor;
 }
 
-void TreeItem::setNote(const QString s)
+void TreeItem::setURL (const QString &u)
 {
-	note.setNote(s);
-	// updateNoteFlag();  FIXME-2 needed?
-	if (model) 
-		model->emitNoteHasChanged (this);
+	url=u;
+	if (!url.isEmpty())
+		systemFlags.activate ("system-url");
+	else
+		systemFlags.deactivate ("system-url");
+}
+
+QString TreeItem::getURL ()
+{
+	return url;
+}
+
+void TreeItem::setVymLink (const QString &vl)
+{
+	if (!vl.isEmpty())
+	{
+		// We need the relative (from loading) 
+		// or absolute path (from User event)
+		// and build the absolute path.
+		// Note: If we have relative, use path of
+		// current map to build absolute path
+		QDir d(vl);
+		if (!d.path().startsWith ("/"))
+		{
+			QString p=model->getDestPath();
+			int i=p.findRev("/",-1);
+			d.setPath(p.left(i)+"/"+vl);
+			d.convertToAbs();
+		}
+		vymLink=d.path();
+		systemFlags.activate("system-vymLink");
+	}	
+	else	
+	{
+		systemFlags.deactivate("system-vymLink");
+		vymLink.clear();
+	}	
+}
+
+QString TreeItem::getVymLink ()
+{
+	return vymLink;
+}
+
+void TreeItem::setNote(const QString &s)
+{
+	NoteObj n;
+	n.setNote(s);
+	setNoteObj (n,false);
+}
+
+void TreeItem::clearNote()
+{
+	note.clear();
+	systemFlags.deactivate ("system-note");
 }
 
 void TreeItem::setNoteObj(const NoteObj &n, bool updateNoteEditor)
 {
 	note=n;
-	// updateNoteFlag();  FIXME-2 needed?
-	if (model && updateNoteEditor)	
-		model->emitNoteHasChanged (this);
+	if (!note.isEmpty() && !systemFlags.isActive ("system-note"))
+		systemFlags.activate ("system-note");
+	if (note.isEmpty() && systemFlags.isActive ("system-note"))
+		systemFlags.deactivate ("system-note");
 }
 
 QString TreeItem::getNote()
@@ -321,28 +373,26 @@
 
 void TreeItem::activateStandardFlag (const QString &name)
 {
-	cout << "TI::activateStandardFlag "<<name.toStdString()<<" for item "<<getHeadingStd()<<endl;
-	cout << "   lmo="<<lmo<< "  "<<isBranchLikeType()<<endl;
 	standardFlags.activate (name);
-	if (lmo &&isBranchLikeType() ) 
-		((BranchObj*)lmo)->activateStandardFlag (name);
+	model->emitDataHasChanged(this);
 }
 
 void TreeItem::deactivateStandardFlag (const QString &name)
 {
-	cout << "TI::deactivateStandardFlag "<<name.toStdString()<<" for item "<<getHeadingStd()<<endl;
 	standardFlags.deactivate (name);
-	if (lmo &&isBranchLikeType() ) 
-		((BranchObj*)lmo)->deactivateStandardFlag (name);
+	model->emitDataHasChanged(this);
 }
 
-void TreeItem::toggleStandardFlag(const QString &name)
+void TreeItem::deactivateAllStandardFlags ()
 {
-	cout << "TI::toggleStandardFlag "<<name.toStdString()<<" for item "<<getHeadingStd()<<endl;
-	if (standardFlags.isActive (name))
-		deactivateStandardFlag (name);
-	else	
-		activateStandardFlag (name);
+	standardFlags.deactivateAll ();
+	model->emitDataHasChanged(this);
+}
+
+void TreeItem::toggleStandardFlag(const QString &name, FlagRow *master)
+{
+	standardFlags.toggle (name,master);
+	model->emitDataHasChanged(this);
 }
 
 bool TreeItem::isActiveStandardFlag (const QString &name)
@@ -350,6 +400,52 @@
 	return standardFlags.isActive (name);
 }
 
+QStringList TreeItem::activeStandardFlagNames ()
+{
+	return standardFlags.activeFlagNames();
+}
+
+QStringList TreeItem::activeSystemFlagNames ()	//FIXME-1 missing: scrolled-tmp,hideInExport
+{
+	return systemFlags.activeFlagNames();
+}
+
+bool TreeItem::canMoveDown()
+{
+	switch (type)
+	{
+		case Undefined: return false;
+		case MapCenter: 
+		case Branch: 
+			if (!parentItem) return false;
+			if (parentItem->num (this) < parentItem->branchCount()-1)
+				return true;
+			else
+				return false;
+			break;	
+		case Image: return false;
+		default: return false;
+	}
+}
+
+bool TreeItem::canMoveUp()
+{
+	switch (type)
+	{
+		case Undefined: return false;
+		case MapCenter: 
+		case Branch: 
+			if (!parentItem) return false;
+			if (parentItem->num (this) > 0)
+				return true;
+			else
+				return false;
+			break;	
+		case Image: return false;
+		default: return false;
+	}
+}
+
 void TreeItem::setID (const QString &s)
 {
 	objID=s;
diff -r 7a71a914afdb -r 6d2b32f305f9 treeitem.h
--- a/treeitem.h	Thu May 07 08:48:53 2009 +0000
+++ b/treeitem.h	Wed May 13 08:26:27 2009 +0000
@@ -25,7 +25,8 @@
     ~TreeItem();
 	void init();
 
-	virtual QString saveToDir (const QString &tmpdir,const QString &prefix, const QPointF& offset);
+	virtual QString saveToDir (const QString &tmpdir=QString(),const
+	QString &prefix=QString(), const QPointF& offset=QPointF());
 
 
 	// General housekeeping
@@ -65,6 +66,7 @@
 // Accessing data
     virtual QVariant data(int column) const;
 
+
 protected:
 	QColor headingColor;
 public:	
@@ -74,10 +76,26 @@
 	virtual void setHeadingColor(QColor color);	//! Set color of heading. In BranchItem overloaded to update QGraphicsView
 	virtual QColor getHeadingColor();			//! Returns color of heading
 
+
+protected:
+	QString url;
+public:
+	void setURL (const QString &url);			//! Set URL
+	QString getURL ();							//! Get URL
+
+
+protected:
+	QString vymLink;
+public:
+	void setVymLink (const QString &url);			//! Set URL
+	QString getVymLink ();							//! Get URL
+
+
 protected:
 	NoteObj note;
 public:	
-	virtual void setNote(const QString s);
+	virtual void setNote(const QString &s);
+	virtual void clearNote();
 	virtual QString getNote();
 	virtual void setNoteObj(const NoteObj &, bool updateNoteEditor=true);
 	virtual NoteObj getNoteObj();			
@@ -85,15 +103,27 @@
     virtual QString getNoteASCII();			// returns note	(ASCII)
     virtual QString getNoteOpenDoc();		// returns note	(OpenDoc)
 
+
 protected:
 	FlagRow standardFlags;
+	FlagRow systemFlags;
 public:	
 	virtual void activateStandardFlag(const QString &flag);
 	virtual void deactivateStandardFlag(const QString &flag);
-	virtual void toggleStandardFlag(const QString &flag);
+	virtual void deactivateAllStandardFlags();
+
+	/*! \brief Toggle a Flag 
+	    If master is not NULL,, only one Flag from FlagRow master may 
+		be active simultanously, the others get deactivated.
+	*/	
+	virtual void toggleStandardFlag(const QString &flag, FlagRow *master=NULL);
 	virtual bool isActiveStandardFlag (const QString &flag);
+	virtual QStringList activeStandardFlagNames();
+	virtual QStringList activeSystemFlagNames();
 
 
+	virtual bool canMoveDown();
+	virtual bool canMoveUp();
 
 protected:
 	QString objID;					//! id set during load/save currently used for xLinks
diff -r 7a71a914afdb -r 6d2b32f305f9 version.h
--- a/version.h	Thu May 07 08:48:53 2009 +0000
+++ b/version.h	Wed May 13 08:26:27 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-01"
+#define __VYM_BUILD_DATE "2009-05-13"
 
 
 bool checkVersion(const QString &);
diff -r 7a71a914afdb -r 6d2b32f305f9 vym.pro
--- a/vym.pro	Thu May 07 08:48:53 2009 +0000
+++ b/vym.pro	Wed May 13 08:26:27 2009 +0000
@@ -4,6 +4,12 @@
 CONFIG	+= qt warn_on release debug
 CONFIG += x86 ppc
 
+
+include (/data/qtanimationframework-2.3-opensource/src/gui-animation.pri)
+include (/data/qtanimationframework-2.3-opensource/src/corelib-animation.pri)
+include (/data/qtanimationframework-2.3-opensource/src/qtanimationframework.pri)
+
+
 TRANSLATIONS += lang/vym_de.ts
 TRANSLATIONS += lang/vym_en.ts
 TRANSLATIONS += lang/vym_es.ts
@@ -29,9 +35,9 @@
 	aboutdialog.h \
 	animpoint.h \
 	attribute.h \
-	attributedelegate.h\
-	attributedialog.h \
-	attributewidget.h \
+#	attributedelegate.h\
+#	attributedialog.h \
+#	attributewidget.h \
 	branchitem.h \
 	branchobj.h \
 	branchpropwindow.h\
@@ -42,6 +48,7 @@
 	extrainfodialog.h \
 	file.h \
 	findwindow.h \
+	flag.h \
 	flagobj.h \
 	flagrowobj.h \
 	flagrow.h \
@@ -89,9 +96,9 @@
 	aboutdialog.cpp \
 	animpoint.cpp \
 	attribute.cpp \
-	attributedelegate.cpp \
-	attributedialog.cpp \
-	attributewidget.cpp \
+#	attributedelegate.cpp \
+#	attributedialog.cpp \
+#	attributewidget.cpp \
 	branchitem.cpp \
 	branchobj.cpp \
 	branchpropwindow.cpp \
@@ -102,6 +109,7 @@
 	extrainfodialog.cpp \
 	file.cpp \
 	findwindow.cpp \
+	flag.cpp \
 	flagobj.cpp \
 	flagrow.cpp \
 	flagrowobj.cpp \
diff -r 7a71a914afdb -r 6d2b32f305f9 vymmodel.cpp
--- a/vymmodel.cpp	Thu May 07 08:48:53 2009 +0000
+++ b/vymmodel.cpp	Wed May 13 08:26:27 2009 +0000
@@ -44,8 +44,6 @@
 extern QDir lastImageDir;
 extern QDir lastFileDir;
 
-extern FlagRowObj *standardFlagsDefault;
-
 extern Settings settings;
 
 
@@ -234,7 +232,7 @@
 	xml.incIndent();
 
 	// Find the used flags while traversing the tree	// FIXME-2 this can be done local to vymmodel maybe...
-	standardFlagsDefault->resetUsedCounter();
+	//FIXME-2 not used any longer: standardFlagsDefault->resetUsedCounter();
 	
 	// Reset the counters before saving
 	// TODO constr. of FIO creates lots of objects, better do this in some other way...
@@ -267,8 +265,7 @@
 	xml.decIndent();
 	s+=xml.endElement("vymmap");
 
-	if (writeflags)
-		standardFlagsDefault->saveToDir (tmpdir+"/flags/","",writeflags);
+	// FIXME-2 if (writeflags) standardFlagsDefault->saveToDir (tmpdir+"/flags/","",writeflags);
 	return s;
 }
 
@@ -1514,14 +1511,11 @@
 			"setHeading (\""+s+"\")", 
 			QString("Set heading of %1 to \"%2\"").arg(getObjectName(selbi)).arg(s) );
 		selbi->setHeading(s );
-		QModelIndex ix2=index (selbi);
-		emit (dataChanged ( ix2,ix2));
-		/* FIXME-3 testing only
-		*/
+		emitDataHasChanged ( selbi);	//FIXME-3 maybe emit signal from TreeItem? 
 
 		reposition();
 //		selection.update();	//FIXME-4
-		emitShowSelection();
+		updateSelection();
 	}
 }
 
@@ -1597,38 +1591,33 @@
 			// which is (still) needed to create MapCenters
 }
 
-void VymModel::setURL(const QString &url) //FIXME-2
-{
-/*
-	BranchObj *bo=getSelectedBranch();
-	if (bo)
+void VymModel::setURL(const QString &url) 
+{
+	TreeItem *selti=getSelectedItem();
+	if (selti)
 	{
-		QString oldurl=bo->getURL();
-		bo->setURL (url);
+		QString oldurl=selti->getURL();
+		selti->setURL (url);
 		saveState (
-			bo,
+			selti,
 			QString ("setURL (\"%1\")").arg(oldurl),
-			bo,
+			selti,
 			QString ("setURL (\"%1\")").arg(url),
-			QString ("set URL of %1 to %2").arg(getObjectName(bo)).arg(url)
+			QString ("set URL of %1 to %2").arg(getObjectName(selti)).arg(url)
 		);
-		updateActions();
 		reposition();
-		selection.update();
+		emitDataHasChanged (selti);
 		emitShowSelection();
 	}
-*/
 }	
 
-QString VymModel::getURL()	//FIXME-2
-{
-/*
-	BranchObj *bo=getSelectedBranch();
-	if (bo)
-		return bo->getURL();
-	else
-		return "";
-*/
+QString VymModel::getURL()	
+{
+	TreeItem *selti=getSelectedItem();
+	if (selti)
+		return selti->getURL();
+	else	
+		return QString();
 }
 
 QStringList VymModel::getURLs()	// FIXME-1	first, next moved to vymmodel
@@ -1864,20 +1853,19 @@
 }
 
 
-void VymModel::copy()	//FIXME-2
-{
-/*
-	LinkableMapObj *sel=getSelectedLMO();
-	if (sel &&
-		(selectionType() == TreeItem::Branch || 
-		selectionType() == TreeItem::MapCenter  ||
-		selectionType() == TreeItem::Image ))
+void VymModel::copy()	
+{
+	TreeItem *selti=getSelectedItem();
+	if (selti &&
+		(selti->getType() == TreeItem::Branch || 
+		selti->getType() == TreeItem::MapCenter  ||
+		selti->getType() == TreeItem::Image ))
 	{
 		if (redosAvail == 0)
 		{
 			// Copy to history
-			QString s=getSelectString(sel);
-			saveState (PartOfMap, s, "nop ()", s, "copy ()","Copy selection to clipboard",sel  );
+			QString s=getSelectString(selti);
+			saveState (PartOfMap, s, "nop ()", s, "copy ()","Copy selection to clipboard",selti  );
 			curClipboard=curStep;
 		}
 
@@ -1889,13 +1877,11 @@
 		clipboardEmpty=false;
 		updateActions();
 	}	    
-*/	
 }
 
 
-void VymModel::pasteNoSave(const int &n)	//FIXME-2
-{
-/*
+void VymModel::pasteNoSave(const int &n)
+{
 	bool old=blockSaveState;
 	blockSaveState=true;
 	bool zippedOrg=zipped;
@@ -1910,87 +1896,59 @@
 		load (clipboardDir+"/"+clipboardFile,ImportAdd, VymMap);
 	zipped=zippedOrg;
 	blockSaveState=old;
-*/
 }
 
-void VymModel::paste()		//FIXME-2
+void VymModel::paste()	
 {   
-/*
-	BranchObj *sel=getSelectedBranch();
-	if (sel)
+	BranchItem *selbi=getSelectedBranchItem();
+	if (selbi)
 	{
 		saveStateChangingPart(
-			sel,
-			sel,
+			selbi,
+			selbi,
 			QString ("paste (%1)").arg(curClipboard),
-			QString("Paste to %1").arg( getObjectName(sel))
+			QString("Paste to %1").arg( getObjectName(selbi))
 		);
 		pasteNoSave(0);
 		reposition();
 	}
-*/	
 }
 
-void VymModel::cut()	//FIXME-2
-{
-/*
-	LinkableMapObj *sel=getSelectedLMO();
-	if ( sel && (selectionType() == TreeItem::Branch ||
-		selectionType()==TreeItem::MapCenter ||
-		selectionType()==TreeItem::Image))
+void VymModel::cut()	
+{
+	TreeItem *selti=getSelectedItem();
+	if ( selti && (selti->isBranchLikeType() ||selti->getType()==TreeItem::Image))
 	{
-*/
-	/* No savestate! savestate is called in cutNoSave
-		saveStateChangingPart(
-			sel->getParObj(),
-			sel,
-			"cut ()",
-			QString("Cut %1").arg(getObjectName(sel ))
-		);
-	*/	
-/*	
 		copy();
 		deleteSelection();
 		reposition();
 	}
-*/}
-
-void VymModel::moveBranchUp()	//FIXME-2
-{
-/*
-	BranchObj* bo=getSelectedBranch();
-	BranchObj* par;
-	if (bo)
+}
+
+void VymModel::moveUp()	
+{
+	BranchItem *selbi=getSelectedBranchItem();
+	if (selbi)
 	{
-		if (!bo->canMoveBranchUp()) return;
-		par=(BranchObj*)(bo->getParObj());
-		BranchObj *obo=par->moveBranchUp (bo);	// bo will be the one below selection
-		saveState (getSelectString(bo),"moveBranchDown ()",getSelectString(obo),"moveBranchUp ()",QString("Move up %1").arg(getObjectName(bo)));
-		reposition();
-		//FIXME-3 VM needed? scene()->update();
-		selection.update();
-		emitShowSelection();
+		if (!selbi->canMoveUp()) return;
+		QString oldsel=getSelectString();
+		if (relinkBranch (selbi,(BranchItem*)selbi->parent(),selbi->num()-1) )
+
+			saveState (getSelectString(),"moveDown ()",oldsel,"moveUp ()",QString("Move up %1").arg(getObjectName(selbi)));
 	}
-	*/
 }
 
-void VymModel::moveBranchDown()	//FIXME-2
-{
-/*
-	BranchObj* bo=getSelectedBranch();
-	BranchObj* par;
-	if (bo)
+void VymModel::moveDown()	
+{
+	BranchItem *selbi=getSelectedBranchItem();
+	if (selbi)
 	{
-		if (!bo->canMoveBranchDown()) return;
-		par=(BranchObj*)(bo->getParObj());
-		BranchObj *obo=par->moveBranchDown(bo);	// bo will be the one above selection
-		saveState(getSelectString(bo),"moveBranchUp ()",getSelectString(obo),"moveBranchDown ()",QString("Move down %1").arg(getObjectName(bo)));
-		reposition();
-		//FIXME-3 VM needed? scene()->update();
-		selection.update();
-		emitShowSelection();
-	}	
-*/	
+		if (!selbi->canMoveDown()) return;
+		QString oldsel=getSelectString();
+		if ( relinkBranch (selbi,(BranchItem*)selbi->parent(),selbi->num()+1) )
+
+			saveState (getSelectString(),"moveUp ()",oldsel,"moveDown ()",QString("Move down %1").arg(getObjectName(selbi)));
+	}
 }
 
 void VymModel::sortChildren()	// FIXME-2 not implemented yet
@@ -2084,7 +2042,6 @@
 	rootItem->appendChild (mci);
 
 	endInsertRows();
-	emit (newChildObject (parix));
 	emit (layoutChanged() );
 
 	// Create MapObj
@@ -2162,7 +2119,6 @@
 			parbi->insertBranch(n,newbi);	
 			endInsertRows ();
 		}
-		emit (newChildObject (parix));
 		emit (layoutChanged() );
 
 		// save scroll state. If scrolled, automatically select
@@ -2251,10 +2207,11 @@
 	return NULL;
 }
 
-BranchItem* VymModel::relinkBranch (BranchItem *branch, BranchItem *dst, int pos)
+bool VymModel::relinkBranch (BranchItem *branch, BranchItem *dst, int pos)
 {
 	if (branch && dst)
 	{
+		cout << "VM::relinkBranch "<<branch->getHeadingStd()<<"  to "<<dst->getHeadingStd()<<"  at "<<pos<<endl;
 		emit (layoutAboutToBeChanged() );
 		BranchItem *branchpi=(BranchItem*)branch->parent();
 		// Remove at current position
@@ -2276,8 +2233,11 @@
 
 		branch->getLMO()->setParObj(dst->getLMO());	//FIXME-5 update parObj in View
 		emit (layoutChanged() );
+		reposition();	// both for moveUp/Down and relinking
 		select (branch);
+		return true;
 	}
+	return false;
 }
 
 void VymModel::deleteSelection()
@@ -2393,21 +2353,23 @@
 		if (bi->isScrolled()) return false;
 		if (bi->branchCount()==0) return false;
 		if (bi->depth()==0) return false;
-		QString u,r;
-		r="scroll";
-		u="unscroll";
-		/* FIXME-3 no savestate yet
-		saveState(
-			bo,
-			QString ("%1 ()").arg(u),
-			bo,
-			QString ("%1 ()").arg(r),
-			QString ("%1 %2").arg(r).arg(getObjectName(bo))
-		);
-		*/
-		bi->toggleScroll();
-		mapScene->update(); //Needed for _quick_ update
-		return true;
+		if (bi->toggleScroll())
+		{
+			QString u,r;
+			r="scroll";
+			u="unscroll";
+			saveState(
+				bi,
+				QString ("%1 ()").arg(u),
+				bi,
+				QString ("%1 ()").arg(r),
+				QString ("%1 %2").arg(r).arg(getObjectName(bi))
+			);
+			emitDataHasChanged(bi);
+			updateSelection();
+			mapScene->update(); //Needed for _quick_ update,  even in 1.13.x //FIXME-3 force update via signal...
+			return true;
+		}
 	}	
 	return false;
 }
@@ -2423,32 +2385,34 @@
 		QString u,r;
 		u="scroll";
 		r="unscroll";
-		/* FIXME-3 no savestate yet
 		saveState(
-			bo,
+			bi,
 			QString ("%1 ()").arg(u),
-			bo,
+			bi,
 			QString ("%1 ()").arg(r),
-			QString ("%1 %2").arg(r).arg(getObjectName(bo))
+			QString ("%1 %2").arg(r).arg(getObjectName(bi))
 		);
-		*/
 		bi->toggleScroll();
-		mapScene->update();	// Needed for _quick_ update
+		emitDataHasChanged(bi);
+		updateSelection();
+
+		mapScene->update(); //Needed for _quick_ update,  even in 1.13.x //FIXME-3 force update via signal...
 		return true;
 	}	
 	return false;
 }
 
-void VymModel::toggleScroll()
+void VymModel::toggleScroll()	
 {
 	BranchItem *bi=(BranchItem*)getSelectedBranchItem();
-	if (bi && bi->getType()==TreeItem::Branch )
+	if (bi && bi->isBranchLikeType() )
 	{
 		if (bi->isScrolled())
 			unscrollBranch (bi);
 		else
 			scrollBranch (bi);
 	}
+	// saveState is called in above functions
 }
 
 void VymModel::unscrollChildren() 	// FIXME-2	first, next moved to vymmodel
@@ -2473,9 +2437,8 @@
 	emit (expandAll() );
 }
 
-void VymModel::toggleStandardFlag (const QString &name)
-{
-	cout << "VM::toggleStandardFlag "<<name.toStdString()<<endl;
+void VymModel::toggleStandardFlag (const QString &name, FlagRow *master)
+{
 	BranchItem *bi=getSelectedBranchItem();
 	if (bi) 
 	{
@@ -2496,8 +2459,9 @@
 			bi,
 			QString("%1 (\"%2\")").arg(r).arg(name),
 			QString("Toggling standard flag \"%1\" of %2").arg(name).arg(getObjectName(bi)));
-		bi->toggleStandardFlag (name); //FIXME-0,mainWindow->useFlagGroups());
-		//FIXME-0 model->updateSelection();	// geometry has changed
+			bi->toggleStandardFlag (name, master);
+		reposition();
+		updateSelection();	
 	}
 }
 
@@ -2568,28 +2532,25 @@
 
 
 
-void VymModel::editURL()	//FIXME-2
-{
-/*
-	BranchObj *bo=getSelectedBranch();
-	if (bo)
+void VymModel::editURL()	
+{
+	TreeItem *selti=getSelectedItem();
+	if (selti)
 	{		
 		bool ok;
 		QString text = QInputDialog::getText(
 				"VYM", tr("Enter URL:"), QLineEdit::Normal,
-				bo->getURL(), &ok, NULL);
+				selti->getURL(), &ok, NULL);
 		if ( ok) 
 			// user entered something and pressed OK
 			setURL(text);
 	}
-*/
 }
 
-void VymModel::editLocalURL()	//FIXME-2
-{
-/*
-	BranchObj *bo=getSelectedBranch();
-	if (bo)
+void VymModel::editLocalURL()
+{
+	TreeItem *selti=getSelectedItem();
+	if (selti)
 	{		
 		QStringList filters;
 		filters <<"All files (*)";
@@ -2601,8 +2562,8 @@
 		fd->setFilters (filters);
 		fd->setCaption(vymName+" - " +tr("Set URL to a local file"));
 		fd->setDirectory (lastFileDir);
-		if (! bo->getVymLink().isEmpty() )
-			fd->selectFile( bo->getURL() );
+		if (! selti->getVymLink().isEmpty() )
+			fd->selectFile( selti->getURL() );
 		fd->show();
 
 		if ( fd->exec() == QDialog::Accepted )
@@ -2611,49 +2572,42 @@
 			setURL (fd->selectedFile() );
 		}
 	}
-	*/
 }
 
 
-void VymModel::editHeading2URL() //FIXME-2
-{
-/*
-	BranchObj *bo=getSelectedBranch();
-	if (bo)
-		setURL (bo->getHeading());
-*/		
+void VymModel::editHeading2URL() 
+{
+	TreeItem *selti=getSelectedItem();
+	if (selti)
+		setURL (selti->getHeading());
 }	
 
-void VymModel::editBugzilla2URL()	//FIXME-2
-{
-/*
-	BranchObj *bo=getSelectedBranch();
-	if (bo)
+void VymModel::editBugzilla2URL()	
+{
+	TreeItem *selti=getSelectedItem();
+	if (selti)
 	{		
-		QString url= "https://bugzilla.novell.com/show_bug.cgi?id="+bo->getHeading();
+		QString url= "https://bugzilla.novell.com/show_bug.cgi?id="+selti->getHeading();
 		setURL (url);
 	}
-*/	
 }	
 
-void VymModel::editFATE2URL()	//FIXME-2
-{
-/*
-	BranchObj *bo=getSelectedBranch();
-	if (bo)
+void VymModel::editFATE2URL()
+{
+	TreeItem *selti=getSelectedItem();
+	if (selti)
 	{		
-		QString url= "http://keeper.suse.de:8080/webfate/match/id?value=ID"+bo->getHeading();
+		QString url= "http://keeper.suse.de:8080/webfate/match/id?value=ID"+selti->getHeading();
 		saveState(
-			bo,
-			"setURL (\""+bo->getURL()+"\")",
-			bo,
+			selti,
+			"setURL (\""+selti->getURL()+"\")",
+			selti,
 			"setURL (\""+url+"\")",
-			QString("Use heading of %1 as link to FATE").arg(getObjectName(bo))
+			QString("Use heading of %1 as link to FATE").arg(getObjectName(selti))
 		);	
-		bo->setURL (url);
-		updateActions();
+		selti->setURL (url);
+		// FIXME-4 updateActions();
 	}
-*/	
 }	
 
 void VymModel::editVymLink()
@@ -2693,7 +2647,7 @@
 	BranchItem *bi=getSelectedBranchItem();
 	if (bi)
 	{
-		bi->getBranchObj()->setVymLink(s);	//FIXME-3 check getBO
+		bi->setVymLink(s);
 		reposition();
 		updateActions();
 		//selection.update();
@@ -2708,16 +2662,14 @@
 	{		
 		saveState(
 			bi,
-			"setVymLink (\""+bi->getBranchObj()->getVymLink()+"\")", //FIXME-3 check getBO
-
+			"setVymLink (\""+bi->getVymLink()+"\")", 
 			bi,
 			"setVymLink (\"\")",
 			QString("Unset vymlink of %1").arg(getObjectName(bi))
 		);	
-		bi->getBranchObj()->setVymLink ("" );	//FIXME-3 check getBO
+		bi->setVymLink ("" );
 		updateActions();
 		reposition();
-		// FIXME-3 VM needed? scene()->update();
 	}
 }
 
@@ -2725,7 +2677,7 @@
 {
 	BranchItem *bi=getSelectedBranchItem();
 	if (bi)
-		return bi->getBranchObj()->getVymLink();	//FIXME-3 check getBO here...
+		return bi->getVymLink();
 	else	
 		return "";
 	
@@ -2907,7 +2859,7 @@
 			}
 		}
 	/////////////////////////////////////////////////////////////////////
-	} else /*if (com=="clearFlags")	// FIXME-2
+	} else if (com=="clearFlags")	
 	{
 		if (!selti )
 		{
@@ -2917,11 +2869,10 @@
 			parser.setError (Aborted,"Type of selection is not a branch");
 		} else if (parser.checkParCount(0))
 		{
-			selb->clearStandardFlags();	
-			selb->updateFlagsToolbar();
+			selbi->deactivateAllStandardFlags();	
 		}
 	/////////////////////////////////////////////////////////////////////
-	} else */ if (com=="colorBranch")
+	} else if (com=="colorBranch")
 	{
 		if (!selti)
 		{
@@ -3172,7 +3123,7 @@
 			if (ok) loadFloatImageInt (s);
 		}	
 	/////////////////////////////////////////////////////////////////////
-	} else if (com=="moveBranchUp")
+	} else if (com=="moveUp")
 	{
 		if (!selti )
 		{
@@ -3182,10 +3133,10 @@
 			parser.setError (Aborted,"Type of selection is not a branch");
 		} else if (parser.checkParCount(0))
 		{
-			moveBranchUp();
+			moveUp();
 		}	
 	/////////////////////////////////////////////////////////////////////
-	} else if (com=="moveBranchDown")
+	} else if (com=="moveDown")
 	{
 		if (!selti )
 		{
@@ -3195,7 +3146,7 @@
 			parser.setError (Aborted,"Type of selection is not a branch");
 		} else if (parser.checkParCount(0))
 		{
-			moveBranchDown();
+			moveDown();
 		}	
 	/////////////////////////////////////////////////////////////////////
 	} else if (com=="move")
@@ -3624,7 +3575,7 @@
 		}	
 	}
 	/////////////////////////////////////////////////////////////////////
-	else /* FIXME-2 if (com=="setFlag")
+	else if (com=="setFlag")
 	{
 		if (!selti )
 		{
@@ -3636,13 +3587,10 @@
 		{
 			s=parser.parString(ok,0);
 			if (ok) 
-			{
-				selb->activateStandardFlag(s);
-				selb->updateFlagsToolbar();
-			}	
+				selbi->activateStandardFlag(s);
 		}
 	/////////////////////////////////////////////////////////////////////
-	} else */ /* FIXME-2 if (com=="setFrameType")
+	} else /* FIXME-2 if (com=="setFrameType")
 	{
 		if (!selti )
 		{
@@ -3670,7 +3618,7 @@
 			sortChildren();
 		}
 	/////////////////////////////////////////////////////////////////////
-	} else /* FIXME-2 if (com=="toggleFlag")
+	} else if (com=="toggleFlag")
 	{
 		if (!selti )
 		{
@@ -3682,13 +3630,10 @@
 		{
 			s=parser.parString(ok,0);
 			if (ok) 
-			{
 				selbi->toggleStandardFlag(s);	
-				selb->updateFlagsToolbar();
-			}	
 		}
 	/////////////////////////////////////////////////////////////////////
-	} else */ if (com=="unscroll")
+	} else  if (com=="unscroll")
 	{
 		if (!selti)
 		{
@@ -3715,9 +3660,9 @@
 			unscrollChildren ();
 		}	
 	/////////////////////////////////////////////////////////////////////
-	} else /* FIXME-2 if (com=="unsetFlag")
+	} else if (com=="unsetFlag")
 	{
-		if (selection.isEmpty() )
+		if (!selti)
 		{
 			parser.setError (Aborted,"Nothing selected");
 		} else if (! selbi )
@@ -3727,12 +3672,9 @@
 		{
 			s=parser.parString(ok,0);
 			if (ok) 
-			{
-				selb->deactivateStandardFlag(s);
-				selb->updateFlagsToolbar();
-			}	
+				selbi->deactivateStandardFlag(s);
 		}
-	} else */
+	} else 
 		parser.setError (Aborted,"Unknown command");
 
 	// Any errors?
@@ -3946,18 +3888,20 @@
 void VymModel::updateNoteFlag()
 {
 	setChanged();
-	cout << "VM::updateNoteFlag()\n";
-	/* FIXME-1 modify note flag
-	BranchObj *bo=getSelectedBranch();
-	if (bo) 
+	TreeItem *selti=getSelectedItem();
+	if (selti)
 	{
-		bo->updateNoteFlag();
-		mainWindow->updateActions();
-	}	
-	*/
+		if (textEditor->isEmpty()) 
+			selti->clearNote();
+		else
+			selti->setNote (textEditor->getText());
+		emitDataHasChanged(selti);		
+		updateSelection();
+
+	}
 }
 
-void VymModel::updateRelPositions()		//FIXME-2 VM should have no need to updateRelPos
+void VymModel::updateRelPositions()		//FIXME-3 VM should have no need to updateRelPos
 {
 	//cout << "VM::updateRelPos...\n";
 	for (int i=0; i<rootItem->branchCount(); i++)
@@ -4694,7 +4638,7 @@
 void VymModel::emitDataHasChanged (TreeItem *ti)
 {
 	QModelIndex ix=index(ti);
-	emit (dataHasChanged (ix) );
+	emit (dataChanged (ix,ix) );
 }
 
 
diff -r 7a71a914afdb -r 6d2b32f305f9 vymmodel.h
--- a/vymmodel.h	Thu May 07 08:48:53 2009 +0000
+++ b/vymmodel.h	Wed May 13 08:26:27 2009 +0000
@@ -277,8 +277,8 @@
     void paste();		//!< Paste clipboard to branch and backup
     void cut();			//!< Cut to clipboard (and copy)
 
-    void moveBranchUp();	//!< Move branch up
-    void moveBranchDown();	//!< Move branch down
+    void moveUp();	//!< Move branch up
+    void moveDown();	//!< Move branch down
 	void sortChildren();	//!< Sort children lexically
 
 	// The create methods are used to quickly parse a XML file
@@ -317,7 +317,14 @@
 	*/
     BranchItem* addNewBranch(int pos);		
     BranchItem* addNewBranchBefore();		//!< Insert branch between selection and its parent
-	BranchItem* relinkBranch (BranchItem* branch, BranchItem* dst, int pos =-1);	//! Relink branch to dst at position pos
+	/*! \brief Relink a branch to a new destination dst 
+	    Relinks branch to dst at branch position pos. There is no saveState
+		here, as for example moveUp or moving in MapEditor have
+		different needs to call saveState
+		Returns true if relinking was successful.
+	*/	
+	bool relinkBranch (BranchItem* branch, BranchItem* dst, int pos =-1);	
+
     void deleteSelection();					//!< Delete selection
 	void deleteKeepChildren();				//!< remove branch, but keep children
 	void deleteChildren();					//!< keep branch, but remove children
@@ -333,7 +340,7 @@
 	void expandAll();
 
 public:	
-	void toggleStandardFlag (const QString &name);
+	void toggleStandardFlag (const QString &name, FlagRow *master=NULL);
     void addFloatImage(const QPixmap &img);
 
     void colorBranch(QColor);
@@ -426,7 +433,6 @@
 
 signals:
 	void noteHasChanged (QModelIndex ix);
-	void dataHasChanged (QModelIndex ix);	//FIXME-3 necessary? There is dataChanged in AbstractModel
 	void newChildObject(QModelIndex ix);
 
 private:
@@ -477,7 +483,7 @@
 	uint animationTicks;
 	uint animationInterval;
 	int timerId;				// animation timer
-	QList <MapObj*> animObjList;// list with animated objects
+	QList <MapObj*> animObjList;// list with animated objects //FIXME-2 should go to MapEditor
 
 private slots:
 	void animate();						//!< Called by timer to animate stuff
diff -r 7a71a914afdb -r 6d2b32f305f9 vymview.cpp
--- a/vymview.cpp	Thu May 07 08:48:53 2009 +0000
+++ b/vymview.cpp	Wed May 13 08:26:27 2009 +0000
@@ -49,12 +49,6 @@
 		model, SIGNAL (selectionChanged(const QItemSelection &, const QItemSelection &)), 
 		mapEditor,SLOT (updateSelection(const QItemSelection &,const QItemSelection &)));
 
-		/*
-	connect (
-		model, SIGNAL (newChildObject(QModelIndex) ),
-		this,SLOT (updateChilds (QModelIndex) ) );
-*/
-
 	connect (
 		model, SIGNAL (noteHasChanged(QModelIndex) ),
 		mainWindow, SLOT (updateNoteEditor (QModelIndex) ) );
@@ -91,13 +85,6 @@
 	return NULL;
 }
 
-
-void VymView::updateChilds (QModelIndex ix)		//FIXME-4 not needed?
-{
-	cout << "VV::updateChilds \n";
-	//treeview->setExpanded (ix,true);	// This is expensive...
-}
-
 void VymView::changeSelection (const QItemSelection &newsel, const QItemSelection &oldsel)
 {
 	/*
@@ -112,6 +99,7 @@
 
 	// Notify mainwindow to update satellites like NoteEditor, if needed (model==currenModel...)
 	mainWindow->changeSelection (model,newsel,oldsel);	// FIXME-3 maybe connect VymModel <-> MainWindow directly?
+	showSelection();
 }
 
 void VymView::expandAll()
@@ -128,7 +116,7 @@
 	);
 
 	LinkableMapObj* lmo=model->getSelectedLMO();
-	if (lmo)
-		mapEditor->ensureVisible(lmo->getBBox() );
+	if (lmo) 
+		mapEditor->setScrollBarPosTarget (lmo->getBBox() );
 }
 
diff -r 7a71a914afdb -r 6d2b32f305f9 vymview.h
--- a/vymview.h	Thu May 07 08:48:53 2009 +0000
+++ b/vymview.h	Wed May 13 08:26:27 2009 +0000
@@ -17,7 +17,6 @@
 	QItemSelectionModel* selectionModel();
 
 public slots:
-	void updateChilds (QModelIndex ix);
 	void changeSelection (const QItemSelection &newSel, const QItemSelection &delSel);
 	void expandAll ();
 	void showSelection ();