More work on removing Selection class
authorinsilmaril
Tue, 20 Jan 2009 15:23:16 +0000
changeset 73584ae10f6e3a3
parent 734 ac4be290c750
child 736 21f115d48daf
More work on removing Selection class
branchobj.cpp
mainwindow.cpp
mapeditor.cpp
selection.cpp
selection.h
treeitem.h
version.h
vymmodel.cpp
vymmodel.h
vymview.cpp
xml-vym.cpp
     1.1 --- a/branchobj.cpp	Thu Jan 15 00:52:35 2009 +0000
     1.2 +++ b/branchobj.cpp	Tue Jan 20 15:23:16 2009 +0000
     1.3 @@ -1080,7 +1080,7 @@
     1.4  	bo->depth=depth+1;
     1.5  	bo->setDefAttr(MovedBranch);
     1.6  	if (scrolled) tmpUnscroll();
     1.7 -	setLastSelectedBranch (bo);
     1.8 +	//setLastSelectedBranch (bo);	//FIXME needed?
     1.9  	return bo;
    1.10  }
    1.11  
    1.12 @@ -1114,7 +1114,7 @@
    1.13  	bo->depth=depth+1;
    1.14  	bo->setDefAttr (MovedBranch);
    1.15  	if (scrolled) tmpUnscroll();
    1.16 -	setLastSelectedBranch (bo);
    1.17 +	//setLastSelectedBranch (bo); //FIXME needed?
    1.18  	qSort (branch.begin(),branch.end(), isAbove);
    1.19  	return bo;
    1.20  }
    1.21 @@ -1167,6 +1167,7 @@
    1.22  
    1.23  void BranchObj::setLastSelectedBranch (BranchObj* bo)
    1.24  {
    1.25 +	cout << "BO::setLastSelectedBranch for "<<getHeading().toStdString()<<endl;
    1.26      lastSelectedBranch=branch.indexOf(bo);
    1.27  }
    1.28  
    1.29 @@ -1554,7 +1555,7 @@
    1.30  	bboxTotal.setHeight(max (r.height(),  bbox.height()));
    1.31  }
    1.32  
    1.33 -void BranchObj::select()
    1.34 +void BranchObj::select()	// FIXME try to get rid of this in BO completely
    1.35  {
    1.36  	// update NoteEditor
    1.37  	textEditor->setText(note.getNote() );
    1.38 @@ -1569,10 +1570,7 @@
    1.39  	// set selected and visible
    1.40      LinkableMapObj::select();
    1.41  
    1.42 -	// Tell parent that I am selected now:
    1.43 -	BranchObj* po=(BranchObj*)(parObj);
    1.44 -    if (po)	// TODO	    Try to get rid of this cast...
    1.45 -        po->setLastSelectedBranch(this);
    1.46 +    //if (po)	po->setLastSelectedBranch(this);
    1.47  		
    1.48  	// temporary unscroll, if we have scrolled parents somewhere
    1.49  	if (parObj) ((BranchObj*)(parObj))->tmpUnscroll();
     2.1 --- a/mainwindow.cpp	Thu Jan 15 00:52:35 2009 +0000
     2.2 +++ b/mainwindow.cpp	Tue Jan 20 15:23:16 2009 +0000
     2.3 @@ -2870,7 +2870,7 @@
     2.4  	VymModel *m=currentModel();
     2.5  	if (m)
     2.6  	{
     2.7 -		BranchObj *bo=(BranchObj*)m->getSelection();
     2.8 +		BranchObj *bo=m->getSelectedBranch();
     2.9  		BranchObj *newbo=m->addNewBranch(0);
    2.10  
    2.11  		prevSelection=m->getSelectString(bo);
    2.12 @@ -2897,7 +2897,7 @@
    2.13  	VymModel *m=currentModel();
    2.14  	if (m)
    2.15  	{
    2.16 -		BranchObj *bo=(BranchObj*)m->getSelection();
    2.17 +		BranchObj *bo=m->getSelectedBranch();
    2.18  		BranchObj *newbo=m->addNewBranchBefore();
    2.19  
    2.20  		if (newbo) 
    2.21 @@ -2919,7 +2919,7 @@
    2.22  	VymModel *m=currentModel();
    2.23  	if ( m)
    2.24  	{
    2.25 -		BranchObj *bo=(BranchObj*)m->getSelection();
    2.26 +		BranchObj *bo=m->getSelectedBranch();
    2.27  		BranchObj *newbo=m->addNewBranch (-1);
    2.28  
    2.29  		if (newbo) 
    2.30 @@ -2941,7 +2941,7 @@
    2.31  	VymModel *m=currentModel();
    2.32  	if (m)
    2.33  	{
    2.34 -		BranchObj *bo=(BranchObj*)m->getSelection();
    2.35 +		BranchObj *bo=m->getSelectedBranch();
    2.36  		BranchObj *newbo=m->addNewBranch (1);
    2.37  
    2.38  		if (newbo) 
    2.39 @@ -3405,7 +3405,7 @@
    2.40  		actionFilePrint->setEnabled (true);
    2.41  
    2.42  		// Selection
    2.43 -		selection=m->getSelection();
    2.44 +		selection=m->getSelectedLMO();
    2.45  
    2.46  		// Link style in context menu
    2.47  		switch (m->getMapLinkStyle())
     3.1 --- a/mapeditor.cpp	Thu Jan 15 00:52:35 2009 +0000
     3.2 +++ b/mapeditor.cpp	Tue Jan 20 15:23:16 2009 +0000
     3.3 @@ -271,7 +271,7 @@
     3.4  			QString("%1 (\"%2\")").arg(r).arg(f),
     3.5  			QString("Toggling standard flag \"%1\" of %2").arg(f).arg(model->getObjectName(bo)));
     3.6  		bo->toggleStandardFlag (f,mainWindow->useFlagGroups());
     3.7 -		model->updateSelection();
     3.8 +		model->updateSelection();	// geometry has changed
     3.9  	}
    3.10  }
    3.11  
    3.12 @@ -391,7 +391,7 @@
    3.13  	
    3.14      if (lmo) 
    3.15  	{	// MapObj was found
    3.16 -		if (model->getSelection() != lmo)
    3.17 +		if (model->getSelectedLMO() != lmo)
    3.18  		{
    3.19  			// select the MapObj
    3.20  			model->select(lmo);
    3.21 @@ -550,19 +550,6 @@
    3.22  		//QModelIndex ix=model->index( ti->row(), ti->column(), model->index (0,0,QModelIndex()) );
    3.23  		QModelIndex ix=model->index(ti);
    3.24  		model->getSelectionModel()->select (ix,QItemSelectionModel::ClearAndSelect  );
    3.25 -		/*
    3.26 -		if (model->getSelectionModel()->hasSelection() ) 
    3.27 -		{
    3.28 -			QModelIndex ixsel=model->getSelectionModel()->selectedIndexes().first();
    3.29 -			TreeItem *tisel= static_cast<TreeItem*>(ixsel.internalPointer());
    3.30 -	;
    3.31 -			cout << "  ti="<<ti<<"  tisel="<<tisel<<endl;
    3.32 -			if (ti!=tisel) int i=1/0;
    3.33 -		}
    3.34 -		else
    3.35 -			cout <<"MapEditor::mousePressed  No selection!!!\n";
    3.36 -		*/
    3.37 -
    3.38  
    3.39  		// Left Button	    Move Branches
    3.40  		if (e->button() == Qt::LeftButton )
    3.41 @@ -585,14 +572,14 @@
    3.42  				if (bo)
    3.43  				{
    3.44  					copyingObj=true;
    3.45 -					bo->addBranch ((BranchObj*)model->getSelection());
    3.46 +					bo->addBranch (model->getSelectedBranch());
    3.47  					model->unselect();
    3.48  					model->select(bo->getLastBranch());
    3.49  					model->reposition();
    3.50  				}
    3.51  			} 
    3.52  
    3.53 -			movingObj=model->getSelection();	
    3.54 +			movingObj=model->getSelectedLMO();	
    3.55  		} else
    3.56  			// Middle Button    Toggle Scroll
    3.57  			// (On Mac OS X this won't work, but we still have 
    3.58 @@ -620,7 +607,7 @@
    3.59  void MapEditor::mouseMoveEvent(QMouseEvent* e)
    3.60  {
    3.61      QPointF p = mapToScene(e->pos());
    3.62 -	LinkableMapObj *lmosel=model->getSelection();
    3.63 +	LinkableMapObj *lmosel=model->getSelectedLMO();
    3.64  
    3.65      // Move the selected MapObj
    3.66      if ( lmosel && movingObj) 
    3.67 @@ -649,7 +636,7 @@
    3.68  			fio->move   (p.x() -movingObj_start.x(), p.y()-movingObj_start.y() );		
    3.69  			fio->setRelPos();
    3.70  			fio->updateLink(); //no need for reposition, if we update link here
    3.71 -			model->updateSelection();
    3.72 +			model->updateSelection();	// position has changed
    3.73  
    3.74  			// Relink float to new mapcenter or branch, if shift is pressed	
    3.75  			// Only relink, if selection really has a new parent
    3.76 @@ -736,7 +723,7 @@
    3.77  			} // depth>0
    3.78  
    3.79  			QItemSelection sel=model->getSelectionModel()->selection();
    3.80 -			updateSelection(sel,sel);
    3.81 +			updateSelection(sel,sel);	// position has changed
    3.82  
    3.83  		} // no FloatImageObj
    3.84  
    3.85 @@ -767,7 +754,7 @@
    3.86  {
    3.87      QPointF p = mapToScene(e->pos());
    3.88  	LinkableMapObj *dst;
    3.89 -	LinkableMapObj *lmosel=model->getSelection();
    3.90 +	LinkableMapObj *lmosel=model->getSelectedLMO();
    3.91  	// Have we been picking color?
    3.92  	if (pickingColor)
    3.93  	{
    3.94 @@ -1094,6 +1081,7 @@
    3.95  		index=newsel.indexes().at(i);
    3.96  		ti= static_cast<TreeItem*>(index.internalPointer());
    3.97  		lmo=ti->getLMO();
    3.98 +	cout << "  ME::updateSelection of "<<((BranchObj*)lmo)->getHeading().toStdString()<<"\n";
    3.99  		bbox=lmo->getBBox();
   3.100  		sb->setRect (
   3.101  			bbox.x(),bbox.y(), 
   3.102 @@ -1104,7 +1092,7 @@
   3.103  	}
   3.104  }
   3.105  
   3.106 -void MapEditor::updateCurrent (const QModelIndex &newsel,const QModelIndex &)
   3.107 +void MapEditor::updateCurrent (const QModelIndex &,const QModelIndex &)	//FIXME not used?
   3.108  {
   3.109  
   3.110  /* FIXME testing
     4.1 --- a/selection.cpp	Thu Jan 15 00:52:35 2009 +0000
     4.2 +++ b/selection.cpp	Tue Jan 20 15:23:16 2009 +0000
     4.3 @@ -1,4 +1,6 @@
     4.4  #include <typeinfo>
     4.5 +#include <iostream>
     4.6 +using namespace std;
     4.7  
     4.8  #include "selection.h"
     4.9  
    4.10 @@ -12,6 +14,7 @@
    4.11  Selection::Selection()
    4.12  {
    4.13  	blocked=false;
    4.14 +	model=NULL;
    4.15  }
    4.16  
    4.17  Selection::~Selection()
    4.18 @@ -23,20 +26,7 @@
    4.19  	model=m;
    4.20  }
    4.21  
    4.22 -void Selection::copy(const Selection &other)
    4.23 -{
    4.24 -	selectList=other.selectList;
    4.25 -	lastSelectList=other.lastSelectList;
    4.26 -}
    4.27 -
    4.28 -void Selection::clear()
    4.29 -{
    4.30 -	unselect();
    4.31 -	lastSelectList.clear();
    4.32 -}
    4.33 -
    4.34 -
    4.35 -void Selection::update() // FIXME VM emit signal in VM instead
    4.36 +void Selection::update() // FIXME VM emit signal in VM instead and get rid of this
    4.37  {
    4.38  /*
    4.39  	QRectF bbox;
    4.40 @@ -54,25 +44,23 @@
    4.41  }
    4.42  bool Selection::select(LinkableMapObj *lmo)	// TODO no multiselections yet
    4.43  {
    4.44 +	return model->select (lmo);
    4.45 +	/*
    4.46  	if (!selectList.isEmpty()) unselect();
    4.47  	selectList.append (lmo);
    4.48 -	/* FIXME VM move to ME
    4.49 -	QGraphicsRectItem *sb = scene->addRect(
    4.50 -		QRectF(0,0,0,0), 
    4.51 -		QPen(color),
    4.52 -		color);
    4.53 -	sb->setZValue(Z_SELBOX);
    4.54 -	sb->show();
    4.55 -	selboxList.append (sb);
    4.56 -	*/
    4.57  	lmo->select();
    4.58  	update();
    4.59  	mainWindow->updateSatellites (model);	
    4.60 +	cout << "Sel::select lmo e\n";
    4.61  	return true;
    4.62 +	*/
    4.63  }
    4.64  
    4.65  bool Selection::select (const QString &s)	// TODO no multiselections yet
    4.66  {
    4.67 +	return model->select (s);
    4.68 +	/*
    4.69 +	cout << "Sel::select s=\n";
    4.70  	LinkableMapObj *lmo=model->findObjBySelect(s);
    4.71  
    4.72  	// Finally select the found object
    4.73 @@ -83,7 +71,7 @@
    4.74  		return true;
    4.75  	} 
    4.76  	return false;
    4.77 -
    4.78 +	*/
    4.79  }
    4.80  
    4.81  bool Selection::reselect ()	// TODO no multiselections yet
    4.82 @@ -99,18 +87,20 @@
    4.83  
    4.84  void Selection::unselect()
    4.85  {
    4.86 +	model->unselect();
    4.87 +	/*
    4.88 +	cout << "Sel::unselect\n";
    4.89  	if (!selectList.isEmpty() )
    4.90  	{
    4.91  		for (int i=0; i< selectList.count(); ++i) 
    4.92  			selectList.at(i)->unselect();
    4.93  		lastSelectList=selectList;
    4.94  		selectList.clear();
    4.95 -		/* FIXME VM move to ME
    4.96 -		while (!selboxList.isEmpty() )	
    4.97 -			delete selboxList.takeFirst();
    4.98 +		// FIXME VM move to ME
    4.99 +		//while (!selboxList.isEmpty() )	
   4.100 +		//	delete selboxList.takeFirst();
   4.101 +	}	
   4.102  		*/	
   4.103 -
   4.104 -	}	
   4.105  }
   4.106  
   4.107  bool Selection::isBlocked()
   4.108 @@ -133,11 +123,14 @@
   4.109  	return selectList.isEmpty();
   4.110  }
   4.111  
   4.112 +/*
   4.113  uint Selection::count()
   4.114  {
   4.115  	return selectList.count();
   4.116  }
   4.117 +*/
   4.118  
   4.119 +/*
   4.120  Selection::Type Selection::type() // TODO no multiselections yet
   4.121  {
   4.122  	if (!selectList.isEmpty())
   4.123 @@ -149,7 +142,9 @@
   4.124  	}
   4.125  	return Undefined;
   4.126  }
   4.127 +*/
   4.128  
   4.129 +/*
   4.130  LinkableMapObj* Selection::first()
   4.131  {
   4.132  	if (!selectList.isEmpty())
   4.133 @@ -166,18 +161,6 @@
   4.134  		return NULL;
   4.135  }
   4.136  
   4.137 -BranchObj* Selection::getBranch()
   4.138 -{
   4.139 -	if (!selectList.isEmpty())
   4.140 -	{
   4.141 -		LinkableMapObj *sel=selectList.first();
   4.142 -		if (typeid (*sel)==typeid (BranchObj) ||
   4.143 -		    typeid (*sel)==typeid (MapCenterObj)) 
   4.144 -			return (BranchObj*)sel;
   4.145 -	}
   4.146 -		return NULL;
   4.147 -}
   4.148 -
   4.149  TreeItem* Selection::getBranchItem()
   4.150  {
   4.151  	BranchObj* bo=getBranch();
   4.152 @@ -190,6 +173,7 @@
   4.153  	return model->getSelectionModel()->selectedIndexes().first();	// TODO no multiselections yet
   4.154  
   4.155  }
   4.156 +*/
   4.157  
   4.158  FloatImageObj* Selection::getFloatImage()
   4.159  {
     5.1 --- a/selection.h	Thu Jan 15 00:52:35 2009 +0000
     5.2 +++ b/selection.h	Tue Jan 20 15:23:16 2009 +0000
     5.3 @@ -21,8 +21,6 @@
     5.4  	enum Type {Undefined,Branch,MapCenter,FloatImage};
     5.5  	Selection ();
     5.6  	~Selection();
     5.7 -	void copy(const Selection&);
     5.8 -	void clear();
     5.9  	void setModel (VymModel *);
    5.10  	void update();      
    5.11  	bool select (LinkableMapObj*);
    5.12 @@ -33,13 +31,13 @@
    5.13  	void block();
    5.14  	void unblock();
    5.15  	bool isEmpty();
    5.16 -	uint count();
    5.17 -	Type type();
    5.18 -	LinkableMapObj * first();		// first in selection list
    5.19 -	LinkableMapObj * single();		// NULL, if multiple selected
    5.20 -	BranchObj* getBranch();
    5.21 -	TreeItem* getBranchItem();		
    5.22 -	QModelIndex getBranchIndex();	//!< Returns index of first selected branch or mapcenter
    5.23 +//	uint count();
    5.24 +//	Type type();
    5.25 +//	LinkableMapObj * first();		// first in selection list
    5.26 +//	LinkableMapObj * single();		// NULL, if multiple selected
    5.27 +//	BranchObj* getBranch();
    5.28 +//	TreeItem* getBranchItem();		
    5.29 +//	QModelIndex getBranchIndex();	//!< Returns index of first selected branch or mapcenter
    5.30  	FloatImageObj* getFloatImage();
    5.31  
    5.32  	QString getSelectString();
     6.1 --- a/treeitem.h	Thu Jan 15 00:52:35 2009 +0000
     6.2 +++ b/treeitem.h	Tue Jan 20 15:23:16 2009 +0000
     6.3 @@ -9,7 +9,7 @@
     6.4  class TreeItem
     6.5  {
     6.6  public:
     6.7 -	enum Type {Undefined,MapCenter,Branch};
     6.8 +	enum Type {Undefined,MapCenter,Branch,Image};
     6.9      TreeItem(const QList<QVariant> &data, TreeItem *parent = 0);
    6.10      ~TreeItem();
    6.11  
     7.1 --- a/version.h	Thu Jan 15 00:52:35 2009 +0000
     7.2 +++ b/version.h	Tue Jan 20 15:23:16 2009 +0000
     7.3 @@ -7,7 +7,7 @@
     7.4  #define __VYM_VERSION "1.13.0"
     7.5  //#define __VYM_CODENAME "Codename: RC-1"
     7.6  #define __VYM_CODENAME "Codename: development version"
     7.7 -#define __VYM_BUILD_DATE "2008-12-10"
     7.8 +#define __VYM_BUILD_DATE "2009-01-20"
     7.9  
    7.10  
    7.11  bool checkVersion(const QString &);
     8.1 --- a/vymmodel.cpp	Thu Jan 15 00:52:35 2009 +0000
     8.2 +++ b/vymmodel.cpp	Tue Jan 20 15:23:16 2009 +0000
     8.3 @@ -67,7 +67,7 @@
     8.4  void VymModel::clear() 
     8.5  {
     8.6  	cout << "VymModel::clear   rows="<<rowCount(index(rootItem))<<endl;	
     8.7 -	selection.clear();
     8.8 +	selModel->clearSelection();
     8.9  
    8.10  	// Remove stuff    
    8.11  	while (!mapCenters.isEmpty())			// FIXME VM needs to be in treemodel only...
    8.12 @@ -123,8 +123,6 @@
    8.13  
    8.14  	// selections
    8.15  	selModel=NULL;
    8.16 -	selection.setModel (this);
    8.17 -	selection.unselect();
    8.18  
    8.19  	// find routine
    8.20  	itFind=NULL;				
    8.21 @@ -342,12 +340,12 @@
    8.22  
    8.23  	if (lmode==NewMap)
    8.24  	{
    8.25 -		selection.clear();
    8.26 +		selModel->clearSelection();
    8.27  		// FIXME VM not needed??? model->setMapEditor(this);
    8.28  		// (map state is set later at end of load...)
    8.29  	} else
    8.30  	{
    8.31 -		BranchObj *bo=selection.getBranch();
    8.32 +		BranchObj *bo=getSelectedBranch();
    8.33  		if (!bo) return aborted;
    8.34  		if (lmode==ImportAdd)
    8.35  			saveStateChangingPart(
    8.36 @@ -589,10 +587,10 @@
    8.37  	else	
    8.38  	{
    8.39  		// Save part of map
    8.40 -		if (selection.type()==Selection::FloatImage)
    8.41 +		if (selectionType()==TreeItem::Image)
    8.42  			saveFloatImage();
    8.43  		else	
    8.44 -			saveFile=saveToDir (fileDir,mapName+"-",true,QPointF(),selection.getBranch());	
    8.45 +			saveFile=saveToDir (fileDir,mapName+"-",true,QPointF(),getSelectedBranch());	
    8.46  		// TODO take care of multiselections
    8.47  	}	
    8.48  
    8.49 @@ -660,7 +658,7 @@
    8.50  
    8.51  void VymModel::addMapInsertInt (const QString &path, int pos)
    8.52  {
    8.53 -	BranchObj *sel=selection.getBranch();
    8.54 +	BranchObj *sel=getSelectedBranch();
    8.55  	if (sel)
    8.56  	{
    8.57  		QString pathDir=path.left(path.findRev("/"));
    8.58 @@ -696,7 +694,7 @@
    8.59  
    8.60  FloatImageObj* VymModel::loadFloatImageInt (QString fn)
    8.61  {
    8.62 -	BranchObj *bo=selection.getBranch();
    8.63 +	BranchObj *bo=getSelectedBranch();
    8.64  	if (bo)
    8.65  	{
    8.66  		FloatImageObj *fio;
    8.67 @@ -712,7 +710,7 @@
    8.68  
    8.69  void VymModel::loadFloatImage ()
    8.70  {
    8.71 -	BranchObj *bo=selection.getBranch();
    8.72 +	BranchObj *bo=getSelectedBranch();
    8.73  	if (bo)
    8.74  	{
    8.75  
    8.76 @@ -810,7 +808,7 @@
    8.77  
    8.78  void VymModel::importDirInt(BranchObj *dst, QDir d)
    8.79  {
    8.80 -	BranchObj *bo=selection.getBranch();
    8.81 +	BranchObj *bo=getSelectedBranch();
    8.82  	if (bo)
    8.83  	{
    8.84  		// Traverse directories
    8.85 @@ -857,7 +855,7 @@
    8.86  
    8.87  void VymModel::importDirInt (const QString &s)
    8.88  {
    8.89 -	BranchObj *bo=selection.getBranch();
    8.90 +	BranchObj *bo=getSelectedBranch();
    8.91  	if (bo)
    8.92  	{
    8.93  		saveStateChangingPart (bo,bo,QString ("importDir (\"%1\")").arg(s),QString("Import directory structure from %1").arg(s));
    8.94 @@ -869,7 +867,7 @@
    8.95  
    8.96  void VymModel::importDir()
    8.97  {
    8.98 -	BranchObj *bo=selection.getBranch();
    8.99 +	BranchObj *bo=getSelectedBranch();
   8.100  	if (bo)
   8.101  	{
   8.102  		QStringList filters;
   8.103 @@ -1490,7 +1488,7 @@
   8.104  
   8.105  void VymModel::setHeading(const QString &s)
   8.106  {
   8.107 -	BranchObj *sel=selection.getBranch();
   8.108 +	BranchObj *sel=getSelectedBranch();
   8.109  	if (sel)
   8.110  	{
   8.111  		saveState(
   8.112 @@ -1500,7 +1498,8 @@
   8.113  			"setHeading (\""+s+"\")", 
   8.114  			QString("Set heading of %1 to \"%2\"").arg(getObjectName(sel)).arg(s) );
   8.115  		sel->setHeading(s );
   8.116 -		TreeItem *ti=selection.getBranchItem();
   8.117 +		/* FIXME testing only
   8.118 +		TreeItem *ti=getSelectedBranchItem();
   8.119  		if (ti)
   8.120  		{
   8.121  			ti->setHeading (s);
   8.122 @@ -1517,6 +1516,7 @@
   8.123  
   8.124  		//cout <<"                (r,c)=("<<ix2.row()<<","<<ix2.column()<<")"<<endl;
   8.125  
   8.126 +		*/
   8.127  		reposition();
   8.128  		selection.update();
   8.129  		ensureSelectionVisible();
   8.130 @@ -1525,7 +1525,7 @@
   8.131  
   8.132  void VymModel::setHeadingInt(const QString &s)
   8.133  {
   8.134 -	BranchObj *bo=selection.getBranch();
   8.135 +	BranchObj *bo=getSelectedBranch();
   8.136  	if (bo)
   8.137  	{
   8.138  		bo->setHeading(s);
   8.139 @@ -1556,9 +1556,9 @@
   8.140  			// Searching in Note
   8.141  			if (itFind->getNote().contains(s,cs))
   8.142  			{
   8.143 -				if (selection.single()!=itFind) 
   8.144 +				if (getSelectedBranch()!=itFind) 
   8.145  				{
   8.146 -					selection.select(itFind);
   8.147 +					select(itFind);
   8.148  					ensureSelectionVisible();
   8.149  				}
   8.150  				if (textEditor->findText(s,flags)) 
   8.151 @@ -1570,7 +1570,7 @@
   8.152  			// Searching in Heading
   8.153  			if (searching && itFind->getHeading().contains (s,cs) ) 
   8.154  			{
   8.155 -				selection.select(itFind);
   8.156 +				select(itFind);
   8.157  				ensureSelectionVisible();
   8.158  				searching=false;
   8.159  			}
   8.160 @@ -1583,7 +1583,7 @@
   8.161  	//cout <<"still searching...  "<<qPrintable( itFind->getHeading())<<endl;
   8.162  	}	
   8.163  	if (!searching)
   8.164 -		return selection.getBranch();
   8.165 +		return getSelectedBranch();
   8.166  	else
   8.167  		return NULL;
   8.168  }
   8.169 @@ -1606,7 +1606,7 @@
   8.170  
   8.171  void VymModel::setURL(const QString &url)
   8.172  {
   8.173 -	BranchObj *bo=selection.getBranch();
   8.174 +	BranchObj *bo=getSelectedBranch();
   8.175  	if (bo)
   8.176  	{
   8.177  		QString oldurl=bo->getURL();
   8.178 @@ -1627,7 +1627,7 @@
   8.179  
   8.180  QString VymModel::getURL()
   8.181  {
   8.182 -	BranchObj *bo=selection.getBranch();
   8.183 +	BranchObj *bo=getSelectedBranch();
   8.184  	if (bo)
   8.185  		return bo->getURL();
   8.186  	else
   8.187 @@ -1637,7 +1637,7 @@
   8.188  QStringList VymModel::getURLs()
   8.189  {
   8.190  	QStringList urls;
   8.191 -	BranchObj *bo=selection.getBranch();
   8.192 +	BranchObj *bo=getSelectedBranch();
   8.193  	if (bo)
   8.194  	{		
   8.195  		bo=bo->first();	
   8.196 @@ -1683,7 +1683,7 @@
   8.197  
   8.198  void VymModel::setFrameType(const FrameObj::FrameType &t)
   8.199  {
   8.200 -	BranchObj *bo=selection.getBranch();
   8.201 +	BranchObj *bo=getSelectedBranch();
   8.202  	if (bo)
   8.203  	{
   8.204  		QString s=bo->getFrameTypeName();
   8.205 @@ -1697,7 +1697,7 @@
   8.206  
   8.207  void VymModel::setFrameType(const QString &s)	
   8.208  {
   8.209 -	BranchObj *bo=selection.getBranch();
   8.210 +	BranchObj *bo=getSelectedBranch();
   8.211  	if (bo)
   8.212  	{
   8.213  		saveState (bo, QString("setFrameType (\"%1\")").arg(bo->getFrameTypeName()),
   8.214 @@ -1710,7 +1710,7 @@
   8.215  
   8.216  void VymModel::setFramePenColor(const QColor &c)	
   8.217  {
   8.218 -	BranchObj *bo=selection.getBranch();
   8.219 +	BranchObj *bo=getSelectedBranch();
   8.220  	if (bo)
   8.221  	{
   8.222  		saveState (bo, QString("setFramePenColor (\"%1\")").arg(bo->getFramePenColor().name() ),
   8.223 @@ -1721,7 +1721,7 @@
   8.224  
   8.225  void VymModel::setFrameBrushColor(const QColor &c)	
   8.226  {
   8.227 -	BranchObj *bo=selection.getBranch();
   8.228 +	BranchObj *bo=getSelectedBranch();
   8.229  	if (bo)
   8.230  	{
   8.231  		saveState (bo, QString("setFrameBrushColor (\"%1\")").arg(bo->getFrameBrushColor().name() ),
   8.232 @@ -1732,7 +1732,7 @@
   8.233  
   8.234  void VymModel::setFramePadding (const int &i)
   8.235  {
   8.236 -	BranchObj *bo=selection.getBranch();
   8.237 +	BranchObj *bo=getSelectedBranch();
   8.238  	if (bo)
   8.239  	{
   8.240  		saveState (bo, QString("setFramePadding (\"%1\")").arg(bo->getFramePadding() ),
   8.241 @@ -1745,7 +1745,7 @@
   8.242  
   8.243  void VymModel::setFrameBorderWidth(const int &i)
   8.244  {
   8.245 -	BranchObj *bo=selection.getBranch();
   8.246 +	BranchObj *bo=getSelectedBranch();
   8.247  	if (bo)
   8.248  	{
   8.249  		saveState (bo, QString("setFrameBorderWidth (\"%1\")").arg(bo->getFrameBorderWidth() ),
   8.250 @@ -1758,7 +1758,7 @@
   8.251  
   8.252  void VymModel::setIncludeImagesVer(bool b)	
   8.253  {
   8.254 -	BranchObj *bo=selection.getBranch();
   8.255 +	BranchObj *bo=getSelectedBranch();
   8.256  	if (bo)
   8.257  	{
   8.258  		QString u= b ? "false" : "true";
   8.259 @@ -1778,7 +1778,7 @@
   8.260  
   8.261  void VymModel::setIncludeImagesHor(bool b)	
   8.262  {
   8.263 -	BranchObj *bo=selection.getBranch();
   8.264 +	BranchObj *bo=getSelectedBranch();
   8.265  	if (bo)
   8.266  	{
   8.267  		QString u= b ? "false" : "true";
   8.268 @@ -1798,11 +1798,11 @@
   8.269  
   8.270  void VymModel::setHideLinkUnselected (bool b)
   8.271  {
   8.272 -	LinkableMapObj *sel=selection.single();
   8.273 +	LinkableMapObj *sel=getSelectedLMO();
   8.274  	if (sel &&
   8.275 -		(selection.type() == Selection::Branch || 
   8.276 -		selection.type() == Selection::MapCenter  ||
   8.277 -		selection.type() == Selection::FloatImage ))
   8.278 +		(selectionType() == TreeItem::Branch || 
   8.279 +		selectionType() == TreeItem::MapCenter  ||
   8.280 +		selectionType() == TreeItem::Image ))
   8.281  	{
   8.282  		QString u= b ? "false" : "true";
   8.283  		QString r=!b ? "false" : "true";
   8.284 @@ -1820,7 +1820,7 @@
   8.285  
   8.286  void VymModel::setHideExport(bool b)
   8.287  {
   8.288 -	BranchObj *bo=selection.getBranch();
   8.289 +	BranchObj *bo=getSelectedBranch();
   8.290  	if (bo)
   8.291  	{
   8.292  		bo->setHideInExport (b);
   8.293 @@ -1843,7 +1843,7 @@
   8.294  
   8.295  void VymModel::toggleHideExport()
   8.296  {
   8.297 -	BranchObj *bo=selection.getBranch();
   8.298 +	BranchObj *bo=getSelectedBranch();
   8.299  	if (bo)
   8.300  		setHideExport ( !bo->hideInExport() );
   8.301  }
   8.302 @@ -1851,8 +1851,11 @@
   8.303  
   8.304  void VymModel::copy()
   8.305  {
   8.306 -	LinkableMapObj *sel=selection.single();
   8.307 -	if (sel)
   8.308 +	LinkableMapObj *sel=getSelectedLMO();
   8.309 +	if (sel &&
   8.310 +		(selectionType() == TreeItem::Branch || 
   8.311 +		selectionType() == TreeItem::MapCenter  ||
   8.312 +		selectionType() == TreeItem::Image ))
   8.313  	{
   8.314  		if (redosAvail == 0)
   8.315  		{
   8.316 @@ -1893,7 +1896,7 @@
   8.317  
   8.318  void VymModel::paste()		
   8.319  {   
   8.320 -	BranchObj *sel=selection.getBranch();
   8.321 +	BranchObj *sel=getSelectedBranch();
   8.322  	if (sel)
   8.323  	{
   8.324  		saveStateChangingPart(
   8.325 @@ -1909,10 +1912,10 @@
   8.326  
   8.327  void VymModel::cut()
   8.328  {
   8.329 -	LinkableMapObj *sel=selection.single();
   8.330 -	if ( sel && (selection.type() == Selection::Branch ||
   8.331 -		selection.type()==Selection::MapCenter ||
   8.332 -		selection.type()==Selection::FloatImage))
   8.333 +	LinkableMapObj *sel=getSelectedLMO();
   8.334 +	if ( sel && (selectionType() == TreeItem::Branch ||
   8.335 +		selectionType()==TreeItem::MapCenter ||
   8.336 +		selectionType()==TreeItem::Image))
   8.337  	{
   8.338  	/* No savestate! savestate is called in cutNoSave
   8.339  		saveStateChangingPart(
   8.340 @@ -1930,7 +1933,7 @@
   8.341  
   8.342  void VymModel::moveBranchUp()
   8.343  {
   8.344 -	BranchObj* bo=selection.getBranch();
   8.345 +	BranchObj* bo=getSelectedBranch();
   8.346  	BranchObj* par;
   8.347  	if (bo)
   8.348  	{
   8.349 @@ -1947,7 +1950,7 @@
   8.350  
   8.351  void VymModel::moveBranchDown()
   8.352  {
   8.353 -	BranchObj* bo=selection.getBranch();
   8.354 +	BranchObj* bo=getSelectedBranch();
   8.355  	BranchObj* par;
   8.356  	if (bo)
   8.357  	{
   8.358 @@ -1964,7 +1967,7 @@
   8.359  
   8.360  void VymModel::sortChildren()
   8.361  {
   8.362 -	BranchObj* bo=selection.getBranch();
   8.363 +	BranchObj* bo=getSelectedBranch();
   8.364  	if (bo)
   8.365  	{
   8.366  		if(bo->countBranches()>1)
   8.367 @@ -1980,12 +1983,12 @@
   8.368  void VymModel::createMapCenter()
   8.369  {
   8.370  	MapCenterObj *mco=addMapCenter (QPointF (0,0) );
   8.371 -	selection.select (mco);
   8.372 +	select (mco);
   8.373  }
   8.374  
   8.375  void VymModel::createBranch()
   8.376  {
   8.377 -	BranchObj *bo=selection.getBranch();
   8.378 +	BranchObj *bo=getSelectedBranch();
   8.379  	if (bo)
   8.380  	{
   8.381  		BranchObj *newbo=addNewBranchInt (-2); // FIXME VM Old model, merge with below
   8.382 @@ -2002,7 +2005,7 @@
   8.383  		if (newbo)
   8.384  		{
   8.385  			newbo->setTreeItem (ti);
   8.386 -			selection.select (newbo); // FIXME VM really needed here?
   8.387 +			select (newbo); // FIXME VM really needed here?
   8.388  		}
   8.389  	}
   8.390  }
   8.391 @@ -2075,7 +2078,7 @@
   8.392  	// -1		insert in children of parent below selection 
   8.393  	// 0..n		insert in children of parent at pos
   8.394  	BranchObj *newbo=NULL;
   8.395 -	BranchObj *bo=selection.getBranch();
   8.396 +	BranchObj *bo=getSelectedBranch();
   8.397  	if (bo)
   8.398  	{
   8.399  		if (num==-2)
   8.400 @@ -2106,7 +2109,7 @@
   8.401  	// -1	add above
   8.402  	//  0	add as child
   8.403  	// +1	add below
   8.404 -	BranchObj *bo = selection.getBranch();
   8.405 +	BranchObj *bo = getSelectedBranch();
   8.406  	BranchObj *newbo=NULL;
   8.407  
   8.408  	if (bo)
   8.409 @@ -2143,8 +2146,8 @@
   8.410  BranchObj* VymModel::addNewBranchBefore()
   8.411  {
   8.412  	BranchObj *newbo=NULL;
   8.413 -	BranchObj *bo = selection.getBranch();
   8.414 -	if (bo && selection.type()==Selection::Branch)
   8.415 +	BranchObj *bo = getSelectedBranch();
   8.416 +	if (bo && selectionType()==TreeItem::Branch)
   8.417  		 // We accept no MapCenterObj here, so we _have_ a parent
   8.418  	{
   8.419  		QPointF p=bo->getRelPos();
   8.420 @@ -2174,9 +2177,9 @@
   8.421  
   8.422  void VymModel::deleteSelection()
   8.423  {
   8.424 -	BranchObj *bo = selection.getBranch();
   8.425 +	BranchObj *bo = getSelectedBranch();
   8.426  	
   8.427 -	if (bo && selection.type()==Selection::MapCenter)
   8.428 +	if (bo && selectionType()==TreeItem::MapCenter)
   8.429  	{
   8.430  	//	BranchObj* par=(BranchObj*)(bo->getParObj());
   8.431  		selection.unselect();
   8.432 @@ -2193,15 +2196,15 @@
   8.433  		reposition();
   8.434  		return;
   8.435  	}
   8.436 -	if (bo && selection.type()==Selection::Branch)
   8.437 +	if (bo && selectionType()==TreeItem::Branch)
   8.438  	{
   8.439 -		QModelIndex ix=selection.getBranchIndex();
   8.440 +		QModelIndex ix=getSelectedIndex();
   8.441  
   8.442  		BranchObj* par=(BranchObj*)bo->getParObj();
   8.443 -		selection.unselect();
   8.444 +		unselect();
   8.445  		saveStateRemovingPart (bo, QString ("Delete %1").arg(getObjectName(bo)));
   8.446  		par->removeBranch(bo);
   8.447 -		selection.select (par);
   8.448 +		select (par);
   8.449  		ensureSelectionVisible();
   8.450  		reposition();
   8.451  		selection.update();
   8.452 @@ -2217,9 +2220,9 @@
   8.453  			"delete ()",
   8.454  			QString("Delete %1").arg(getObjectName(fio))
   8.455  		);
   8.456 -		selection.unselect();
   8.457 +		unselect();
   8.458  		par->removeFloatImage(fio);
   8.459 -		selection.select (par);
   8.460 +		select (par);
   8.461  		reposition();
   8.462  		selection.update();
   8.463  		ensureSelectionVisible();
   8.464 @@ -2229,7 +2232,7 @@
   8.465  
   8.466  void VymModel::deleteKeepChildren()
   8.467  {
   8.468 -	BranchObj *bo=selection.getBranch();
   8.469 +	BranchObj *bo=getSelectedBranch();
   8.470  	BranchObj *par;
   8.471  	if (bo)
   8.472  	{
   8.473 @@ -2258,14 +2261,14 @@
   8.474  		par->removeBranchHere(bo);
   8.475  		reposition();
   8.476  		select (sel);
   8.477 -		selection.getBranch()->move2RelPos (p);
   8.478 +		getSelectedBranch()->move2RelPos (p);
   8.479  		reposition();
   8.480  	}	
   8.481  }
   8.482  
   8.483  void VymModel::deleteChildren()
   8.484  {
   8.485 -	BranchObj *bo=selection.getBranch();
   8.486 +	BranchObj *bo=getSelectedBranch();
   8.487  	if (bo)
   8.488  	{		
   8.489  		saveStateChangingPart(
   8.490 @@ -2332,8 +2335,8 @@
   8.491  
   8.492  void VymModel::toggleScroll()
   8.493  {
   8.494 -	BranchObj *bo=selection.getBranch();
   8.495 -	if (selection.type()==Selection::Branch )
   8.496 +	BranchObj *bo=getSelectedBranch();
   8.497 +	if (selectionType()==TreeItem::Branch )
   8.498  	{
   8.499  		if (bo->isScrolled())
   8.500  			unscrollBranch (bo);
   8.501 @@ -2344,7 +2347,7 @@
   8.502  
   8.503  void VymModel::unscrollChildren() 
   8.504  {
   8.505 -	BranchObj *bo=selection.getBranch();
   8.506 +	BranchObj *bo=getSelectedBranch();
   8.507  	if (bo)
   8.508  	{
   8.509  		bo->first();
   8.510 @@ -2357,7 +2360,7 @@
   8.511  }
   8.512  void VymModel::addFloatImage (const QPixmap &img) 
   8.513  {
   8.514 -	BranchObj *bo=selection.getBranch();
   8.515 +	BranchObj *bo=getSelectedBranch();
   8.516  	if (bo)
   8.517    {
   8.518  	FloatImageObj *fio=bo->addFloatImage();
   8.519 @@ -2374,7 +2377,7 @@
   8.520  
   8.521  void VymModel::colorBranch (QColor c)
   8.522  {
   8.523 -	BranchObj *bo=selection.getBranch();
   8.524 +	BranchObj *bo=getSelectedBranch();
   8.525  	if (bo)
   8.526  	{
   8.527  		saveState(
   8.528 @@ -2390,7 +2393,7 @@
   8.529  
   8.530  void VymModel::colorSubtree (QColor c)
   8.531  {
   8.532 -	BranchObj *bo=selection.getBranch();
   8.533 +	BranchObj *bo=getSelectedBranch();
   8.534  	if (bo) 
   8.535  	{
   8.536  		saveStateChangingPart(
   8.537 @@ -2405,7 +2408,7 @@
   8.538  
   8.539  QColor VymModel::getCurrentHeadingColor()
   8.540  {
   8.541 -	BranchObj *bo=selection.getBranch();
   8.542 +	BranchObj *bo=getSelectedBranch();
   8.543  	if (bo) return bo->getColor(); 
   8.544  	
   8.545  	QMessageBox::warning(0,"Warning","Can't get color of heading,\nthere's no branch selected");
   8.546 @@ -2416,7 +2419,7 @@
   8.547  
   8.548  void VymModel::editURL()
   8.549  {
   8.550 -	BranchObj *bo=selection.getBranch();
   8.551 +	BranchObj *bo=getSelectedBranch();
   8.552  	if (bo)
   8.553  	{		
   8.554  		bool ok;
   8.555 @@ -2431,7 +2434,7 @@
   8.556  
   8.557  void VymModel::editLocalURL()
   8.558  {
   8.559 -	BranchObj *bo=selection.getBranch();
   8.560 +	BranchObj *bo=getSelectedBranch();
   8.561  	if (bo)
   8.562  	{		
   8.563  		QStringList filters;
   8.564 @@ -2459,14 +2462,14 @@
   8.565  
   8.566  void VymModel::editHeading2URL()
   8.567  {
   8.568 -	BranchObj *bo=selection.getBranch();
   8.569 +	BranchObj *bo=getSelectedBranch();
   8.570  	if (bo)
   8.571  		setURL (bo->getHeading());
   8.572  }	
   8.573  
   8.574  void VymModel::editBugzilla2URL()
   8.575  {
   8.576 -	BranchObj *bo=selection.getBranch();
   8.577 +	BranchObj *bo=getSelectedBranch();
   8.578  	if (bo)
   8.579  	{		
   8.580  		QString url= "https://bugzilla.novell.com/show_bug.cgi?id="+bo->getHeading();
   8.581 @@ -2476,7 +2479,7 @@
   8.582  
   8.583  void VymModel::editFATE2URL()
   8.584  {
   8.585 -	BranchObj *bo=selection.getBranch();
   8.586 +	BranchObj *bo=getSelectedBranch();
   8.587  	if (bo)
   8.588  	{		
   8.589  		QString url= "http://keeper.suse.de:8080/webfate/match/id?value=ID"+bo->getHeading();
   8.590 @@ -2494,7 +2497,7 @@
   8.591  
   8.592  void VymModel::editVymLink()
   8.593  {
   8.594 -	BranchObj *bo=selection.getBranch();
   8.595 +	BranchObj *bo=getSelectedBranch();
   8.596  	if (bo)
   8.597  	{		
   8.598  		QStringList filters;
   8.599 @@ -2526,7 +2529,7 @@
   8.600  void VymModel::setVymLink (const QString &s)
   8.601  {
   8.602  	// Internal function, no saveState needed
   8.603 -	BranchObj *bo=selection.getBranch();
   8.604 +	BranchObj *bo=getSelectedBranch();
   8.605  	if (bo)
   8.606  	{
   8.607  		bo->setVymLink(s);
   8.608 @@ -2539,7 +2542,7 @@
   8.609  
   8.610  void VymModel::deleteVymLink()
   8.611  {
   8.612 -	BranchObj *bo=selection.getBranch();
   8.613 +	BranchObj *bo=getSelectedBranch();
   8.614  	if (bo)
   8.615  	{		
   8.616  		saveState(
   8.617 @@ -2558,7 +2561,7 @@
   8.618  
   8.619  QString VymModel::getVymLink()
   8.620  {
   8.621 -	BranchObj *bo=selection.getBranch();
   8.622 +	BranchObj *bo=getSelectedBranch();
   8.623  	if (bo)
   8.624  		return bo->getVymLink();
   8.625  	else	
   8.626 @@ -2569,7 +2572,7 @@
   8.627  QStringList VymModel::getVymLinks()
   8.628  {
   8.629  	QStringList links;
   8.630 -	BranchObj *bo=selection.getBranch();
   8.631 +	BranchObj *bo=getSelectedBranch();
   8.632  	if (bo)
   8.633  	{		
   8.634  		bo=bo->first();	
   8.635 @@ -2585,7 +2588,7 @@
   8.636  
   8.637  void VymModel::followXLink(int i)
   8.638  {
   8.639 -	BranchObj *bo=selection.getBranch();
   8.640 +	BranchObj *bo=getSelectedBranch();
   8.641  	if (bo)
   8.642  	{
   8.643  		bo=bo->XLinkTargetAt(i);
   8.644 @@ -2599,7 +2602,7 @@
   8.645  
   8.646  void VymModel::editXLink(int i)	// FIXME VM missing saveState
   8.647  {
   8.648 -	BranchObj *bo=selection.getBranch();
   8.649 +	BranchObj *bo=getSelectedBranch();
   8.650  	if (bo)
   8.651  	{
   8.652  		XLinkObj *xlo=bo->XLinkAt(i);
   8.653 @@ -2632,7 +2635,7 @@
   8.654  
   8.655  void VymModel::parseAtom(const QString &atom)
   8.656  {
   8.657 -	BranchObj *selb=selection.getBranch();
   8.658 +	BranchObj *selb=getSelectedBranch();
   8.659  	QString s,t;
   8.660  	double x,y;
   8.661  	int n;
   8.662 @@ -2791,9 +2794,9 @@
   8.663  		if (selection.isEmpty())
   8.664  		{
   8.665  			parser.setError (Aborted,"Nothing selected");
   8.666 -		} else if ( selection.type()!=Selection::Branch  && 
   8.667 -					selection.type()!=Selection::MapCenter  &&
   8.668 -					selection.type()!=Selection::FloatImage )
   8.669 +		} else if ( selectionType()!=TreeItem::Branch  && 
   8.670 +					selectionType()!=TreeItem::MapCenter  &&
   8.671 +					selectionType()!=TreeItem::Image )
   8.672  		{				  
   8.673  			parser.setError (Aborted,"Type of selection is not a branch or floatimage");
   8.674  		} else if (parser.checkParCount(0))
   8.675 @@ -2807,7 +2810,7 @@
   8.676  		{
   8.677  			parser.setError (Aborted,"Nothing selected");
   8.678  		} 
   8.679 -		/*else if (selection.type() != Selection::Branch && selection.type() != Selection::FloatImage )
   8.680 +		/*else if (selectionType() != TreeItem::Branch && selectionType() != TreeItem::Image )
   8.681  		{
   8.682  			parser.setError (Aborted,"Type of selection is wrong.");
   8.683  		} 
   8.684 @@ -2964,7 +2967,7 @@
   8.685  					}	
   8.686  				}	
   8.687  			}	
   8.688 -		} else if ( selection.type() == Selection::FloatImage) 
   8.689 +		} else if ( selectionType() == TreeItem::Image) 
   8.690  		{
   8.691  			if (parser.checkParCount(1))
   8.692  			{
   8.693 @@ -3027,9 +3030,9 @@
   8.694  		if (selection.isEmpty() )
   8.695  		{
   8.696  			parser.setError (Aborted,"Nothing selected");
   8.697 -		} else if ( selection.type()!=Selection::Branch  && 
   8.698 -					selection.type()!=Selection::MapCenter  &&
   8.699 -					selection.type()!=Selection::FloatImage )
   8.700 +		} else if ( selectionType()!=TreeItem::Branch  && 
   8.701 +					selectionType()!=TreeItem::MapCenter  &&
   8.702 +					selectionType()!=TreeItem::Image )
   8.703  		{				  
   8.704  			parser.setError (Aborted,"Type of selection is not a branch or floatimage");
   8.705  		} else if (parser.checkParCount(2))
   8.706 @@ -3047,9 +3050,9 @@
   8.707  		if (selection.isEmpty() )
   8.708  		{
   8.709  			parser.setError (Aborted,"Nothing selected");
   8.710 -		} else if ( selection.type()!=Selection::Branch  && 
   8.711 -					selection.type()!=Selection::MapCenter  &&
   8.712 -					selection.type()!=Selection::FloatImage )
   8.713 +		} else if ( selectionType()!=TreeItem::Branch  && 
   8.714 +					selectionType()!=TreeItem::MapCenter  &&
   8.715 +					selectionType()!=TreeItem::Image )
   8.716  		{				  
   8.717  			parser.setError (Aborted,"Type of selection is not a branch or floatimage");
   8.718  		} else if (parser.checkParCount(2))
   8.719 @@ -3230,7 +3233,7 @@
   8.720  	/////////////////////////////////////////////////////////////////////
   8.721  	} else if (com=="setFrameType")
   8.722  	{
   8.723 -		if ( selection.type()!=Selection::Branch && selection.type()!= Selection::MapCenter && selection.type()!=Selection::FloatImage)
   8.724 +		if ( selectionType()!=TreeItem::Branch && selectionType()!= TreeItem::MapCenter && selectionType()!=TreeItem::Image)
   8.725  		{
   8.726  			parser.setError (Aborted,"Type of selection does not allow setting frame type");
   8.727  		}
   8.728 @@ -3242,7 +3245,7 @@
   8.729  	/////////////////////////////////////////////////////////////////////
   8.730  	} else if (com=="setFramePenColor")
   8.731  	{
   8.732 -		if ( selection.type()!=Selection::Branch && selection.type()!= Selection::MapCenter && selection.type()!=Selection::FloatImage)
   8.733 +		if ( selectionType()!=TreeItem::Branch && selectionType()!= TreeItem::MapCenter && selectionType()!=TreeItem::Image)
   8.734  		{
   8.735  			parser.setError (Aborted,"Type of selection does not allow setting of pen color");
   8.736  		}
   8.737 @@ -3254,7 +3257,7 @@
   8.738  	/////////////////////////////////////////////////////////////////////
   8.739  	} else if (com=="setFrameBrushColor")
   8.740  	{
   8.741 -		if ( selection.type()!=Selection::Branch && selection.type()!= Selection::MapCenter && selection.type()!=Selection::FloatImage)
   8.742 +		if ( selectionType()!=TreeItem::Branch && selectionType()!= TreeItem::MapCenter && selectionType()!=TreeItem::Image)
   8.743  		{
   8.744  			parser.setError (Aborted,"Type of selection does not allow setting brush color");
   8.745  		}
   8.746 @@ -3266,7 +3269,7 @@
   8.747  	/////////////////////////////////////////////////////////////////////
   8.748  	} else if (com=="setFramePadding")
   8.749  	{
   8.750 -		if ( selection.type()!=Selection::Branch && selection.type()!= Selection::MapCenter && selection.type()!=Selection::FloatImage)
   8.751 +		if ( selectionType()!=TreeItem::Branch && selectionType()!= TreeItem::MapCenter && selectionType()!=TreeItem::Image)
   8.752  		{
   8.753  			parser.setError (Aborted,"Type of selection does not allow setting frame padding");
   8.754  		}
   8.755 @@ -3278,7 +3281,7 @@
   8.756  	/////////////////////////////////////////////////////////////////////
   8.757  	} else if (com=="setFrameBorderWidth")
   8.758  	{
   8.759 -		if ( selection.type()!=Selection::Branch && selection.type()!= Selection::MapCenter && selection.type()!=Selection::FloatImage)
   8.760 +		if ( selectionType()!=TreeItem::Branch && selectionType()!= TreeItem::MapCenter && selectionType()!=TreeItem::Image)
   8.761  		{
   8.762  			parser.setError (Aborted,"Type of selection does not allow setting frame border width");
   8.763  		}
   8.764 @@ -3309,7 +3312,7 @@
   8.765  		if (selection.isEmpty() )
   8.766  		{
   8.767  			parser.setError (Aborted,"Nothing selected");
   8.768 -		} else if (! selection.getBranch() )
   8.769 +		} else if (! getSelectedBranch() )
   8.770  		{				  
   8.771  			parser.setError (Aborted,"Type of selection is not a branch");
   8.772  		} else if (parser.checkParCount(1))
   8.773 @@ -3360,7 +3363,7 @@
   8.774  		if (selection.isEmpty() )
   8.775  		{
   8.776  			parser.setError (Aborted,"Nothing selected");
   8.777 -		} else if (selection.type()!=Selection::Branch && selection.type() != Selection::MapCenter &&selection.type()!=Selection::FloatImage)
   8.778 +		} else if (selectionType()!=TreeItem::Branch && selectionType() != TreeItem::MapCenter &&selectionType()!=TreeItem::Image)
   8.779  		{				  
   8.780  			parser.setError (Aborted,"Type of selection is not a branch or floatimage");
   8.781  		} else if (parser.checkParCount(1))
   8.782 @@ -3402,7 +3405,7 @@
   8.783  		if (selection.isEmpty() )
   8.784  		{
   8.785  			parser.setError (Aborted,"Nothing selected");
   8.786 -		} else if ( selection.type()!=Selection::Branch && selection.type()!= Selection::MapCenter && selection.type()!=Selection::FloatImage)
   8.787 +		} else if ( selectionType()!=TreeItem::Branch && selectionType()!= TreeItem::MapCenter && selectionType()!=TreeItem::Image)
   8.788  		{				  
   8.789  			parser.setError (Aborted,"Type of selection does not allow hiding the link");
   8.790  		} else if (parser.checkParCount(1))
   8.791 @@ -3772,7 +3775,7 @@
   8.792  void VymModel::updateNoteFlag()
   8.793  {
   8.794  	setChanged();
   8.795 -	BranchObj *bo=selection.getBranch();
   8.796 +	BranchObj *bo=getSelectedBranch();
   8.797  	if (bo) 
   8.798  	{
   8.799  		bo->updateNoteFlag();
   8.800 @@ -4077,20 +4080,24 @@
   8.801  
   8.802  void VymModel::move(const double &x, const double &y)
   8.803  {
   8.804 -	LinkableMapObj *sel=selection.single();
   8.805 -	if (sel)
   8.806 +	BranchObj *bo = getSelectedBranch();
   8.807 +	if (bo && 
   8.808 +		(selectionType()==TreeItem::Branch ||
   8.809 +		 selectionType()==TreeItem::MapCenter ||
   8.810 +		 selectionType()==TreeItem::Image
   8.811 +		))
   8.812  	{
   8.813 -        QPointF ap(sel->getAbsPos());
   8.814 +        QPointF ap(bo->getAbsPos());
   8.815          QPointF to(x, y);
   8.816          if (ap != to)
   8.817          {
   8.818              QString ps=qpointfToString(ap);
   8.819 -            QString s=selection.getSelectString();
   8.820 +            QString s=getSelectString();
   8.821              saveState(
   8.822                  s, "move "+ps, 
   8.823                  s, "move "+qpointfToString(to), 
   8.824 -                QString("Move %1 to %2").arg(getObjectName(sel)).arg(ps));
   8.825 -            sel->move(x,y);
   8.826 +                QString("Move %1 to %2").arg(getObjectName(bo)).arg(ps));
   8.827 +            bo->move(x,y);
   8.828              reposition();
   8.829              selection.update();
   8.830          }
   8.831 @@ -4099,22 +4106,27 @@
   8.832  
   8.833  void VymModel::moveRel (const double &x, const double &y)
   8.834  {
   8.835 -	LinkableMapObj *sel=selection.single();
   8.836 -	if (sel)
   8.837 +	BranchObj *bo = getSelectedBranch();
   8.838 +	if (bo && 
   8.839 +		(selectionType()==TreeItem::Branch ||
   8.840 +		 selectionType()==TreeItem::MapCenter ||
   8.841 +		 selectionType()==TreeItem::Image
   8.842 +		))
   8.843 +	if (bo)
   8.844  	{
   8.845 -        QPointF rp(sel->getRelPos());
   8.846 +        QPointF rp(bo->getRelPos());
   8.847          QPointF to(x, y);
   8.848          if (rp != to)
   8.849          {
   8.850 -            QString ps=qpointfToString (sel->getRelPos());
   8.851 -            QString s=getSelectString(sel);
   8.852 +            QString ps=qpointfToString (bo->getRelPos());
   8.853 +            QString s=getSelectString(bo);
   8.854              saveState(
   8.855                  s, "moveRel "+ps, 
   8.856                  s, "moveRel "+qpointfToString(to), 
   8.857 -                QString("Move %1 to relative position %2").arg(getObjectName(sel)).arg(ps));
   8.858 -            ((OrnamentedObj*)sel)->move2RelPos (x,y);
   8.859 +                QString("Move %1 to relative position %2").arg(getObjectName(bo)).arg(ps));
   8.860 +            ((OrnamentedObj*)bo)->move2RelPos (x,y);
   8.861              reposition();
   8.862 -            sel->updateLink();
   8.863 +            bo->updateLink();
   8.864              selection.update();
   8.865          }
   8.866  	}
   8.867 @@ -4140,7 +4152,9 @@
   8.868  		bo->reposition();
   8.869  		i++;
   8.870  	} 
   8.871 -	emit (selectionChanged(selModel->selection(), selModel->selection()) );
   8.872 +	QItemSelection sel=selModel->selection();
   8.873 +	emit (selectionChanged(sel,sel));
   8.874 +
   8.875  	mapScene->update();
   8.876  	if (!animObjList.isEmpty()) animationTimer->start();
   8.877  }
   8.878 @@ -4324,7 +4338,24 @@
   8.879  
   8.880  void VymModel::updateSelection()
   8.881  {
   8.882 -	selection.update();
   8.883 +	cout << "VM::updateSelection ()\n";
   8.884 +	QItemSelection newsel=selModel->selection();
   8.885 +	updateSelection (newsel);
   8.886 +}
   8.887 +
   8.888 +void VymModel::updateSelection(const QItemSelection &oldsel)
   8.889 +{
   8.890 +	QItemSelection newsel=selModel->selection();
   8.891 +	cout << "VM::updateSelection   new=";
   8.892 +	if (!newsel.indexes().isEmpty() )
   8.893 +		cout << newsel.indexes().first().row()<<"," << newsel.indexes().first().column();
   8.894 +	cout << "  old=";
   8.895 +	if (!oldsel.indexes().isEmpty() )
   8.896 +		cout << oldsel.indexes().first().row()<<"," << oldsel.indexes().first().column();
   8.897 +	cout <<endl;
   8.898 +	//emit (selectionChanged(newsel,oldsel));
   8.899 +	ensureSelectionVisible();
   8.900 +	sendSelection();
   8.901  }
   8.902  
   8.903  void VymModel::setSelectionColor(QColor col)
   8.904 @@ -4399,24 +4430,28 @@
   8.905  
   8.906  bool VymModel::select (const QString &s)
   8.907  {
   8.908 -	if (selection.select(s))
   8.909 +	LinkableMapObj *lmo=findObjBySelect(s);
   8.910 +
   8.911 +	// Finally select the found object
   8.912 +	if (lmo)
   8.913  	{
   8.914 -		selection.update();
   8.915 -		ensureSelectionVisible();
   8.916 -		sendSelection ();
   8.917 +		unselect();
   8.918 +		select (lmo);
   8.919  		return true;
   8.920 -	}
   8.921 +	} 
   8.922  	return false;
   8.923 -
   8.924  }
   8.925  
   8.926  bool VymModel::select (LinkableMapObj *lmo)
   8.927  {
   8.928 -	if (selection.select(lmo))
   8.929 +	QItemSelection oldsel=selModel->selection();
   8.930 +
   8.931 +	if (lmo)
   8.932  	{
   8.933 -		selection.update();
   8.934 -		ensureSelectionVisible();
   8.935 -		sendSelection ();
   8.936 +		TreeItem *ti=lmo->getTreeItem();
   8.937 +		QModelIndex ix=index(ti);
   8.938 +		selModel->select (ix,QItemSelectionModel::ClearAndSelect  );
   8.939 +		//updateSelection(oldsel);
   8.940  		return true;
   8.941  	}
   8.942  	return false;
   8.943 @@ -4424,7 +4459,7 @@
   8.944  
   8.945  void VymModel::unselect()
   8.946  {
   8.947 -	selection.unselect();
   8.948 +	selModel->clearSelection();
   8.949  }	
   8.950  
   8.951  void VymModel::reselect()
   8.952 @@ -4434,7 +4469,7 @@
   8.953  
   8.954  void VymModel::ensureSelectionVisible()
   8.955  {
   8.956 -	LinkableMapObj *lmo=selection.single();
   8.957 +	LinkableMapObj *lmo=getSelectedLMO();
   8.958  	if (lmo &&mapEditor) mapEditor->ensureVisible (lmo->getBBox() );
   8.959  	
   8.960  }
   8.961 @@ -4452,10 +4487,10 @@
   8.962  void VymModel::selectNextBranchInt()
   8.963  {
   8.964  	// Increase number of branch
   8.965 -	LinkableMapObj *sel=selection.single();
   8.966 +	LinkableMapObj *sel=getSelectedBranch();
   8.967  	if (sel)
   8.968  	{
   8.969 -		QString s=selection.getSelectString();
   8.970 +		QString s=getSelectString();
   8.971  		QString part;
   8.972  		QString typ;
   8.973  		QString num;
   8.974 @@ -4479,7 +4514,7 @@
   8.975  		// try to increase the parental number in order to
   8.976  		// find a successor with same depth
   8.977  
   8.978 -		int d=selection.single()->getDepth();
   8.979 +		int d=getSelectedLMO()->getDepth();
   8.980  		int oldDepth=d;
   8.981  		int i;
   8.982  		bool found=false;
   8.983 @@ -4500,7 +4535,7 @@
   8.984  			} else
   8.985  			{
   8.986  				// Special case, look at orientation
   8.987 -				if (selection.single()->getOrientation()==LinkableMapObj::RightOfCenter)
   8.988 +				if (getSelectedLMO()->getOrientation()==LinkableMapObj::RightOfCenter)
   8.989  					num=QString ("%1").arg(num.toUInt()+1);
   8.990  				else	
   8.991  					num=QString ("%1").arg(num.toUInt()-1);
   8.992 @@ -4514,7 +4549,7 @@
   8.993  					b=select (s);
   8.994  					if (b)
   8.995  					{	
   8.996 -						if ( selection.getBranch()->countBranches()>0)
   8.997 +						if ( getSelectedBranch()->countBranches()>0)
   8.998  							s+=",bo:0";
   8.999  						else	
  8.1000  							break;
  8.1001 @@ -4533,7 +4568,7 @@
  8.1002  void VymModel::selectPrevBranchInt()
  8.1003  {
  8.1004  	// Decrease number of branch
  8.1005 -	BranchObj *bo=selection.getBranch();
  8.1006 +	BranchObj *bo=getSelectedBranch();
  8.1007  	if (bo)
  8.1008  	{
  8.1009  		QString s=selection.getSelectString();
  8.1010 @@ -4561,7 +4596,7 @@
  8.1011  		// try to decrease the parental number in order to
  8.1012  		// find a precessor with same depth
  8.1013  
  8.1014 -		int d=selection.single()->getDepth();
  8.1015 +		int d=getSelectedLMO()->getDepth();
  8.1016  		int oldDepth=d;
  8.1017  		int i;
  8.1018  		bool found=false;
  8.1019 @@ -4582,7 +4617,7 @@
  8.1020  			} else
  8.1021  			{
  8.1022  				// Special case, look at orientation
  8.1023 -				if (selection.single()->getOrientation()==LinkableMapObj::RightOfCenter)
  8.1024 +				if (getSelectedLMO()->getOrientation()==LinkableMapObj::RightOfCenter)
  8.1025  					num=QString ("%1").arg(num.toInt()-1);
  8.1026  				else	
  8.1027  					num=QString ("%1").arg(num.toInt()+1);
  8.1028 @@ -4595,8 +4630,8 @@
  8.1029  				{
  8.1030  					b=select (s);
  8.1031  					if (b)
  8.1032 -						if ( selection.getBranch()->countBranches()>0)
  8.1033 -							s+=",bo:"+ QString ("%1").arg( selection.getBranch()->countBranches()-1 );
  8.1034 +						if ( getSelectedBranch()->countBranches()>0)
  8.1035 +							s+=",bo:"+ QString ("%1").arg( getSelectedBranch()->countBranches()-1 );
  8.1036  						else	
  8.1037  							break;
  8.1038  					else
  8.1039 @@ -4615,8 +4650,8 @@
  8.1040  {
  8.1041  	if (selection.isBlocked() ) return;
  8.1042  
  8.1043 -	BranchObj *bo=selection.getBranch();
  8.1044 -	if (bo && selection.type()==Selection::Branch)
  8.1045 +	BranchObj *bo=getSelectedBranch();
  8.1046 +	if (bo && selectionType()==TreeItem::Branch)
  8.1047  	{
  8.1048  		if (bo->getOrientation()==LinkableMapObj::RightOfCenter)
  8.1049  			selectPrevBranchInt();
  8.1050 @@ -4632,8 +4667,8 @@
  8.1051  {
  8.1052  	if (selection.isBlocked() ) return;
  8.1053  
  8.1054 -	BranchObj *bo=selection.getBranch();
  8.1055 -	if (bo && selection.type()==Selection::Branch)
  8.1056 +	BranchObj *bo=getSelectedBranch();
  8.1057 +	if (bo && selectionType()==TreeItem::Branch)
  8.1058  	{
  8.1059  		if (bo->getOrientation()==LinkableMapObj::RightOfCenter)
  8.1060  			selectNextBranchInt();
  8.1061 @@ -4650,57 +4685,40 @@
  8.1062  {
  8.1063  	if (selection.isBlocked() ) return;
  8.1064  
  8.1065 -	BranchObj* bo;
  8.1066 +	QItemSelection oldsel=selModel->selection();
  8.1067 +
  8.1068  	BranchObj* par;
  8.1069 -	LinkableMapObj *sel=selection.single();
  8.1070 +	LinkableMapObj *sel=getSelectedBranch();
  8.1071  	if (sel)
  8.1072  	{
  8.1073 -		if (selection.type()== Selection::MapCenter)
  8.1074 +		if (selectionType()== TreeItem::MapCenter)
  8.1075  		{
  8.1076 -			par=selection.getBranch();
  8.1077 -			bo=par->getLastSelectedBranch();
  8.1078 -			if (bo)
  8.1079 -			{
  8.1080 -				// Workaround for reselecting on left and right side
  8.1081 -				if (bo->getOrientation()==LinkableMapObj::RightOfCenter)
  8.1082 -					bo=par->getLastBranch();
  8.1083 -				if (bo)
  8.1084 -				{
  8.1085 -					bo=par->getLastBranch();
  8.1086 -					selection.select(bo);
  8.1087 -					selection.update();
  8.1088 -					ensureSelectionVisible();
  8.1089 -					sendSelection();
  8.1090 -				}
  8.1091 -			}	
  8.1092 +			QModelIndex ix=getSelectedIndex();
  8.1093 +			selModel->select (index (rowCount(ix)-1,0,ix),QItemSelectionModel::ClearAndSelect  );
  8.1094  		} else
  8.1095  		{
  8.1096  			par=(BranchObj*)(sel->getParObj());
  8.1097  			if (sel->getOrientation()==LinkableMapObj::RightOfCenter)
  8.1098  			{
  8.1099 -				if (selection.type() == Selection::Branch ||
  8.1100 -					selection.type() == Selection::FloatImage)
  8.1101 +				// right of center
  8.1102 +				if (selectionType() == TreeItem::Branch ||
  8.1103 +					selectionType() == TreeItem::Image)
  8.1104  				{
  8.1105 -					selection.select(par);
  8.1106 -					selection.update();
  8.1107 -					ensureSelectionVisible();
  8.1108 -					sendSelection();
  8.1109 +					QModelIndex ix=getSelectedIndex();
  8.1110 +					ix=parent(ix);
  8.1111 +					selModel->select (ix,QItemSelectionModel::ClearAndSelect  );
  8.1112  				}
  8.1113  			} else
  8.1114  			{
  8.1115 -				if (selection.type() == Selection::Branch )
  8.1116 +				// left of center
  8.1117 +				if (selectionType() == TreeItem::Branch )
  8.1118  				{
  8.1119 -					bo=selection.getBranch()->getLastSelectedBranch();
  8.1120 -					if (bo) 
  8.1121 -					{
  8.1122 -						selection.select(bo);
  8.1123 -						selection.update();
  8.1124 -						ensureSelectionVisible();
  8.1125 -					sendSelection();
  8.1126 -					}
  8.1127 +					selectLastSelectedBranch();
  8.1128 +					return;
  8.1129  				}
  8.1130  			}
  8.1131  		}	
  8.1132 +		updateSelection (oldsel);
  8.1133  	}
  8.1134  }
  8.1135  
  8.1136 @@ -4708,14 +4726,16 @@
  8.1137  {
  8.1138  	if (selection.isBlocked() ) return;
  8.1139  
  8.1140 +	QItemSelection oldsel=selModel->selection();
  8.1141 +
  8.1142  	BranchObj* bo;
  8.1143  	BranchObj* par;
  8.1144 -	LinkableMapObj *sel=selection.single();
  8.1145 +	LinkableMapObj *sel=getSelectedBranch();
  8.1146  	if (sel)
  8.1147  	{
  8.1148 -		if (selection.type()==Selection::MapCenter) 
  8.1149 +		if (selectionType()==TreeItem::MapCenter) 
  8.1150  		{
  8.1151 -			par=selection.getBranch();
  8.1152 +			par=getSelectedBranch();
  8.1153  			bo=par->getLastSelectedBranch();
  8.1154  			if (bo)
  8.1155  			{
  8.1156 @@ -4725,45 +4745,48 @@
  8.1157  				if (bo)
  8.1158  				{
  8.1159  					selection.select(bo);
  8.1160 -					selection.update();
  8.1161 -					ensureSelectionVisible();
  8.1162 -					sendSelection();
  8.1163 +					//selection.update();
  8.1164 +					//ensureSelectionVisible();
  8.1165 +					//sendSelection();
  8.1166  				}
  8.1167  			}
  8.1168  		} else
  8.1169  		{
  8.1170 -			par=(BranchObj*)(selection.single()->getParObj());
  8.1171 -			if (selection.single()->getOrientation()==LinkableMapObj::LeftOfCenter)
  8.1172 +			par=(BranchObj*)(getSelectedLMO()->getParObj());
  8.1173 +			if (getSelectedLMO()->getOrientation()==LinkableMapObj::LeftOfCenter)
  8.1174  			{
  8.1175 -				if (selection.type() == Selection::Branch ||
  8.1176 -					selection.type() == Selection::FloatImage)
  8.1177 +				if (selectionType() == TreeItem::Branch ||
  8.1178 +					selectionType() == TreeItem::Image)
  8.1179  				{
  8.1180 -					selection.select(par);
  8.1181 -					selection.update();
  8.1182 -					ensureSelectionVisible();
  8.1183 -					sendSelection();
  8.1184 +					QModelIndex ix=getSelectedIndex();
  8.1185 +					ix=parent(ix);
  8.1186 +					selModel->select (ix,QItemSelectionModel::ClearAndSelect  );
  8.1187  				}
  8.1188  			} else
  8.1189  			{
  8.1190 -				if (selection.type()  == Selection::Branch) 
  8.1191 +				if (selectionType()  == TreeItem::Branch) 
  8.1192  				{
  8.1193 -					bo=selection.getBranch()->getLastSelectedBranch();
  8.1194 +					bo=getSelectedBranch()->getLastSelectedBranch();
  8.1195  					if (bo) 
  8.1196  					{
  8.1197  						selection.select(bo);
  8.1198 -						selection.update();
  8.1199 -						ensureSelectionVisible();
  8.1200 -					sendSelection();
  8.1201 +						//selection.update();
  8.1202 +						//ensureSelectionVisible();
  8.1203 +						//sendSelection();
  8.1204  					}
  8.1205  				}
  8.1206  			}
  8.1207  		}
  8.1208 +		QItemSelection newsel=selModel->selection();
  8.1209 +		emit (selectionChanged(newsel,oldsel));
  8.1210 +		ensureSelectionVisible();
  8.1211 +		sendSelection();
  8.1212  	}
  8.1213  }
  8.1214  
  8.1215  void VymModel::selectFirstBranch()
  8.1216  {
  8.1217 -	BranchObj *bo1=selection.getBranch();
  8.1218 +	BranchObj *bo1=getSelectedBranch();
  8.1219  	BranchObj *bo2;
  8.1220  	BranchObj* par;
  8.1221  	if (bo1)
  8.1222 @@ -4782,7 +4805,7 @@
  8.1223  
  8.1224  void VymModel::selectLastBranch()
  8.1225  {
  8.1226 -	BranchObj *bo1=selection.getBranch();
  8.1227 +	BranchObj *bo1=getSelectedBranch();
  8.1228  	BranchObj *bo2;
  8.1229  	BranchObj* par;
  8.1230  	if (bo1)
  8.1231 @@ -4800,33 +4823,94 @@
  8.1232  	}		
  8.1233  }
  8.1234  
  8.1235 +void VymModel::selectLastSelectedBranch()
  8.1236 +{
  8.1237 +	QItemSelection oldsel=selModel->selection();
  8.1238 +
  8.1239 +	BranchObj *bo1=getSelectedBranch();
  8.1240 +	BranchObj *bo2;
  8.1241 +	if (bo1)
  8.1242 +	{
  8.1243 +		cout << "bo1="<<bo1->getHeading().toStdString()<<endl;
  8.1244 +		bo2=bo1->getLastSelectedBranch();
  8.1245 +		if (bo2) 
  8.1246 +		{
  8.1247 +			cout << "bo2="<<bo2->getHeading().toStdString()<<endl;
  8.1248 +			select(bo2);
  8.1249 +		}
  8.1250 +	}		
  8.1251 +}
  8.1252 +
  8.1253  void VymModel::selectParent()
  8.1254  {
  8.1255 -	LinkableMapObj *lmo=selection.first();
  8.1256 +	LinkableMapObj *lmo=getSelectedLMO();
  8.1257  	BranchObj* par;
  8.1258  	if (lmo)
  8.1259  	{
  8.1260  		par=(BranchObj*)(lmo->getParObj());
  8.1261  		if (!par) return;
  8.1262 -		selection.select(par);
  8.1263 +		select(par);
  8.1264  		selection.update();
  8.1265  		ensureSelectionVisible();
  8.1266  		sendSelection();
  8.1267  	}		
  8.1268  }
  8.1269  
  8.1270 -Selection::Type VymModel::selectionType()
  8.1271 +TreeItem::Type VymModel::selectionType()
  8.1272  {
  8.1273 -	return selection.type();
  8.1274 +	QModelIndexList list=selModel->selectedIndexes();
  8.1275 +	if (list.isEmpty()) return TreeItem::Undefined;	
  8.1276 +	TreeItem *ti = static_cast<TreeItem*>(list.first().internalPointer());
  8.1277 +	return ti->getType();
  8.1278 +
  8.1279  }
  8.1280  
  8.1281 -LinkableMapObj* VymModel::getSelection()
  8.1282 +LinkableMapObj* VymModel::getSelectedLMO()
  8.1283  {
  8.1284 -	return selection.single();	
  8.1285 +	QModelIndexList list=selModel->selectedIndexes();
  8.1286 +	if (!list.isEmpty() )
  8.1287 +	{
  8.1288 +		TreeItem *ti = static_cast<TreeItem*>(list.first().internalPointer());
  8.1289 +		TreeItem::Type type=ti->getType();
  8.1290 +		if (type ==TreeItem::Branch || type==TreeItem::MapCenter || type==TreeItem::Image)
  8.1291 +		{
  8.1292 +			return ti->getLMO();
  8.1293 +		}	
  8.1294 +	}
  8.1295 +	return NULL;
  8.1296  }
  8.1297 +
  8.1298  BranchObj* VymModel::getSelectedBranch()
  8.1299  {
  8.1300 -	return selection.getBranch();	
  8.1301 +	QModelIndexList list=selModel->selectedIndexes();
  8.1302 +	if (!list.isEmpty() )
  8.1303 +	{
  8.1304 +		TreeItem *ti = static_cast<TreeItem*>(list.first().internalPointer());
  8.1305 +		TreeItem::Type type=ti->getType();
  8.1306 +		if (type ==TreeItem::Branch || type==TreeItem::MapCenter)
  8.1307 +		{
  8.1308 +			return (BranchObj*)ti->getLMO();
  8.1309 +		}	
  8.1310 +	}
  8.1311 +	return NULL;
  8.1312 +
  8.1313 +}
  8.1314 +
  8.1315 +TreeItem* VymModel::getSelectedTreeItem()
  8.1316 +{
  8.1317 +	// FIXME this may not only be branch, but also float etc...
  8.1318 +	BranchObj* bo=getSelectedBranch();
  8.1319 +	if (bo) return bo->getTreeItem(); // FIXME VM get directly from treemodl
  8.1320 +	return NULL;
  8.1321 +}
  8.1322 +
  8.1323 +QModelIndex VymModel::getSelectedIndex()
  8.1324 +{
  8.1325 +	QModelIndexList list=selModel->selectedIndexes();
  8.1326 +	if (list.isEmpty() )
  8.1327 +		return QModelIndex();
  8.1328 +	else
  8.1329 +		return list.first();
  8.1330  }
  8.1331  
  8.1332  FloatImageObj* VymModel::getSelectedFloatImage()
  8.1333 @@ -4854,7 +4938,7 @@
  8.1334  				s= "bo:" + QString("%1").arg(((BranchObj*)lmo)->getNum());
  8.1335  			else	
  8.1336  			{
  8.1337 -				//cout << "VM::getSelectString  lmo="<<lmo<<"  d="<<lmo->getDepth()<<"  s="<<s.toStdString()<<"  h="<<((BranchObj*)lmo)->getHeading().toStdString()<<endl;
  8.1338 +				cout << "VM::getSelectString  lmo="<<lmo<<"  d="<<lmo->getDepth()<<"  s="<<s.toStdString()<<"  h="<<((BranchObj*)lmo)->getHeading().toStdString()<<endl;
  8.1339  				// Branch, call myself recursively
  8.1340  				s= getSelectString(par) + ",bo:" + QString("%1").arg(((BranchObj*)lmo)->getNum());
  8.1341  			}
     9.1 --- a/vymmodel.h	Thu Jan 15 00:52:35 2009 +0000
     9.2 +++ b/vymmodel.h	Tue Jan 20 15:23:16 2009 +0000
     9.3 @@ -554,16 +554,20 @@
     9.4      void selectRightBranch();
     9.5      void selectFirstBranch();
     9.6      void selectLastBranch();
     9.7 +	void selectLastSelectedBranch();
     9.8  	void selectParent();
     9.9  
    9.10  public:
    9.11 -	Selection::Type selectionType();
    9.12 -	LinkableMapObj* getSelection();
    9.13 +	TreeItem::Type selectionType();
    9.14 +	LinkableMapObj* getSelectedLMO();
    9.15  	BranchObj* getSelectedBranch();
    9.16 +	TreeItem* getSelectedTreeItem();
    9.17 +	QModelIndex getSelectedIndex();
    9.18  	FloatImageObj* getSelectedFloatImage();
    9.19  	QString getSelectString ();
    9.20  	QString getSelectString (LinkableMapObj *lmo);
    9.21  	
    9.22 +	void updateSelection(const QItemSelection &oldsel);
    9.23  	void updateSelection();
    9.24  	void selectMapLinkColor();
    9.25      void selectMapSelectionColor();
    10.1 --- a/vymview.cpp	Thu Jan 15 00:52:35 2009 +0000
    10.2 +++ b/vymview.cpp	Tue Jan 20 15:23:16 2009 +0000
    10.3 @@ -37,7 +37,7 @@
    10.4  		model, SIGNAL (selectionChanged(const QItemSelection &, const QItemSelection &)), 
    10.5  		me,SLOT (updateSelection(const QItemSelection &,const QItemSelection &)));
    10.6  
    10.7 -	//me->viewport()->setFocus();
    10.8 +	//me->viewport()->setFocus();	//FIXME needed?
    10.9  	me->setAntiAlias (mainWindow->isAliased());
   10.10  	me->setSmoothPixmap(mainWindow->hasSmoothPixmapTransform());
   10.11  
   10.12 @@ -46,7 +46,7 @@
   10.13  
   10.14  	// Set geometry
   10.15  	QList <int> sizes;
   10.16 -	sizes.append (150);
   10.17 +	sizes.append (120);
   10.18  	sizes.append (600);
   10.19  	setSizes (sizes);
   10.20  }
   10.21 @@ -66,6 +66,6 @@
   10.22  	// FIXME Currently this works only from treeview->ME
   10.23  	treeview->expandAll();	//FIXME only for testing
   10.24  
   10.25 -	((VymModel*)treeview->model())->select ();
   10.26 +	//((VymModel*)treeview->model())->select ();
   10.27  }
   10.28  
    11.1 --- a/xml-vym.cpp	Thu Jan 15 00:52:35 2009 +0000
    11.2 +++ b/xml-vym.cpp	Tue Jan 20 15:23:16 2009 +0000
    11.3 @@ -35,13 +35,13 @@
    11.4  {
    11.5      QColor col;
    11.6  	/* Testing
    11.7 +	*/	
    11.8  	cout << "startElement <"<< qPrintable(eName)
    11.9  		<<">  state="<<state 
   11.10  		<<"  laststate="<<stateStack.last()
   11.11  		<<"   loadMode="<<loadMode
   11.12 -		<<"       line="<<QXmlDefaultHandler::lineNumber()
   11.13 +	//	<<"       line="<<QXmlDefaultHandler::lineNumber()
   11.14  		<<endl;
   11.15 -	*/	
   11.16  	stateStack.append (state);	
   11.17      if ( state == StateInit && (eName == "vymmap")  ) 
   11.18  	{
   11.19 @@ -121,12 +121,14 @@
   11.20  			// Really use the found mapcenter as MCO in a new map
   11.21  
   11.22  			model->createMapCenter(); 
   11.23 +			cout << "ok0\n";
   11.24  			lastBranch=model->getSelectedBranch();
   11.25 +			cout << "ok1 lastBranch="<<lastBranch<<endl;
   11.26  		} else
   11.27  		{
   11.28  			// Treat the found mapcenter as a branch 
   11.29  			// in an existing map
   11.30 -			LinkableMapObj* lmo=model->getSelection();
   11.31 +			LinkableMapObj* lmo=model->getSelectedLMO();
   11.32  			if (lmo && ( (typeid(*lmo) == typeid(BranchObj) ) 
   11.33  			        || (typeid(*lmo) == typeid(MapCenterObj) ) ) )
   11.34  			{
   11.35 @@ -175,7 +177,7 @@
   11.36  	{
   11.37  		// This is used in vymparts, which have no mapcenter!
   11.38  		isVymPart=true;
   11.39 -		LinkableMapObj* lmo=model->getSelection();
   11.40 +		LinkableMapObj* lmo=model->getSelectedLMO();
   11.41  		if (!lmo)
   11.42  		{
   11.43  			// If a vym part is _loaded_ (not imported),