Various fixes and simplifications
authorinsilmaril
Tue, 26 May 2009 11:23:44 +0000
changeset 773340bc29da9a0
parent 772 e3f722759c7e
child 774 2f002657dada
Various fixes and simplifications
branchitem.cpp
branchitem.h
branchobj.cpp
branchobj.h
editxlinkdialog.cpp
exports.cpp
floatobj.cpp
linkablemapobj.cpp
linkablemapobj.h
mainwindow.cpp
mapcenteritem.cpp
mapcenteritem.h
mapcenterobj.cpp
mapcenterobj.h
mapeditor.cpp
ornamentedobj.cpp
selection.cpp
selection.h
treeitem.cpp
treeitem.h
treemodel.cpp
treemodel.h
version.h
vym.pro
vymmodel.cpp
vymmodel.h
xml-vym.cpp
     1.1 --- a/branchitem.cpp	Wed May 20 15:40:14 2009 +0000
     1.2 +++ b/branchitem.cpp	Tue May 26 11:23:44 2009 +0000
     1.3 @@ -84,7 +84,13 @@
     1.4  		idAttr="";
     1.5  
     1.6  	*/
     1.7 -    s=beginElement ("branch" 
     1.8 +	QString elementName;
     1.9 +	if (parentItem==rootItem)
    1.10 +		elementName="mapcenter";
    1.11 +	else	
    1.12 +		elementName="branch";
    1.13 +
    1.14 +    s=beginElement (elementName
    1.15  		+getAttr()
    1.16  	//	+getOrnXMLAttr() 
    1.17  		+scrolledAttr 
    1.18 @@ -146,7 +152,7 @@
    1.19  	*/
    1.20  
    1.21      decIndent();
    1.22 -    s+=endElement   ("branch");
    1.23 +    s+=endElement   (elementName);
    1.24      return s;
    1.25  }
    1.26  
    1.27 @@ -337,6 +343,15 @@
    1.28      return NULL;
    1.29  }
    1.30  
    1.31 +void BranchItem::updateStyles()
    1.32 +{
    1.33 +	// FIXME-5 compare also MapItem::initLMO...
    1.34 +
    1.35 +	if (lmo)
    1.36 +	{
    1.37 +		lmo->setParObj (parentItem->getLMO() );
    1.38 +	}
    1.39 +}
    1.40  
    1.41  BranchObj* BranchItem::getBranchObj()	// FIXME-3 only for transition BO->BI
    1.42  {
    1.43 @@ -345,22 +360,50 @@
    1.44  
    1.45  BranchObj* BranchItem::createMapObj(QGraphicsScene *scene)	
    1.46  {
    1.47 +	BranchObj *newbo;
    1.48 +	cout << "BI::createMO  "<<getHeadingStd()<<"  pI="<<parentItem<<"  rI="<<rootItem<<endl;
    1.49 +	if (parentItem==rootItem)
    1.50 +	{
    1.51 +		// Initialize MapCenterObj, order of things is important...
    1.52 +		cout << "BI::createMO  (MCO) "<<getHeadingStd()<<endl;
    1.53 +		MapCenterObj* mco=new MapCenterObj(scene);
    1.54 +		newbo=mco;
    1.55 +		lmo=mco;
    1.56 +		newbo->setParObj(NULL);
    1.57 +		newbo->setTreeItem (this);
    1.58 +		newbo->setDefAttr(BranchObj::NewBranch);
    1.59 +	} else
    1.60 +	{
    1.61  	// Initialize BranchObj, order of things is important...
    1.62 -    BranchObj* newbo=new BranchObj(scene);
    1.63 -	lmo=newbo;
    1.64 -	BranchObj* parbo=(BranchObj*)(parentItem->getLMO());
    1.65 -    newbo->setParObj(parbo);
    1.66 -	newbo->setTreeItem (this);
    1.67 -	newbo->setDefAttr(BranchObj::NewBranch);
    1.68 -	if (((BranchItem*)parentItem)->scrolled || !parbo->isVisibleObj() )
    1.69 -		newbo->setVisibility (false);
    1.70 -	
    1.71 +		cout << "BI::createMO  (BO) "<<getHeadingStd()<<endl;
    1.72 +		newbo=new BranchObj(scene);
    1.73 +		lmo=newbo;
    1.74 +		BranchObj* parbo=(BranchObj*)(parentItem->getLMO());
    1.75 +		newbo->setParObj(parbo);
    1.76 +		newbo->setTreeItem (this);
    1.77 +		newbo->setDefAttr(BranchObj::NewBranch);
    1.78 +
    1.79 +		if (parentItem->isBranchLikeType())
    1.80 +		{
    1.81 +			// Set visibility depending on parents
    1.82 +			if (((BranchItem*)parentItem)->scrolled || !parbo->isVisibleObj() )
    1.83 +			{
    1.84 +				if (parentItem && parentItem->isBranchLikeType())
    1.85 +					cout <<"  scrolled="<<((BranchItem*)parentItem)->scrolled<<endl;
    1.86 +				if (parbo)
    1.87 +					cout <<"  par->vis="<<parbo->isVisibleObj()<<endl;
    1.88 +				newbo->setVisibility (false);
    1.89 +			}	
    1.90 +		} else
    1.91 +			cout <<"   pI=no branch!\n";
    1.92 +
    1.93 +	}
    1.94  	initLMO();
    1.95  
    1.96  	if (!getHeading().isEmpty() ) 
    1.97  	{
    1.98 -		newbo->updateData();	//FIXME-3 maybe better model->emitDataHasChanged()?
    1.99 -		newbo->setColor (headingColor);
   1.100 +		((BranchObj*)lmo)->updateData();	//FIXME-3 maybe better model->emitDataHasChanged()?
   1.101 +		((BranchObj*)lmo)->setColor (headingColor);
   1.102  	}	
   1.103  
   1.104  		
     2.1 --- a/branchitem.h	Wed May 20 15:40:14 2009 +0000
     2.2 +++ b/branchitem.h	Tue May 26 11:23:44 2009 +0000
     2.3 @@ -41,8 +41,9 @@
     2.4  	virtual void resetTmpUnscroll();		// scroll all tmp scrolled parents again e.g. when unselecting
     2.5  
     2.6  	TreeItem* findMapItem (QPointF p,TreeItem* excludeTI);	//! search map for branches or images. Ignore excludeTI, where search is started 
     2.7 -	virtual TreeItem* findID (QString sid);		//! search map for object with ID string
     2.8 +	virtual TreeItem* findID (QString sid);	//! search map for object with ID string
     2.9  
    2.10 +	virtual void updateStyles ();			//! update related fonts, parObjects, links, ...
    2.11  	virtual BranchObj* getBranchObj();	
    2.12  	virtual BranchObj* createMapObj(QGraphicsScene *scene);		//! Create classic object in GraphicsView
    2.13  };
     3.1 --- a/branchobj.cpp	Wed May 20 15:40:14 2009 +0000
     3.2 +++ b/branchobj.cpp	Tue May 26 11:23:44 2009 +0000
     3.3 @@ -33,7 +33,7 @@
     3.4  //    cout << "Const BranchObj (s,p)\n";
     3.5      scene=s;
     3.6      setParObj (p);	
     3.7 -	if (treeItem->depth()==1)
     3.8 +	if (treeItem->depth()==1)	// FIXME-3 needed to recursively calc depth?
     3.9  		// Calc angle to mapCenter if I am a mainbranch
    3.10  		// needed for reordering the mainbranches clockwise 
    3.11  		// around mapcenter 
    3.12 @@ -50,6 +50,7 @@
    3.13  	if (anim.isAnimated() )
    3.14  	{
    3.15  		anim.setAnimated (false);
    3.16 +		VymModel *model=treeItem->getModel();
    3.17  		model->stopAnimation (this);
    3.18  	}
    3.19  
    3.20 @@ -86,8 +87,6 @@
    3.21  		absPos+=parObj->getChildPos();
    3.22  	}
    3.23  
    3.24 -    setChildObj(this);
    3.25 -
    3.26  	includeImagesVer=false;
    3.27  	includeImagesHor=false;
    3.28  }
    3.29 @@ -153,7 +152,7 @@
    3.30  	// Usually the positioning would be done by reposition(),
    3.31  	// but then also the destination branch would "Jump" around...
    3.32  	// Better just do it approximately
    3.33 -	if (treeItem->depth()==1)
    3.34 +	if (treeItem->depth()==1)	// FIXME-3 needed to recursively calc depth?
    3.35  	{	// new parent is the mapcenter itself
    3.36  
    3.37  		QPointF p= normalise ( QPointF (m.x() - o->getChildPos().x(),
    3.38 @@ -245,6 +244,7 @@
    3.39  	// Overloaded from LinkableMapObj
    3.40  	// BranchObj can use color of heading
    3.41  
    3.42 +	VymModel *model=treeItem->getModel();
    3.43  	if (model)
    3.44  	{
    3.45  		if (model->getMapLinkColorHint()==HeadingColor)
    3.46 @@ -254,13 +254,6 @@
    3.47  	}		
    3.48  }
    3.49  
    3.50 -void BranchObj::setColorSubtree(QColor col)
    3.51 -{
    3.52 -	setColor (col);
    3.53 -	for (int i=0; i<treeItem->branchCount(); ++i)
    3.54 -		treeItem->getBranchObjNum(i)->setColorSubtree(col);
    3.55 -}
    3.56 -
    3.57  void BranchObj::updateContentSize()
    3.58  {
    3.59  	calcBBoxSize();
    3.60 @@ -663,7 +656,7 @@
    3.61  void BranchObj::alignRelativeTo (QPointF ref,bool alignSelf)
    3.62  {
    3.63  	qreal th = bboxTotal.height();	
    3.64 -	int depth=treeItem->depth();
    3.65 +	int depth=treeItem->depth();	// FIXME-3 needed to recursively calc depth?
    3.66  // TODO testing
    3.67  /*
    3.68  
    3.69 @@ -918,7 +911,11 @@
    3.70  
    3.71  QString BranchObj::getSelectString()
    3.72  {
    3.73 -	return model->getSelectString (this);
    3.74 +	VymModel *model=treeItem->getModel();
    3.75 +	if (model)
    3.76 +		return model->getSelectString (this);
    3.77 +	else
    3.78 +		return QString();
    3.79  }
    3.80  
    3.81  void BranchObj::setAnimation(const AnimPoint &ap)
     4.1 --- a/branchobj.h	Wed May 20 15:40:14 2009 +0000
     4.2 +++ b/branchobj.h	Tue May 26 11:23:44 2009 +0000
     4.3 @@ -34,7 +34,6 @@
     4.4  	virtual void setVisibility(bool,int);	// set visibility
     4.5      virtual void setVisibility(bool);	    // set vis. for w
     4.6  	virtual void setLinkColor();			// set the color of link
     4.7 -	virtual void setColorSubtree(QColor);	// set the color of heading
     4.8  
     4.9  	virtual void updateContentSize();
    4.10  	virtual void positionContents();
     5.1 --- a/editxlinkdialog.cpp	Wed May 20 15:40:14 2009 +0000
     5.2 +++ b/editxlinkdialog.cpp	Tue May 26 11:23:44 2009 +0000
     5.3 @@ -57,19 +57,21 @@
     5.4  	}
     5.5  }
     5.6  
     5.7 -void EditXLinkDialog::setColorHeadingButtonPressed()
     5.8 +void EditXLinkDialog::setColorHeadingButtonPressed()	//FIXME-2
     5.9  {
    5.10 +/*
    5.11  	if (xlo)
    5.12  	{	
    5.13  		if (selection && 
    5.14 -			(typeid(*selection) == typeid(BranchObj) || 
    5.15 -			typeid(*selection) == typeid(MapCenterObj))  )
    5.16 +			(typid(*selection) == typid(BranchObj) || 
    5.17 +			typid(*selection) == typid(MapCenterObj))  )
    5.18  		{
    5.19  			QColor col=((BranchObj*)(selection))->getColor();
    5.20  			xlo->setColor(col);
    5.21  			ui.colorButton->setPaletteBackgroundColor (col);
    5.22  		}
    5.23  	}
    5.24 +	*/
    5.25  }
    5.26  
    5.27  bool EditXLinkDialog::useSettingsGlobal ()
     6.1 --- a/exports.cpp	Wed May 20 15:40:14 2009 +0000
     6.2 +++ b/exports.cpp	Tue May 26 11:23:44 2009 +0000
     6.3 @@ -147,10 +147,9 @@
     6.4  	int i;
     6.5  	BranchItem *cur=NULL;
     6.6  	BranchItem *prev=NULL;
     6.7 -	int d;
     6.8  
     6.9  	BranchObj *bo;	//FIXME-3 still needed?
    6.10 -	cur=model->next (cur,prev,d);
    6.11 +	cur=model->next (cur,prev);
    6.12  	while (cur) 
    6.13  	{
    6.14  		if (cur->getType()==TreeItem::Branch || cur->getType()==TreeItem::MapCenter)
    6.15 @@ -199,7 +198,7 @@
    6.16  				}
    6.17  			}
    6.18  		}
    6.19 -		cur=model->next(cur,prev,d);
    6.20 +		cur=model->next(cur,prev);
    6.21  	}
    6.22  	file.close();
    6.23  }
    6.24 @@ -233,8 +232,7 @@
    6.25  	BranchObj *bo;  //FIXME-3 still needed?
    6.26  	BranchItem *cur=NULL;
    6.27  	BranchItem *prev=NULL;
    6.28 -	int d;
    6.29 -	cur=model->next (cur,prev,d);
    6.30 +	cur=model->next (cur,prev);
    6.31  	while (cur) 
    6.32  	{
    6.33  		bo=(BranchObj*)(cur->getLMO());
    6.34 @@ -257,7 +255,7 @@
    6.35  			ts << curIndent << "\"" << cur->getHeading()<<"\""<<endl;
    6.36  		}
    6.37  		
    6.38 -		cur=model->next(cur,prev,d);
    6.39 +		cur=model->next(cur,prev);
    6.40  		curIndent="";
    6.41  	}
    6.42  	file.close();
    6.43 @@ -393,8 +391,7 @@
    6.44    BranchObj *bo;
    6.45    BranchItem *cur=NULL;
    6.46    BranchItem *prev=NULL;
    6.47 -  int d;  //FIXME-3 still needed?
    6.48 -  model->next(cur,prev,d);
    6.49 +  model->next(cur,prev);
    6.50    while (cur) 
    6.51    {
    6.52  	bo=(BranchObj*)(cur->getLMO());
    6.53 @@ -426,7 +423,7 @@
    6.54  		  ts << ("\n");
    6.55  		}
    6.56  	}
    6.57 -    cur=model->next(cur,prev,d);
    6.58 +    cur=model->next(cur,prev);
    6.59     }
    6.60    file.close();
    6.61  }
     7.1 --- a/floatobj.cpp	Wed May 20 15:40:14 2009 +0000
     7.2 +++ b/floatobj.cpp	Tue May 26 11:23:44 2009 +0000
     7.3 @@ -34,7 +34,6 @@
     7.4  
     7.5  void FloatObj::init () 
     7.6  {
     7.7 -    setChildObj(this);
     7.8  	floatExport=true;
     7.9  	zPlane=Z_ICON;
    7.10  	setLinkStyle (LinkableMapObj::Parabel);
     8.1 --- a/linkablemapobj.cpp	Wed May 20 15:40:14 2009 +0000
     8.2 +++ b/linkablemapobj.cpp	Tue May 26 11:23:44 2009 +0000
     8.3 @@ -57,9 +57,6 @@
     8.4  
     8.5  void LinkableMapObj::init ()
     8.6  {
     8.7 -	model=NULL;
     8.8 -
     8.9 -    childObj=NULL;
    8.10      parObj=NULL;
    8.11      parObjTmpBuf=NULL;
    8.12      parPos=QPointF(0,0);
    8.13 @@ -103,7 +100,6 @@
    8.14  void LinkableMapObj::copy (LinkableMapObj* other)
    8.15  {
    8.16      MapObj::copy(other);
    8.17 -	model=other->model;
    8.18  	bboxTotal=other->bboxTotal;
    8.19      setLinkStyle(other->style);
    8.20      setLinkColor (other->linkcolor);
    8.21 @@ -122,25 +118,9 @@
    8.22  	return treeItem;
    8.23  }
    8.24  
    8.25 -void LinkableMapObj::setModel (VymModel *vm)
    8.26 -{
    8.27 -	model=vm;
    8.28 -}
    8.29 -
    8.30 -VymModel* LinkableMapObj::getModel()
    8.31 -{
    8.32 -	return model;
    8.33 -}
    8.34 -
    8.35 -void LinkableMapObj::setChildObj(LinkableMapObj* o)
    8.36 -{
    8.37 -    childObj=o;
    8.38 -}
    8.39 -
    8.40  void LinkableMapObj::setParObj(LinkableMapObj* o)
    8.41  {
    8.42      parObj=o;
    8.43 -	if (parObj) model=parObj->getModel();
    8.44  }
    8.45  
    8.46  void LinkableMapObj::setParObjTmp(LinkableMapObj*,QPointF,int)	// FIXME-3 make pure virtual
    8.47 @@ -205,6 +185,7 @@
    8.48  
    8.49  LinkableMapObj::Style LinkableMapObj::getDefLinkStyle ()
    8.50  {
    8.51 +	VymModel *model=treeItem->getModel();
    8.52  	if (!model)
    8.53  	{
    8.54  		qWarning ("LMO::getDefLinkStyle   model=NULL");
    8.55 @@ -246,7 +227,7 @@
    8.56  		
    8.57  	style=newstyle;
    8.58  
    8.59 -    if (childObj!=NULL && parObj != NULL)
    8.60 +    if (parObj != NULL)
    8.61      {
    8.62  		QGraphicsLineItem *cl;
    8.63  		switch (style)
    8.64 @@ -332,6 +313,7 @@
    8.65  {
    8.66  	// Overloaded in BranchObj and children
    8.67  	// here only set default color
    8.68 +	VymModel *model=treeItem->getModel();
    8.69  	if (model)
    8.70  		setLinkColor (model->getMapDefLinkColor());
    8.71  }
    8.72 @@ -554,11 +536,6 @@
    8.73  	} // switch (style)	
    8.74  }
    8.75  	
    8.76 -LinkableMapObj* LinkableMapObj::getChildObj()
    8.77 -{
    8.78 -    return childObj;
    8.79 -}
    8.80 -
    8.81  LinkableMapObj* LinkableMapObj::getParObj()
    8.82  {
    8.83      return parObj;
    8.84 @@ -621,6 +598,7 @@
    8.85  	// we want to block expensive repositioning, but just do it once at
    8.86  	// the end, thus check first:
    8.87  
    8.88 +	VymModel *model=treeItem->getModel();
    8.89  	if (model->isRepositionBlocked()) return;	
    8.90  	
    8.91  	// Pass on the request to parent objects, if this hasn't been done yet
     9.1 --- a/linkablemapobj.h	Wed May 20 15:40:14 2009 +0000
     9.2 +++ b/linkablemapobj.h	Tue May 26 11:23:44 2009 +0000
     9.3 @@ -59,8 +59,6 @@
     9.4  
     9.5  	virtual void setTreeItem(TreeItem *);
     9.6  	virtual TreeItem* getTreeItem() const;
     9.7 -	virtual void setModel (VymModel *vm);
     9.8 -	virtual VymModel* getModel ();
     9.9  
    9.10      void setChildObj (LinkableMapObj*);
    9.11      virtual void setParObj (LinkableMapObj*);
    9.12 @@ -110,7 +108,7 @@
    9.13  
    9.14  	virtual void calcBBoxSizeWithChildren()=0;// calc size of  BBox including children recursivly
    9.15  
    9.16 -    virtual void select();
    9.17 +    virtual void select();					// FIXME-3  show/hide links...
    9.18      virtual void unselect();
    9.19  
    9.20  protected:
    9.21 @@ -121,13 +119,11 @@
    9.22      QPointF parPos;
    9.23  	bool link2ParPos;				// While moving around, sometimes link to parent
    9.24  
    9.25 -	VymModel* model;												
    9.26      Orientation orientation;     
    9.27      qreal linkwidth;				// width of a link
    9.28  	QRectF bboxTotal;				// bounding box including children
    9.29  
    9.30 -    LinkableMapObj* childObj;
    9.31 -    LinkableMapObj* parObj;		// FIXME-2 really still needed? Better get from TreeItem
    9.32 +    LinkableMapObj* parObj;		
    9.33      LinkableMapObj* parObjTmpBuf;	// temporary buffer the original parent
    9.34      qreal bottomlineY;              // vertical offset of dockpos to pos
    9.35  
    9.36 @@ -152,7 +148,6 @@
    9.37  		leftPad, rightPad;          // padding within bbox
    9.38  
    9.39  	QPointF	 relPos;				// position relative to childPos of parent
    9.40 -	//AnimPoint relPos;				// position relative to childPos of parent
    9.41  	bool useRelPos;
    9.42  	bool useOrientation;
    9.43  
    10.1 --- a/mainwindow.cpp	Wed May 20 15:40:14 2009 +0000
    10.2 +++ b/mainwindow.cpp	Tue May 26 11:23:44 2009 +0000
    10.3 @@ -1451,10 +1451,7 @@
    10.4  	a->setToggleAction(true);
    10.5  	a->setOn (settings.value("/animation/use",false).toBool() );
    10.6      connect( a, SIGNAL( triggered() ), this, SLOT( settingsToggleAnimation() ) );
    10.7 -	if (settings.value( "/mainwindow/showTestMenu",false).toBool() )
    10.8 -	{
    10.9 -		settingsMenu->addAction (a);
   10.10 -	}	
   10.11 +	settingsMenu->addAction (a);
   10.12  	actionSettingsUseAnimation=a;
   10.13  }
   10.14  
    11.1 --- a/mapcenteritem.cpp	Wed May 20 15:40:14 2009 +0000
    11.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    11.3 @@ -1,143 +0,0 @@
    11.4 -#include "mapcenteritem.h"
    11.5 -#include "mapcenterobj.h"
    11.6 -
    11.7 -#include <iostream>
    11.8 -using namespace std;
    11.9 -
   11.10 -MapCenterItem::MapCenterItem(const QList<QVariant> &data, TreeItem *parent):BranchItem (data,parent)
   11.11 -{
   11.12 -	//cout << "Constr. MapCenterItem\n";
   11.13 -	type=MapCenter;
   11.14 -}
   11.15 -
   11.16 -MapCenterItem::~MapCenterItem()
   11.17 -{
   11.18 -//	cout << "Destr. MapCenterItem\n";
   11.19 -    qDeleteAll(childItems);
   11.20 -}
   11.21 -
   11.22 -QString MapCenterItem::saveToDir (const QString &tmpdir,const QString &prefix, const QPointF& offset)	//FIXME-3 Check if everything is saved...
   11.23 -{
   11.24 -	// Cloudy stuff can be hidden during exports
   11.25 -	if (hidden) return QString();
   11.26 -
   11.27 -    QString s,a;
   11.28 -	BranchObj *bo=(BranchObj*)lmo;
   11.29 -
   11.30 -	QString scrolledAttr;
   11.31 -	if (scrolled) 
   11.32 -		scrolledAttr=attribut ("scrolled","yes");
   11.33 -	else
   11.34 -		scrolledAttr="";
   11.35 -
   11.36 -	/* 
   11.37 -	// save area, if not scrolled
   11.38 -	QString areaAttr;
   11.39 -	if (!((BranchObj*)(parObj))->isScrolled() )
   11.40 -	{
   11.41 -		areaAttr=
   11.42 -			attribut("x1",QString().setNum(absPos.x()-offset.x())) +
   11.43 -			attribut("y1",QString().setNum(absPos.y()-offset.y())) +
   11.44 -			attribut("x2",QString().setNum(absPos.x()+width()-offset.x())) +
   11.45 -			attribut("y2",QString().setNum(absPos.y()+height()-offset.y()));
   11.46 -
   11.47 -	} else
   11.48 -		areaAttr="";
   11.49 -	
   11.50 -	// Providing an ID for a branch makes export to XHTML easier
   11.51 -	QString idAttr;
   11.52 -	if (countXLinks()>0)
   11.53 -		idAttr=attribut ("id",model->getSelectString(this)); //TODO directly access model
   11.54 -	else
   11.55 -		idAttr="";
   11.56 -
   11.57 -	*/
   11.58 -    s=beginElement ("mapcenter" 
   11.59 -		+getAttr()
   11.60 -	//	+getOrnXMLAttr() 
   11.61 -		+scrolledAttr 
   11.62 -	//	+areaAttr 
   11.63 -	//	+idAttr 
   11.64 -	//	+getIncludeImageAttr() 
   11.65 -		);
   11.66 -    incIndent();
   11.67 -
   11.68 -	// save heading
   11.69 -    s+=valueElement("heading", getHeading(),
   11.70 -		attribut ("textColor",QColor( bo->getColor()).name()));
   11.71 -
   11.72 -/*
   11.73 -	// Save frame
   11.74 -	if (frame->getFrameType()!=FrameObj::NoFrame) 
   11.75 -		s+=frame->saveToDir ();
   11.76 -
   11.77 -	// save names of flags set
   11.78 -	s+=standardFlags->saveToDir(tmpdir,prefix,0);
   11.79 -	
   11.80 -	// Save FloatImages
   11.81 -	for (int i=0; i<floatimage.size(); ++i)
   11.82 -		s+=floatimage.at(i)->saveToDir (tmpdir,prefix);
   11.83 -*/
   11.84 -
   11.85 -	// save note
   11.86 -	if (!note.isEmpty() )
   11.87 -		s+=note.saveToDir();
   11.88 -	
   11.89 -	// Save branches
   11.90 -	int i=0;
   11.91 -	TreeItem *ti=getBranchNum(i);
   11.92 -	while (ti)
   11.93 -	{
   11.94 -		s+=getBranchNum(i)->saveToDir(tmpdir,prefix,offset);
   11.95 -		i++;
   11.96 -		ti=getBranchNum(i);
   11.97 -	}	
   11.98 -
   11.99 -
  11.100 -	/*
  11.101 -	// Save XLinks
  11.102 -	QString ol;	// old link
  11.103 -	QString cl;	// current link
  11.104 -	for (int i=0; i<xlink.size(); ++i)
  11.105 -	{
  11.106 -		cl=xlink.at(i)->saveToDir();
  11.107 -		if (cl!=ol)
  11.108 -		{
  11.109 -			s+=cl;
  11.110 -			ol=cl;
  11.111 -		} else
  11.112 -		{
  11.113 -			qWarning (QString("Ignoring of duplicate xLink in %1").arg(getHeading()));
  11.114 -		}
  11.115 -	}	
  11.116 -	*/
  11.117 -
  11.118 -    decIndent();
  11.119 -    s+=endElement   ("mapcenter");
  11.120 -    return s;
  11.121 -}
  11.122 -
  11.123 -BranchObj* MapCenterItem::createMapObj(QGraphicsScene *scene)	
  11.124 -{
  11.125 -	// Initialize MapCenterObj, order of things is important...
  11.126 -    MapCenterObj* mco=new MapCenterObj(scene);
  11.127 -	lmo=mco;
  11.128 -    mco->setParObj(NULL);
  11.129 -	mco->setModel (model);
  11.130 -	mco->setTreeItem (this);
  11.131 -	mco->setDefAttr(BranchObj::NewBranch);
  11.132 -
  11.133 -	initLMO();
  11.134 -
  11.135 -	if (!getHeading().isEmpty() ) 
  11.136 -	{
  11.137 -		mco->updateData();	//FIXME-3 better call model->emitDataHasChanged(treeItem);
  11.138 -		mco->setColor (headingColor);
  11.139 -	}	
  11.140 -		
  11.141 -	//mco->updateLink();	//FIXME-3
  11.142 -
  11.143 -	return mco;
  11.144 -}
  11.145 -
  11.146 -
    12.1 --- a/mapcenteritem.h	Wed May 20 15:40:14 2009 +0000
    12.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    12.3 @@ -1,17 +0,0 @@
    12.4 -#ifndef MAPCENTERITEM_H
    12.5 -#define MAPCENTERITEM_H
    12.6 -
    12.7 -#include "branchitem.h"
    12.8 -
    12.9 -
   12.10 -class MapCenterItem:public BranchItem
   12.11 -{
   12.12 -public:
   12.13 -    MapCenterItem(const QList<QVariant> &data, TreeItem *parent = 0);
   12.14 -    virtual ~MapCenterItem();
   12.15 -
   12.16 -	QString saveToDir (const QString &tmpdir,const QString &prefix, const QPointF& offset);
   12.17 -	virtual BranchObj* createMapObj (QGraphicsScene *scene);
   12.18 -};
   12.19 -
   12.20 -#endif
    13.1 --- a/mapcenterobj.cpp	Wed May 20 15:40:14 2009 +0000
    13.2 +++ b/mapcenterobj.cpp	Tue May 26 11:23:44 2009 +0000
    13.3 @@ -19,13 +19,6 @@
    13.4      init();
    13.5  }
    13.6  
    13.7 -MapCenterObj::MapCenterObj(QGraphicsScene* s,VymModel *m) : BranchObj (s)
    13.8 -{
    13.9 -//    cout << "Const MapCenterObj   canvas="<<s<<"\n";
   13.10 -	model=m;
   13.11 -    init();
   13.12 -}
   13.13 -
   13.14  MapCenterObj::~MapCenterObj() 
   13.15  {
   13.16  //    cout << "Destr MapCenterObj\n";
   13.17 @@ -45,41 +38,11 @@
   13.18  	// TODO this should be done in TextObj later...
   13.19  	//QFont font ("Sans Serif,16,-1,5,50,0,0,0,0,0");		
   13.20  	//heading->setFont(font);
   13.21 -	//FIXME-2 no treeitem yet:  setDefAttr(MovedBranch);
   13.22 +	//FIXME-2 no treeitem yet:  setDefAttr(MovedBranch); and already in BI::createMapObj ?!?
   13.23  
   13.24  	frame->setFrameType (FrameObj::Rectangle);
   13.25  }
   13.26  
   13.27 -void MapCenterObj::move (double x, double y)
   13.28 -{
   13.29 -	BranchObj::move(x,y);
   13.30 -}
   13.31 -
   13.32 -void MapCenterObj::move (QPointF absPos)
   13.33 -{
   13.34 -	BranchObj::move(absPos);
   13.35 -}
   13.36 -
   13.37 -void MapCenterObj::moveBy (double x, double y)
   13.38 -{
   13.39 -	BranchObj::moveBy(x,y);
   13.40 -}
   13.41 -
   13.42 -void MapCenterObj::moveAll (double x, double y)
   13.43 -{
   13.44 -	// Get rel. position
   13.45 -	double dx=x-absPos.x();
   13.46 -	double dy=y-absPos.y();
   13.47 -
   13.48 -	// Move myself and branches
   13.49 -	moveAllBy (dx,dy);
   13.50 -}
   13.51 -
   13.52 -void MapCenterObj::moveAllBy (double dx, double dy)
   13.53 -{
   13.54 -	// Move myself and children
   13.55 -	BranchObj::moveBy(dx,dy);
   13.56 -}
   13.57  
   13.58  void MapCenterObj::updateLink()
   13.59  {
    14.1 --- a/mapcenterobj.h	Wed May 20 15:40:14 2009 +0000
    14.2 +++ b/mapcenterobj.h	Tue May 26 11:23:44 2009 +0000
    14.3 @@ -16,15 +16,9 @@
    14.4  public:
    14.5      MapCenterObj ();
    14.6      MapCenterObj (QGraphicsScene *);
    14.7 -    MapCenterObj (QGraphicsScene *, VymModel *);
    14.8      ~MapCenterObj ();
    14.9      void clear();
   14.10      void init();
   14.11 -    virtual void move      (double,double);
   14.12 -    virtual void move      (QPointF absPos);
   14.13 -    virtual void moveBy    (double,double);
   14.14 -    virtual void moveAll   (double,double);
   14.15 -    virtual void moveAllBy (double,double);
   14.16      virtual void updateLink();
   14.17      virtual void updateRelPositions();
   14.18  };
    15.1 --- a/mapeditor.cpp	Wed May 20 15:40:14 2009 +0000
    15.2 +++ b/mapeditor.cpp	Tue May 26 11:23:44 2009 +0000
    15.3 @@ -560,7 +560,7 @@
    15.4  	}
    15.5  	BranchObj *bo=model->getSelectedBranchObj();
    15.6  	BranchItem *bi=model->getSelectedBranchItem();
    15.7 -	if (bo)	//FIXME-3
    15.8 +	if (bo)	
    15.9  	{
   15.10  		model->setSelectionBlocked(true);
   15.11  
   15.12 @@ -680,14 +680,13 @@
   15.13      QPointF p = mapToScene(e->pos());
   15.14      TreeItem *ti=findMapItem (p, NULL);
   15.15      LinkableMapObj* lmo=NULL;
   15.16 -	if (ti) lmo=ti->getLMO();	//FIXME-2 get rid of lmo...
   15.17 +	if (ti) lmo=ti->getLMO();	//FIXME-3 get rid of lmo...
   15.18  	
   15.19  	e->accept();
   15.20  
   15.21  	//Take care of  system flags _or_ modifier modes
   15.22  	//
   15.23 -	if (lmo && (typeid(*lmo)==typeid(BranchObj) ||
   15.24 -		typeid(*lmo)==typeid(MapCenterObj) ))
   15.25 +	if (lmo && ti->isBranchLikeType() )
   15.26  	{
   15.27  		QString foname=((BranchObj*)lmo)->getSystemFlagName(p);
   15.28  		if (!foname.isEmpty())
   15.29 @@ -866,27 +865,23 @@
   15.30  			if ( (e->modifiers()==Qt::ShiftModifier) && dst && ( dst != fio->getParObj())  
   15.31  				)
   15.32  			{
   15.33 -				if (typeid(*fio) == typeid(FloatImageObj) )  
   15.34 -				{
   15.35 +				// Also save the move which was done so far
   15.36 +				QString pold=qpointfToString(movingObj_orgRelPos);
   15.37 +				QString pnow=qpointfToString(fio->getRelPos());
   15.38 +				model->saveState(
   15.39 +					fio->getTreeItem(),  // FIXME-3 
   15.40 +					"moveRel "+pold,
   15.41 +					fio->getTreeItem(),
   15.42 +					"moveRel "+pnow,
   15.43 +					QString("Move %1 to relative position %2").arg(model->getObjectName(fio)).arg(pnow));
   15.44 +				fio->getParObj()->requestReposition();
   15.45 +				model->reposition();
   15.46  
   15.47 -					// Also save the move which was done so far
   15.48 -					QString pold=qpointfToString(movingObj_orgRelPos);
   15.49 -					QString pnow=qpointfToString(fio->getRelPos());
   15.50 -					model->saveState(
   15.51 -						fio->getTreeItem(),  // FIXME-3 
   15.52 -						"moveRel "+pold,
   15.53 -						fio->getTreeItem(),
   15.54 -						"moveRel "+pnow,
   15.55 -						QString("Move %1 to relative position %2").arg(model->getObjectName(fio)).arg(pnow));
   15.56 -					fio->getParObj()->requestReposition();
   15.57 -					model->reposition();
   15.58 +				model->linkFloatImageTo (model->getSelectString(dst));
   15.59 +				//movingObj=lmosel;
   15.60 +				//movingObj_orgRelPos=lmosel->getRelPos();	
   15.61  
   15.62 -					model->linkFloatImageTo (model->getSelectString(dst));
   15.63 -					//movingObj=lmosel;
   15.64 -					//movingObj_orgRelPos=lmosel->getRelPos();	
   15.65 -
   15.66 -					model->reposition();
   15.67 -				}	
   15.68 +				model->reposition();
   15.69  			}
   15.70  		} else	
   15.71  		{	// selection != a FloatObj
   15.72 @@ -894,7 +889,9 @@
   15.73  			{
   15.74  				// Move MapCenter
   15.75  				if (e->buttons()== Qt::LeftButton && e->modifiers()==Qt::ShiftModifier) 
   15.76 -					((MapCenterObj*)lmosel)->moveAll(p.x() -movingObj_start.x(), p.y()-movingObj_start.y() );		
   15.77 +					((BranchObj*)lmosel)->moveBy(
   15.78 +						QPointF(p.x() -movingObj_start.x(), 
   15.79 +						p.y()-movingObj_start.y()) );		
   15.80  				else	
   15.81  					lmosel->move   (p.x() -movingObj_start.x(), p.y()-movingObj_start.y() );		
   15.82  				model->updateRelPositions();
   15.83 @@ -1051,7 +1048,7 @@
   15.84              }
   15.85  		}
   15.86  	
   15.87 -		if (seli->getType() == TreeItem::Branch )
   15.88 +		if (seli->isBranchLikeType() ) //(seli->getType() == TreeItem::Branch )
   15.89  		{	// A branch was moved
   15.90  			LinkableMapObj* lmosel=NULL;		//FIXME-2 get rid of lmosel
   15.91  			lmosel=seli->getLMO();
   15.92 @@ -1063,7 +1060,7 @@
   15.93  			lmosel->unsetParObjTmp();
   15.94  
   15.95  			// For Redo we may need to save original selection
   15.96 -			QString preSelStr=model->getSelectString(lmosel);
   15.97 +			QString preSelStr=model->getSelectString(seli);
   15.98  
   15.99  			copyingObj=false;	
  15.100  			if (dsti)
    16.1 --- a/ornamentedobj.cpp	Wed May 20 15:40:14 2009 +0000
    16.2 +++ b/ornamentedobj.cpp	Tue May 26 11:23:44 2009 +0000
    16.3 @@ -62,6 +62,8 @@
    16.4  
    16.5  void OrnamentedObj::setLinkColor()
    16.6  {
    16.7 +	VymModel *model=treeItem->getModel();
    16.8 +	if (!model) return;
    16.9  	if (model->getMapLinkColorHint()==HeadingColor)
   16.10  		LinkableMapObj::setLinkColor (heading->getColor());
   16.11  	else	
   16.12 @@ -261,7 +263,7 @@
   16.13  }
   16.14  */
   16.15  
   16.16 -QString OrnamentedObj::getOrnXMLAttr()	//FIXME-2
   16.17 +QString OrnamentedObj::getOrnXMLAttr()	//FIXME-2 still needed?
   16.18  {
   16.19  	QString posAttr;
   16.20  
   16.21 @@ -271,7 +273,8 @@
   16.22  			attribut("absPosY",QString().setNum(absPos.y())); 
   16.23  	else
   16.24  	{
   16.25 -		if (treeItem->depth()==1 || typeid (*this)==typeid (FloatImageObj))
   16.26 +	/* FIXME-2
   16.27 +		if (treeItem->depth()==1 || typid (*this)==typid (FloatImageObj))
   16.28  		{
   16.29  			if (relPos.x()==0 && relPos.y()==0)
   16.30  				setRelPos();
   16.31 @@ -280,6 +283,7 @@
   16.32  				attribut("relPosY",QString().setNum(relPos.y())); 
   16.33  		} else
   16.34  			posAttr="";
   16.35 +	*/		
   16.36  	}	
   16.37  
   16.38  /* FIXME-2 QString hideExpAttr;
    17.1 --- a/selection.cpp	Wed May 20 15:40:14 2009 +0000
    17.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    17.3 @@ -1,189 +0,0 @@
    17.4 -#include <typeinfo>
    17.5 -#include <iostream>
    17.6 -using namespace std;
    17.7 -
    17.8 -#include "selection.h"
    17.9 -
   17.10 -#include "mainwindow.h"
   17.11 -#include "vymmodel.h"
   17.12 -
   17.13 -
   17.14 -
   17.15 -extern Main *mainWindow;
   17.16 -
   17.17 -Selection::Selection()
   17.18 -{
   17.19 -	blocked=false;
   17.20 -	model=NULL;
   17.21 -}
   17.22 -
   17.23 -Selection::~Selection()
   17.24 -{
   17.25 -}
   17.26 -
   17.27 -void Selection::setModel (VymModel *m)
   17.28 -{
   17.29 -	model=m;
   17.30 -}
   17.31 -
   17.32 -void Selection::update() // FIXME-2 VM emit signal in VM instead and get rid of this
   17.33 -{
   17.34 -/*
   17.35 -	QRectF bbox;
   17.36 -	//int w=0;
   17.37 -	for (int i=0; i< selectList.count(); ++i) 
   17.38 -	{
   17.39 -		bbox=selectList.at(i)->getBBox();
   17.40 -		selboxList.at(i)->setRect (
   17.41 -			bbox.x()-w,bbox.y()-w, 
   17.42 -			bbox.width()+2*w, bbox.height()+2*w);
   17.43 -		selboxList.at(i)->setPen (color);	
   17.44 -		selboxList.at(i)->setBrush (color);	
   17.45 -	}	
   17.46 -*/
   17.47 -}
   17.48 -bool Selection::select(LinkableMapObj *lmo)// FIXME-2 VM emit signal in VM instead and get rid of this
   17.49 -
   17.50 -{
   17.51 -	return model->select (lmo);
   17.52 -	/*
   17.53 -	if (!selectList.isEmpty()) unselect();
   17.54 -	selectList.append (lmo);
   17.55 -	lmo->select();
   17.56 -	update();
   17.57 -	mainWindow->updateSatellites (model);	
   17.58 -	cout << "Sel::select lmo e\n";
   17.59 -	return true;
   17.60 -	*/
   17.61 -}
   17.62 -
   17.63 -bool Selection::select (const QString &s)// FIXME-2 VM emit signal in VM instead and get rid of this
   17.64 -
   17.65 -{
   17.66 -	return model->select (s);
   17.67 -	/*
   17.68 -	cout << "Sel::select s=\n";
   17.69 -	LinkableMapObj *lmo=model->findObjBySelect(s);
   17.70 -
   17.71 -	// Finally select the found object
   17.72 -	if (lmo)
   17.73 -	{
   17.74 -		unselect();
   17.75 -		select (lmo);
   17.76 -		return true;
   17.77 -	} 
   17.78 -	return false;
   17.79 -	*/
   17.80 -}
   17.81 -
   17.82 -bool Selection::reselect ()	// TODO no multiselections yet
   17.83 -{
   17.84 -	if (!lastSelectList.isEmpty())
   17.85 -	{
   17.86 -		select (lastSelectList.first());
   17.87 -		return true;
   17.88 -	}
   17.89 -	return false;
   17.90 -
   17.91 -}
   17.92 -
   17.93 -void Selection::unselect()
   17.94 -{
   17.95 -	model->unselect();
   17.96 -}
   17.97 -
   17.98 -bool Selection::isBlocked()
   17.99 -{
  17.100 -	return blocked;
  17.101 -}
  17.102 -
  17.103 -void Selection::block()
  17.104 -{
  17.105 -	blocked=true;
  17.106 -}
  17.107 -
  17.108 -void Selection::unblock()
  17.109 -{
  17.110 -	blocked=false;
  17.111 -}
  17.112 -
  17.113 -bool Selection::isEmpty()
  17.114 -{
  17.115 -	return selectList.isEmpty();
  17.116 -}
  17.117 -
  17.118 -/*
  17.119 -uint Selection::count()
  17.120 -{
  17.121 -	return selectList.count();
  17.122 -}
  17.123 -*/
  17.124 -
  17.125 -/*
  17.126 -Selection::Type Selection::type() // TODO no multiselections yet
  17.127 -{
  17.128 -	if (!selectList.isEmpty())
  17.129 -	{
  17.130 -		LinkableMapObj *sel=selectList.first();
  17.131 -		if (typeid (*sel)==typeid (BranchObj)) return Branch;
  17.132 -		if (typeid (*sel)==typeid (MapCenterObj)) return MapCenter;
  17.133 -		if (typeid (*sel)==typeid (FloatImageObj)) return FloatImage;
  17.134 -	}
  17.135 -	return Undefined;
  17.136 -}
  17.137 -*/
  17.138 -
  17.139 -/*
  17.140 -LinkableMapObj* Selection::first()
  17.141 -{
  17.142 -	if (!selectList.isEmpty())
  17.143 -		return selectList.first();
  17.144 -	else	
  17.145 -		return NULL;
  17.146 -}
  17.147 -
  17.148 -LinkableMapObj* Selection::single()
  17.149 -{
  17.150 -	if (selectList.count() == 1)
  17.151 -		return selectList.first();
  17.152 -	else	
  17.153 -		return NULL;
  17.154 -}
  17.155 -
  17.156 -TreeItem* Selection::getBranchItem()
  17.157 -{
  17.158 -	BranchObj* bo=getBranch();
  17.159 -	if (bo) return bo->getTreeItem(); //  VM get directly from treemodl
  17.160 -	return NULL;
  17.161 -}
  17.162 -
  17.163 -QModelIndex Selection::getBranchIndex()
  17.164 -{
  17.165 -	return model->getSelectionModel()->selectedIndexes().first();	// TODO no multiselections yet
  17.166 -
  17.167 -}
  17.168 -*/
  17.169 -
  17.170 -FloatImageObj* Selection::getFloatImage()
  17.171 -{
  17.172 -	if (!selectList.isEmpty())
  17.173 -	{
  17.174 -		LinkableMapObj *sel=selectList.first();
  17.175 -		if (typeid (*sel)==typeid (FloatImageObj)) 
  17.176 -			return (FloatImageObj*)sel;
  17.177 -	}
  17.178 -		return NULL;
  17.179 -}
  17.180 -
  17.181 -QString Selection::getSelectString() // FIXME-2 VM this is also in VM ?! clean up here...
  17.182 -// TODO no multiselections yet
  17.183 -{
  17.184 -	if (selectList.count()==1)
  17.185 -	{
  17.186 -		return model->getSelectString (selectList.first() );
  17.187 -	}
  17.188 -	else
  17.189 -		return"";
  17.190 -}
  17.191 -
  17.192 -
    18.1 --- a/selection.h	Wed May 20 15:40:14 2009 +0000
    18.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    18.3 @@ -1,56 +0,0 @@
    18.4 -#ifndef SELECTION_H
    18.5 -#define SELECTION_H
    18.6 -
    18.7 -#include <QString>
    18.8 -#include <QList>
    18.9 -#include <QGraphicsScene>
   18.10 -#include <QItemSelectionModel>
   18.11 -
   18.12 -#include "treeitem.h"
   18.13 -
   18.14 -class BranchObj;
   18.15 -class FloatImageObj;
   18.16 -class MapCenterObj;
   18.17 -class LinkableMapObj;
   18.18 -class VymModel;
   18.19 -
   18.20 -
   18.21 -class Selection 
   18.22 -{
   18.23 -public:
   18.24 -	enum Type {Undefined,Branch,MapCenter,FloatImage};
   18.25 -	Selection ();
   18.26 -	~Selection();
   18.27 -	void setModel (VymModel *);
   18.28 -	void update();      
   18.29 -	bool select (LinkableMapObj*);
   18.30 -	bool select (const QString &);
   18.31 -	bool reselect ();
   18.32 -	void unselect ();
   18.33 -	bool isBlocked ();
   18.34 -	void block();
   18.35 -	void unblock();
   18.36 -	bool isEmpty();
   18.37 -//	uint count();
   18.38 -//	Type type();
   18.39 -//	LinkableMapObj * first();		// first in selection list
   18.40 -//	LinkableMapObj * single();		// NULL, if multiple selected
   18.41 -//	BranchObj* getBranch();
   18.42 -//	TreeItem* getBranchItem();		
   18.43 -//	QModelIndex getBranchIndex();	//!< Returns index of first selected branch or mapcenter
   18.44 -	FloatImageObj* getFloatImage();
   18.45 -
   18.46 -	QString getSelectString();
   18.47 -
   18.48 -private:
   18.49 -	QList <LinkableMapObj*> selectList;
   18.50 -	QList <LinkableMapObj*> lastSelectList;
   18.51 -
   18.52 -	VymModel *model;
   18.53 -
   18.54 -	QColor color;
   18.55 -	bool blocked;					//!< if true, no new selection possible
   18.56 -};
   18.57 -
   18.58 -#endif
   18.59 -
    19.1 --- a/treeitem.cpp	Wed May 20 15:40:14 2009 +0000
    19.2 +++ b/treeitem.cpp	Tue May 26 11:23:44 2009 +0000
    19.3 @@ -5,7 +5,6 @@
    19.4  
    19.5  #include "branchobj.h"
    19.6  #include "branchitem.h"
    19.7 -#include "mapcenteritem.h"
    19.8  #include "vymmodel.h"
    19.9  
   19.10  using namespace std;
   19.11 @@ -14,10 +13,14 @@
   19.12  
   19.13  TreeItem::TreeItem(const QList<QVariant> &data, TreeItem *parent):MapItem()
   19.14  {
   19.15 -	//cout << "Constructor TreeItem "<<endl;
   19.16 +	//cout << "Constructor TreeItem this="<<this<<"  parent="<<parent<<endl;
   19.17  	init();
   19.18      parentItem = parent;
   19.19      itemData = data;
   19.20 +	
   19.21 +	rootItem=this;
   19.22 +	if (parentItem )
   19.23 +		rootItem=parentItem->rootItem;
   19.24  }
   19.25  
   19.26  TreeItem::~TreeItem()
   19.27 @@ -30,7 +33,7 @@
   19.28  		switch (ti->getType() )
   19.29  		{
   19.30  			case TreeItem::MapCenter:
   19.31 -				delete (MapCenterItem*)ti;
   19.32 +				delete (BranchItem*)ti;
   19.33  				break;
   19.34  			case TreeItem::Branch:
   19.35  				delete (BranchItem*)ti;
   19.36 @@ -69,12 +72,6 @@
   19.37  	standardFlags.setMasterRow (standardFlagsMaster);
   19.38  }
   19.39  
   19.40 -QString TreeItem::saveToDir (const QString &tmpdir,const QString &prefix, const QPointF& offset)
   19.41 -{
   19.42 -	cout<< "TreeItem::saveToDir called directly for ("<<getHeadingStd()<<"), instead of inherited type...\n";
   19.43 -	return QString();
   19.44 -}
   19.45 -
   19.46  
   19.47  /*
   19.48  void TreeItem::copy (OrnamentedObj* other)	//FIXME-2	probably need deep copy of branches and data!
   19.49 @@ -101,6 +98,7 @@
   19.50  {
   19.51      childItems.append(item);
   19.52  	item->parentItem=this;
   19.53 +	item->rootItem=rootItem;
   19.54  	item->setModel (model);
   19.55  
   19.56  	if (item->type == Branch || item->type ==MapCenter)
    20.1 --- a/treeitem.h	Wed May 20 15:40:14 2009 +0000
    20.2 +++ b/treeitem.h	Tue May 26 11:23:44 2009 +0000
    20.3 @@ -25,10 +25,6 @@
    20.4      ~TreeItem();
    20.5  	void init();
    20.6  
    20.7 -	virtual QString saveToDir (const QString &tmpdir=QString(),const
    20.8 -	QString &prefix=QString(), const QPointF& offset=QPointF());
    20.9 -
   20.10 -
   20.11  	// General housekeeping
   20.12  	virtual void setModel (VymModel *m);
   20.13  	virtual VymModel* getModel();
   20.14 @@ -166,6 +162,10 @@
   20.15      QList<TreeItem*> childItems;
   20.16      QList<QVariant> itemData;
   20.17      TreeItem *parentItem;
   20.18 +
   20.19 +	/*!  Set rootItem (does not change, needed for quick check 
   20.20 +	     if some branch is mapCenter */
   20.21 +	TreeItem *rootItem;
   20.22   
   20.23  	int branchOffset;
   20.24  	int branchCounter;
    21.1 --- a/treemodel.cpp	Wed May 20 15:40:14 2009 +0000
    21.2 +++ b/treemodel.cpp	Tue May 26 11:23:44 2009 +0000
    21.3 @@ -106,7 +106,7 @@
    21.4          return rootItem->columnCount();
    21.5  }
    21.6  
    21.7 -BranchItem* TreeModel::next(BranchItem* &current, BranchItem* &previous, int &d0)
    21.8 +BranchItem* TreeModel::next(BranchItem* &current, BranchItem* &previous, BranchItem* start)
    21.9  {
   21.10  	// Walk through map beginning at current with previous==0
   21.11  	// Start at root, if current==NULL
   21.12 @@ -115,8 +115,8 @@
   21.13  	// Are we just beginning to walk the map?
   21.14  	if (!previous)
   21.15  	{
   21.16 +		if (!start) start=current;
   21.17  		previous=current;
   21.18 -		d0=current->depth();
   21.19  		current=current->getFirstBranch();
   21.20  		return current;
   21.21  	}
   21.22 @@ -138,7 +138,8 @@
   21.23  		// turn around and go up again
   21.24  	}	
   21.25  
   21.26 -	// Coming from below,
   21.27 +	// Coming from below
   21.28 +
   21.29  	// Trying to go down again to siblings
   21.30  
   21.31  	BranchItem *sibling=current->getBranchNum (previous->num()+1);
   21.32 @@ -151,6 +152,9 @@
   21.33  		return current;
   21.34  	} 
   21.35  
   21.36 +	// If we only needed to go through subtree, we are done now
   21.37 +	if (start==current) return NULL;
   21.38 +
   21.39  	// Go up and try to find siblings of current
   21.40  	previous=current;
   21.41  	current=(BranchItem*)current->parent();
   21.42 @@ -159,27 +163,11 @@
   21.43  	if (!current) return current;
   21.44  	
   21.45  	while (current && current->depth() < previous->depth() )
   21.46 -		next (current,previous,d0);
   21.47 +		current=next (current,previous,start);
   21.48  		
   21.49  	return current;
   21.50  }
   21.51  
   21.52 -/*
   21.53 -bool TreeModel::insertRows ( int row, int count, const QModelIndex & parent)
   21.54 -{
   21.55 -	std::cout << "TreeModel insertRows()\n";
   21.56 -	int last=row+count-1;
   21.57 -	beginInsertRows (parent,row,last);
   21.58 -
   21.59 -	for (int i=row; i<=last; i++)
   21.60 -	{
   21.61 -		std::cout << "TreeModel::insertRows inserting i="<<i<<std::endl;
   21.62 -	}
   21.63 -	endInsertRows ();
   21.64 -	return true;
   21.65 -}
   21.66 -*/
   21.67 -
   21.68  bool TreeModel::removeRows ( int row, int count, const QModelIndex & parent)
   21.69  {
   21.70  	int last=row+count-1;
    22.1 --- a/treemodel.h	Wed May 20 15:40:14 2009 +0000
    22.2 +++ b/treemodel.h	Tue May 26 11:23:44 2009 +0000
    22.3 @@ -28,12 +28,8 @@
    22.4      int rowCount(const QModelIndex &parent = QModelIndex()) const;
    22.5      int columnCount(const QModelIndex &parent = QModelIndex()) const;
    22.6  
    22.7 -	BranchItem* next(BranchItem* &current, BranchItem* &previous, int &d0);
    22.8 +	BranchItem* next(BranchItem* &current, BranchItem* &previous, BranchItem* start=NULL);
    22.9  
   22.10 -/*
   22.11 -	bool insertRows ( int row, int count, 
   22.12 -				const QModelIndex & parent = QModelIndex() ); 
   22.13 -*/				
   22.14  	bool removeRows ( int row, int count, 
   22.15  				const QModelIndex & parent = QModelIndex() ); 
   22.16  
    23.1 --- a/version.h	Wed May 20 15:40:14 2009 +0000
    23.2 +++ b/version.h	Tue May 26 11:23:44 2009 +0000
    23.3 @@ -7,7 +7,7 @@
    23.4  #define __VYM_VERSION "1.13.0"
    23.5  //#define __VYM_CODENAME "Codename: RC-1"
    23.6  #define __VYM_CODENAME "Codename: development version, not for production!"
    23.7 -#define __VYM_BUILD_DATE "2009-05-18"
    23.8 +#define __VYM_BUILD_DATE "2009-05-26"
    23.9  
   23.10  
   23.11  bool checkVersion(const QString &);
    24.1 --- a/vym.pro	Wed May 20 15:40:14 2009 +0000
    24.2 +++ b/vym.pro	Tue May 26 11:23:44 2009 +0000
    24.3 @@ -64,7 +64,6 @@
    24.4  	linkablemapobj.h \
    24.5  	mainwindow.h \
    24.6  	mapcenterobj.h \
    24.7 -	mapcenteritem.h \
    24.8  	mapeditor.h \
    24.9  	mapitem.h \
   24.10  	mapobj.h \
   24.11 @@ -74,7 +73,6 @@
   24.12  	ornamentedobj.h \
   24.13  	parser.h \
   24.14  	process.h \
   24.15 -	selection.h \
   24.16  	showtextdialog.h\
   24.17  	simplescripteditor.h\
   24.18  	texteditor.h \
   24.19 @@ -126,7 +124,6 @@
   24.20  	linkablemapobj.cpp \
   24.21  	main.cpp \
   24.22  	mainwindow.cpp \
   24.23 -	mapcenteritem.cpp \
   24.24  	mapcenterobj.cpp \
   24.25  	mapeditor.cpp \
   24.26  	mapitem.cpp \
   24.27 @@ -137,7 +134,6 @@
   24.28  	ornamentedobj.cpp \
   24.29  	parser.cpp \
   24.30  	process.cpp \
   24.31 -	selection.cpp \
   24.32  	showtextdialog.cpp \
   24.33  	simplescripteditor.cpp \
   24.34  	texteditor.cpp \
    25.1 --- a/vymmodel.cpp	Wed May 20 15:40:14 2009 +0000
    25.2 +++ b/vymmodel.cpp	Tue May 26 11:23:44 2009 +0000
    25.3 @@ -5,7 +5,6 @@
    25.4  
    25.5  #include "treeitem.h"
    25.6  #include "branchitem.h"
    25.7 -#include "mapcenteritem.h"
    25.8  #include "editxlinkdialog.h"
    25.9  #include "exports.h"
   25.10  #include "exportxhtmldialog.h"
   25.11 @@ -15,8 +14,6 @@
   25.12  #include "mapcenterobj.h"
   25.13  #include "misc.h"
   25.14  #include "parser.h"
   25.15 -#include "selection.h"
   25.16 -
   25.17  
   25.18  #include "warningdialog.h"
   25.19  #include "xml-freemind.h"
   25.20 @@ -121,6 +118,7 @@
   25.21  
   25.22  	// selections
   25.23  	selModel=NULL;
   25.24 +	selectionBlocked=false;
   25.25  
   25.26  	// find routine
   25.27  	findCurrent=NULL;				
   25.28 @@ -245,9 +243,9 @@
   25.29  		s+=saveTreeToDir(tmpdir,prefix,writeflags,offset);
   25.30  	else
   25.31  	{
   25.32 -		if (saveSel->getType()==TreeItem::Branch)
   25.33 +		if (saveSel->isBranchLikeType())
   25.34  			// Save Subtree
   25.35 -			s+=saveSel->saveToDir(tmpdir,prefix,offset);
   25.36 +			s+=((BranchItem*)saveSel)->saveToDir(tmpdir,prefix,offset);
   25.37  		//FIXME-2 else if (saveSel->getType()==TreeItem::Image)
   25.38  			// Save image
   25.39  			//s+=((FloatImageObj*)(saveSel))->saveToDir(tmpdir,prefix);
   25.40 @@ -272,7 +270,7 @@
   25.41      QString s;
   25.42  
   25.43  	for (int i=0; i<rootItem->branchCount(); i++)
   25.44 -		s+=((MapCenterItem*)rootItem->getBranchNum(i))->saveToDir (tmpdir,prefix,offset);
   25.45 +		s+=rootItem->getBranchNum(i)->saveToDir (tmpdir,prefix,offset);
   25.46      return s;
   25.47  }
   25.48  
   25.49 @@ -465,7 +463,7 @@
   25.50  		if ( ok ) 
   25.51  		{
   25.52  			reposition();	// FIXME-2 VM reposition the view instead...
   25.53 -			selection.update();
   25.54 +			updateSelection();
   25.55  			if (lmode==NewMap)
   25.56  			{
   25.57  				mapDefault=false;
   25.58 @@ -585,7 +583,7 @@
   25.59  	makeSubDirs (fileDir);
   25.60  
   25.61  	QString saveFile;
   25.62 -	if (savemode==CompleteMap || selection.isEmpty())
   25.63 +	if (savemode==CompleteMap || selModel->selection().isEmpty())
   25.64  	{
   25.65  		// Save complete map
   25.66  		saveFile=saveToDir (fileDir,mapName+"-",true,QPointF(),NULL);
   25.67 @@ -770,7 +768,8 @@
   25.68  
   25.69  void VymModel::saveFloatImage ()
   25.70  {
   25.71 -	FloatImageObj *fio=selection.getFloatImage();
   25.72 +	//FIXME-1 FloatImageObj *fio=selection.getFloatImage();
   25.73 +	FloatImageObj *fio=NULL;
   25.74  	if (fio)
   25.75  	{
   25.76  		QFileDialog *fd=new QFileDialog( NULL);
   25.77 @@ -998,15 +997,15 @@
   25.78  	QString s;
   25.79  	if (!lmo) return QString("Error: NULL has no name!");
   25.80  
   25.81 -	if ((typeid(*lmo) == typeid(BranchObj) ||
   25.82 -				      typeid(*lmo) == typeid(MapCenterObj))) 
   25.83 +	TreeItem *ti=lmo->getTreeItem();
   25.84 +	if (ti->isBranchLikeType() )
   25.85  	{
   25.86  		
   25.87  		s=lmo->getTreeItem()->getHeading();
   25.88  		if (s=="") s="unnamed";
   25.89  		return QString("branch (%1)").arg(s);
   25.90  	}	
   25.91 -	if ((typeid(*lmo) == typeid(FloatImageObj) ))
   25.92 +	if (ti->getType()==TreeItem::Image)
   25.93  		return QString ("floatimage [%1]").arg(((FloatImageObj*)lmo)->getOriginalFilename());
   25.94  	return QString("Unknown type has no name!");
   25.95  }
   25.96 @@ -1180,8 +1179,7 @@
   25.97  
   25.98  	mainWindow->updateHistory (undoSet);
   25.99  	updateActions();
  25.100 -	selection.update();
  25.101 -	emitShowSelection();
  25.102 +	updateSelection();
  25.103  }
  25.104  
  25.105  bool VymModel::isUndoAvailable()
  25.106 @@ -1487,12 +1485,11 @@
  25.107  	int c=0;
  25.108  	BranchItem *cur=NULL;
  25.109  	BranchItem *prev=NULL;
  25.110 -	int d;
  25.111 -	next(cur,prev,d);
  25.112 +	next(cur,prev);
  25.113  	while (cur) 
  25.114  	{
  25.115  		c++;
  25.116 -		next(cur,prev,d);
  25.117 +		next(cur,prev);
  25.118  	}
  25.119  	return c;
  25.120  }
  25.121 @@ -1512,14 +1509,12 @@
  25.122  		emitDataHasChanged ( selbi);	//FIXME-3 maybe emit signal from TreeItem? 
  25.123  
  25.124  		reposition();
  25.125 -//		selection.update();	//FIXME-4
  25.126  		updateSelection();
  25.127  	}
  25.128  }
  25.129  
  25.130  BranchItem* VymModel::findText (QString s, bool cs)   
  25.131  {
  25.132 -	int d=0;
  25.133  	QTextDocument::FindFlags flags=0;
  25.134  	if (cs) flags=QTextDocument::FindCaseSensitively;
  25.135  
  25.136 @@ -1530,7 +1525,7 @@
  25.137  			EOFind=false;
  25.138  		findCurrent=NULL;	
  25.139  		findPrevious=NULL;	
  25.140 -		next (findCurrent,findPrevious,d);
  25.141 +		next (findCurrent,findPrevious);
  25.142  	}	
  25.143  	bool searching=true;
  25.144  	bool foundNote=false;
  25.145 @@ -1564,7 +1559,7 @@
  25.146  		}	
  25.147  		if (!foundNote)
  25.148  		{
  25.149 -			if (!next(findCurrent,findPrevious,d) )
  25.150 +			if (!next(findCurrent,findPrevious) )
  25.151  				EOFind=true;
  25.152  		}
  25.153  	//cout <<"still searching...  "<<qPrintable( itFind->getHeading())<<endl;
  25.154 @@ -1621,21 +1616,21 @@
  25.155  QStringList VymModel::getURLs()	
  25.156  {
  25.157  	QStringList urls;
  25.158 -	BranchItem *cur=getSelectedBranchItem();
  25.159 +	BranchItem *selbi=getSelectedBranchItem();
  25.160 +	BranchItem *cur=selbi;
  25.161  	BranchItem *prev=NULL;
  25.162 -	int d=0;
  25.163 -	next (cur,prev,d);
  25.164  	while (cur) 
  25.165  	{
  25.166  		if (!cur->getURL().isEmpty()) urls.append( cur->getURL());
  25.167 -		cur=next (cur,prev,d);
  25.168 +		cur=next (cur,prev,selbi);
  25.169  	}	
  25.170  	return urls;
  25.171  }
  25.172  
  25.173 -void VymModel::linkFloatImageTo(const QString &dstString)	// FIXME-2
  25.174 -{
  25.175 -	FloatImageObj *fio=selection.getFloatImage();
  25.176 +void VymModel::linkFloatImageTo(const QString &dstString)	// FIXME-1
  25.177 +{
  25.178 +	//FIXME-1 FloatImageObj *fio=selection.getFloatImage();
  25.179 +	FloatImageObj *fio=NULL;
  25.180  	if (fio)
  25.181  	{
  25.182  		TreeItem *dst=findBySelectString (dstString);
  25.183 @@ -1645,7 +1640,7 @@
  25.184  			QString parString=getSelectString(dstPar);
  25.185  			QString fioPreSelectString=getSelectString(fio);
  25.186  			QString fioPreParentSelectString=getSelectString (fio->getParObj());
  25.187 -			// FIXME-2 ((BranchObj*)dst)->addFloatImage (fio);
  25.188 +			// FIXME-1 ((BranchObj*)dst)->addFloatImage (fio);
  25.189  			unselect();
  25.190  			// ((BranchObj*)(fio->getParObj()))->removeFloatImage (fio);
  25.191  			fio=((BranchObj*)dst)->getLastFloatImage();
  25.192 @@ -1834,7 +1829,7 @@
  25.193  		);	
  25.194  		updateActions();
  25.195  		reposition();
  25.196 -		// selection.update();
  25.197 +		// updateSelection();
  25.198  		// FIXME-3 VM needed? scene()->update();
  25.199  	}
  25.200  }
  25.201 @@ -1962,11 +1957,11 @@
  25.202  */
  25.203  }
  25.204  
  25.205 -MapCenterItem* VymModel::createMapCenter()
  25.206 -{
  25.207 -	MapCenterItem *mci=addMapCenter (QPointF (0,0) );
  25.208 -	select (mci);
  25.209 -	return mci;
  25.210 +BranchItem* VymModel::createMapCenter()
  25.211 +{
  25.212 +	BranchItem *newbi=addMapCenter (QPointF (0,0) );
  25.213 +	select (newbi);
  25.214 +	return newbi;
  25.215  }
  25.216  
  25.217  BranchItem* VymModel::createBranch()	
  25.218 @@ -1978,8 +1973,9 @@
  25.219  		return NULL;
  25.220  }
  25.221  
  25.222 -TreeItem* VymModel::createImage()	//FIXME-2
  25.223 -{
  25.224 +TreeItem* VymModel::createImage()	//FIXME-1
  25.225 +{
  25.226 +	return NULL;
  25.227  /*
  25.228  	BranchObj *bo=getSelectedBranch();
  25.229  	if (bo)
  25.230 @@ -2002,26 +1998,25 @@
  25.231  			return ti;
  25.232  		}
  25.233  	}
  25.234 -	return NULL;
  25.235  */
  25.236  }
  25.237  
  25.238 -MapCenterItem* VymModel::addMapCenter ()
  25.239 -{
  25.240 -	MapCenterItem *mci=addMapCenter (contextPos);
  25.241 +BranchItem* VymModel::addMapCenter ()
  25.242 +{
  25.243 +	BranchItem *bi=addMapCenter (contextPos);
  25.244  	updateActions();
  25.245  	emitShowSelection();
  25.246  	saveState (
  25.247 -		mci,
  25.248 +		bi,
  25.249  		"delete()",
  25.250  		NULL,
  25.251  		QString ("addMapCenter (%1,%2)").arg (contextPos.x()).arg(contextPos.y()),
  25.252  		QString ("Adding MapCenter to (%1,%2)").arg (contextPos.x()).arg(contextPos.y())
  25.253  	);	
  25.254 -	return mci;	
  25.255 +	return bi;	
  25.256  }
  25.257  
  25.258 -MapCenterItem* VymModel::addMapCenter(QPointF absPos)
  25.259 +BranchItem* VymModel::addMapCenter(QPointF absPos)	//FIXME-2 absPos not used in context menu?!
  25.260  {
  25.261  
  25.262  	// Create TreeItem
  25.263 @@ -2034,17 +2029,17 @@
  25.264  
  25.265  	QList<QVariant> cData;
  25.266  	cData << "VM:addMapCenter" << "undef"<<"undef";
  25.267 -	MapCenterItem *mci=new MapCenterItem (cData);
  25.268 -	mci->setHeading (QApplication::translate("Heading of mapcenter in new map", "New map"));
  25.269 -	rootItem->appendChild (mci);
  25.270 +	BranchItem *newbi=new BranchItem (cData);
  25.271 +	newbi->setHeading (QApplication::translate("Heading of mapcenter in new map", "New map"));
  25.272 +	rootItem->appendChild (newbi);
  25.273  
  25.274  	endInsertRows();
  25.275  	emit (layoutChanged() );
  25.276  
  25.277  	// Create MapObj
  25.278 -	BranchObj *newbo=mci->createMapObj(mapScene);
  25.279 +	newbi->createMapObj(mapScene);
  25.280  		
  25.281 -	return mci;
  25.282 +	return newbi;
  25.283  }
  25.284  
  25.285  BranchItem* VymModel::addNewBranchInt(BranchItem *dst,int num)	//FIXME-4 simplify...
  25.286 @@ -2121,7 +2116,7 @@
  25.287  				QString ("Add new branch to %1").arg(getObjectName(selbi)));	
  25.288  
  25.289  			reposition();
  25.290 -			// selection.update(); FIXME-3
  25.291 +			// updateSelection(); FIXME-3
  25.292  			latestAddedItem=newbi;
  25.293  			// In Network mode, the client needs to know where the new branch is,
  25.294  			// so we have to pass on this information via saveState.
  25.295 @@ -2161,7 +2156,7 @@
  25.296  				QString ("Add branch before %1").arg(getObjectName(selbi)));
  25.297  
  25.298  			// FIXME-3 needed? reposition();
  25.299 -			// selection.update(); FIXME-3 
  25.300 +			// updateSelection(); FIXME-3 
  25.301  		}
  25.302  	}	
  25.303  	//FIXME-3 needed? latestSelectionString=selection.getSelectString();
  25.304 @@ -2172,6 +2167,10 @@
  25.305  {
  25.306  	if (branch && dst)
  25.307  	{
  25.308 +		if (branch->depth()==0) 
  25.309 +		{
  25.310 +			cout <<"VM::relinkBranch  d=0 for "<<branch->getHeadingStd()<<endl;
  25.311 +		}
  25.312  		emit (layoutAboutToBeChanged() );
  25.313  		BranchItem *branchpi=(BranchItem*)branch->parent();
  25.314  		// Remove at current position
  25.315 @@ -2191,7 +2190,9 @@
  25.316  		dst->insertBranch (pos,branch);
  25.317  		endInsertRows();
  25.318  
  25.319 -		branch->getLMO()->setParObj(dst->getLMO());	//FIXME-5 update parObj in View
  25.320 +		// reset parObj, fonts, frame, etc in related LMO or other view-objects
  25.321 +		branch->updateStyles();
  25.322 +
  25.323  		emit (layoutChanged() );
  25.324  		reposition();	// both for moveUp/Down and relinking
  25.325  		select (branch);
  25.326 @@ -2449,49 +2450,50 @@
  25.327  }
  25.328  
  25.329  
  25.330 -void VymModel::colorBranch (QColor c)	//FIXME-2
  25.331 -{
  25.332 -/*
  25.333 -	BranchObj *bo=getSelectedBranch();
  25.334 -	if (bo)
  25.335 +void VymModel::colorBranch (QColor c)	
  25.336 +{
  25.337 +	BranchItem *selbi=getSelectedBranchItem();
  25.338 +	if (selbi)
  25.339  	{
  25.340  		saveState(
  25.341 -			bo, 
  25.342 -			QString ("colorBranch (\"%1\")").arg(bo->getColor().name()),
  25.343 -			bo,
  25.344 +			selbi, 
  25.345 +			QString ("colorBranch (\"%1\")").arg(selbi->getHeadingColor().name()),
  25.346 +			selbi,
  25.347  			QString ("colorBranch (\"%1\")").arg(c.name()),
  25.348 -			QString("Set color of %1 to %2").arg(getObjectName(bo)).arg(c.name())
  25.349 +			QString("Set color of %1 to %2").arg(getObjectName(selbi)).arg(c.name())
  25.350  		);	
  25.351 -		bo->setColor(c); // color branch
  25.352 +		selbi->setHeadingColor(c); // color branch
  25.353  	}
  25.354 -*/
  25.355  }
  25.356  
  25.357 -void VymModel::colorSubtree (QColor c) //FIXME-2
  25.358 -{
  25.359 -/*
  25.360 -	BranchObj *bo=getSelectedBranch();
  25.361 -	if (bo) 
  25.362 +void VymModel::colorSubtree (QColor c) 
  25.363 +{
  25.364 +	BranchItem *selbi=getSelectedBranchItem();
  25.365 +	if (selbi)
  25.366  	{
  25.367  		saveStateChangingPart(
  25.368 -			bo, 
  25.369 -			bo,
  25.370 +			selbi,
  25.371 +			selbi,
  25.372  			QString ("colorSubtree (\"%1\")").arg(c.name()),
  25.373 -			QString ("Set color of %1 and children to %2").arg(getObjectName(bo)).arg(c.name())
  25.374 +			QString ("Set color of %1 and children to %2").arg(getObjectName(selbi)).arg(c.name())
  25.375  		);	
  25.376 -		bo->setColorSubtree (c); // color links, color children
  25.377 +		BranchItem *prev=NULL;
  25.378 +		BranchItem *cur=selbi;
  25.379 +		while (cur) 
  25.380 +		{
  25.381 +			cur->setHeadingColor(c); // color links, color children
  25.382 +			cur=next (cur,prev,selbi);
  25.383 +		}	
  25.384 +
  25.385  	}
  25.386 -*/	
  25.387  }
  25.388  
  25.389 -QColor VymModel::getCurrentHeadingColor()	//FIXME-2
  25.390 -{
  25.391 -/*
  25.392 -	BranchObj *bo=getSelectedBranch();
  25.393 -	if (bo) return bo->getColor(); 
  25.394 -	
  25.395 +QColor VymModel::getCurrentHeadingColor()	
  25.396 +{
  25.397 +	BranchItem *selbi=getSelectedBranchItem();
  25.398 +	if (selbi)	return selbi->getHeadingColor();
  25.399 +		
  25.400  	QMessageBox::warning(0,"Warning","Can't get color of heading,\nthere's no branch selected");
  25.401 -	*/
  25.402  	return Qt::black;
  25.403  }
  25.404  
  25.405 @@ -2615,8 +2617,7 @@
  25.406  		bi->setVymLink(s);
  25.407  		reposition();
  25.408  		updateActions();
  25.409 -		//selection.update();
  25.410 -		emitShowSelection();
  25.411 +		//updateSelection();
  25.412  	}
  25.413  }
  25.414  
  25.415 @@ -2651,14 +2652,13 @@
  25.416  QStringList VymModel::getVymLinks()	
  25.417  {
  25.418  	QStringList links;
  25.419 -	BranchItem *cur=getSelectedBranchItem();
  25.420 +	BranchItem *selbi=getSelectedBranchItem();
  25.421 +	BranchItem *cur=selbi;
  25.422  	BranchItem *prev=NULL;
  25.423 -	int d=0;
  25.424 -	next (cur,prev,d);
  25.425  	while (cur) 
  25.426  	{
  25.427  		if (!cur->getVymLink().isEmpty()) links.append( cur->getVymLink());
  25.428 -		cur=next (cur,prev,d);
  25.429 +		cur=next (cur,prev,selbi);
  25.430  	}	
  25.431  	return links;
  25.432  }
  25.433 @@ -3027,16 +3027,16 @@
  25.434  				LinkableMapObj *dst=findObjBySelect (s);
  25.435  				if (dst)
  25.436  				{	
  25.437 -					if (typeid(*dst) == typeid(BranchObj) ) 
  25.438 +					if (typid(*dst) == typid(BranchObj) ) 
  25.439  					{
  25.440  						// Get number in parent
  25.441  						n=parser.parInt (ok,1);
  25.442  						if (ok)
  25.443  						{
  25.444  							selb->linkTo ((BranchObj*)(dst),n);
  25.445 -							selection.update();
  25.446 +							updateSelection();
  25.447  						}	
  25.448 -					} else if (typeid(*dst) == typeid(MapCenterObj) ) 
  25.449 +					} else if (typid(*dst) == typid(MapCenterObj) ) 
  25.450  					{
  25.451  						selb->linkTo ((BranchObj*)(dst),-1);
  25.452  						// Get coordinates of mainbranch
  25.453 @@ -3047,7 +3047,7 @@
  25.454  							if (ok) 
  25.455  							{
  25.456  								selbi->move (x,y);
  25.457 -								selection.update();
  25.458 +								updateSelection();
  25.459  							}
  25.460  						}
  25.461  					}	
  25.462 @@ -3062,8 +3062,8 @@
  25.463  				LinkableMapObj *dst=findObjBySelect (s);
  25.464  				if (dst)
  25.465  				{	
  25.466 -					if (typeid(*dst) == typeid(BranchObj) ||
  25.467 -						typeid(*dst) == typeid(MapCenterObj)) 
  25.468 +					if (typid(*dst) == typid(BranchObj) ||
  25.469 +						typid(*dst) == typid(MapCenterObj)) 
  25.470  						linkFloatImageTo (getSelectString(dst));
  25.471  				} else	
  25.472  					parser.setError (Aborted,"Destination is not a branch");
  25.473 @@ -3236,7 +3236,8 @@
  25.474  	/////////////////////////////////////////////////////////////////////
  25.475  	} else if (com=="saveImage")
  25.476  	{
  25.477 -		FloatImageObj *fio=selection.getFloatImage();
  25.478 +		//FIXME-2 FloatImageObj *fio=selection.getFloatImage();
  25.479 +		FloatImageObj* fio=NULL;
  25.480  		if (!fio)
  25.481  		{
  25.482  			parser.setError (Aborted,"Type of selection is not an image");
  25.483 @@ -3879,9 +3880,10 @@
  25.484  		rootItem->getBranchObjNum(i)->reposition();	//	for positioning heading
  25.485  }
  25.486  
  25.487 +/*
  25.488  QPolygonF VymModel::shape(BranchObj *bo)	//FIXME-4
  25.489  {
  25.490 -/*
  25.491 +	return QPolygonF ();
  25.492  	// Creating (arbitrary) shapes
  25.493  
  25.494  	QPolygonF p;
  25.495 @@ -3911,9 +3913,10 @@
  25.496  			<<rb.bottomLeft()
  25.497  			<<QPointF (rb.bottomRight().x(), ra.bottomRight().y() ) ;
  25.498  	return p;		
  25.499 -	*/
  25.500  }
  25.501 -
  25.502 +*/
  25.503 +
  25.504 +/*
  25.505  void VymModel::moveAway(LinkableMapObj *lmo)	//FIXME-5
  25.506  {
  25.507  	// Autolayout:
  25.508 @@ -3921,7 +3924,6 @@
  25.509  	// Move all branches and MapCenters away from lmo 
  25.510  	// to avoid collisions 
  25.511  
  25.512 -		/*
  25.513  	QPolygonF pA;
  25.514  	QPolygonF pB;
  25.515  
  25.516 @@ -3941,8 +3943,8 @@
  25.517  			<<r.willIntersect 
  25.518  			<<"  minT="<<r.minTranslation<<endl<<endl;
  25.519  	}
  25.520 -			*/
  25.521  }
  25.522 +*/
  25.523  
  25.524  QPixmap VymModel::getPixmap()
  25.525  {
  25.526 @@ -3953,14 +3955,14 @@
  25.527  	pp.setRenderHints(mapEditor->renderHints());
  25.528  
  25.529  	// Don't print the visualisation of selection
  25.530 -	selection.unselect();
  25.531 +	unselect();
  25.532  
  25.533  	mapScene->render (	&pp, 
  25.534  		QRectF(0,0,mapRect.width()+2,mapRect.height()+2),
  25.535  		QRectF(mapRect.x(),mapRect.y(),mapRect.width(),mapRect.height() ));
  25.536  
  25.537  	// Restore selection
  25.538 -	selection.reselect();
  25.539 +	reselect();
  25.540  	
  25.541  	return pix;
  25.542  }
  25.543 @@ -4007,14 +4009,13 @@
  25.544  
  25.545  	BranchItem *cur=NULL;
  25.546  	BranchItem *prev=NULL;
  25.547 -	int d=0;
  25.548  	BranchObj *bo;
  25.549 -	next (cur,prev,d);
  25.550 +	next (cur,prev);
  25.551  	while (cur) 
  25.552  	{
  25.553  		bo=(BranchObj*)(cur->getLMO() );
  25.554  		bo->setLinkStyle(bo->getDefLinkStyle());
  25.555 -		cur=next(cur,prev,d);
  25.556 +		cur=next(cur,prev);
  25.557  	}
  25.558  	reposition();
  25.559  }
  25.560 @@ -4036,14 +4037,13 @@
  25.561  	defLinkColor=col;
  25.562  	BranchItem *cur=NULL;
  25.563  	BranchItem *prev=NULL;
  25.564 -	int d=0;
  25.565  	BranchObj *bo;
  25.566 -	cur=next(cur,prev,d);
  25.567 +	cur=next(cur,prev);
  25.568  	while (cur) 
  25.569  	{
  25.570  		bo=(BranchObj*)(cur->getLMO() );
  25.571  		bo->setLinkColor();
  25.572 -		next(cur,prev,d);
  25.573 +		next(cur,prev);
  25.574  	}
  25.575  	updateActions();
  25.576  }
  25.577 @@ -4053,14 +4053,13 @@
  25.578  	// called from setMapLinkColorHint(lch) or at end of parse
  25.579  	BranchItem *cur=NULL;
  25.580  	BranchItem *prev=NULL;
  25.581 -	int d=0;
  25.582  	BranchObj *bo;
  25.583 -	cur=next(cur,prev,d);
  25.584 +	cur=next(cur,prev);
  25.585  	while (cur) 
  25.586  	{
  25.587  		bo=(BranchObj*)(cur->getLMO() );
  25.588  		bo->setLinkColor();
  25.589 -		cur=next(cur,prev,d);
  25.590 +		cur=next(cur,prev);
  25.591  	}
  25.592  }
  25.593  
  25.594 @@ -4078,14 +4077,13 @@
  25.595  		linkcolorhint=LinkableMapObj::HeadingColor;
  25.596  	BranchItem *cur=NULL;
  25.597  	BranchItem *prev=NULL;
  25.598 -	int d=0;
  25.599  	BranchObj *bo;
  25.600 -	cur=next(cur,prev,d);
  25.601 +	cur=next(cur,prev);
  25.602  	while (cur) 
  25.603  	{
  25.604  		bo=(BranchObj*)(cur->getLMO() );
  25.605  		bo->setLinkColor();
  25.606 -		next(cur,prev,d);
  25.607 +		next(cur,prev);
  25.608  	}
  25.609  }
  25.610  
  25.611 @@ -4203,7 +4201,7 @@
  25.612                  QString("Move %1 to %2").arg(getObjectName(bo)).arg(ps));
  25.613              bo->move(x,y);
  25.614              reposition();
  25.615 -            selection.update();
  25.616 +            updateSelection();
  25.617          }
  25.618  	}
  25.619  */	
  25.620 @@ -4234,7 +4232,7 @@
  25.621              ((OrnamentedObj*)bo)->move2RelPos (x,y);
  25.622              reposition();
  25.623              bo->updateLink();
  25.624 -            selection.update();
  25.625 +            updateSelection();
  25.626          }
  25.627  	}
  25.628  */	
  25.629 @@ -4294,7 +4292,7 @@
  25.630  void VymModel::sendSelection()
  25.631  {
  25.632  	if (netstate!=Server) return;
  25.633 -	sendData (QString("select (\"%1\")").arg(selection.getSelectString()) );
  25.634 +	sendData (QString("select (\"%1\")").arg(getSelectString()) );
  25.635  }
  25.636  
  25.637  void VymModel::newServer()
  25.638 @@ -4522,15 +4520,12 @@
  25.639  
  25.640  void VymModel::setSelectionBlocked (bool b)
  25.641  {
  25.642 -	if (b)
  25.643 -		selection.block();
  25.644 -	else	
  25.645 -		selection.unblock();
  25.646 +	selectionBlocked=b;
  25.647  }
  25.648  
  25.649  bool VymModel::isSelectionBlocked()
  25.650  {
  25.651 -	return selection.isBlocked();
  25.652 +	return selectionBlocked;
  25.653  }
  25.654  
  25.655  bool VymModel::select ()
  25.656 @@ -4582,12 +4577,13 @@
  25.657  
  25.658  void VymModel::unselect()
  25.659  {
  25.660 +	lastSelectString=getSelectString();
  25.661  	selModel->clearSelection();
  25.662  }	
  25.663  
  25.664  void VymModel::reselect()
  25.665  {
  25.666 -	selection.reselect();
  25.667 +	select (lastSelectString);
  25.668  }	
  25.669  
  25.670  void VymModel::emitShowSelection()	
  25.671 @@ -4614,8 +4610,7 @@
  25.672  {
  25.673  	if (selection.select(lmo))
  25.674  	{
  25.675 -		//selection.update();
  25.676 -		sendSelection ();	// FIXME-4 VM use signal
  25.677 +		//updateSelection();
  25.678  	}
  25.679  }
  25.680  
  25.681 @@ -4623,8 +4618,7 @@
  25.682  {
  25.683  	if (selection.select(lmo))
  25.684  	{
  25.685 -		//selection.update();
  25.686 -		sendSelection ();	// FIXME-4 VM use signal
  25.687 +		//updateSelection();
  25.688  	}
  25.689  }
  25.690  */
  25.691 @@ -4747,8 +4741,6 @@
  25.692  
  25.693  void VymModel::selectUpperBranch()
  25.694  {
  25.695 -	if (selection.isBlocked() ) return;
  25.696 -
  25.697  	BranchItem *bi=getSelectedBranchItem();
  25.698  	if (bi && bi->isBranchLikeType())
  25.699  		selectAboveBranchInt();
  25.700 @@ -4756,8 +4748,6 @@
  25.701  
  25.702  void VymModel::selectLowerBranch()
  25.703  {
  25.704 -	if (selection.isBlocked() ) return;
  25.705 -
  25.706  	BranchItem *bi=getSelectedBranchItem();
  25.707  	if (bi && bi->isBranchLikeType())
  25.708  		selectBelowBranchInt();
  25.709 @@ -4766,8 +4756,6 @@
  25.710  
  25.711  void VymModel::selectLeftBranch()
  25.712  {
  25.713 -	if (selection.isBlocked() ) return;
  25.714 -
  25.715  	QItemSelection oldsel=selModel->selection();
  25.716  
  25.717  	BranchItem* par;
  25.718 @@ -4806,8 +4794,6 @@
  25.719  
  25.720  void VymModel::selectRightBranch()
  25.721  {
  25.722 -	if (selection.isBlocked() ) return;
  25.723 -
  25.724  	QItemSelection oldsel=selModel->selection();
  25.725  
  25.726  	BranchItem* par;
  25.727 @@ -4854,9 +4840,7 @@
  25.728  		TreeItem *ti2=par->getFirstBranch();
  25.729  		if (ti2) {
  25.730  			select(ti2);
  25.731 -			selection.update();
  25.732 -			emitShowSelection();
  25.733 -			sendSelection();
  25.734 +			updateSelection();
  25.735  		}
  25.736  	}		
  25.737  }
  25.738 @@ -4871,9 +4855,7 @@
  25.739  		TreeItem *ti2=par->getLastBranch();
  25.740  		if (ti2) {
  25.741  			select(ti2);
  25.742 -			selection.update();
  25.743 -			emitShowSelection();
  25.744 -			sendSelection();
  25.745 +			updateSelection();
  25.746  		}
  25.747  	}		
  25.748  }
  25.749 @@ -4897,9 +4879,7 @@
  25.750  		par=ti->parent();
  25.751  		if (!par) return;
  25.752  		select(par);
  25.753 -		selection.update();
  25.754 -		emitShowSelection();
  25.755 -		sendSelection();
  25.756 +		updateSelection();
  25.757  	}		
  25.758  }
  25.759  
  25.760 @@ -4969,7 +4949,8 @@
  25.761  
  25.762  FloatImageObj* VymModel::getSelectedFloatImage()
  25.763  {
  25.764 -	return selection.getFloatImage();	
  25.765 +	//FIXME-2 return selection.getFloatImage();	
  25.766 +	return NULL;
  25.767  }
  25.768  
  25.769  QString VymModel::getSelectString ()
    26.1 --- a/vymmodel.h	Wed May 20 15:40:14 2009 +0000
    26.2 +++ b/vymmodel.h	Tue May 26 11:23:44 2009 +0000
    26.3 @@ -8,12 +8,10 @@
    26.4  #include "mapcenterobj.h"
    26.5  #include "mapeditor.h"
    26.6  #include "parser.h"
    26.7 -#include "selection.h"
    26.8  #include "treeitem.h"
    26.9  #include "treemodel.h"
   26.10  
   26.11  class BranchItem;
   26.12 -class MapCenterItem;
   26.13  class MapEditor;
   26.14  
   26.15  class VymModel : public TreeModel {		
   26.16 @@ -282,7 +280,7 @@
   26.17  	void sortChildren();	//!< Sort children lexically
   26.18  
   26.19  	// The create methods are used to quickly parse a XML file
   26.20 -	MapCenterItem* createMapCenter();	//!< Create and select MapCenter
   26.21 +	BranchItem* createMapCenter();	//!< Create and select MapCenter // FIXME-3 maybe join this also with createBranch
   26.22  	BranchItem* createBranch();			//!< Create and select Branch
   26.23  	TreeItem* createImage();			//!< Create and select image
   26.24  
   26.25 @@ -290,9 +288,9 @@
   26.26  
   26.27  	    Disclaimer: Still experimental, not fully supported yet.
   26.28  	*/	
   26.29 -	MapCenterItem* addMapCenter();
   26.30 +	BranchItem* addMapCenter();
   26.31  private:	
   26.32 -	MapCenterItem* addMapCenter(QPointF absPos);
   26.33 +	BranchItem* addMapCenter(QPointF absPos);
   26.34  
   26.35  	/*! \brief Add new branch
   26.36  
   26.37 @@ -425,8 +423,8 @@
   26.38  	void reposition();					//!< Call reposition for all MCOs
   26.39  	void setHideTmpMode (TreeItem::HideTmpMode mode);	
   26.40  
   26.41 -	QPolygonF shape(BranchObj *bo);		//!< Returns arbitrary shape of subtree
   26.42 -	void moveAway (LinkableMapObj *lmo);//!< Autolayout: Move all out of the way
   26.43 +	//FIXME-5 QPolygonF shape(BranchObj *bo);		//!< Returns arbitrary shape of subtree
   26.44 +	//FIXME-5 void moveAway (LinkableMapObj *lmo);//!< Autolayout: Move all out of the way
   26.45  
   26.46  	void emitNoteHasChanged (TreeItem *ti);
   26.47  	void emitDataHasChanged (TreeItem *ti);
   26.48 @@ -539,7 +537,6 @@
   26.49  // Selection related 
   26.50  ////////////////////////////////////////////
   26.51  private:
   26.52 -	Selection selection;
   26.53  	TreeItem *latestAddedItem;				// latest added object, reset on setChanged()
   26.54  
   26.55  signals:
   26.56 @@ -607,6 +604,8 @@
   26.57  private:	
   26.58      void setSelectionColorInt(QColor);
   26.59  	QItemSelectionModel *selModel;
   26.60 +	QString lastSelectString;
   26.61 +	bool selectionBlocked;		//! Used to block changes of selection while editing a heading
   26.62  
   26.63  public:	
   26.64      void setSelectionColor(QColor);
    27.1 --- a/xml-vym.cpp	Wed May 20 15:40:14 2009 +0000
    27.2 +++ b/xml-vym.cpp	Tue May 26 11:23:44 2009 +0000
    27.3 @@ -186,8 +186,8 @@
    27.4  				(state == StateMapCenter ||state==StateBranch)) 
    27.5  	{
    27.6  		state=StateFloatImage;
    27.7 -        //FIXME-2lastBranch->addFloatImage();
    27.8 -		//FIXME-2lastFloat=lastBranch->getLastFloatImage();
    27.9 +        //FIXME-2 lastBranch->addFloatImage();
   27.10 +		//FIXME-2 lastFloat=lastBranch->getLastFloatImage();
   27.11  		if (!readFloatImageAttr(atts)) return false;
   27.12  	} else if ( (eName == "branch"||eName=="floatimage") && state == StateMap) 
   27.13  	{
   27.14 @@ -591,7 +591,7 @@
   27.15  			/* FIXME-2 xLinks
   27.16  				xlo->setBegin ((BranchObj*)lmo);
   27.17  				lmo=model->findBySelectString (a.value( "endBranch"));
   27.18 -				if (lmo && typeid (*lmo)==typeid (BranchObj))
   27.19 +				if (lmo && typid (*lmo)==typid (BranchObj))
   27.20  				{
   27.21  					xlo->setEnd ((BranchObj*)(lmo));
   27.22  					xlo->activate();
   27.23 @@ -609,11 +609,11 @@
   27.24  		if (!a.value( "endID").isEmpty() ) 
   27.25  		{
   27.26  			LinkableMapObj *lmo=model->findID (a.value( "beginID"));
   27.27 -			if (lmo && typeid (*lmo)==typeid (BranchObj))
   27.28 +			if (lmo && typid (*lmo)==typid (BranchObj))
   27.29  			{
   27.30  				xlo->setBegin ((BranchObj*)lmo);
   27.31  				lmo=model->findID (a.value( "endID"));
   27.32 -				if (lmo && typeid (*lmo)==typeid (BranchObj))
   27.33 +				if (lmo && typid (*lmo)==typid (BranchObj))
   27.34  				{
   27.35  					xlo->setEnd ((BranchObj*)(lmo));
   27.36  					xlo->activate();