more data in Tree, less in Map
authorinsilmaril
Thu Apr 23 12:15:31 2009 +0000 (2009-04-23)
changeset 755ed5b407975b3
parent 754 db0ec4bcf416
child 756 a8a5c7288f57
more data in Tree, less in Map
branchitem.cpp
branchitem.h
branchobj.cpp
branchobj.h
floatimageobj.cpp
floatobj.cpp
linkablemapobj.cpp
linkablemapobj.h
mainwindow.cpp
mapcenterobj.cpp
mapeditor.cpp
ornamentedobj.cpp
treeitem.cpp
treeitem.h
treemodel.cpp
version.h
vymmodel.cpp
vymmodel.h
     1.1 --- a/branchitem.cpp	Mon Apr 20 10:42:05 2009 +0000
     1.2 +++ b/branchitem.cpp	Thu Apr 23 12:15:31 2009 +0000
     1.3 @@ -307,3 +307,17 @@
     1.4  	return (BranchObj*)lmo;
     1.5  }
     1.6  
     1.7 +BranchObj* BranchItem::createMapObj(QGraphicsScene *scene)	
     1.8 +{
     1.9 +	// Initialize BranchObj, order of things is important...
    1.10 +	cout << "BI::createMO scene="<<scene<<endl;
    1.11 +    BranchObj* newbo=new BranchObj(scene);
    1.12 +    newbo->setParObj(parent()->getLMO() );
    1.13 +	newbo->setTreeItem (this);
    1.14 +	newbo->setDefAttr(BranchObj::NewBranch);
    1.15 +	//newbo->updateLink();
    1.16 +
    1.17 +	lmo=newbo;
    1.18 +	return newbo;
    1.19 +}
    1.20 +
     2.1 --- a/branchitem.h	Mon Apr 20 10:42:05 2009 +0000
     2.2 +++ b/branchitem.h	Thu Apr 23 12:15:31 2009 +0000
     2.3 @@ -3,8 +3,10 @@
     2.4  
     2.5  #include "treeitem.h"
     2.6  
     2.7 +
     2.8  class QString;
     2.9  class BranchObj;
    2.10 +class QGraphicsScene;
    2.11  
    2.12  class BranchItem:public TreeItem
    2.13  {
    2.14 @@ -38,6 +40,7 @@
    2.15  	virtual TreeItem* findID (QString sid);		//! search map for object with ID string
    2.16  
    2.17  	BranchObj* getBranchObj();	
    2.18 +	BranchObj* createMapObj(QGraphicsScene *scene);		//! Create classic object in GraphicsView
    2.19  };
    2.20  
    2.21  #endif
     3.1 --- a/branchobj.cpp	Mon Apr 20 10:42:05 2009 +0000
     3.2 +++ b/branchobj.cpp	Thu Apr 23 12:15:31 2009 +0000
     3.3 @@ -22,23 +22,22 @@
     3.4  //    cout << "Const BranchObj ()\n";
     3.5      setParObj (this);	
     3.6      init();
     3.7 -    depth=-1;
     3.8  }
     3.9  
    3.10 -BranchObj::BranchObj (QGraphicsScene* s):OrnamentedObj (s)
    3.11 +BranchObj::BranchObj (QGraphicsScene* s):OrnamentedObj (s)// FIXME-3 needed at all?
    3.12  {
    3.13 -//    cout << "Const BranchObj (s)  called from MapCenterObj (s)\n";
    3.14 +//    cout << "Const BranchObj (s)  \n";
    3.15  	parObj=NULL;
    3.16      scene=s;
    3.17 +	init();
    3.18  }
    3.19  
    3.20 -BranchObj::BranchObj (QGraphicsScene* s, LinkableMapObj* p):OrnamentedObj (s)
    3.21 +BranchObj::BranchObj (QGraphicsScene* s, LinkableMapObj* p):OrnamentedObj (s)// FIXME-3 needed at all?
    3.22  {
    3.23  //    cout << "Const BranchObj (s,p)\n";
    3.24      scene=s;
    3.25      setParObj (p);	
    3.26 -    depth=p->getDepth()+1;
    3.27 -	if (depth==1)
    3.28 +	if (treeItem->depth()==1)
    3.29  		// Calc angle to mapCenter if I am a mainbranch
    3.30  		// needed for reordering the mainbranches clockwise 
    3.31  		// around mapcenter 
    3.32 @@ -120,7 +119,7 @@
    3.33  
    3.34  void BranchObj::clear() 
    3.35  {
    3.36 -	setVisibility (true);
    3.37 +	//setVisibility (true); //FIXME-4 needed?
    3.38  
    3.39  	while (!floatimage.isEmpty())
    3.40  		delete floatimage.takeFirst();
    3.41 @@ -149,14 +148,14 @@
    3.42  		parObjTmpBuf=parObj;
    3.43  
    3.44  	// ignore mapcenter and mainbranch
    3.45 -	if (lmo->getDepth()<2) off=0;
    3.46 +	if (treeItem->depth()<2) off=0;
    3.47  	if (off==0)
    3.48  		link2ParPos=false;
    3.49  	else
    3.50  		link2ParPos=true;
    3.51  	parObj=o;
    3.52  
    3.53 -	depth=parObj->getDepth()+1;
    3.54 +	// FIXME-2 depth=parObj->getDepth()+1;
    3.55  
    3.56  	// setLinkStyle calls updateLink, only set it once
    3.57  	if (style!=getDefLinkStyle() ) setLinkStyle (getDefLinkStyle());
    3.58 @@ -165,7 +164,7 @@
    3.59  	// Usually the positioning would be done by reposition(),
    3.60  	// but then also the destination branch would "Jump" around...
    3.61  	// Better just do it approximately
    3.62 -	if (depth==1)
    3.63 +	if (treeItem->depth()==1)
    3.64  	{	// new parent is the mapcenter itself
    3.65  
    3.66  		QPointF p= normalise ( QPointF (m.x() - o->getChildPos().x(),
    3.67 @@ -213,7 +212,7 @@
    3.68  		link2ParPos=false;
    3.69  		parObj=parObjTmpBuf;
    3.70  		parObjTmpBuf=NULL;
    3.71 -		depth=parObj->getDepth()+1;
    3.72 +		//FIXME-2 depth=parObj->getDepth()+1;
    3.73  		setLinkStyle (getDefLinkStyle() );
    3.74  		updateLink();
    3.75  	}		
    3.76 @@ -222,7 +221,7 @@
    3.77  void BranchObj::setVisibility(bool v, int toDepth)
    3.78  {
    3.79  	BranchItem *bi=(BranchItem*)treeItem;
    3.80 -    if (depth <= toDepth)
    3.81 +    if (bi->depth() <= toDepth)
    3.82      {
    3.83  		frame->setVisibility(v);
    3.84  		heading->setVisibility(v);
    3.85 @@ -669,7 +668,7 @@
    3.86  void BranchObj::setDefAttr (BranchModification mod)
    3.87  {
    3.88  	int fontsize;
    3.89 -	switch (depth)
    3.90 +	switch (treeItem->depth())
    3.91  	{
    3.92  		case 0: fontsize=16; break;
    3.93  		case 1: fontsize=12; break;
    3.94 @@ -688,7 +687,7 @@
    3.95  	calcBBoxSize();
    3.96  }
    3.97  
    3.98 -BranchObj* BranchObj::addBranch()
    3.99 +BranchObj* BranchObj::addBranch()	// FIXME-3 still needed?
   3.100  {
   3.101      BranchObj* newbo=new BranchObj(scene,this);
   3.102      newbo->setParObj(this);
   3.103 @@ -724,7 +723,7 @@
   3.104  {
   3.105  	//FIXME-1 branch.append (bo);
   3.106  	bo->setParObj (this);
   3.107 -	bo->depth=depth+1;
   3.108 +	//FIXME-2 bo->depth=depth+1;
   3.109  	bo->setDefAttr(MovedBranch);
   3.110  	BranchItem *bi=(BranchItem*)treeItem;
   3.111  	if ( bi->isScrolled() ) bi->tmpUnscroll();
   3.112 @@ -757,14 +756,14 @@
   3.113  	savePosInAngle();
   3.114  	// Add new bo and resort branches
   3.115  	bo->angle=pos-0.5;
   3.116 -	//FIXME-1 branch.append (bo);
   3.117 +	//FIXME-4 branch.append (bo);
   3.118  	bo->setParObj (this);
   3.119 -	bo->depth=depth+1;
   3.120 +	//FIXME-2 bo->depth=depth+1;
   3.121  	bo->setDefAttr (MovedBranch);
   3.122  	BranchItem *bi=(BranchItem*)treeItem;
   3.123  	if ( bi->isScrolled() ) bi->tmpUnscroll();
   3.124  	//setLastSelectedBranch (bo); //FIXME-3 needed?
   3.125 -	//FIXME-1 qSort (branch.begin(),branch.end(), isAbove);
   3.126 +	//FIXME-2 qSort (branch.begin(),branch.end(), isAbove);
   3.127  	return bo;
   3.128  }
   3.129  
   3.130 @@ -785,7 +784,7 @@
   3.131  	*/
   3.132  }
   3.133  
   3.134 -void BranchObj::removeChildren()
   3.135 +void BranchObj::removeChildren()	// FIXME-3 not needed here
   3.136  {
   3.137  	clear();
   3.138  }
   3.139 @@ -914,6 +913,7 @@
   3.140  	else
   3.141  		return NULL;
   3.142  
   3.143 +/* FIXME-1
   3.144  	// Create new pointer to myself at dst
   3.145  	if (pos<0||dst->getDepth()==0)
   3.146  	{	
   3.147 @@ -934,22 +934,25 @@
   3.148  		} else
   3.149  			return NULL;
   3.150  	}	
   3.151 +*/	
   3.152  }
   3.153  
   3.154  void BranchObj::alignRelativeTo (QPointF ref,bool alignSelf)
   3.155  {
   3.156  	qreal th = bboxTotal.height();	
   3.157 +	int depth=treeItem->depth();
   3.158  // TODO testing
   3.159  /*
   3.160 -	QString h=QString (treeItem->depth(),' ');
   3.161 +
   3.162 +	QString h=QString (depth,' ');
   3.163  	h+=treeItem->getHeading();
   3.164  	h+=QString (15,' ');
   3.165  	h.truncate (15);
   3.166  	QPointF pp; if (parObj) pp=parObj->getChildPos();
   3.167  	cout << "BO::alignRelTo ";
   3.168  	cout<<h.toStdString();
   3.169 -//	cout << "    d="<<treeItem->depth()<<
   3.170 -cout<<  "  ref="<<ref<<
   3.171 +	cout << "    d="<<depth<<
   3.172 +//cout<<  "  ref="<<ref<<
   3.173        	"  bbox.tL="<<bboxTotal.topLeft()<<
   3.174  		"  absPos="<<absPos<<
   3.175  //		"  relPos="<<relPos<<
   3.176 @@ -968,7 +971,7 @@
   3.177  	setOrientation();
   3.178  	//updateLink();
   3.179  
   3.180 -	if (depth==1)
   3.181 +	if (depth==1 && parObj)
   3.182  	{
   3.183  		// Position relatively, if needed
   3.184  		//if (useRelPos) move2RelPos (relPos.x(), relPos.y());
   3.185 @@ -1046,7 +1049,7 @@
   3.186  //	cout << "  orient="<<orientation<<endl;
   3.187  */		
   3.188  
   3.189 -	if (depth==0)
   3.190 +	if (treeItem->depth()==0)
   3.191  	{
   3.192  		// only calculate the sizes once. If the deepest LMO 
   3.193  		// changes its height,
   3.194 @@ -1108,6 +1111,11 @@
   3.195  		if (!treeItem->getBranchNum(i)->isHidden())
   3.196  			r=addBBox(treeItem->getBranchObjNum(i)->getTotalBBox(),r);
   3.197  
   3.198 +/* FIXME-3 lots of occurences of treeItem->getBranchObjNum(i) in branchobj.cpp
   3.199 +            better check if they are not NULL and maybe simplify...
   3.200 +			(have been NULL at least in calcBBoxSizeWithChilds...)
   3.201 +*/			
   3.202 +
   3.203  /*
   3.204  	FIXME-1 for (int i=0; i<floatimage.size(); ++i)
   3.205  		if (!floatimage.at(i)->isHidden())
   3.206 @@ -1164,7 +1172,7 @@
   3.207  	// sum of heights 
   3.208  	// maximum of widths 
   3.209  	// minimum of y
   3.210 -	for (int i=0; i<treeItem->branchCount(); ++i)
   3.211 +	for (int i=0; i<treeItem->branchCount(); i++)
   3.212  	{
   3.213  		if (!bi->getBranchNum(i)->isHidden())
   3.214  		{
     4.1 --- a/branchobj.h	Mon Apr 20 10:42:05 2009 +0000
     4.2 +++ b/branchobj.h	Thu Apr 23 12:15:31 2009 +0000
     4.3 @@ -71,8 +71,8 @@
     4.4  	virtual FloatImageObj* getFloatImageNum(const uint &);
     4.5  protected:	
     4.6  	virtual void savePosInAngle();					// write pos in angle for resorting			
     4.7 +public:	
     4.8  	virtual void setDefAttr (BranchModification);	// set default attributes (font, size, ...)
     4.9 -public:	
    4.10      virtual BranchObj* addBranch();
    4.11      virtual BranchObj* addBranch(BranchObj*);		// makes deep copy of BranchObj
    4.12      virtual BranchObj* addBranchPtr(BranchObj*);	// just adds pointer
     5.1 --- a/floatimageobj.cpp	Mon Apr 20 10:42:05 2009 +0000
     5.2 +++ b/floatimageobj.cpp	Thu Apr 23 12:15:31 2009 +0000
     5.3 @@ -16,7 +16,6 @@
     5.4  //    cout << "Const FloatImageObj ()\n";
     5.5      setParObj (this);	
     5.6      init();
     5.7 -    depth=-1;
     5.8  }
     5.9  
    5.10  FloatImageObj::FloatImageObj (QGraphicsScene* s):FloatObj(s)
    5.11 @@ -24,7 +23,6 @@
    5.12   //   cout << "Const FloatImageObj (s)  called from MapCenterObj (s)\n";
    5.13      setParObj (this);	
    5.14      init();
    5.15 -    depth=-1;
    5.16  }
    5.17  
    5.18  FloatImageObj::FloatImageObj (QGraphicsScene *s, OrnamentedObj* p):FloatObj(s,p)
     6.1 --- a/floatobj.cpp	Mon Apr 20 10:42:05 2009 +0000
     6.2 +++ b/floatobj.cpp	Thu Apr 23 12:15:31 2009 +0000
     6.3 @@ -11,7 +11,6 @@
     6.4  //    cout << "Const FloatObj ()\n";
     6.5      setParObj (this);	
     6.6      init();
     6.7 -    depth=-1;
     6.8  }
     6.9  
    6.10  FloatObj::FloatObj (QGraphicsScene* s):OrnamentedObj(s)
    6.11 @@ -19,14 +18,12 @@
    6.12  //	cout << "Const FloatObj (s)  called from MapCenterObj (s)\n";
    6.13      setParObj (this);	
    6.14      init();
    6.15 -    depth=-1;
    6.16  }
    6.17  
    6.18  FloatObj::FloatObj (QGraphicsScene* s, LinkableMapObj* p):OrnamentedObj (s)
    6.19  {
    6.20  //    cout << "Const FloatObj (s,p)\n";
    6.21      setParObj (p);	
    6.22 -    depth=p->getDepth()+1;
    6.23      init();
    6.24  }
    6.25  
     7.1 --- a/linkablemapobj.cpp	Mon Apr 20 10:42:05 2009 +0000
     7.2 +++ b/linkablemapobj.cpp	Thu Apr 23 12:15:31 2009 +0000
     7.3 @@ -59,7 +59,6 @@
     7.4  {
     7.5  	model=NULL;
     7.6  
     7.7 -    depth=-1;	
     7.8      childObj=NULL;
     7.9      parObj=NULL;
    7.10      parObjTmpBuf=NULL;
    7.11 @@ -212,6 +211,7 @@
    7.12  		//return UndefinedStyle;
    7.13  	}
    7.14  	Style ls=model->getMapLinkStyle();
    7.15 +	int depth=treeItem->depth();
    7.16  	if (depth==0) return UndefinedStyle;
    7.17  	switch (ls)
    7.18  	{
    7.19 @@ -360,7 +360,7 @@
    7.20  			break;
    7.21  		default:
    7.22  			break;
    7.23 -	} // switch (style)	
    7.24 +	} 
    7.25  }
    7.26  
    7.27  QColor LinkableMapObj::getLinkColor()
    7.28 @@ -577,7 +577,7 @@
    7.29  		num=part.right(part.length() - 3);
    7.30  		if (typ=="mc:")
    7.31  		{
    7.32 -			if (depth>0)
    7.33 +			if (treeItem->depth()>0)
    7.34  				return false;	// in a subtree there is no center
    7.35  			else
    7.36  				break;
    7.37 @@ -621,11 +621,6 @@
    7.38      return orientation;
    7.39  }
    7.40  
    7.41 -int LinkableMapObj::getDepth()
    7.42 -{
    7.43 -    return depth;
    7.44 -}
    7.45 -
    7.46  QPointF LinkableMapObj::getRandPos()
    7.47  {
    7.48  	// Choose a random position with given distance to parent:
     8.1 --- a/linkablemapobj.h	Mon Apr 20 10:42:05 2009 +0000
     8.2 +++ b/linkablemapobj.h	Thu Apr 23 12:15:31 2009 +0000
     8.3 @@ -19,7 +19,7 @@
     8.4  */
     8.5  
     8.6  class LinkableMapObj:public QObject, public MapObj {
     8.7 -	Q_OBJECT
     8.8 +	Q_OBJECT		// FIXME-3 really needed here?
     8.9  public:
    8.10  	/*! Orientation of an object depends on the position relative to the parent */
    8.11  	enum Orientation {
    8.12 @@ -101,7 +101,6 @@
    8.13      QPointF getChildPos();					// returns pos where children dock
    8.14      QPointF getParPos();						// returns pos where parents dock
    8.15      Orientation getOrientation();			// get orientation
    8.16 -    virtual int getDepth();					// return depth
    8.17  	virtual QPointF getRandPos();			// make randomised position
    8.18  
    8.19  	virtual void reposition();
    8.20 @@ -126,11 +125,10 @@
    8.21  	VymModel* model;												
    8.22      Orientation orientation;     
    8.23      qreal linkwidth;				// width of a link
    8.24 -    int depth;						// depth: undef=-1 mapCenter=0 branch=1..n
    8.25  	QRectF bboxTotal;				// bounding box including children
    8.26  
    8.27      LinkableMapObj* childObj;
    8.28 -    LinkableMapObj* parObj;
    8.29 +    LinkableMapObj* parObj;		// FIXME-2 really still needed? Better get from TreeItem
    8.30      LinkableMapObj* parObjTmpBuf;	// temporary buffer the original parent
    8.31      qreal bottomlineY;              // vertical offset of dockpos to pos
    8.32  
     9.1 --- a/mainwindow.cpp	Mon Apr 20 10:42:05 2009 +0000
     9.2 +++ b/mainwindow.cpp	Thu Apr 23 12:15:31 2009 +0000
     9.3 @@ -3070,7 +3070,7 @@
     9.4  void Main::editUpperBranch()
     9.5  {
     9.6  	VymModel *m=currentModel();
     9.7 -	if (m) m->selectUpperBranch();
     9.8 +	if (m) m->selectUpperBranch();	// FIXME-0 check also lower... this probably should go into view...
     9.9  }
    9.10  
    9.11  void Main::editLowerBranch()
    10.1 --- a/mapcenterobj.cpp	Mon Apr 20 10:42:05 2009 +0000
    10.2 +++ b/mapcenterobj.cpp	Thu Apr 23 12:15:31 2009 +0000
    10.3 @@ -45,7 +45,6 @@
    10.4  	// TODO this should be done in TextObj later...
    10.5  	//QFont font ("Sans Serif,16,-1,5,50,0,0,0,0,0");		
    10.6  	//heading->setFont(font);
    10.7 -	depth=0;
    10.8  	setDefAttr(MovedBranch);
    10.9  
   10.10  	frame->setFrameType (FrameObj::Rectangle);
    11.1 --- a/mapeditor.cpp	Mon Apr 20 10:42:05 2009 +0000
    11.2 +++ b/mapeditor.cpp	Thu Apr 23 12:15:31 2009 +0000
    11.3 @@ -719,7 +719,7 @@
    11.4  			}
    11.5  		} else	
    11.6  		{	// selection != a FloatObj
    11.7 -			if (lmosel->getDepth()==0)		//FIXME-1 also moved mapcenters could be linked, but not working here...
    11.8 +			if (seli->depth()==0)		//FIXME-1 also moved mapcenters could be linked, but not working here...
    11.9  			{
   11.10  				// Move MapCenter
   11.11  				if (e->buttons()== Qt::LeftButton && e->modifiers()==Qt::ShiftModifier) 
   11.12 @@ -729,7 +729,7 @@
   11.13  				model->updateRelPositions();
   11.14  			} else
   11.15  			{	
   11.16 -				if (lmosel->getDepth()==1)
   11.17 +				if (seli->depth()==1)
   11.18  				{
   11.19  					// Move mainbranch
   11.20  					lmosel->move(p.x() -movingObj_start.x(), p.y()-movingObj_start.y() );		
   11.21 @@ -797,13 +797,12 @@
   11.22  void MapEditor::mouseReleaseEvent(QMouseEvent* e)
   11.23  {
   11.24      QPointF p = mapToScene(e->pos());
   11.25 -	TreeItem *dsti=findMapItem(p, NULL);
   11.26 -	LinkableMapObj* dst=NULL;
   11.27 -	if (dsti) dst=dsti->getLMO();	//FIXME-2 get rid of dst...
   11.28 -
   11.29  	TreeItem *seli=model->getSelectedItem();
   11.30  	LinkableMapObj *lmosel=seli->getLMO();	// FIXME-2 get rid of lmosel
   11.31  
   11.32 +	TreeItem *dsti=findMapItem(p, seli);
   11.33 +	LinkableMapObj* dst=NULL;
   11.34 +	if (dsti) dst=dsti->getLMO();	//FIXME-2 get rid of dst...
   11.35  
   11.36  
   11.37  	// Have we been picking color?
   11.38 @@ -905,37 +904,36 @@
   11.39  			QString preSelStr=model->getSelectString(lmosel);
   11.40  
   11.41  			copyingObj=false;	
   11.42 -			if (dsti ) 
   11.43 +			if (dsti && dsti->isBranchLikeType() ) 
   11.44  			{
   11.45  				// We have a destination, relink to that
   11.46  
   11.47  				BranchObj* bsel=model->getSelectedBranchObj();
   11.48 -				TreeItem * tisel=model->getSelectedItem();
   11.49  				BranchObj* bdst=(BranchObj*)dst;
   11.50 -				TreeItem* tidst=dst->getTreeItem();
   11.51  
   11.52  				QString preParStr=model->getSelectString (bsel->getParObj());
   11.53 -				QString preNum=QString::number (tisel->num(),10);
   11.54 +				QString preNum=QString::number (seli->num(),10);
   11.55  				QString preDstParStr;
   11.56  
   11.57  				if (e->state() & Qt::ShiftModifier && dst->getParObj())
   11.58  				{	// Link above dst
   11.59  					preDstParStr=model->getSelectString (dst->getParObj());
   11.60 -					bsel->linkTo ( (BranchObj*)(bdst->getParObj()), tidst->num());
   11.61 +					bsel->linkTo ( (BranchObj*)(bdst->getParObj()), seli->num());
   11.62  				} else 
   11.63  				if (e->state() & Qt::ControlModifier && dst->getParObj())
   11.64  				{
   11.65  					// Link below dst
   11.66  					preDstParStr=model->getSelectString (dst->getParObj());
   11.67 -					bsel->linkTo ( (BranchObj*)(bdst->getParObj()), tidst->num()+1);
   11.68 +					bsel->linkTo ( (BranchObj*)(bdst->getParObj()), seli->num()+1);
   11.69  				} else	
   11.70  				{	// Append to dst
   11.71  					preDstParStr=model->getSelectString(dst);
   11.72  					bsel->linkTo (bdst,-1);
   11.73 -					if (dst->getDepth()==0) bsel->move (savePos);
   11.74 +					model->relinkBranch ((BranchItem*)seli,(BranchItem*)dsti);
   11.75 +					if (dsti->depth()==0) bsel->move (savePos);
   11.76  				} 
   11.77  				QString postSelStr=model->getSelectString(lmosel);
   11.78 -				QString postNum=QString::number (tisel->num(),10);
   11.79 +				QString postNum=QString::number (seli->num(),10);
   11.80  
   11.81  				QString undoCom="linkTo (\""+ 
   11.82  					preParStr+ "\"," + preNum  +"," + 
   11.83 @@ -955,7 +953,7 @@
   11.84  			{
   11.85  				// No destination, undo  temporary move
   11.86  
   11.87 -				if (lmosel->getDepth()==1)
   11.88 +				if (seli->depth()==1)
   11.89  				{
   11.90  					cout << "ME::releaseMouse d=1\n"; // FIXME_1    better use depth
   11.91  					// The select string might be different _after_ moving around.
   11.92 @@ -974,7 +972,7 @@
   11.93  				}
   11.94  
   11.95  				// Draw the original link, before selection was moved around
   11.96 -				if (settings.value("/animation/use",false).toBool() && lmosel->getDepth()>1) 
   11.97 +				if (settings.value("/animation/use",false).toBool() && seli->depth()>1) 
   11.98  				{
   11.99  					lmosel->setRelPos();	// calc relPos first for starting point
  11.100  					QPointF dst=bi->getBranchObj()->getParObj()->getChildPos();		// FIXME-3 check getBO here...
    12.1 --- a/ornamentedobj.cpp	Mon Apr 20 10:42:05 2009 +0000
    12.2 +++ b/ornamentedobj.cpp	Thu Apr 23 12:15:31 2009 +0000
    12.3 @@ -407,13 +407,13 @@
    12.4  {
    12.5  	QString posAttr;
    12.6  
    12.7 -	if (depth==0)
    12.8 +	if (treeItem->depth()==0)
    12.9  		posAttr=		
   12.10  			attribut("absPosX",QString().setNum(absPos.x())) +
   12.11  			attribut("absPosY",QString().setNum(absPos.y())); 
   12.12  	else
   12.13  	{
   12.14 -		if (depth==1 || typeid (*this)==typeid (FloatImageObj))
   12.15 +		if (treeItem->depth()==1 || typeid (*this)==typeid (FloatImageObj))
   12.16  		{
   12.17  			if (relPos.x()==0 && relPos.y()==0)
   12.18  				setRelPos();
    13.1 --- a/treeitem.cpp	Mon Apr 20 10:42:05 2009 +0000
    13.2 +++ b/treeitem.cpp	Thu Apr 23 12:15:31 2009 +0000
    13.3 @@ -35,12 +35,14 @@
    13.4  
    13.5  TreeItem::~TreeItem()
    13.6  {
    13.7 +	cout << "Destructor TreeItem\n";
    13.8 +	//if (lmo) delete (lmo);
    13.9      qDeleteAll(childItems);
   13.10  }
   13.11  
   13.12  QString TreeItem::saveToDir (const QString &tmpdir,const QString &prefix, const QPointF& offset)
   13.13  {
   13.14 -	qWarning ("TreeItem::saveToDir called directly");
   13.15 +	cout << "TreeItem::saveToDir called directly for ("<<getHeadingStd()<<"), instead of inherited type...\n";	//FIXME-1 triggered on save
   13.16  	return QString();
   13.17  }
   13.18  
   13.19 @@ -86,7 +88,9 @@
   13.20  	else
   13.21  	{
   13.22  		cout << "TI::removeChild this="<<this<<"  row="<<row<<endl;
   13.23 -		delete childItems.takeAt (row);
   13.24 +		if (childItems.at(row)->isBranchLikeType())
   13.25 +			branchCounter--;
   13.26 +		childItems.removeAt (row);
   13.27  	}
   13.28  }
   13.29  
   13.30 @@ -145,7 +149,7 @@
   13.31  
   13.32  int TreeItem::depth() 
   13.33  {
   13.34 -	int d=-1;
   13.35 +	int d=-2;
   13.36  	TreeItem *ti=this;
   13.37  	while (ti!=NULL)
   13.38  	{
   13.39 @@ -160,6 +164,11 @@
   13.40      return parentItem;
   13.41  }
   13.42  
   13.43 +int TreeItem::childNum()
   13.44 +{
   13.45 +	return parentItem->childItems.indexOf (this);
   13.46 +}
   13.47 +
   13.48  int TreeItem::num()
   13.49  {
   13.50  	switch (type)
   13.51 @@ -200,7 +209,7 @@
   13.52  	return itemData[0].toString();
   13.53  }
   13.54  
   13.55 -std::string TreeItem::headingStd () const
   13.56 +std::string TreeItem::getHeadingStd () const
   13.57  {
   13.58  	return itemData[0].toString().toStdString();
   13.59  }
    14.1 --- a/treeitem.h	Mon Apr 20 10:42:05 2009 +0000
    14.2 +++ b/treeitem.h	Thu Apr 23 12:15:31 2009 +0000
    14.3 @@ -47,14 +47,15 @@
    14.4  
    14.5  	/*! Return number of item in parent by type, 
    14.6  	    e.g. first branch has number 0           */
    14.7 -	int num();		
    14.8 +	int childNum();				//! Return number of item in list of all children
    14.9 +	int num();					//! Return number of item by type
   14.10  	int num (TreeItem *item);	//! Return number of item by type
   14.11  
   14.12  	// Accessing data
   14.13      QVariant data(int column) const;
   14.14  	void setHeading (const QString s);
   14.15  	QString getHeading() const;
   14.16 -	std::string headingStd() const;	//! convenience function used for debugging
   14.17 +	std::string getHeadingStd() const;	//! convenience function used for debugging
   14.18  
   14.19  protected:
   14.20  	NoteObj note;
    15.1 --- a/treemodel.cpp	Mon Apr 20 10:42:05 2009 +0000
    15.2 +++ b/treemodel.cpp	Thu Apr 23 12:15:31 2009 +0000
    15.3 @@ -186,13 +186,16 @@
    15.4  	int last=row+count-1;
    15.5  	cout << "TreeModel::removeRows row="<<row<<"  count="<<count<<"  last="<<last<<endl;
    15.6      TreeItem *pi= getItem (parent);
    15.7 +	TreeItem *ti;
    15.8  	cout << "  pi="<<pi<<"  "<<pi->getHeading().toStdString()<<endl;
    15.9  	beginRemoveRows (parent,row,last);
   15.10  
   15.11  	for (int i=row; i<=last; i++)
   15.12  	{
   15.13  		cout << "TreeModel::removeRows removing i="<<i<<std::endl;
   15.14 -		pi->removeChild (row);
   15.15 +		ti=pi->getChildNum (row);
   15.16 +		pi->removeChild (row);	// does not delete object!
   15.17 +		delete (ti);
   15.18  	}
   15.19  	endRemoveRows ();
   15.20  	return true;
    16.1 --- a/version.h	Mon Apr 20 10:42:05 2009 +0000
    16.2 +++ b/version.h	Thu Apr 23 12:15:31 2009 +0000
    16.3 @@ -6,8 +6,8 @@
    16.4  #define __VYM_NAME "VYM"
    16.5  #define __VYM_VERSION "1.13.0"
    16.6  //#define __VYM_CODENAME "Codename: RC-1"
    16.7 -#define __VYM_CODENAME "Codename: development version"
    16.8 -#define __VYM_BUILD_DATE "2009-04-20"
    16.9 +#define __VYM_CODENAME "Codename: development version, not for production!"
   16.10 +#define __VYM_BUILD_DATE "2009-04-23"
   16.11  
   16.12  
   16.13  bool checkVersion(const QString &);
    17.1 --- a/vymmodel.cpp	Mon Apr 20 10:42:05 2009 +0000
    17.2 +++ b/vymmodel.cpp	Thu Apr 23 12:15:31 2009 +0000
    17.3 @@ -2008,10 +2008,9 @@
    17.4  	return mci;
    17.5  }
    17.6  
    17.7 -BranchItem* VymModel::createBranch()	// FIXME-2 switcht addNewBrancInt to BranchItem...
    17.8 -{
    17.9 -	BranchObj* bo=addNewBranchInt (-2);
   17.10 -	return (BranchItem*)bo->getTreeItem();
   17.11 +BranchItem* VymModel::createBranch()	
   17.12 +{
   17.13 +	return addNewBranchInt (-2);
   17.14  }
   17.15  
   17.16  TreeItem* VymModel::createImage()	//FIXME-2
   17.17 @@ -2123,7 +2122,7 @@
   17.18  }
   17.19  
   17.20  
   17.21 -BranchObj* VymModel::addNewBranchInt(int num)
   17.22 +BranchItem* VymModel::addNewBranchInt(int num)
   17.23  {
   17.24  	// Depending on pos:
   17.25  	// -3		insert in children of parent  above selection 
   17.26 @@ -2158,6 +2157,8 @@
   17.27  
   17.28  			// save scroll state. If scrolled, automatically select
   17.29  			// new branch in order to tmp unscroll parent...
   17.30 +			newbo=bi->createMapObj(mapScene);
   17.31 +			/*
   17.32  			newbo=bo->addBranch();
   17.33  
   17.34  			if (newbo)
   17.35 @@ -2166,63 +2167,70 @@
   17.36  				newbo->setTreeItem (bi);
   17.37  				select (bi); 
   17.38  			}
   17.39 +			*/
   17.40 +			select (bi);
   17.41  			
   17.42  		}else if (num==-1)
   17.43  		{
   17.44 +		/*
   17.45  			num=bi->num()+1;
   17.46  			bo=(BranchObj*)bo->getParObj();
   17.47  			if (bo) newbo=bo->insertBranch(num);	//FIXME-1 VM still missing 
   17.48 +		*/	
   17.49  		}else if (num==-3)
   17.50  		{
   17.51 +		/*
   17.52  			num=bi->num();
   17.53  			bo=(BranchObj*)bo->getParObj();
   17.54  			if (bo) newbo=bo->insertBranch(num);	//FIXME-1 VM still missing
   17.55 +		*/	
   17.56  		}
   17.57  	}	
   17.58 -	return newbo;
   17.59 +	return bi;
   17.60  }	
   17.61  
   17.62 -BranchObj* VymModel::addNewBranch(int pos)
   17.63 +BranchItem* VymModel::addNewBranch(int pos)
   17.64  {
   17.65  	// Different meaning than num in addNewBranchInt!
   17.66  	// -1	add above
   17.67  	//  0	add as child
   17.68  	// +1	add below
   17.69 -	BranchObj *bo = getSelectedBranchObj();	//FIXME-2
   17.70 -	BranchObj *newbo=NULL;
   17.71 -
   17.72 -	if (bo)
   17.73 +	BranchItem *newbi=NULL;
   17.74 +	BranchItem *selbi=getSelectedBranchItem();
   17.75 +
   17.76 +	if (selbi)
   17.77  	{
   17.78  		// FIXME-2 VM  do we still need this in model? setCursor (Qt::ArrowCursor);
   17.79  
   17.80 -		newbo=addNewBranchInt (pos-2);
   17.81 -
   17.82 -		if (newbo)
   17.83 +		newbi=addNewBranchInt (pos-2);
   17.84 +
   17.85 +		if (newbi)
   17.86  		{
   17.87  			saveState(
   17.88 -				newbo->getTreeItem(),		
   17.89 +				newbi,		
   17.90  				"delete ()",
   17.91 -				bo->getTreeItem(),
   17.92 +				selbi,
   17.93  				QString ("addBranch (%1)").arg(pos),
   17.94 -				QString ("Add new branch to %1").arg(getObjectName(bo)));	
   17.95 +				QString ("Add new branch to %1").arg(getObjectName(selbi)));	
   17.96  
   17.97  			reposition();
   17.98  			// selection.update(); FIXME-3
   17.99 -			latestSelectionString=getSelectString(newbo);
  17.100 +			latestSelectionString=getSelectString(newbi);
  17.101  			// In Network mode, the client needs to know where the new branch is,
  17.102  			// so we have to pass on this information via saveState.
  17.103  			// TODO: Get rid of this positioning workaround
  17.104 -			QString ps=qpointfToString (newbo->getAbsPos());
  17.105 +			/* FIXME-4  network problem:  QString ps=qpointfToString (newbo->getAbsPos());
  17.106  			sendData ("selectLatestAdded ()");
  17.107  			sendData (QString("move %1").arg(ps));
  17.108  			sendSelection();
  17.109 +			*/
  17.110  		}
  17.111  	}	
  17.112 -	return newbo;
  17.113 +	return newbi;
  17.114  }
  17.115  
  17.116  
  17.117 -BranchObj* VymModel::addNewBranchBefore()	//FIXME-2
  17.118 +BranchItem* VymModel::addNewBranchBefore()	//FIXME-2
  17.119  {
  17.120  /*
  17.121  	BranchObj *newbo=NULL;
  17.122 @@ -2258,6 +2266,22 @@
  17.123  	return NULL;
  17.124  }
  17.125  
  17.126 +BranchItem* VymModel::relinkBranch (BranchItem *branch, BranchItem *dst, int pos)
  17.127 +{
  17.128 +	cout << "VM::relinkBranch  "<<branch->getHeadingStd()<<"  to "<<dst->getHeadingStd()<<"  at pos="<<pos<<endl;
  17.129 +	if (branch && dst)
  17.130 +	{
  17.131 +		BranchItem *branchpi=(BranchItem*)branch->parent();
  17.132 +		BranchItem *dstpi=(BranchItem*)dst->parent();
  17.133 +		if (pos<0)
  17.134 +		{
  17.135 +			// Append as last branch to dst
  17.136 +			branchpi->removeChild (branch->childNum() );
  17.137 +			dst->appendChild (branch);
  17.138 +		}
  17.139 +	}
  17.140 +}
  17.141 +
  17.142  void VymModel::deleteSelection()
  17.143  {
  17.144  	BranchObj *bo = getSelectedBranchObj();	// FIXME-2 VM should not be necessary
  17.145 @@ -2319,7 +2343,7 @@
  17.146  		beginRemoveRows (parentIndex,n,n);
  17.147  		removeRows (n,1,parentIndex);
  17.148  		endRemoveRows();
  17.149 -		par->removeBranch(bo);	// remove from BranchObj lists...
  17.150 +		//	delete (selbi->getLMO() );	// FIXME-0 selbi is removed implicetely, destructor is called. from there BO is deleted, but somhow still segfaulting :-(
  17.151  		select (par);
  17.152  		ensureSelectionVisible();
  17.153  		reposition();
  17.154 @@ -3964,8 +3988,9 @@
  17.155  		rootItem->getBranchObjNum(i)->reposition();	//	for positioning heading
  17.156  }
  17.157  
  17.158 -QPolygonF VymModel::shape(BranchObj *bo)
  17.159 -{
  17.160 +QPolygonF VymModel::shape(BranchObj *bo)	//FIXME-4
  17.161 +{
  17.162 +/*
  17.163  	// Creating (arbitrary) shapes
  17.164  
  17.165  	QPolygonF p;
  17.166 @@ -3995,7 +4020,7 @@
  17.167  			<<rb.bottomLeft()
  17.168  			<<QPointF (rb.bottomRight().x(), ra.bottomRight().y() ) ;
  17.169  	return p;		
  17.170 -
  17.171 +	*/
  17.172  }
  17.173  
  17.174  void VymModel::moveAway(LinkableMapObj *lmo)	//FIXME-5
  17.175 @@ -4354,7 +4379,7 @@
  17.176  
  17.177  void VymModel::startAnimation(BranchObj *bo, const QPointF &start, const QPointF &dest)
  17.178  {
  17.179 -	if (bo && bo->getDepth()>0) 
  17.180 +	if (bo && bo->getTreeItem()->depth()>0) 
  17.181  	{
  17.182  		AnimPoint ap;
  17.183  		ap.setStart (start);
  17.184 @@ -4710,197 +4735,136 @@
  17.185  
  17.186  void VymModel::selectNextBranchInt()
  17.187  {
  17.188 -	// Increase number of branch
  17.189 -	BranchItem *selbi=getSelectedBranchItem();
  17.190 -	if (selbi)
  17.191 +	BranchItem *bi=getSelectedBranchItem();
  17.192 +	if (bi)
  17.193  	{
  17.194 -		QString s=getSelectString();
  17.195 -		QString part;
  17.196 -		QString typ;
  17.197 -		QString num;
  17.198 -
  17.199 -		// Where am I? 
  17.200 -		part=s.section(",",-1);
  17.201 -		typ=part.left (3);
  17.202 -		num=part.right(part.length() - 3);
  17.203 -
  17.204 -		s=s.left (s.length() -num.length());
  17.205 -
  17.206 -		// Go to next lmo
  17.207 -		num=QString ("%1").arg(num.toUInt()+1);
  17.208 -
  17.209 -		s=s+num;
  17.210 +		TreeItem *pi=bi->parent();
  17.211 +		if (bi!=rootItem)
  17.212 +		{
  17.213 +			int i=bi->num();
  17.214 +			if (i<pi->branchCount() )
  17.215 +			{
  17.216 +				// select previous branch with same parent
  17.217 +				i++;
  17.218 +				select (pi->getBranchNum(i));
  17.219 +				return;
  17.220 +			}
  17.221 +		}
  17.222  		
  17.223 -		// Try to select this one
  17.224 -		if (select (s)) return;
  17.225 -
  17.226 -		// We have no direct successor, 
  17.227 -		// try to increase the parental number in order to
  17.228 -		// find a successor with same depth
  17.229 -
  17.230 -		int d=getSelectedBranchItem()->depth();
  17.231 -		int oldDepth=d;
  17.232 -		int i;
  17.233 -		bool found=false;
  17.234 -		bool b;
  17.235 -		while (!found && d>0)
  17.236 -		{
  17.237 -			s=s.section (",",0,d-1);
  17.238 -			// replace substring of current depth in s with "1"
  17.239 -			part=s.section(",",-1);
  17.240 -			typ=part.left (3);
  17.241 -			num=part.right(part.length() - 3);
  17.242 -
  17.243 -			if (d>1)
  17.244 -			{	
  17.245 -				// increase number of parent
  17.246 -				num=QString ("%1").arg(num.toUInt()+1);
  17.247 -				s=s.section (",",0,d-2) + ","+ typ+num;
  17.248 -			} else
  17.249 -			{
  17.250 -				// Special case, look at orientation
  17.251 -				if (getSelectedLMO()->getOrientation()==LinkableMapObj::RightOfCenter)	// FIXME-3 check access to LMO
  17.252 -					num=QString ("%1").arg(num.toUInt()+1);
  17.253 -				else	
  17.254 -					num=QString ("%1").arg(num.toUInt()-1);
  17.255 -				s=typ+num;
  17.256 -			}	
  17.257 -
  17.258 -			if (select (s))
  17.259 -				// pad to oldDepth, select the first branch for each depth
  17.260 -				for (i=d;i<oldDepth;i++)
  17.261 -				{
  17.262 -					b=select (s);
  17.263 -					if (b)
  17.264 -					{	
  17.265 -						if ( getSelectedItem()->branchCount()>0)
  17.266 -							s+=",bo:0";
  17.267 -						else	
  17.268 -							break;
  17.269 -					} else
  17.270 -						break;
  17.271 -				}	
  17.272 -
  17.273 -			// try to select the freshly built string
  17.274 -			found=select(s);
  17.275 -			d--;
  17.276 -		}
  17.277 -		return;
  17.278 -	}	
  17.279 -}
  17.280 -
  17.281 -void VymModel::selectPrevBranchInt()
  17.282 -{
  17.283 -	// Decrease number of branch
  17.284 -	if (selectionType()==TreeItem::Branch)
  17.285 -	{
  17.286 -		QString s=getSelectString();
  17.287 -		QString part;
  17.288 -		QString typ;
  17.289 -		QString num;
  17.290 -
  17.291 -		// Where am I? 
  17.292 -		part=s.section(",",-1);
  17.293 -		typ=part.left (3);
  17.294 -		num=part.right(part.length() - 3);
  17.295 -
  17.296 -		s=s.left (s.length() -num.length());
  17.297 -
  17.298 -		int n=num.toInt()-1;
  17.299 -		
  17.300 -		// Go to next lmo
  17.301 -		num=QString ("%1").arg(n);
  17.302 -		s=s+num;
  17.303 -		
  17.304 -		// Try to select this one
  17.305 -		if (n>=0 && select (s)) return;
  17.306 -
  17.307 -		// We have no direct precessor, 
  17.308 -		// try to decrease the parental number in order to
  17.309 -		// find a precessor with same depth
  17.310 -
  17.311 -		int d=getSelectedBranchItem()->depth();
  17.312 -		int oldDepth=d;
  17.313 -		int i;
  17.314 -		bool found=false;
  17.315 -		bool b;
  17.316 -		while (!found && d>0)
  17.317 -		{
  17.318 -			s=s.section (",",0,d-1);
  17.319 -			// replace substring of current depth in s with "1"
  17.320 -			part=s.section(",",-1);
  17.321 -			typ=part.left (3);
  17.322 -			num=part.right(part.length() - 3);
  17.323 -
  17.324 -			if (d>1)
  17.325 -			{
  17.326 -				// decrease number of parent
  17.327 -				num=QString ("%1").arg(num.toInt()-1);
  17.328 -				s=s.section (",",0,d-2) + ","+ typ+num;
  17.329 -			} else
  17.330 -			{
  17.331 -				// Special case, look at orientation
  17.332 -				if (getSelectedLMO()->getOrientation()==LinkableMapObj::RightOfCenter)	// FIXME-3 check access to LMO
  17.333 -					num=QString ("%1").arg(num.toInt()-1);
  17.334 -				else	
  17.335 -					num=QString ("%1").arg(num.toInt()+1);
  17.336 -				s=typ+num;
  17.337 -			}	
  17.338 -
  17.339 -			if (select(s))
  17.340 -				// pad to oldDepth, select the last branch for each depth
  17.341 -				for (i=d;i<oldDepth;i++)
  17.342 -				{
  17.343 -					b=select (s);
  17.344 -					if (b)
  17.345 -						if ( getSelectedItem()->branchCount()>0)
  17.346 -							s+=",bo:"+ QString ("%1").arg( getSelectedItem()->branchCount()-1 );
  17.347 -						else	
  17.348 -							break;
  17.349 -					else
  17.350 -						break;
  17.351 -				}	
  17.352 -			
  17.353 -			// try to select the freshly built string
  17.354 -			found=select(s);
  17.355 -			d--;
  17.356 -		}
  17.357 -		return;
  17.358 -	}	
  17.359 -}
  17.360 -
  17.361 -void VymModel::selectUpperBranch()
  17.362 -{
  17.363 -	if (selection.isBlocked() ) return;
  17.364 -
  17.365 -	BranchItem *bi=getSelectedBranchItem();
  17.366 -	if (bi && bi->getType()==TreeItem::Branch)
  17.367 -	{
  17.368 -		if (bi->getBranchObj()->getOrientation()==LinkableMapObj::RightOfCenter)	//FIXME-3 check getBO
  17.369 -			selectPrevBranchInt();
  17.370 -		else
  17.371 -			if (bi->depth()==1)
  17.372 -				selectNextBranchInt();
  17.373 -			else
  17.374 -				selectPrevBranchInt();
  17.375  	}
  17.376  }
  17.377  
  17.378 +void VymModel::selectPrevBranchInt()
  17.379 +{
  17.380 +
  17.381 +	BranchItem *bi=getSelectedBranchItem();
  17.382 +	if (bi)
  17.383 +	{
  17.384 +		BranchItem *pi=(BranchItem*)bi->parent();
  17.385 +		if (bi!=rootItem)
  17.386 +		{
  17.387 +			int i=bi->num();
  17.388 +			if (i>0)
  17.389 +			{
  17.390 +				// select previous branch with same parent
  17.391 +				bi=pi->getBranchNum(i-1);
  17.392 +				select (bi);
  17.393 +				return;
  17.394 +			}
  17.395 +			bi=pi;
  17.396 +			while (bi->branchCount() >0)
  17.397 +				bi=bi->getLastBranch();
  17.398 +			select (bi);	
  17.399 +
  17.400 +			// Try to select last branch in parent pi2 previous to own parent pi
  17.401 +			/*
  17.402 +			TreeItem *pi2=pi->parent();
  17.403 +			if (pi2)
  17.404 +			{
  17.405 +				int j=pi->num();
  17.406 +				if (pi2->)
  17.407 +			}
  17.408 +			*/
  17.409 +		}
  17.410 +	}
  17.411 +}
  17.412 +
  17.413 +void VymModel::selectAboveBranchInt()
  17.414 +{
  17.415 +	BranchItem *bi=getSelectedBranchItem();
  17.416 +	if (bi)
  17.417 +	{
  17.418 +		BranchItem *newbi=NULL;
  17.419 +		BranchItem *pi=(BranchItem*)bi->parent();
  17.420 +		int i=bi->num();
  17.421 +		if (i>0)
  17.422 +		{
  17.423 +			// goto previous branch with same parent
  17.424 +			newbi=pi->getBranchNum(i-1);
  17.425 +			while (newbi->branchCount() >0 )
  17.426 +				newbi=newbi->getLastBranch();
  17.427 +		}
  17.428 +		else
  17.429 +			newbi=pi;
  17.430 +		if (newbi==rootItem) 
  17.431 + 			// already at top branch (resp. mapcenter)
  17.432 +			return;
  17.433 +		select (newbi);
  17.434 +	}
  17.435 +}
  17.436 +
  17.437 +void VymModel::selectBelowBranchInt()
  17.438 +{
  17.439 +	BranchItem *bi=getSelectedBranchItem();
  17.440 +	if (bi)
  17.441 +	{
  17.442 +		BranchItem *newbi=NULL;
  17.443 +
  17.444 +		if (bi->branchCount() >0)
  17.445 +			newbi=bi->getFirstBranch();
  17.446 +		else
  17.447 +		{
  17.448 +			BranchItem *pi;
  17.449 +			int i;
  17.450 +			while (!newbi)
  17.451 +			{
  17.452 +				pi=(BranchItem*)bi->parent();
  17.453 +				i=bi->num();
  17.454 +				if (pi->branchCount()-1 > i)
  17.455 +				{
  17.456 +					newbi=(BranchItem*)pi->getBranchNum(i+1);
  17.457 +					//done...
  17.458 +					break;
  17.459 +				}	
  17.460 +				else
  17.461 +					// look for siblings of myself 
  17.462 +					// or parent, or parent of parent...
  17.463 +					bi=pi;
  17.464 +				if (bi==rootItem)
  17.465 +					// already at end
  17.466 +					return;
  17.467 +			}	
  17.468 +		}
  17.469 +		select (newbi);
  17.470 +	}
  17.471 +}
  17.472 +
  17.473 +void VymModel::selectUpperBranch()
  17.474 +{
  17.475 +	if (selection.isBlocked() ) return;
  17.476 +
  17.477 +	BranchItem *bi=getSelectedBranchItem();
  17.478 +	if (bi && bi->isBranchLikeType())
  17.479 +		selectAboveBranchInt();
  17.480 +}
  17.481 +
  17.482  void VymModel::selectLowerBranch()
  17.483  {
  17.484  	if (selection.isBlocked() ) return;
  17.485  
  17.486  	BranchItem *bi=getSelectedBranchItem();
  17.487 -	if (bi && bi->getType()==TreeItem::Branch)
  17.488 -	{
  17.489 -		if (bi->getBranchObj()->getOrientation()==LinkableMapObj::RightOfCenter)	//FIXME-3 check getBO
  17.490 -			selectNextBranchInt();
  17.491 -		else
  17.492 -			if (bi->depth()==1)
  17.493 -				selectPrevBranchInt();
  17.494 -			else
  17.495 -				selectNextBranchInt();
  17.496 -	}			
  17.497 +	if (bi && bi->isBranchLikeType())
  17.498 +		selectBelowBranchInt();
  17.499  }
  17.500  
  17.501  
    18.1 --- a/vymmodel.h	Mon Apr 20 10:42:05 2009 +0000
    18.2 +++ b/vymmodel.h	Thu Apr 23 12:15:31 2009 +0000
    18.3 @@ -309,7 +309,7 @@
    18.4  	MapCenterObj* getLastMapCenter();		//!< get last added MapCenter, used for context menu
    18.5  
    18.6  private:	
    18.7 -    BranchObj* addNewBranchInt(int);		// pos allows to add above/below selection
    18.8 +    BranchItem* addNewBranchInt(int);		// pos allows to add above/below selection
    18.9  public:	
   18.10  	/*! \Add new branch
   18.11  		
   18.12 @@ -318,8 +318,9 @@
   18.13  		 0 as child of selection
   18.14  		 1 below selection
   18.15  	*/
   18.16 -    BranchObj* addNewBranch(int pos);		
   18.17 -    BranchObj* addNewBranchBefore();		//!< Insert branch between selection and its parent
   18.18 +    BranchItem* addNewBranch(int pos);		
   18.19 +    BranchItem* addNewBranchBefore();		//!< Insert branch between selection and its parent
   18.20 +	BranchItem* relinkBranch (BranchItem* branch, BranchItem* dst, int pos =-1);	//! Relink branch to dst at position pos
   18.21      void deleteSelection();					//!< Delete selection
   18.22  	void deleteKeepChildren();				//!< remove branch, but keep children
   18.23  	void deleteChildren();					//!< keep branch, but remove children
   18.24 @@ -558,7 +559,9 @@
   18.25  
   18.26  private:	
   18.27  	void selectNextBranchInt();		// Increment number of branch
   18.28 -	void selectPrevBranchInt();		// Decrement number of branch
   18.29 +	void selectPrevBranchInt();		//! Select the branch which would be above in vymmap view
   18.30 +	void selectAboveBranchInt();	//! Select the branch which would be above current selection in TreeView
   18.31 +	void selectBelowBranchInt();		// Increment number of branch
   18.32  public:	
   18.33      void selectUpperBranch();
   18.34      void selectLowerBranch();