Fixed selections with cursor in MapEditor
authorinsilmaril
Sat, 08 Aug 2009 21:58:26 +0000
changeset 787c6bb4fdcc55f
parent 786 6269016c9905
child 788 78ba80b54bc4
Fixed selections with cursor in MapEditor
branchitem.cpp
branchitem.h
branchpropwindow.cpp
branchpropwindow.h
floatobj.cpp
mainwindow.cpp
mapeditor.cpp
mapeditor.h
tex/vym.changelog
treeitem.cpp
treeitem.h
version.h
vymmodel.cpp
vymmodel.h
xml-freemind.cpp
xml-vym.cpp
     1.1 --- a/branchitem.cpp	Thu Aug 06 10:42:17 2009 +0000
     1.2 +++ b/branchitem.cpp	Sat Aug 08 21:58:26 2009 +0000
     1.3 @@ -17,6 +17,9 @@
     1.4  
     1.5  	includeImagesVer=false;
     1.6  	includeImagesHor=false;
     1.7 +	 
     1.8 +	lastSelectedBranchNum=-1;
     1.9 +	lastSelectedBranchNumAlt=-1;
    1.10  }
    1.11  
    1.12  BranchItem::~BranchItem()
    1.13 @@ -299,6 +302,41 @@
    1.14  	return a;	
    1.15  }
    1.16  
    1.17 +void BranchItem::setLastSelectedBranch()
    1.18 +{
    1.19 +	int d=depth();
    1.20 +	if (d>=0)
    1.21 +	{
    1.22 +		if (d==1)
    1.23 +			// Hack to save an additional lastSelected for mapcenters in MapEditor
    1.24 +			// depending on orientation
    1.25 +			// this allows to go both left and right from there
    1.26 +			if (lmo && lmo->getOrientation()==LinkableMapObj::LeftOfCenter)
    1.27 +			{
    1.28 +				((BranchItem*)parentItem)->lastSelectedBranchNumAlt=parentItem->num(this);
    1.29 +				return;
    1.30 +			}
    1.31 +		((BranchItem*)parentItem)->lastSelectedBranchNum=parentItem->num(this);
    1.32 +	}
    1.33 +}
    1.34 +
    1.35 +void BranchItem::setLastSelectedBranch(int i)
    1.36 +{
    1.37 +		lastSelectedBranchNum=i;
    1.38 +}
    1.39 +
    1.40 +BranchItem* BranchItem::getLastSelectedBranch()
    1.41 +{
    1.42 +	return getBranchNum (lastSelectedBranchNum);
    1.43 +}
    1.44 +
    1.45 +BranchItem* BranchItem::getLastSelectedBranchAlt()
    1.46 +{
    1.47 +	return getBranchNum (lastSelectedBranchNumAlt);
    1.48 +}
    1.49 +
    1.50 +
    1.51 +
    1.52  
    1.53  
    1.54  TreeItem* BranchItem::findMapItem (QPointF p, TreeItem* excludeTI)
     2.1 --- a/branchitem.h	Thu Aug 06 10:42:17 2009 +0000
     2.2 +++ b/branchitem.h	Sat Aug 08 21:58:26 2009 +0000
     2.3 @@ -45,9 +45,16 @@
     2.4  	bool getIncludeImagesHor();
     2.5  	QString getIncludeImageAttr();
     2.6  
     2.7 +protected:
     2.8 +	int lastSelectedBranchNum;
     2.9 +	int lastSelectedBranchNumAlt;
    2.10  public:
    2.11 +	virtual void setLastSelectedBranch();			//! Set myself as last selected in parent
    2.12 +	virtual void setLastSelectedBranch(int i);		//! Set last selected branch directly
    2.13 +	virtual BranchItem* getLastSelectedBranch();	//! Returns last selected branch usually
    2.14 +	virtual BranchItem* getLastSelectedBranchAlt(); //! Used to return last selected branch left of a mapcenter
    2.15  
    2.16 -
    2.17 +public:
    2.18  	TreeItem* findMapItem (QPointF p,TreeItem* excludeTI);	//! search map for branches or images. Ignore excludeTI, where search is started 
    2.19  	virtual TreeItem* findID (QString sid);	//! search map for object with ID string
    2.20  
     3.1 --- a/branchpropwindow.cpp	Thu Aug 06 10:42:17 2009 +0000
     3.2 +++ b/branchpropwindow.cpp	Sat Aug 08 21:58:26 2009 +0000
     3.3 @@ -46,10 +46,6 @@
     3.4  		show();
     3.5  	else	
     3.6  		hide();
     3.7 -
     3.8 -	// FIXME-2 for now remove attribute tab
     3.9 -	ui.tabWidget->removeTab (3);
    3.10 -
    3.11  }
    3.12  
    3.13  BranchPropertyWindow::~BranchPropertyWindow ()
    3.14 @@ -59,17 +55,22 @@
    3.15  	settings.setValue( "/satellite/propertywindow/showWithMain",isVisible() );
    3.16  }
    3.17  
    3.18 -void BranchPropertyWindow::setBranch (BranchItem *bi)	
    3.19 +void BranchPropertyWindow::setItem (TreeItem *ti)	
    3.20  {
    3.21  	disconnectSignals();
    3.22 -	branchItem=bi;
    3.23 -	if (branchItem)
    3.24 +	if (!ti)
    3.25 +		ui.tabWidget->setEnabled (false);
    3.26 +	else if (ti->isBranchLikeType() )
    3.27  	{
    3.28 +		branchItem=(BranchItem*)ti;
    3.29  
    3.30  		branch=(BranchObj*)(branchItem->getLMO());
    3.31 -		if (branch)		// FIXME-3 move to branchItem later, when Frame is ported...
    3.32 +		if (branch)		// FIXME-3 replace by branchItem later, when Frame is ported...
    3.33  		{
    3.34  			ui.tabWidget->setEnabled (true);
    3.35 +			for (int i=0; i<3;++i)
    3.36 +				ui.tabWidget->setTabEnabled (i,true);
    3.37 +			ui.tabWidget->setTabEnabled (3,false);
    3.38  
    3.39  			// Frame
    3.40  			FrameObj::FrameType t=branch->getFrameType();
    3.41 @@ -153,7 +154,13 @@
    3.42  
    3.43  			// Finally activate signals
    3.44  			connectSignals();
    3.45 -		} // BranchObj	
    3.46 +		} // BranchItem
    3.47 +	} else if (ti->getType()==TreeItem::Attribute)
    3.48 +	{
    3.49 +		ui.tabWidget->setEnabled (true);
    3.50 +		for (int i=0; i<3;++i)
    3.51 +			ui.tabWidget->setTabEnabled (i,false);
    3.52 +		ui.tabWidget->setTabEnabled (3,true);
    3.53  	} else
    3.54  	{
    3.55  		ui.tabWidget->setEnabled (false);
    3.56 @@ -164,7 +171,7 @@
    3.57  {
    3.58  	model=m;
    3.59  	if (model) 
    3.60 -		setBranch (model->getSelectedBranchItem() );
    3.61 +		setItem (model->getSelectedItem() );
    3.62  	else
    3.63  		ui.tabWidget->setEnabled (false);
    3.64  		
    3.65 @@ -185,7 +192,7 @@
    3.66  				model->setFramePadding (5); 
    3.67  				break;
    3.68  		}
    3.69 -		setBranch (branchItem);
    3.70 +		setItem (branchItem);
    3.71  	}	
    3.72  }
    3.73  
     4.1 --- a/branchpropwindow.h	Thu Aug 06 10:42:17 2009 +0000
     4.2 +++ b/branchpropwindow.h	Sat Aug 08 21:58:26 2009 +0000
     4.3 @@ -20,7 +20,7 @@
     4.4  public:
     4.5  	BranchPropertyWindow (QWidget *parent=0);
     4.6  	~BranchPropertyWindow ();
     4.7 -	void setBranch (BranchItem *);
     4.8 +	void setItem (TreeItem *);
     4.9  	void setModel (VymModel *);
    4.10  
    4.11  private slots:
     5.1 --- a/floatobj.cpp	Thu Aug 06 10:42:17 2009 +0000
     5.2 +++ b/floatobj.cpp	Sat Aug 08 21:58:26 2009 +0000
     5.3 @@ -37,7 +37,6 @@
     5.4  	zPlane=Z_ICON;
     5.5  	setLinkStyle (LinkableMapObj::Parabel);
     5.6  	//FIXME-2 setHideLinkUnselected(true);
     5.7 -	cout << "FO::init  tI="<<treeItem<<endl;
     5.8  }
     5.9  
    5.10  void FloatObj::copy (FloatObj* other)
     6.1 --- a/mainwindow.cpp	Thu Aug 06 10:42:17 2009 +0000
     6.2 +++ b/mainwindow.cpp	Sat Aug 08 21:58:26 2009 +0000
     6.3 @@ -3373,7 +3373,7 @@
     6.4  	if (m)
     6.5  	{
     6.6  		TreeItem *selti=m->getSelectedItem();
     6.7 -		BranchItem *selbi=m->getSelectedBranchItem();
     6.8 +		BranchItem *selbi=m->getSelectedBranch();
     6.9  		if (selti)
    6.10  		{
    6.11  			if (selbi)
     7.1 --- a/mapeditor.cpp	Thu Aug 06 10:42:17 2009 +0000
     7.2 +++ b/mapeditor.cpp	Sat Aug 08 21:58:26 2009 +0000
     7.3 @@ -555,25 +555,185 @@
     7.4  */		
     7.5  }
     7.6  
     7.7 +BranchItem* MapEditor::getBranchDirectAbove (BranchItem *bi)
     7.8 +{
     7.9 +	if (bi)
    7.10 +	{
    7.11 +		int i=bi->num();
    7.12 +		if (i>0) return bi->parent()->getBranchNum(i-1);
    7.13 +	}
    7.14 +	return NULL;
    7.15 +}
    7.16 +
    7.17 +BranchItem* MapEditor::getBranchAbove (BranchItem *selbi)
    7.18 +{
    7.19 +	if (selbi)
    7.20 +	{
    7.21 +		int dz=selbi->depth();	// original depth
    7.22 +		bool invert=false;
    7.23 +		if (selbi->getLMO()->getOrientation()==LinkableMapObj::LeftOfCenter)
    7.24 +			invert=true;
    7.25 +
    7.26 +		BranchItem *bi;
    7.27 +
    7.28 +		// Look for branch with same parent but directly above
    7.29 +		if (dz==1 && invert)
    7.30 +			bi=getBranchDirectBelow(selbi);
    7.31 +		else
    7.32 +			bi=getBranchDirectAbove (selbi);
    7.33 +
    7.34 +		if (bi) 
    7.35 +			// direct predecessor
    7.36 +			return bi;
    7.37 +
    7.38 +		// Go towards center and look for predecessor
    7.39 +		while (selbi->depth()>0)
    7.40 +		{
    7.41 +			selbi=(BranchItem*)(selbi->parent());
    7.42 +			if (selbi->depth()==1 && invert)
    7.43 +				bi=getBranchDirectBelow (selbi);
    7.44 +			else
    7.45 +				bi=getBranchDirectAbove (selbi);
    7.46 +			if (bi)
    7.47 +			{
    7.48 +				// turn 
    7.49 +				selbi=bi;
    7.50 +				while (selbi->depth()<dz)
    7.51 +				{
    7.52 +					// try to get back to original depth dz
    7.53 +					bi=selbi->getLastBranch();
    7.54 +					if (!bi) 
    7.55 +					{
    7.56 +						return selbi;
    7.57 +					}
    7.58 +					selbi=bi;
    7.59 +				}
    7.60 +				return selbi;
    7.61 +			}
    7.62 +		}
    7.63 +	}
    7.64 +	return NULL;
    7.65 +}
    7.66 +
    7.67 +BranchItem* MapEditor::getBranchDirectBelow(BranchItem *bi)
    7.68 +{
    7.69 +	if (bi)
    7.70 +	{
    7.71 +		int i=bi->num();
    7.72 +		if (i+1<bi->parent()->branchCount()) return bi->parent()->getBranchNum(i+1);
    7.73 +	}
    7.74 +	return NULL;
    7.75 +}
    7.76 +
    7.77 +BranchItem* MapEditor::getBranchBelow (BranchItem *selbi)
    7.78 +{
    7.79 +	if (selbi)
    7.80 +	{
    7.81 +		BranchItem *bi;
    7.82 +		int dz=selbi->depth();	// original depth
    7.83 +		bool invert=false;
    7.84 +		if (selbi->getLMO()->getOrientation()==LinkableMapObj::LeftOfCenter)
    7.85 +			invert=true;
    7.86 +
    7.87 +
    7.88 +		// Look for branch with same parent but directly below
    7.89 +		if (dz==1 && invert)
    7.90 +			bi=getBranchDirectAbove (selbi);
    7.91 +		else
    7.92 +			bi=getBranchDirectBelow (selbi);
    7.93 +		if (bi) 
    7.94 +			// direct successor
    7.95 +			return bi;
    7.96 +
    7.97 +
    7.98 +		// Go towards center and look for neighbour
    7.99 +		while (selbi->depth()>0)
   7.100 +		{
   7.101 +			selbi=(BranchItem*)(selbi->parent());
   7.102 +			if (selbi->depth()==1 && invert)
   7.103 +				bi=getBranchDirectAbove (selbi);
   7.104 +			else
   7.105 +				bi=getBranchDirectBelow (selbi);
   7.106 +			if (bi)
   7.107 +			{
   7.108 +				// turn 
   7.109 +				selbi=bi;
   7.110 +				while (selbi->depth()<dz)
   7.111 +				{
   7.112 +					// try to get back to original depth dz
   7.113 +					bi=selbi->getFirstBranch();
   7.114 +					if (!bi) 
   7.115 +					{
   7.116 +						return selbi;
   7.117 +					}
   7.118 +					selbi=bi;
   7.119 +				}
   7.120 +				return selbi;
   7.121 +			}
   7.122 +		}
   7.123 +	}
   7.124 +	return NULL;
   7.125 +}
   7.126 +
   7.127 +BranchItem* MapEditor::getLeftBranch (BranchItem *bi)
   7.128 +{
   7.129 +	if (bi)
   7.130 +	{
   7.131 +		if (bi->depth()==0)
   7.132 +			// Special case: use alternative selection index
   7.133 +			return bi->getLastSelectedBranchAlt();	
   7.134 +		if (bi->getBranchObj()->getOrientation()==LinkableMapObj::RightOfCenter)	
   7.135 +			// right of center
   7.136 +			return (BranchItem*)(bi->parent());
   7.137 +		else
   7.138 +			// left of center
   7.139 +			if (bi->getType()== TreeItem::Branch )
   7.140 +				return bi->getLastSelectedBranch();
   7.141 +	}
   7.142 +	return NULL;
   7.143 +}
   7.144 +
   7.145 +BranchItem* MapEditor::getRightBranch(BranchItem *bi)
   7.146 +{
   7.147 +	if (bi)
   7.148 +	{
   7.149 +		if (bi->depth()==0) return bi->getLastSelectedBranch();	
   7.150 +		if (bi->getBranchObj()->getOrientation()==LinkableMapObj::LeftOfCenter)	
   7.151 +			// left of center
   7.152 +			return (BranchItem*)(bi->parent());
   7.153 +		else
   7.154 +			// right of center
   7.155 +			if (bi->getType()== TreeItem::Branch )
   7.156 +				return (BranchItem*)bi->getLastSelectedBranch();
   7.157 +	}
   7.158 +	return NULL;
   7.159 +}
   7.160 +
   7.161 +
   7.162 +
   7.163  void MapEditor::cursorUp()
   7.164  {
   7.165 -	model->selectUpperBranch();
   7.166 +	BranchItem *bi=model->getSelectedBranch();
   7.167 +	if (bi) model->select (getBranchAbove(bi));
   7.168  }
   7.169  
   7.170  void MapEditor::cursorDown()	
   7.171  
   7.172  {
   7.173 -	model->selectLowerBranch();
   7.174 +	BranchItem *bi=model->getSelectedBranch();
   7.175 +	if (bi) model->select (getBranchBelow(bi));
   7.176  }
   7.177  
   7.178  void MapEditor::cursorLeft()
   7.179  {
   7.180 -	model->selectLeftBranch();
   7.181 +	BranchItem *bi=getLeftBranch (model->getSelectedBranch());
   7.182 +	if (bi) model->select (bi);
   7.183  }
   7.184  
   7.185  void MapEditor::cursorRight()	
   7.186  {
   7.187 -	model->selectRightBranch();
   7.188 +	BranchItem *bi=getRightBranch (model->getSelectedBranch());
   7.189 +	if (bi) model->select (bi);
   7.190  }
   7.191  
   7.192  void MapEditor::cursorFirst()	
   7.193 @@ -595,7 +755,7 @@
   7.194  		return;
   7.195  	}
   7.196  	BranchObj *bo=model->getSelectedBranchObj();
   7.197 -	BranchItem *bi=model->getSelectedBranchItem();
   7.198 +	BranchItem *bi=model->getSelectedBranch();
   7.199  	if (bo)	
   7.200  	{
   7.201  		model->setSelectionBlocked(true);
   7.202 @@ -649,7 +809,7 @@
   7.203  			branchContextMenu->popup(e->globalPos() );
   7.204  		} else
   7.205  		{
   7.206 -			if (model->getSelectedImageItem() )
   7.207 +			if (model->getSelectedImage() )
   7.208  			{
   7.209  				// Context Menu on floatimage
   7.210  				// model->updateActions(); FIXME-3 needed?
   7.211 @@ -808,12 +968,12 @@
   7.212  			if (mainWindow->getModMode()==Main::ModModeCopy &&
   7.213  				e->state() & Qt::ControlModifier)
   7.214  			{
   7.215 -				BranchItem *bi=model->getSelectedBranchItem();
   7.216 +				BranchItem *bi=model->getSelectedBranch();
   7.217  				if (bi)
   7.218  				{
   7.219  					copyingObj=true;
   7.220  					//FIXME-2   TreeItem::addBranch (BranchItem still missing) 
   7.221 -					//bi->addBranch (model->getSelectedBranchItem());
   7.222 +					//bi->addBranch (model->getSelectedBranch());
   7.223  					model->unselect();
   7.224  					model->select(bi->getLastBranch());
   7.225  					model->reposition();
   7.226 @@ -1065,7 +1225,7 @@
   7.227  			}	
   7.228  		}
   7.229  
   7.230 -		BranchItem *bi=model->getSelectedBranchItem();
   7.231 +		BranchItem *bi=model->getSelectedBranch();
   7.232  		if (bi && bi->depth()==0)
   7.233  		{	
   7.234              if (movingObj_orgPos != bi->getBranchObj()->getAbsPos())	// FIXME-3 check getBO here...
   7.235 @@ -1242,7 +1402,7 @@
   7.236  
   7.237  void MapEditor::dropEvent(QDropEvent *event)
   7.238  {
   7.239 -	BranchItem *selbi=model->getSelectedBranchItem();
   7.240 +	BranchItem *selbi=model->getSelectedBranch();
   7.241  	if (selbi)
   7.242  	{
   7.243  		if (debug)
   7.244 @@ -1317,13 +1477,13 @@
   7.245  	foreach (ix,newsel.indexes() )
   7.246  	{
   7.247  		TreeItem *ti= static_cast<TreeItem*>(ix.internalPointer());
   7.248 -		if (ti->getType()==TreeItem::Branch || ti->getType()==TreeItem::Image )
   7.249 +		if (ti->isBranchLikeType() || ti->getType()==TreeItem::Image )
   7.250  			if (!treeItemsNew.contains(ti)) treeItemsNew.append (ti);
   7.251  	}
   7.252  	foreach (ix,oldsel.indexes() )
   7.253  	{
   7.254  		TreeItem *ti= static_cast<TreeItem*>(ix.internalPointer());
   7.255 -		if (ti->getType()==TreeItem::Branch || ti->getType()==TreeItem::Image )
   7.256 +		if (ti->isBranchLikeType() || ti->getType()==TreeItem::Image )
   7.257  			if (!treeItemsOld.contains(ti)) treeItemsOld.append (ti);
   7.258  	}
   7.259  
     8.1 --- a/mapeditor.h	Thu Aug 06 10:42:17 2009 +0000
     8.2 +++ b/mapeditor.h	Sat Aug 08 21:58:26 2009 +0000
     8.3 @@ -61,6 +61,14 @@
     8.4      void testFunction1();				// just testing new stuff
     8.5      void testFunction2();				// just testing new stuff
     8.6  
     8.7 +protected:	
     8.8 +	BranchItem* getBranchDirectAbove(BranchItem *bi);	//!  get branch direct above bi (in TreeView) 
     8.9 +	BranchItem* getBranchAbove(BranchItem *bi);			//! get branch above bi (in TreeView) 
    8.10 +	BranchItem* getBranchDirectBelow(BranchItem *bi);	//!  bet branch direct below bi (in TreeView)
    8.11 +	BranchItem* getBranchBelow(BranchItem *bi);			//! bet branch below bi (in TreeView)
    8.12 +	BranchItem* getLeftBranch(BranchItem *bi);			//! bet branch left of bi (in TreeView)
    8.13 +	BranchItem* getRightBranch(BranchItem *bi);			//! bet branch right of bi (in TreeView)
    8.14 +
    8.15  public slots:
    8.16  	void cursorUp();
    8.17  	void cursorDown();
     9.1 --- a/tex/vym.changelog	Thu Aug 06 10:42:17 2009 +0000
     9.2 +++ b/tex/vym.changelog	Sat Aug 08 21:58:26 2009 +0000
     9.3 @@ -1,3 +1,15 @@
     9.4 +-------------------------------------------------------------------
     9.5 +Sat Aug  8 23:54:38 CEST 2009 - uwedr@suse.de
     9.6 +
     9.7 +- Feature: Selecting with cursor now remembers left & right of
     9.8 +  mapcenters. Also improved selections in deeper trees
     9.9 +- Bugfix: Selecting with cursor in MapEditor
    9.10 +
    9.11 +-------------------------------------------------------------------
    9.12 +Thu Aug  6 19:33:01 CEST 2009 - uwedr@suse.de
    9.13 +
    9.14 +- Bugfix: Removed the "new" in new branches to allow easier copy & paste
    9.15 +
    9.16  -------------------------------------------------------------------
    9.17  Wed Jul 22 21:51:04 CEST 2009 - uwedr@suse.de
    9.18  
    10.1 --- a/treeitem.cpp	Thu Aug 06 10:42:17 2009 +0000
    10.2 +++ b/treeitem.cpp	Sat Aug 08 21:58:26 2009 +0000
    10.3 @@ -67,7 +67,6 @@
    10.4  
    10.5  	branchOffset=0;
    10.6  	branchCounter=0;
    10.7 -	lastSelectedBranchNum=-1;
    10.8  
    10.9  	imageOffset=0;
   10.10  	imageCounter=0;
   10.11 @@ -244,6 +243,8 @@
   10.12  
   10.13  int TreeItem::depth() 
   10.14  {
   10.15 +	// Rootitem d=-1
   10.16 +	// MapCenter d=0
   10.17  	int d=-2;
   10.18  	TreeItem *ti=this;
   10.19  	while (ti!=NULL)
   10.20 @@ -271,6 +272,7 @@
   10.21  		case MapCenter: return parentItem->childItems.indexOf (this) - parentItem->branchOffset;
   10.22  		case Branch: return parentItem->childItems.indexOf (this) - parentItem->branchOffset;
   10.23  		case Image: return parentItem->childItems.indexOf (this) - parentItem->imageOffset;
   10.24 +		case Attribute: return parentItem->childItems.indexOf (this) - parentItem->attributeOffset;
   10.25  		default: return -1;
   10.26  	}
   10.27  }
   10.28 @@ -284,6 +286,7 @@
   10.29  		case MapCenter: return childItems.indexOf (item) - branchOffset;
   10.30  		case Branch: return childItems.indexOf (item) - branchOffset;
   10.31  		case Image: return parentItem->childItems.indexOf (item) - imageOffset;
   10.32 +		case Attribute: return parentItem->childItems.indexOf (item) - attributeOffset;
   10.33  		default: return -1;
   10.34  	}
   10.35  }
   10.36 @@ -295,6 +298,7 @@
   10.37  
   10.38  TreeItem::Type TreeItem::getType()
   10.39  {
   10.40 +	if (type==Branch && depth()==0) return MapCenter;
   10.41  	return type;
   10.42  }
   10.43  
   10.44 @@ -592,22 +596,6 @@
   10.45  		return NULL;
   10.46  }
   10.47  
   10.48 -void TreeItem::setLastSelectedBranch()
   10.49 -{
   10.50 -	if (parentItem)
   10.51 -		parentItem->lastSelectedBranchNum=parentItem->childItems.indexOf(this);
   10.52 -}
   10.53 -
   10.54 -void TreeItem::setLastSelectedBranch(int i)
   10.55 -{
   10.56 -		lastSelectedBranchNum=i;
   10.57 -}
   10.58 -
   10.59 -TreeItem* TreeItem::getLastSelectedBranch()
   10.60 -{
   10.61 -	return getBranchNum (lastSelectedBranchNum);
   10.62 -}
   10.63 -
   10.64  ImageItem* TreeItem::getImageNum (const int &n)
   10.65  {
   10.66  	if (n>=0 && n<imageCounter)
    11.1 --- a/treeitem.h	Thu Aug 06 10:42:17 2009 +0000
    11.2 +++ b/treeitem.h	Sat Aug 08 21:58:26 2009 +0000
    11.3 @@ -151,9 +151,6 @@
    11.4  
    11.5  	virtual BranchItem* getBranchNum(const int &n);
    11.6  	virtual BranchObj* getBranchObjNum(const int &n);
    11.7 -	virtual void setLastSelectedBranch();		//! Set myself as last selected in parent
    11.8 -	virtual void setLastSelectedBranch(int i);	//! Set last selected branch directly
    11.9 -	virtual TreeItem* getLastSelectedBranch();
   11.10  
   11.11  	virtual ImageItem* getImageNum(const int &n);
   11.12  	virtual FloatImageObj* getImageObjNum(const int &n);
   11.13 @@ -182,8 +179,6 @@
   11.14   
   11.15  	int branchOffset;
   11.16  	int branchCounter;
   11.17 -	int lastSelectedBranchNum;
   11.18 -
   11.19  	int imageOffset;
   11.20  	int imageCounter;
   11.21  
    12.1 --- a/version.h	Thu Aug 06 10:42:17 2009 +0000
    12.2 +++ b/version.h	Sat Aug 08 21:58:26 2009 +0000
    12.3 @@ -7,7 +7,7 @@
    12.4  #define __VYM_VERSION "1.13.0"
    12.5  //#define __VYM_CODENAME "Codename: RC-1"
    12.6  #define __VYM_CODENAME "Codename: development version, not for production!"
    12.7 -#define __VYM_BUILD_DATE "2009-08-03"
    12.8 +#define __VYM_BUILD_DATE "2009-08-08"
    12.9  
   12.10  
   12.11  bool checkVersion(const QString &);
    13.1 --- a/vymmodel.cpp	Thu Aug 06 10:42:17 2009 +0000
    13.2 +++ b/vymmodel.cpp	Sat Aug 08 21:58:26 2009 +0000
    13.3 @@ -360,7 +360,7 @@
    13.4  		// (map state is set later at end of load...)
    13.5  	} else
    13.6  	{
    13.7 -		BranchItem *bi=getSelectedBranchItem();
    13.8 +		BranchItem *bi=getSelectedBranch();
    13.9  		if (!bi) return aborted;
   13.10  		if (lmode==ImportAdd)
   13.11  			saveStateChangingPart(
   13.12 @@ -607,7 +607,7 @@
   13.13  		if (selectionType()==TreeItem::Image)
   13.14  			saveFloatImage();
   13.15  		else	
   13.16 -			saveFile=saveToDir (fileDir,mapName+"-",true,QPointF(),getSelectedBranchItem());	
   13.17 +			saveFile=saveToDir (fileDir,mapName+"-",true,QPointF(),getSelectedBranch());	
   13.18  		// TODO take care of multiselections
   13.19  	}	
   13.20  
   13.21 @@ -725,7 +725,7 @@
   13.22  
   13.23  void VymModel::loadFloatImage ()
   13.24  {
   13.25 -	BranchItem *selbi=getSelectedBranchItem();
   13.26 +	BranchItem *selbi=getSelectedBranch();
   13.27  	if (selbi)
   13.28  	{
   13.29  
   13.30 @@ -776,7 +776,7 @@
   13.31  
   13.32  void VymModel::saveFloatImage ()
   13.33  {
   13.34 -	ImageItem *ii=getSelectedImageItem();
   13.35 +	ImageItem *ii=getSelectedImage();
   13.36  	if (ii)
   13.37  	{
   13.38  		QFileDialog *fd=new QFileDialog( NULL);
   13.39 @@ -1487,7 +1487,7 @@
   13.40  
   13.41  void VymModel::setHeading(const QString &s)
   13.42  {
   13.43 -	BranchItem *selbi=getSelectedBranchItem();
   13.44 +	BranchItem *selbi=getSelectedBranch();
   13.45  	if (selbi)
   13.46  	{
   13.47  		saveState(
   13.48 @@ -1564,7 +1564,7 @@
   13.49  	//cout <<"still searching...  "<<qPrintable( itFind->getHeading())<<endl;
   13.50  	}	
   13.51  	if (!searching)
   13.52 -		return getSelectedBranchItem();
   13.53 +		return getSelectedBranch();
   13.54  	else
   13.55  		return NULL;
   13.56  }
   13.57 @@ -1615,7 +1615,7 @@
   13.58  QStringList VymModel::getURLs()	
   13.59  {
   13.60  	QStringList urls;
   13.61 -	BranchItem *selbi=getSelectedBranchItem();
   13.62 +	BranchItem *selbi=getSelectedBranch();
   13.63  	BranchItem *cur=selbi;
   13.64  	BranchItem *prev=NULL;
   13.65  	while (cur) 
   13.66 @@ -1629,7 +1629,7 @@
   13.67  
   13.68  void VymModel::setFrameType(const FrameObj::FrameType &t)	//FIXME-4 not saved if there is no LMO
   13.69  {
   13.70 -	BranchItem *bi=getSelectedBranchItem();
   13.71 +	BranchItem *bi=getSelectedBranch();
   13.72  	if (bi)
   13.73  	{
   13.74  		BranchObj *bo=(BranchObj*)(bi->getLMO());
   13.75 @@ -1647,7 +1647,7 @@
   13.76  
   13.77  void VymModel::setFrameType(const QString &s)	//FIXME-4 not saved if there is no LMO
   13.78  {
   13.79 -	BranchItem *bi=getSelectedBranchItem();
   13.80 +	BranchItem *bi=getSelectedBranch();
   13.81  	if (bi)
   13.82  	{
   13.83  		BranchObj *bo=(BranchObj*)(bi->getLMO());
   13.84 @@ -1665,7 +1665,7 @@
   13.85  void VymModel::setFramePenColor(const QColor &c)	//FIXME-4 not saved if there is no LMO
   13.86  
   13.87  {
   13.88 -	BranchItem *bi=getSelectedBranchItem();
   13.89 +	BranchItem *bi=getSelectedBranch();
   13.90  	if (bi)
   13.91  	{
   13.92  		BranchObj *bo=(BranchObj*)(bi->getLMO());
   13.93 @@ -1680,7 +1680,7 @@
   13.94  
   13.95  void VymModel::setFrameBrushColor(const QColor &c)	//FIXME-4 not saved if there is no LMO
   13.96  {
   13.97 -	BranchItem *bi=getSelectedBranchItem();
   13.98 +	BranchItem *bi=getSelectedBranch();
   13.99  	if (bi)
  13.100  	{
  13.101  		BranchObj *bo=(BranchObj*)(bi->getLMO());
  13.102 @@ -1695,7 +1695,7 @@
  13.103  
  13.104  void VymModel::setFramePadding (const int &i) //FIXME-4 not saved if there is no LMO
  13.105  {
  13.106 -	BranchItem *bi=getSelectedBranchItem();
  13.107 +	BranchItem *bi=getSelectedBranch();
  13.108  	if (bi)
  13.109  	{
  13.110  		BranchObj *bo=(BranchObj*)(bi->getLMO());
  13.111 @@ -1712,7 +1712,7 @@
  13.112  
  13.113  void VymModel::setFrameBorderWidth(const int &i) //FIXME-4 not saved if there is no LMO
  13.114  {
  13.115 -	BranchItem *bi=getSelectedBranchItem();
  13.116 +	BranchItem *bi=getSelectedBranch();
  13.117  	if (bi)
  13.118  	{
  13.119  		BranchObj *bo=(BranchObj*)(bi->getLMO());
  13.120 @@ -1729,7 +1729,7 @@
  13.121  
  13.122  void VymModel::setIncludeImagesVer(bool b)
  13.123  {
  13.124 -	BranchItem *bi=getSelectedBranchItem();
  13.125 +	BranchItem *bi=getSelectedBranch();
  13.126  	if (bi)
  13.127  	{
  13.128  		QString u= b ? "false" : "true";
  13.129 @@ -1750,7 +1750,7 @@
  13.130  
  13.131  void VymModel::setIncludeImagesHor(bool b)	
  13.132  {
  13.133 -	BranchItem *bi=getSelectedBranchItem();
  13.134 +	BranchItem *bi=getSelectedBranch();
  13.135  	if (bi)
  13.136  	{
  13.137  		QString u= b ? "false" : "true";
  13.138 @@ -1869,7 +1869,7 @@
  13.139  
  13.140  void VymModel::paste()	
  13.141  {   
  13.142 -	BranchItem *selbi=getSelectedBranchItem();
  13.143 +	BranchItem *selbi=getSelectedBranch();
  13.144  	if (selbi)
  13.145  	{
  13.146  		saveStateChangingPart(
  13.147 @@ -1896,7 +1896,7 @@
  13.148  
  13.149  void VymModel::moveUp()	
  13.150  {
  13.151 -	BranchItem *selbi=getSelectedBranchItem();
  13.152 +	BranchItem *selbi=getSelectedBranch();
  13.153  	if (selbi)
  13.154  	{
  13.155  		if (!selbi->canMoveUp()) return;
  13.156 @@ -1909,7 +1909,7 @@
  13.157  
  13.158  void VymModel::moveDown()	
  13.159  {
  13.160 -	BranchItem *selbi=getSelectedBranchItem();
  13.161 +	BranchItem *selbi=getSelectedBranch();
  13.162  	if (selbi)
  13.163  	{
  13.164  		if (!selbi->canMoveDown()) return;
  13.165 @@ -1985,8 +1985,6 @@
  13.166  
  13.167  AttributeItem* VymModel::addAttribute()
  13.168  {
  13.169 -	cout << "VM::addAttribute\n";
  13.170 -
  13.171  	TreeItem *selti=getSelectedItem();
  13.172  	if (selti)
  13.173  	{
  13.174 @@ -2108,7 +2106,7 @@
  13.175  	//  0	add as child
  13.176  	// +1	add below
  13.177  	BranchItem *newbi=NULL;
  13.178 -	BranchItem *selbi=getSelectedBranchItem();
  13.179 +	BranchItem *selbi=getSelectedBranch();
  13.180  
  13.181  	if (selbi)
  13.182  	{
  13.183 @@ -2145,7 +2143,7 @@
  13.184  BranchItem* VymModel::addNewBranchBefore()	
  13.185  {
  13.186  	BranchItem *newbi=NULL;
  13.187 -	BranchItem *selbi=getSelectedBranchItem();
  13.188 +	BranchItem *selbi=getSelectedBranch();
  13.189  	if (selbi && selbi->getType()==TreeItem::Branch)
  13.190  		 // We accept no MapCenter here, so we _have_ a parent
  13.191  	{
  13.192 @@ -2255,7 +2253,7 @@
  13.193  
  13.194  void VymModel::deleteSelection()	// FIXME-2 include fix for deleted mapcenters from 1.12.4
  13.195  {
  13.196 -	BranchItem *selbi=getSelectedBranchItem();
  13.197 +	BranchItem *selbi=getSelectedBranch();
  13.198  
  13.199  	if (selbi && selbi->isBranchLikeType() )
  13.200  	{
  13.201 @@ -2270,18 +2268,19 @@
  13.202  		}
  13.203  		return;
  13.204  	}
  13.205 -	ImageItem *ii=getSelectedImageItem();
  13.206 -	if (ii)
  13.207 +	TreeItem *ti=getSelectedImage();
  13.208 +	if (ti->getType()==TreeItem::Image || ti->getType()==TreeItem::Attribute)
  13.209  	{
  13.210 -		BranchItem *pi=(BranchItem*)(ii->parent());
  13.211 +		TreeItem *pi=ti->parent();
  13.212  		saveStateChangingPart(
  13.213  			pi, 
  13.214 -			ii,
  13.215 +			ti,
  13.216  			"delete ()",
  13.217 -			QString("Delete %1").arg(getObjectName(ii))
  13.218 +			QString("Delete %1").arg(getObjectName(ti))
  13.219  		);
  13.220  		unselect();
  13.221 -		deleteItem (ii);
  13.222 +		deleteItem (ti);
  13.223 +		emitDataHasChanged (pi);
  13.224  		select (pi);
  13.225  		reposition();
  13.226  		emitShowSelection();
  13.227 @@ -2289,10 +2288,10 @@
  13.228  	}
  13.229  }
  13.230  
  13.231 -void VymModel::deleteKeepChildren()	//FIXME-2 does not work yet for mapcenters
  13.232 -
  13.233 -{
  13.234 -	BranchItem *selbi=getSelectedBranchItem();
  13.235 +void VymModel::deleteKeepChildren()	//FIXME-3 does not work yet for mapcenters
  13.236 +
  13.237 +{
  13.238 +	BranchItem *selbi=getSelectedBranch();
  13.239  	BranchItem *pi;
  13.240  	if (selbi)
  13.241  	{
  13.242 @@ -2341,7 +2340,7 @@
  13.243  void VymModel::deleteChildren()		
  13.244  
  13.245  {
  13.246 -	BranchItem *selbi=getSelectedBranchItem();
  13.247 +	BranchItem *selbi=getSelectedBranch();
  13.248  	if (selbi)
  13.249  	{		
  13.250  		saveStateChangingPart(
  13.251 @@ -2442,7 +2441,7 @@
  13.252  
  13.253  void VymModel::toggleScroll()	
  13.254  {
  13.255 -	BranchItem *bi=(BranchItem*)getSelectedBranchItem();
  13.256 +	BranchItem *bi=(BranchItem*)getSelectedBranch();
  13.257  	if (bi && bi->isBranchLikeType() )
  13.258  	{
  13.259  		if (bi->isScrolled())
  13.260 @@ -2477,7 +2476,7 @@
  13.261  
  13.262  void VymModel::toggleStandardFlag (const QString &name, FlagRow *master)
  13.263  {
  13.264 -	BranchItem *bi=getSelectedBranchItem();
  13.265 +	BranchItem *bi=getSelectedBranch();
  13.266  	if (bi) 
  13.267  	{
  13.268  		QString u,r;
  13.269 @@ -2524,7 +2523,7 @@
  13.270  
  13.271  void VymModel::colorBranch (QColor c)	
  13.272  {
  13.273 -	BranchItem *selbi=getSelectedBranchItem();
  13.274 +	BranchItem *selbi=getSelectedBranch();
  13.275  	if (selbi)
  13.276  	{
  13.277  		saveState(
  13.278 @@ -2540,7 +2539,7 @@
  13.279  
  13.280  void VymModel::colorSubtree (QColor c) 
  13.281  {
  13.282 -	BranchItem *selbi=getSelectedBranchItem();
  13.283 +	BranchItem *selbi=getSelectedBranch();
  13.284  	if (selbi)
  13.285  	{
  13.286  		saveStateChangingPart(
  13.287 @@ -2562,7 +2561,7 @@
  13.288  
  13.289  QColor VymModel::getCurrentHeadingColor()	
  13.290  {
  13.291 -	BranchItem *selbi=getSelectedBranchItem();
  13.292 +	BranchItem *selbi=getSelectedBranch();
  13.293  	if (selbi)	return selbi->getHeadingColor();
  13.294  		
  13.295  	QMessageBox::warning(0,"Warning","Can't get color of heading,\nthere's no branch selected");
  13.296 @@ -2651,7 +2650,7 @@
  13.297  
  13.298  void VymModel::editVymLink()
  13.299  {
  13.300 -	BranchItem *bi=getSelectedBranchItem();
  13.301 +	BranchItem *bi=getSelectedBranch();
  13.302  	if (bi)
  13.303  	{		
  13.304  		QStringList filters;
  13.305 @@ -2695,7 +2694,7 @@
  13.306  
  13.307  void VymModel::deleteVymLink()
  13.308  {
  13.309 -	BranchItem *bi=getSelectedBranchItem();
  13.310 +	BranchItem *bi=getSelectedBranch();
  13.311  	if (bi)
  13.312  	{		
  13.313  		saveState(
  13.314 @@ -2713,7 +2712,7 @@
  13.315  
  13.316  QString VymModel::getVymLink()
  13.317  {
  13.318 -	BranchItem *bi=getSelectedBranchItem();
  13.319 +	BranchItem *bi=getSelectedBranch();
  13.320  	if (bi)
  13.321  		return bi->getVymLink();
  13.322  	else	
  13.323 @@ -2724,7 +2723,7 @@
  13.324  QStringList VymModel::getVymLinks()	
  13.325  {
  13.326  	QStringList links;
  13.327 -	BranchItem *selbi=getSelectedBranchItem();
  13.328 +	BranchItem *selbi=getSelectedBranch();
  13.329  	BranchItem *cur=selbi;
  13.330  	BranchItem *prev=NULL;
  13.331  	while (cur) 
  13.332 @@ -2792,7 +2791,7 @@
  13.333  void VymModel::parseAtom(const QString &atom)
  13.334  {
  13.335  	TreeItem* selti=getSelectedItem();
  13.336 -	BranchItem *selbi=getSelectedBranchItem();
  13.337 +	BranchItem *selbi=getSelectedBranch();
  13.338  	QString s,t;
  13.339  	double x,y;
  13.340  	int n;
  13.341 @@ -3307,7 +3306,7 @@
  13.342  	/////////////////////////////////////////////////////////////////////
  13.343  	} else if (com=="saveImage")
  13.344  	{
  13.345 -		ImageItem *ii=getSelectedImageItem();
  13.346 +		ImageItem *ii=getSelectedImage();
  13.347  		if (!ii )
  13.348  		{
  13.349  			parser.setError (Aborted,"No image selected");
  13.350 @@ -4612,12 +4611,7 @@
  13.351  bool VymModel::select (const QString &s)
  13.352  {
  13.353  	TreeItem *ti=findBySelectString(s);
  13.354 -	if (ti)
  13.355 -	{
  13.356 -		unselect();
  13.357 -		select (ti);
  13.358 -		return true;
  13.359 -	} 
  13.360 +	if (ti) return select (index(ti));
  13.361  	return false;
  13.362  }
  13.363  
  13.364 @@ -4626,7 +4620,7 @@
  13.365  	QItemSelection oldsel=selModel->selection();
  13.366  
  13.367  	if (lmo)
  13.368 -		return select (lmo->getTreeItem() );
  13.369 +		return select (index (lmo->getTreeItem()) );
  13.370  	else	
  13.371  		return false;
  13.372  }
  13.373 @@ -4642,7 +4636,8 @@
  13.374  	if (index.isValid() )
  13.375  	{
  13.376  		selModel->select (index,QItemSelectionModel::ClearAndSelect  );
  13.377 -		getSelectedItem()->setLastSelectedBranch();
  13.378 +		BranchItem *bi=getSelectedBranch();
  13.379 +		if (bi) bi->setLastSelectedBranch();
  13.380  		return true;
  13.381  	}
  13.382  	return false;
  13.383 @@ -4654,9 +4649,9 @@
  13.384  	selModel->clearSelection();
  13.385  }	
  13.386  
  13.387 -void VymModel::reselect()
  13.388 -{
  13.389 -	select (lastSelectString);
  13.390 +bool VymModel::reselect()
  13.391 +{
  13.392 +	return select (lastSelectString);
  13.393  }	
  13.394  
  13.395  void VymModel::emitShowSelection()	
  13.396 @@ -4678,7 +4673,7 @@
  13.397  }
  13.398  
  13.399  
  13.400 -//void VymModel::selectInt (LinkableMapObj *lmo)	// FIXME-3 still needed?
  13.401 +//bool VymModel::selectInt (LinkableMapObj *lmo)	// FIXME-3 still needed?
  13.402  /*
  13.403  {
  13.404  	if (selection.select(lmo))
  13.405 @@ -4687,7 +4682,7 @@
  13.406  	}
  13.407  }
  13.408  
  13.409 -void VymModel::selectInt (TreeItem *ti)	
  13.410 +bool VymModel::selectInt (TreeItem *ti)	
  13.411  {
  13.412  	if (selection.select(lmo))
  13.413  	{
  13.414 @@ -4696,264 +4691,58 @@
  13.415  }
  13.416  */
  13.417  
  13.418 -void VymModel::selectNextBranchInt()
  13.419 -{
  13.420 -	BranchItem *bi=getSelectedBranchItem();
  13.421 -	if (bi)
  13.422 -	{
  13.423 -		TreeItem *pi=bi->parent();
  13.424 -		if (bi!=rootItem)
  13.425 -		{
  13.426 -			int i=bi->num();
  13.427 -			if (i<pi->branchCount() )
  13.428 -			{
  13.429 -				// select previous branch with same parent
  13.430 -				i++;
  13.431 -				select (pi->getBranchNum(i));
  13.432 -				return;
  13.433 -			}
  13.434 -		}
  13.435 -		
  13.436 -	}
  13.437 -}
  13.438 -
  13.439 -void VymModel::selectPrevBranchInt()
  13.440 -{
  13.441 -
  13.442 -	BranchItem *bi=getSelectedBranchItem();
  13.443 -	if (bi)
  13.444 -	{
  13.445 -		BranchItem *pi=(BranchItem*)bi->parent();
  13.446 -		if (bi!=rootItem)
  13.447 -		{
  13.448 -			int i=bi->num();
  13.449 -			if (i>0)
  13.450 -			{
  13.451 -				// select previous branch with same parent
  13.452 -				bi=pi->getBranchNum(i-1);
  13.453 -				select (bi);
  13.454 -				return;
  13.455 -			}
  13.456 -			bi=pi;
  13.457 -			while (bi->branchCount() >0)
  13.458 -				bi=bi->getLastBranch();
  13.459 -			select (bi);	
  13.460 -
  13.461 -			// Try to select last branch in parent pi2 previous to own parent pi
  13.462 -			/*
  13.463 -			TreeItem *pi2=pi->parent();
  13.464 -			if (pi2)
  13.465 -			{
  13.466 -				int j=pi->num();
  13.467 -				if (pi2->)
  13.468 -			}
  13.469 -			*/
  13.470 -		}
  13.471 -	}
  13.472 -}
  13.473 -
  13.474 -void VymModel::selectAboveBranchInt()
  13.475 -{
  13.476 -	BranchItem *bi=getSelectedBranchItem();
  13.477 -	if (bi)
  13.478 -	{
  13.479 -		BranchItem *newbi=NULL;
  13.480 -		BranchItem *pi=(BranchItem*)bi->parent();
  13.481 -		int i=bi->num();
  13.482 -		if (i>0)
  13.483 -		{
  13.484 -			// goto previous branch with same parent
  13.485 -			newbi=pi->getBranchNum(i-1);
  13.486 -			while (newbi->branchCount() >0 )
  13.487 -				newbi=newbi->getLastBranch();
  13.488 -		}
  13.489 -		else
  13.490 -			newbi=pi;
  13.491 -		if (newbi==rootItem) 
  13.492 - 			// already at top branch (resp. mapcenter)
  13.493 -			return;
  13.494 -		select (newbi);
  13.495 -	}
  13.496 -}
  13.497 -
  13.498 -void VymModel::selectBelowBranchInt()
  13.499 -{
  13.500 -	BranchItem *bi=getSelectedBranchItem();
  13.501 -	if (bi)
  13.502 -	{
  13.503 -		BranchItem *newbi=NULL;
  13.504 -
  13.505 -		if (bi->branchCount() >0)
  13.506 -			newbi=bi->getFirstBranch();
  13.507 -		else
  13.508 -		{
  13.509 -			BranchItem *pi;
  13.510 -			int i;
  13.511 -			while (!newbi)
  13.512 -			{
  13.513 -				pi=(BranchItem*)bi->parent();
  13.514 -				i=bi->num();
  13.515 -				if (pi->branchCount()-1 > i)
  13.516 -				{
  13.517 -					newbi=(BranchItem*)pi->getBranchNum(i+1);
  13.518 -					//done...
  13.519 -					break;
  13.520 -				}	
  13.521 -				else
  13.522 -					// look for siblings of myself 
  13.523 -					// or parent, or parent of parent...
  13.524 -					bi=pi;
  13.525 -				if (bi==rootItem)
  13.526 -					// already at end
  13.527 -					return;
  13.528 -			}	
  13.529 -		}
  13.530 -		select (newbi);
  13.531 -	}
  13.532 -}
  13.533 -
  13.534 -void VymModel::selectUpperBranch()
  13.535 -{
  13.536 -	BranchItem *bi=getSelectedBranchItem();
  13.537 -	if (bi && bi->isBranchLikeType())
  13.538 -		selectAboveBranchInt();
  13.539 -}
  13.540 -
  13.541 -void VymModel::selectLowerBranch()
  13.542 -{
  13.543 -	BranchItem *bi=getSelectedBranchItem();
  13.544 -	if (bi && bi->isBranchLikeType())
  13.545 -		selectBelowBranchInt();
  13.546 -}
  13.547 -
  13.548 -
  13.549 -void VymModel::selectLeftBranch()
  13.550 -{
  13.551 -	QItemSelection oldsel=selModel->selection();
  13.552 -
  13.553 -	BranchItem* par;
  13.554 -	BranchItem *selbi=getSelectedBranchItem();
  13.555 -	TreeItem::Type type=selbi->getType();
  13.556 -	if (selbi)
  13.557 -	{
  13.558 -		if (type == TreeItem::MapCenter)
  13.559 -		{
  13.560 -			QModelIndex ix=index(selbi);
  13.561 -			selModel->select (index (rowCount(ix)-1,0,ix),QItemSelectionModel::ClearAndSelect  );
  13.562 -		} else
  13.563 -		{
  13.564 -			par=(BranchItem*)selbi->parent();
  13.565 -			if (selbi->getBranchObj()->getOrientation()==LinkableMapObj::RightOfCenter)	//FIXME-3 check getBO...
  13.566 -			{
  13.567 -				// right of center
  13.568 -				if (type == TreeItem::Branch ||
  13.569 -					type == TreeItem::Image)
  13.570 -				{
  13.571 -					QModelIndex ix=index (selbi->parent());
  13.572 -					selModel->select (ix,QItemSelectionModel::ClearAndSelect  );
  13.573 -				}
  13.574 -			} else
  13.575 -			{
  13.576 -				// left of center
  13.577 -				if (type == TreeItem::Branch )
  13.578 -				{
  13.579 -					selectLastSelectedBranch();
  13.580 -					return;
  13.581 -				}
  13.582 -			}
  13.583 -		}	
  13.584 -	}
  13.585 -}
  13.586 -
  13.587 -void VymModel::selectRightBranch()
  13.588 -{
  13.589 -	QItemSelection oldsel=selModel->selection();
  13.590 -
  13.591 -	BranchItem* par;
  13.592 -	BranchItem *selbi=getSelectedBranchItem();
  13.593 -	TreeItem::Type type=selbi->getType();
  13.594 -	if (selbi)
  13.595 -	{
  13.596 -		if (type==TreeItem::MapCenter)
  13.597 -		{
  13.598 -			QModelIndex ix=index(selbi);
  13.599 -			selModel->select (index (0,0,ix),QItemSelectionModel::ClearAndSelect  );
  13.600 -		} else
  13.601 -		{
  13.602 -			par=(BranchItem*)selbi->parent();
  13.603 -			if (selbi->getBranchObj()->getOrientation()==LinkableMapObj::RightOfCenter)	//FIXME-3 check getBO
  13.604 -			{
  13.605 -				// right of center
  13.606 -				if ( type== TreeItem::Branch )
  13.607 -				{
  13.608 -					selectLastSelectedBranch();
  13.609 -					return;
  13.610 -				}
  13.611 -			} else
  13.612 -			{
  13.613 -				// left of center
  13.614 -				if (type == TreeItem::Branch ||
  13.615 -					type == TreeItem::Image)
  13.616 -				{
  13.617 -					QModelIndex ix=index(selbi->parent());
  13.618 -					selModel->select (ix,QItemSelectionModel::ClearAndSelect  );
  13.619 -				}
  13.620 -			}
  13.621 -		}	
  13.622 -	}
  13.623 -}
  13.624 -
  13.625 -void VymModel::selectFirstBranch()
  13.626 -{
  13.627 -	TreeItem *ti=getSelectedBranchItem();
  13.628 +bool VymModel::selectFirstBranch()
  13.629 +{
  13.630 +	TreeItem *ti=getSelectedBranch();
  13.631  	if (ti)
  13.632  	{
  13.633  		TreeItem *par=ti->parent();
  13.634 -		if (!par) return;
  13.635 -		TreeItem *ti2=par->getFirstBranch();
  13.636 -		if (ti2) {
  13.637 -			select(ti2);
  13.638 -			emitSelectionChanged();
  13.639 +		if (par) 
  13.640 +		{
  13.641 +			TreeItem *ti2=par->getFirstBranch();
  13.642 +			if (ti2) return  select(ti2);
  13.643  		}
  13.644  	}		
  13.645 +	return false;
  13.646  }
  13.647  
  13.648 -void VymModel::selectLastBranch()
  13.649 -{
  13.650 -	TreeItem *ti=getSelectedBranchItem();
  13.651 +bool VymModel::selectLastBranch()
  13.652 +{
  13.653 +	TreeItem *ti=getSelectedBranch();
  13.654  	if (ti)
  13.655  	{
  13.656  		TreeItem *par=ti->parent();
  13.657 -		if (!par) return;
  13.658 -		TreeItem *ti2=par->getLastBranch();
  13.659 -		if (ti2) {
  13.660 -			select(ti2);
  13.661 -			emitSelectionChanged();
  13.662 +		if (par) 
  13.663 +		{
  13.664 +			TreeItem *ti2=par->getLastBranch();
  13.665 +			if (ti2) return select(ti2);
  13.666  		}
  13.667  	}		
  13.668 +	return false;
  13.669  }
  13.670  
  13.671 -void VymModel::selectLastSelectedBranch()
  13.672 -{
  13.673 -	TreeItem *ti=getSelectedBranchItem();
  13.674 -	if (ti)
  13.675 +bool VymModel::selectLastSelectedBranch()
  13.676 +{
  13.677 +	BranchItem *bi=getSelectedBranch();
  13.678 +	if (bi)
  13.679  	{
  13.680 -		ti=ti->getLastSelectedBranch();
  13.681 -		if (ti) select (ti);
  13.682 +		bi=bi->getLastSelectedBranch();
  13.683 +		if (bi) return select (bi);
  13.684  	}		
  13.685 +	return false;
  13.686  }
  13.687  
  13.688 -void VymModel::selectParent()
  13.689 +bool VymModel::selectParent()
  13.690  {
  13.691  	TreeItem *ti=getSelectedItem();
  13.692  	TreeItem *par;
  13.693  	if (ti)
  13.694  	{
  13.695  		par=ti->parent();
  13.696 -		if (!par) return;
  13.697 -		select(par);
  13.698 -		emitSelectionChanged();
  13.699 +		if (par) 
  13.700 +			return select(par);
  13.701  	}		
  13.702 +	return false;
  13.703  }
  13.704  
  13.705  TreeItem::Type VymModel::selectionType()
  13.706 @@ -4980,14 +4769,14 @@
  13.707  
  13.708  BranchObj* VymModel::getSelectedBranchObj()	// FIXME-3 this should not be needed in the end!!!
  13.709  {
  13.710 -	TreeItem *ti = getSelectedBranchItem();
  13.711 +	TreeItem *ti = getSelectedBranch();
  13.712  	if (ti)
  13.713  		return (BranchObj*)(  ((MapItem*)ti)->getLMO());
  13.714  	else	
  13.715  		return NULL;
  13.716  }
  13.717  
  13.718 -BranchItem* VymModel::getSelectedBranchItem()
  13.719 +BranchItem* VymModel::getSelectedBranch()
  13.720  {
  13.721  	QModelIndexList list=selModel->selectedIndexes();
  13.722  	if (!list.isEmpty() )
  13.723 @@ -5000,25 +4789,7 @@
  13.724  	return NULL;
  13.725  }
  13.726  
  13.727 -TreeItem* VymModel::getSelectedItem()	
  13.728 -{
  13.729 -	QModelIndexList list=selModel->selectedIndexes();
  13.730 -	if (!list.isEmpty() )
  13.731 -		return getItem (list.first() );
  13.732 -	else	
  13.733 -		return NULL;
  13.734 -}
  13.735 -
  13.736 -QModelIndex VymModel::getSelectedIndex()
  13.737 -{
  13.738 -	QModelIndexList list=selModel->selectedIndexes();
  13.739 -	if (list.isEmpty() )
  13.740 -		return QModelIndex();
  13.741 -	else
  13.742 -		return list.first();
  13.743 -}
  13.744 -
  13.745 -ImageItem* VymModel::getSelectedImageItem()
  13.746 +ImageItem* VymModel::getSelectedImage()
  13.747  {
  13.748  	QModelIndexList list=selModel->selectedIndexes();
  13.749  	if (!list.isEmpty())
  13.750 @@ -5030,6 +4801,37 @@
  13.751  	return NULL;
  13.752  }
  13.753  
  13.754 +AttributeItem* VymModel::getSelectedAttribute()	
  13.755 +{
  13.756 +	QModelIndexList list=selModel->selectedIndexes();
  13.757 +	if (!list.isEmpty() )
  13.758 +	{
  13.759 +		TreeItem *ti = getItem (list.first() );
  13.760 +		TreeItem::Type type=ti->getType();
  13.761 +		if (type ==TreeItem::Attribute)
  13.762 +			return (AttributeItem*)ti;
  13.763 +	} 
  13.764 +	return NULL;
  13.765 +}
  13.766 +
  13.767 +TreeItem* VymModel::getSelectedItem()	
  13.768 +{
  13.769 +	QModelIndexList list=selModel->selectedIndexes();
  13.770 +	if (!list.isEmpty() )
  13.771 +		return getItem (list.first() );
  13.772 +	else	
  13.773 +		return NULL;
  13.774 +}
  13.775 +
  13.776 +QModelIndex VymModel::getSelectedIndex()
  13.777 +{
  13.778 +	QModelIndexList list=selModel->selectedIndexes();
  13.779 +	if (list.isEmpty() )
  13.780 +		return QModelIndex();
  13.781 +	else
  13.782 +		return list.first();
  13.783 +}
  13.784 +
  13.785  QString VymModel::getSelectString ()
  13.786  {
  13.787  	return getSelectString (getSelectedItem());
  13.788 @@ -5050,6 +4852,7 @@
  13.789  		case TreeItem::MapCenter: s="mc:"; break;
  13.790  		case TreeItem::Branch: s="bo:";break;
  13.791  		case TreeItem::Image: s="fi:";break;
  13.792 +		case TreeItem::Attribute: s="ai:";break;
  13.793  		default:break;
  13.794  	}
  13.795  	s=  s + QString("%1").arg(ti->num());
    14.1 --- a/vymmodel.h	Thu Aug 06 10:42:17 2009 +0000
    14.2 +++ b/vymmodel.h	Sat Aug 08 21:58:26 2009 +0000
    14.3 @@ -565,37 +565,29 @@
    14.4  	bool select (TreeItem *ti );			//! Select by pointer to TreeItem
    14.5  	bool select (const QModelIndex &index);	//! Select by ModelIndex
    14.6  	void unselect();
    14.7 -	void reselect();
    14.8 +	bool reselect();
    14.9  
   14.10  	void emitShowSelection();				//!< Show selection in all views
   14.11  signals:
   14.12  	void showSelection();
   14.13  
   14.14 -//	void selectInt(LinkableMapObj*);	//FIXME-4
   14.15 +//	bool selectInt(LinkableMapObj*);	//FIXME-4
   14.16  
   14.17 -private:	
   14.18 -	void selectNextBranchInt();		// Increment number of branch
   14.19 -	void selectPrevBranchInt();		//! Select the branch which would be above in vymmap view
   14.20 -	void selectAboveBranchInt();	//! Select the branch which would be above current selection in TreeView
   14.21 -	void selectBelowBranchInt();		// Increment number of branch
   14.22  public:	
   14.23 -    void selectUpperBranch();
   14.24 -    void selectLowerBranch();
   14.25 -    void selectLeftBranch();
   14.26 -    void selectRightBranch();
   14.27 -    void selectFirstBranch();
   14.28 -    void selectLastBranch();
   14.29 -	void selectLastSelectedBranch();
   14.30 -	void selectParent();
   14.31 +    bool selectFirstBranch();
   14.32 +    bool selectLastBranch();
   14.33 +	bool selectLastSelectedBranch();
   14.34 +	bool selectParent();
   14.35  
   14.36  public:
   14.37  	TreeItem::Type selectionType();
   14.38  	LinkableMapObj* getSelectedLMO();
   14.39  	BranchObj* getSelectedBranchObj();	// FIXME-3 replace by item...
   14.40 -	BranchItem* getSelectedBranchItem();
   14.41 +	BranchItem* getSelectedBranch();
   14.42 +	ImageItem* getSelectedImage();
   14.43 +	AttributeItem* getSelectedAttribute();
   14.44  	TreeItem* getSelectedItem();
   14.45  	QModelIndex getSelectedIndex();
   14.46 -	ImageItem* getSelectedImageItem();
   14.47  	QString getSelectString ();
   14.48  	QString getSelectString (LinkableMapObj *lmo);
   14.49  	QString getSelectString (TreeItem *item);
    15.1 --- a/xml-freemind.cpp	Thu Aug 06 10:42:17 2009 +0000
    15.2 +++ b/xml-freemind.cpp	Sat Aug 08 21:58:26 2009 +0000
    15.3 @@ -90,7 +90,7 @@
    15.4  			if (atts.value ("POSITION")=="left")
    15.5  			{
    15.6  				model->select ("bo:1");
    15.7 -				lastBranchItem=model->getSelectedBranchItem();
    15.8 +				lastBranchItem=model->getSelectedBranch();
    15.9  				if (lastBranchItem)
   15.10  				{	
   15.11  					lastBranchItem=model->createBranch(lastBranchItem);
   15.12 @@ -99,7 +99,7 @@
   15.13  			} else if (atts.value ("POSITION")=="right")
   15.14  			{
   15.15  				model->select ("bo:0");
   15.16 -				lastBranchItem=model->getSelectedBranchItem();
   15.17 +				lastBranchItem=model->getSelectedBranch();
   15.18  				if (lastBranchItem)
   15.19  				{	
   15.20  					lastBranchItem=model->createBranch(lastBranchItem);
    16.1 --- a/xml-vym.cpp	Thu Aug 06 10:42:17 2009 +0000
    16.2 +++ b/xml-vym.cpp	Sat Aug 08 21:58:26 2009 +0000
    16.3 @@ -145,7 +145,7 @@
    16.4  		{
    16.5  			// Treat the found mapcenter as a branch 
    16.6  			// in an existing map
    16.7 -			BranchItem *bi=model->getSelectedBranchItem();	//FIXME-3 selection is no longer used here...
    16.8 +			BranchItem *bi=model->getSelectedBranch();	//FIXME-3 selection is no longer used here...
    16.9  			if (bi)
   16.10  			{
   16.11  				lastBranch=bi;
   16.12 @@ -271,7 +271,7 @@
   16.13  		<<">  state=" <<state 
   16.14  	//	<<"  laststate=" <<laststate
   16.15  	//	<<"  stateStack="<<stateStack.last() 
   16.16 -		<<"  selString="<<model->getSelectString().toStdString()
   16.17 +	//	<<"  selString="<<model->getSelectString().toStdString()
   16.18  		<<endl;
   16.19  	*/
   16.20      switch ( state ) 
   16.21 @@ -282,7 +282,7 @@
   16.22          case StateMapCenter: 
   16.23  			model->emitDataHasChanged (lastBranch);
   16.24  			lastBranch=(BranchItem*)(lastBranch->parent());
   16.25 -			lastBranch->setLastSelectedBranch (0);	// Reset last selected to first child branch
   16.26 +		//	lastBranch->setLastSelectedBranch (0);	// Reset last selected to first child branch
   16.27              break;
   16.28          case StateBranch: 
   16.29  			// Empty branches may not be scrolled