Iteration over map works now (again)
authorinsilmaril
Fri, 06 Mar 2009 15:02:58 +0000
changeset 7411b4d1ea6ea8c
parent 740 6dc0a20031f7
child 742 54d44ecd6097
Iteration over map works now (again)
editxlinkdialog.cpp
exports.cpp
mapeditor.cpp
treeitem.cpp
treeitem.h
treemodel.cpp
treemodel.h
version.h
vymmodel.cpp
vymmodel.h
xml-freemind.cpp
xml-vym.cpp
     1.1 --- a/editxlinkdialog.cpp	Wed Feb 04 16:33:16 2009 +0000
     1.2 +++ b/editxlinkdialog.cpp	Fri Mar 06 15:02:58 2009 +0000
     1.3 @@ -62,8 +62,8 @@
     1.4  	if (xlo)
     1.5  	{	
     1.6  		if (selection && 
     1.7 -			(typeid(*selection) == typeid(BranchObj)) || 
     1.8 -			(typeid(*selection) == typeid(MapCenterObj))  )
     1.9 +			(typeid(*selection) == typeid(BranchObj) || 
    1.10 +			typeid(*selection) == typeid(MapCenterObj))  )
    1.11  		{
    1.12  			QColor col=((BranchObj*)(selection))->getColor();
    1.13  			xlo->setColor(col);
     2.1 --- a/exports.cpp	Wed Feb 04 16:33:16 2009 +0000
     2.2 +++ b/exports.cpp	Fri Mar 06 15:02:58 2009 +0000
     2.3 @@ -143,43 +143,47 @@
     2.4  	QString s;
     2.5  	QString curIndent;
     2.6  	int i;
     2.7 -	TreeItem *ti;
     2.8 -	ti=model->first();
     2.9 +	TreeItem *cur=NULL;
    2.10 +	TreeItem *prev=NULL;
    2.11 +	int d;
    2.12 +
    2.13  	BranchObj *bo;
    2.14 -	while (ti) 
    2.15 +	cur=model->next (cur,prev,d);
    2.16 +	while (cur) 
    2.17  	{
    2.18 -		if (ti->getType()==TreeItem::Branch || ti->getType()==TreeItem::MapCenter)
    2.19 +		if (cur->getType()==TreeItem::Branch || cur->getType()==TreeItem::MapCenter)
    2.20  		{
    2.21 -			bo=(BranchObj*)(ti->getLMO());
    2.22 +			bo=(BranchObj*)(cur->getLMO());
    2.23 +			std::cout << "ExportASCII::  "<<cur->getHeading().toStdString()<<std::endl;
    2.24  
    2.25  			// Make indentstring
    2.26  			curIndent="";
    2.27 -			for (i=0;i<ti->depth()-1;i++) curIndent+= indentPerDepth;
    2.28 +			for (i=0;i<cur->depth()-1;i++) curIndent+= indentPerDepth;
    2.29  
    2.30  			if (!bo->hasHiddenExportParent() )
    2.31  			{
    2.32 -				switch (ti->depth())
    2.33 +				switch (cur->depth())
    2.34  				{
    2.35  					case 0:
    2.36 -						ts << underline (ti->getHeading(),QString("="));
    2.37 +						ts << underline (cur->getHeading(),QString("="));
    2.38  						ts << "\n";
    2.39  						break;
    2.40  					case 1:
    2.41  						ts << "\n";
    2.42 -						ts << (underline (getSectionString(bo) + ti->getHeading(), QString("-") ) );
    2.43 +						ts << (underline (getSectionString(bo) + cur->getHeading(), QString("-") ) );
    2.44  						ts << "\n";
    2.45  						break;
    2.46  					case 2:
    2.47  						ts << "\n";
    2.48 -						ts << (curIndent + "* " + ti->getHeading());
    2.49 +						ts << (curIndent + "* " + cur->getHeading());
    2.50  						ts << "\n";
    2.51  						break;
    2.52  					case 3:
    2.53 -						ts << (curIndent + "- " + ti->getHeading());
    2.54 +						ts << (curIndent + "- " + cur->getHeading());
    2.55  						ts << "\n";
    2.56  						break;
    2.57  					default:
    2.58 -						ts << (curIndent + "- " + ti->getHeading());
    2.59 +						ts << (curIndent + "- " + cur->getHeading());
    2.60  						ts << "\n";
    2.61  						break;
    2.62  				}
    2.63 @@ -193,7 +197,7 @@
    2.64  				}
    2.65  			}
    2.66  		}
    2.67 -		ti=model->next();
    2.68 +		cur=model->next(cur,prev,d);
    2.69  	}
    2.70  	file.close();
    2.71  }
    2.72 @@ -225,10 +229,13 @@
    2.73  	QString curIndent("");
    2.74  	int i;
    2.75  	BranchObj *bo;
    2.76 -	TreeItem *ti=model->first();
    2.77 -	while (ti) 
    2.78 +	TreeItem *cur=NULL;
    2.79 +	TreeItem *prev=NULL;
    2.80 +	int d;
    2.81 +	cur=model->next (cur,prev,d);
    2.82 +	while (cur) 
    2.83  	{
    2.84 -		bo=(BranchObj*)(ti->getLMO());
    2.85 +		bo=(BranchObj*)(cur->getLMO());
    2.86  
    2.87  		if (!bo->hasHiddenExportParent() )
    2.88  		{
    2.89 @@ -242,13 +249,13 @@
    2.90  				ts <<"\"\",";
    2.91  
    2.92  			// Make indentstring
    2.93 -			for (i=0;i<ti->depth();i++) curIndent+= "\"\",";
    2.94 +			for (i=0;i<cur->depth();i++) curIndent+= "\"\",";
    2.95  
    2.96  			// Write heading
    2.97 -			ts << curIndent << "\"" << ti->getHeading()<<"\""<<endl;
    2.98 +			ts << curIndent << "\"" << cur->getHeading()<<"\""<<endl;
    2.99  		}
   2.100  		
   2.101 -		ti=model->next();
   2.102 +		cur=model->next(cur,prev,d);
   2.103  		curIndent="";
   2.104  	}
   2.105  	file.close();
   2.106 @@ -352,14 +359,17 @@
   2.107    // QString curIndent("");
   2.108    // int i;
   2.109    BranchObj *bo;
   2.110 -  TreeItem *ti=model->first();
   2.111 -  while (ti) 
   2.112 +  TreeItem *cur=NULL;
   2.113 +  TreeItem *prev=NULL;
   2.114 +  int d;
   2.115 +  model->next(cur,prev,d);
   2.116 +  while (cur) 
   2.117    {
   2.118 -	bo=(BranchObj*)(ti->getLMO());
   2.119 +	bo=(BranchObj*)(cur->getLMO());
   2.120  
   2.121  	if (!bo->hasHiddenExportParent() )
   2.122  	{
   2.123 -		switch (ti->depth() ) 
   2.124 +		switch (cur->depth() ) 
   2.125  		{
   2.126  			case 0: break;
   2.127  			case 1: 
   2.128 @@ -384,7 +394,7 @@
   2.129  		  ts << ("\n");
   2.130  		}
   2.131  	}
   2.132 -    ti=model->next();
   2.133 +    cur=model->next(cur,prev,d);
   2.134     }
   2.135    file.close();
   2.136  }
     3.1 --- a/mapeditor.cpp	Wed Feb 04 16:33:16 2009 +0000
     3.2 +++ b/mapeditor.cpp	Fri Mar 06 15:02:58 2009 +0000
     3.3 @@ -282,30 +282,41 @@
     3.4  
     3.5  void MapEditor::testFunction1()
     3.6  {
     3.7 +	TreeItem *cur=NULL;
     3.8 +	TreeItem *prev=NULL;
     3.9 +	int d;
    3.10 +	cout << "ME::testFunction1  starting to walk the map...\n";
    3.11 +	while (model->next (cur,prev,d) )
    3.12 +		cout << "*** " <<cur->getHeading().toStdString()<<endl;
    3.13 +
    3.14 +
    3.15  	//BranchObj *bo=model->getSelectedBranch();
    3.16  	//if (bo) model->moveAway (bo);
    3.17  	//if (bo) bo->setLinkStyle (LinkableMapObj::Line);
    3.18  	
    3.19  
    3.20 +/*
    3.21  	// Displacement and animation of all non-mainbranches
    3.22  	QPointF p;
    3.23  	QPointF q;
    3.24  	BranchObj *bo;
    3.25 -	TreeItem *ti=model->first();
    3.26 -	while (ti) 
    3.27 +	TreeItem *cur=NULL;
    3.28 +	TreeItem *prev=NULL;
    3.29 +	int d;
    3.30 +	while (cur) 
    3.31  	{
    3.32 -		bo=(BranchObj*)(ti->getLMO());
    3.33 +		bo=(BranchObj*)(cur->getLMO());
    3.34  
    3.35 -		if (ti->depth() >0 && !bo->hasScrolledParent(bo) )
    3.36 +		if (cur->depth() >0 && !bo->hasScrolledParent(bo) )
    3.37  		{
    3.38  			p=QPointF (qrand() %600-300, qrand () %600-300);
    3.39  			bo->setRelPos();
    3.40  			q=bo->getRelPos();
    3.41  			model->startAnimation (bo,p, q);
    3.42  		}
    3.43 -		ti=model->next();
    3.44 +		model->next(cur,prev,d);
    3.45  	}
    3.46 -
    3.47 +*/
    3.48  
    3.49  
    3.50  /* TODO Hide hidden stuff temporary, maybe add this as regular function somewhere
     4.1 --- a/treeitem.cpp	Wed Feb 04 16:33:16 2009 +0000
     4.2 +++ b/treeitem.cpp	Fri Mar 06 15:02:58 2009 +0000
     4.3 @@ -1,5 +1,6 @@
     4.4  #include <QStringList>
     4.5  
     4.6 +#include "branchobj.h"
     4.7  #include "treeitem.h"
     4.8  
     4.9  TreeItem::TreeItem(const QList<QVariant> &data, TreeItem *parent)
    4.10 @@ -9,7 +10,7 @@
    4.11  	lmo=NULL;
    4.12  
    4.13  	branchOffset=0;
    4.14 -	branchCount=0;
    4.15 +	branchCounter=0;
    4.16  	lastSelectedBranchNum=-1;
    4.17  }
    4.18  
    4.19 @@ -18,14 +19,17 @@
    4.20      qDeleteAll(childItems);
    4.21  }
    4.22  
    4.23 +
    4.24  void TreeItem::appendChild(TreeItem *item)
    4.25  {
    4.26      childItems.append(item);
    4.27 -	if (item->type == Branch)
    4.28 +	
    4.29 +
    4.30 +	if (item->type == Branch || item->type ==MapCenter)
    4.31  	{
    4.32 -		if (branchCount==0)
    4.33 +		if (branchCounter==0)
    4.34  			branchOffset=childItems.count()-1;
    4.35 -		branchCount++;
    4.36 +		branchCounter++;
    4.37  	}
    4.38  }
    4.39  
    4.40 @@ -53,6 +57,11 @@
    4.41  {
    4.42      return itemData.count();
    4.43  }
    4.44 +
    4.45 +int TreeItem::branchCount() const
    4.46 +{
    4.47 +    return branchCounter;
    4.48 +}
    4.49  int TreeItem::row() const
    4.50  {
    4.51      if (parentItem)
    4.52 @@ -83,6 +92,18 @@
    4.53      return parentItem;
    4.54  }
    4.55  
    4.56 +int TreeItem::num()
    4.57 +{
    4.58 +	switch (type)
    4.59 +	{
    4.60 +		case Undefined: return -1;
    4.61 +		case MapCenter: return parentItem->childItems.indexOf (this) - branchOffset;
    4.62 +		case Branch: return parentItem->childItems.indexOf (this) - branchOffset;
    4.63 +		case Image: return -1; // FIXME
    4.64 +		default: return -1;
    4.65 +	}
    4.66 +	
    4.67 +}
    4.68  
    4.69  QVariant TreeItem::data(int column) const
    4.70  {
    4.71 @@ -99,6 +120,30 @@
    4.72  	return itemData[0].toString();
    4.73  }
    4.74  
    4.75 +void TreeItem::setNote(const QString s)
    4.76 +{
    4.77 +	switch (type)
    4.78 +	{
    4.79 +		case MapCenter: 
    4.80 +			((BranchObj*)lmo)->setNote(s);
    4.81 +			break;
    4.82 +		case Branch: 
    4.83 +			((BranchObj*)lmo)->setNote(s);
    4.84 +			break;
    4.85 +		default: ;
    4.86 +	}
    4.87 +}
    4.88 +
    4.89 +QString TreeItem::getNote()
    4.90 +{
    4.91 +	switch (type)
    4.92 +	{
    4.93 +		case MapCenter: return ((BranchObj*)lmo)->getNote();
    4.94 +		case Branch: return ((BranchObj*)lmo)->getNote();
    4.95 +		default: return QString ();
    4.96 +	}
    4.97 +}
    4.98 +
    4.99  void TreeItem::setType(const Type t)
   4.100  {
   4.101  	type=t;
   4.102 @@ -132,7 +177,7 @@
   4.103  
   4.104  TreeItem* TreeItem::getFirstBranch()
   4.105  {
   4.106 -	if (branchCount>0)
   4.107 +	if (branchCounter>0)
   4.108  		return getBranchNum (branchOffset);
   4.109  	else
   4.110  		return NULL;
   4.111 @@ -140,8 +185,8 @@
   4.112  
   4.113  TreeItem* TreeItem::getLastBranch()
   4.114  {
   4.115 -	if (branchCount>0)
   4.116 -		return getBranchNum (branchOffset + branchCount-1);
   4.117 +	if (branchCounter>0)
   4.118 +		return getBranchNum (branchOffset + branchCounter-1);
   4.119  	else
   4.120  		return NULL;
   4.121  }
   4.122 @@ -149,7 +194,7 @@
   4.123  
   4.124  TreeItem* TreeItem::getBranchNum(const int &n)
   4.125  {
   4.126 -	if (branchCount>0)
   4.127 +	if (branchCounter>0)
   4.128  		return getChildNum (branchOffset + n);
   4.129  	else
   4.130  		return NULL;
     5.1 --- a/treeitem.h	Wed Feb 04 16:33:16 2009 +0000
     5.2 +++ b/treeitem.h	Fri Mar 06 15:02:58 2009 +0000
     5.3 @@ -20,16 +20,20 @@
     5.4      TreeItem *child(int row);
     5.5      int childCount() const;
     5.6      int columnCount() const;
     5.7 +	int branchCount() const;
     5.8  
     5.9      int row() const;
    5.10  	int column() const;
    5.11  	int depth() ;
    5.12      TreeItem *parent();
    5.13 +	int num();		// object index, e.g. branch number
    5.14  
    5.15  	// Accessing data
    5.16      QVariant data(int column) const;
    5.17  	void setHeading (const QString s);
    5.18  	QString getHeading();
    5.19 +	void setNote(const QString s);
    5.20 +	QString getNote();
    5.21  	void setType (const Type t);
    5.22  	Type getType ();
    5.23  	QString getTypeName ();
    5.24 @@ -47,7 +51,7 @@
    5.25  	LinkableMapObj* getLMO();
    5.26  	void setLMO (LinkableMapObj*);
    5.27  
    5.28 -private:
    5.29 +protected:
    5.30      QList<TreeItem*> childItems;
    5.31      QList<QVariant> itemData;
    5.32      TreeItem *parentItem;
    5.33 @@ -56,7 +60,7 @@
    5.34  	LinkableMapObj *lmo;
    5.35  
    5.36  	int branchOffset;
    5.37 -	int branchCount;
    5.38 +	int branchCounter;
    5.39  	int lastSelectedBranchNum;
    5.40  };
    5.41  
     6.1 --- a/treemodel.cpp	Wed Feb 04 16:33:16 2009 +0000
     6.2 +++ b/treemodel.cpp	Fri Mar 06 15:02:58 2009 +0000
     6.3 @@ -1,11 +1,11 @@
     6.4  #include <QtGui>
     6.5  
     6.6 +#include <iostream>
     6.7 +using namespace std;
     6.8 +
     6.9  #include "treeitem.h"
    6.10  #include "treemodel.h"
    6.11  
    6.12 -QModelIndex TreeModel::ixCur=QModelIndex();
    6.13 -TreeItem* TreeModel::itStartParent=NULL;
    6.14 -
    6.15  TreeModel::TreeModel(QObject *parent)
    6.16      : QAbstractItemModel(parent)
    6.17  {
    6.18 @@ -19,14 +19,6 @@
    6.19      delete rootItem;
    6.20  }
    6.21  
    6.22 -int TreeModel::columnCount(const QModelIndex &parent) const
    6.23 -{
    6.24 -    if (parent.isValid())
    6.25 -        return static_cast<TreeItem*>(parent.internalPointer())->columnCount();
    6.26 -    else
    6.27 -        return rootItem->columnCount();
    6.28 -}
    6.29 -
    6.30  QVariant TreeModel::data(const QModelIndex &index, int role) const
    6.31  {
    6.32      if (!index.isValid())
    6.33 @@ -100,30 +92,72 @@
    6.34      return parentItem->childCount();
    6.35  }
    6.36  
    6.37 -TreeItem* TreeModel::first()
    6.38 +int TreeModel::columnCount(const QModelIndex &parent) const
    6.39  {
    6.40 -	if (rootItem->childCount()  ==0)
    6.41 -	{
    6.42 -		ixCur=QModelIndex();
    6.43 -		return NULL;
    6.44 -	} 
    6.45 -	ixCur=index (0,0);
    6.46 -	return 	static_cast<TreeItem*>(ixCur.internalPointer());
    6.47 -}
    6.48 -	
    6.49 -TreeItem* TreeModel::next()
    6.50 -{
    6.51 -	if (!ixCur.isValid() )
    6.52 -		return NULL;
    6.53 -
    6.54 -	ixCur=index (ixCur.row()+1,0);
    6.55 -	if (ixCur.isValid())
    6.56 -		return 	static_cast<TreeItem*>(ixCur.internalPointer());
    6.57 -	return NULL;	
    6.58 -
    6.59 +    if (parent.isValid())
    6.60 +        return static_cast<TreeItem*>(parent.internalPointer())->columnCount();
    6.61 +    else
    6.62 +        return rootItem->columnCount();
    6.63  }
    6.64  
    6.65 -#include <iostream>
    6.66 +TreeItem* TreeModel::next(TreeItem* &current, TreeItem* &previous, int &d0)
    6.67 +{
    6.68 +	// Walk through map beginning at current with previous==0
    6.69 +	// Start at root, if current==NULL
    6.70 +	if (!current) current=rootItem;
    6.71 +
    6.72 +	// Are we just beginning to walk the map?
    6.73 +	if (!previous)
    6.74 +	{
    6.75 +		previous=current;
    6.76 +		d0=current->depth();
    6.77 +		current=current->getFirstBranch();
    6.78 +		return current;
    6.79 +	}
    6.80 +
    6.81 +	//std::cout << " cur="<<current->getHeading().toStdString();
    6.82 +	//std::cout << " prev="<<previous->getHeading().toStdString()<<std::endl;
    6.83 +
    6.84 +	// Going up or down (deeper)?
    6.85 +	if (current->depth() > previous->depth() )
    6.86 +	{	
    6.87 +		// Coming from above
    6.88 +		// Trying  to go down deeper
    6.89 +		if (current->branchCount() >0 )
    6.90 +		{
    6.91 +			previous=current;
    6.92 +			current=current->getFirstBranch();
    6.93 +			return current;
    6.94 +		}	
    6.95 +		// turn around and go up again
    6.96 +	}	
    6.97 +
    6.98 +	// Coming from below,
    6.99 +	// Trying to go down again to siblings
   6.100 +
   6.101 +	TreeItem *sibling=current->getBranchNum (previous->num()+1);
   6.102 +
   6.103 +	if (sibling)
   6.104 +	{	
   6.105 +		// Found sibling of previous, go there
   6.106 +		previous=current;
   6.107 +		current=sibling;
   6.108 +		return current;
   6.109 +	} 
   6.110 +
   6.111 +	// Go up and try to find siblings of current
   6.112 +	previous=current;
   6.113 +	current=current->parent();
   6.114 +
   6.115 +	// Check if we still can go somewhere
   6.116 +	if (!current) return current;
   6.117 +	
   6.118 +	while (current && current->depth() < previous->depth() )
   6.119 +		next (current,previous,d0);
   6.120 +		
   6.121 +	return current;
   6.122 +}
   6.123 +
   6.124  bool TreeModel::removeRows ( int row, int count, const QModelIndex & parent)
   6.125  {
   6.126  	int last=row+count-1;
     7.1 --- a/treemodel.h	Wed Feb 04 16:33:16 2009 +0000
     7.2 +++ b/treemodel.h	Fri Mar 06 15:02:58 2009 +0000
     7.3 @@ -27,8 +27,7 @@
     7.4      int rowCount(const QModelIndex &parent = QModelIndex()) const;
     7.5      int columnCount(const QModelIndex &parent = QModelIndex()) const;
     7.6  
     7.7 -	TreeItem *first();
     7.8 -	TreeItem *next();
     7.9 +	TreeItem* next(TreeItem* &current, TreeItem* &previous, int &d0);
    7.10  
    7.11  	bool removeRows ( int row, int count, 
    7.12  				const QModelIndex & parent = QModelIndex() ); 
    7.13 @@ -37,8 +36,6 @@
    7.14  
    7.15  protected:
    7.16      TreeItem *rootItem;
    7.17 -	static QModelIndex ixCur;
    7.18 -	static TreeItem *itStartParent;
    7.19  };
    7.20  
    7.21  #endif
     8.1 --- a/version.h	Wed Feb 04 16:33:16 2009 +0000
     8.2 +++ b/version.h	Fri Mar 06 15:02:58 2009 +0000
     8.3 @@ -7,7 +7,7 @@
     8.4  #define __VYM_VERSION "1.13.0"
     8.5  //#define __VYM_CODENAME "Codename: RC-1"
     8.6  #define __VYM_CODENAME "Codename: development version"
     8.7 -#define __VYM_BUILD_DATE "2009-02-04"
     8.8 +#define __VYM_BUILD_DATE "2009-03-06"
     8.9  
    8.10  
    8.11  bool checkVersion(const QString &);
     9.1 --- a/vymmodel.cpp	Wed Feb 04 16:33:16 2009 +0000
     9.2 +++ b/vymmodel.cpp	Fri Mar 06 15:02:58 2009 +0000
     9.3 @@ -125,7 +125,8 @@
     9.4  	selModel=NULL;
     9.5  
     9.6  	// find routine
     9.7 -	itFind=NULL;				
     9.8 +	findCurrent=NULL;				
     9.9 +	findPrevious=NULL;				
    9.10  	EOFind=false;
    9.11  
    9.12  	// animations
    9.13 @@ -1490,33 +1491,38 @@
    9.14  	}
    9.15  }
    9.16  
    9.17 -BranchObj* VymModel::findText (QString s, bool cs)   // FIXME needs to converted to first() next() next (ti)
    9.18 +BranchObj* VymModel::findText (QString s, bool cs)   
    9.19  {
    9.20 -	/*
    9.21 +	int d=0;
    9.22  	QTextDocument::FindFlags flags=0;
    9.23  	if (cs) flags=QTextDocument::FindCaseSensitively;
    9.24  
    9.25 -	if (!itFind) 
    9.26 +	if (!findCurrent) 
    9.27  	{	// Nothing found or new find process
    9.28  		if (EOFind)
    9.29  			// nothing found, start again
    9.30  			EOFind=false;
    9.31 -		itFind=first();
    9.32 +		findCurrent=NULL;	
    9.33 +		findPrevious=NULL;	
    9.34 +		next (findCurrent,findPrevious,d);
    9.35  	}	
    9.36  	bool searching=true;
    9.37  	bool foundNote=false;
    9.38  	while (searching && !EOFind)
    9.39  	{
    9.40 -		if (itFind)
    9.41 +		if (findCurrent)
    9.42  		{
    9.43  			// Searching in Note
    9.44 -			if (itFind->getNote().contains(s,cs))
    9.45 +			if (findCurrent->getNote().contains(s,cs))
    9.46  			{
    9.47 +				select (findCurrent);
    9.48 +				/*
    9.49  				if (getSelectedBranch()!=itFind) 
    9.50  				{
    9.51  					select(itFind);
    9.52  					ensureSelectionVisible();
    9.53  				}
    9.54 +				*/
    9.55  				if (textEditor->findText(s,flags)) 
    9.56  				{
    9.57  					searching=false;
    9.58 @@ -1524,17 +1530,16 @@
    9.59  				}	
    9.60  			}
    9.61  			// Searching in Heading
    9.62 -			if (searching && itFind->getHeading().contains (s,cs) ) 
    9.63 +			if (searching && findCurrent->getHeading().contains (s,cs) ) 
    9.64  			{
    9.65 -				select(itFind);
    9.66 -				ensureSelectionVisible();
    9.67 +				select(findCurrent);
    9.68  				searching=false;
    9.69  			}
    9.70  		}	
    9.71  		if (!foundNote)
    9.72  		{
    9.73 -			itFind=next(itFind);
    9.74 -			if (!itFind) EOFind=true;
    9.75 +			if (!next(findCurrent,findPrevious,d) )
    9.76 +				EOFind=true;
    9.77  		}
    9.78  	//cout <<"still searching...  "<<qPrintable( itFind->getHeading())<<endl;
    9.79  	}	
    9.80 @@ -1542,12 +1547,12 @@
    9.81  		return getSelectedBranch();
    9.82  	else
    9.83  		return NULL;
    9.84 -		*/
    9.85  }
    9.86  
    9.87  void VymModel::findReset()
    9.88  {	// Necessary if text to find changes during a find process
    9.89 -	itFind=NULL;
    9.90 +	findCurrent=NULL;
    9.91 +	findPrevious=NULL;
    9.92  	EOFind=false;
    9.93  }
    9.94  
    9.95 @@ -1979,7 +1984,7 @@
    9.96  {
    9.97  	MapCenterObj *mco=addMapCenter (contextPos);
    9.98  	cout <<"VM::addMCO ()  mapScene="<<mapScene<<endl;
    9.99 -	selection.select (mco);
   9.100 +	//FIXME selection.select (mco);
   9.101  	updateActions();
   9.102  	ensureSelectionVisible();
   9.103  	saveState (
   9.104 @@ -3897,13 +3902,16 @@
   9.105  	else
   9.106  		linkstyle=LinkableMapObj::UndefinedStyle;
   9.107  
   9.108 -	TreeItem *ti=first();
   9.109 +	TreeItem *cur=NULL;
   9.110 +	TreeItem *prev=NULL;
   9.111 +	int d=0;
   9.112  	BranchObj *bo;
   9.113 -	while (ti) 
   9.114 +	next (cur,prev,d);
   9.115 +	while (cur) 
   9.116  	{
   9.117 -		bo=(BranchObj*)(ti->getLMO() );
   9.118 +		bo=(BranchObj*)(cur->getLMO() );
   9.119  		bo->setLinkStyle(bo->getDefLinkStyle());
   9.120 -		ti=next();
   9.121 +		cur=next(cur,prev,d);
   9.122  	}
   9.123  	reposition();
   9.124  }
   9.125 @@ -3923,14 +3931,16 @@
   9.126  	);
   9.127  
   9.128  	defLinkColor=col;
   9.129 -	TreeItem *ti;
   9.130 +	TreeItem *cur=NULL;
   9.131 +	TreeItem *prev=NULL;
   9.132 +	int d=0;
   9.133  	BranchObj *bo;
   9.134 -	ti=first();
   9.135 -	while (ti) 
   9.136 +	cur=next(cur,prev,d);
   9.137 +	while (cur) 
   9.138  	{
   9.139 -		bo=(BranchObj*)(ti->getLMO() );
   9.140 +		bo=(BranchObj*)(cur->getLMO() );
   9.141  		bo->setLinkColor();
   9.142 -		ti=next();
   9.143 +		next(cur,prev,d);
   9.144  	}
   9.145  	updateActions();
   9.146  }
   9.147 @@ -3938,14 +3948,16 @@
   9.148  void VymModel::setMapLinkColorHintInt()
   9.149  {
   9.150  	// called from setMapLinkColorHint(lch) or at end of parse
   9.151 -	TreeItem *ti;
   9.152 +	TreeItem *cur=NULL;
   9.153 +	TreeItem *prev=NULL;
   9.154 +	int d=0;
   9.155  	BranchObj *bo;
   9.156 -	ti=first();
   9.157 -	while (ti) 
   9.158 +	cur=next(cur,prev,d);
   9.159 +	while (cur) 
   9.160  	{
   9.161 -		bo=(BranchObj*)(ti->getLMO() );
   9.162 +		bo=(BranchObj*)(cur->getLMO() );
   9.163  		bo->setLinkColor();
   9.164 -		ti=next();
   9.165 +		cur=next(cur,prev,d);
   9.166  	}
   9.167  }
   9.168  
   9.169 @@ -3961,14 +3973,16 @@
   9.170  		linkcolorhint=LinkableMapObj::DefaultColor;
   9.171  	else	
   9.172  		linkcolorhint=LinkableMapObj::HeadingColor;
   9.173 -	TreeItem *ti;
   9.174 +	TreeItem *cur=NULL;
   9.175 +	TreeItem *prev=NULL;
   9.176 +	int d=0;
   9.177  	BranchObj *bo;
   9.178 -	ti=first();
   9.179 -	while (bo) 
   9.180 +	cur=next(cur,prev,d);
   9.181 +	while (cur) 
   9.182  	{
   9.183 -		bo=(BranchObj*)(ti->getLMO() );
   9.184 +		bo=(BranchObj*)(cur->getLMO() );
   9.185  		bo->setLinkColor();
   9.186 -		ti=next();
   9.187 +		next(cur,prev,d);
   9.188  	}
   9.189  }
   9.190  
    10.1 --- a/vymmodel.h	Wed Feb 04 16:33:16 2009 +0000
    10.2 +++ b/vymmodel.h	Fri Mar 06 15:02:58 2009 +0000
    10.3 @@ -235,7 +235,8 @@
    10.4  //	QString getHeading (bool &ok,QPoint &p); //!< Get heading, ok if selection is branch
    10.5  
    10.6  private:
    10.7 -	BranchObj* itFind;			// next object in find process
    10.8 +	TreeItem* findCurrent;		// next object in find process
    10.9 +	TreeItem* findPrevious;		// next object in find process
   10.10  	bool EOFind;				// true, if search failed
   10.11  public:
   10.12      BranchObj* findText(QString,bool);		// Find object
    11.1 --- a/xml-freemind.cpp	Wed Feb 04 16:33:16 2009 +0000
    11.2 +++ b/xml-freemind.cpp	Fri Mar 06 15:02:58 2009 +0000
    11.3 @@ -67,14 +67,16 @@
    11.4  				   "saved using freemind " +atts.value("version")+". "
    11.5  				   "The version of this vym can parse freemind " + v +"."); 
    11.6  		}
    11.7 -		TreeItem *ti=model->first();	// FIXME this will be NULL !!!
    11.8 +		//FIXME TreeItem *ti=model->first();	// FIXME this will be NULL !!!
    11.9 +		TreeItem *ti=NULL; // FIXME
   11.10 +
   11.11  		BranchObj *bo;
   11.12  		if (ti->getType()==TreeItem::MapCenter)
   11.13  			bo=(BranchObj*)(ti->getLMO());
   11.14  		else
   11.15  			qWarning ("parseFreeMindHandler::startElement  no mapCenter!!");
   11.16  
   11.17 -		cout <<"model="<<model<<"   first="<<model->first()<<endl;
   11.18 +		//FIXME cout <<"model="<<model<<"   first="<<model->first()<<endl;
   11.19  
   11.20  		lastBranch=bo->addBranch();
   11.21  
    12.1 --- a/xml-vym.cpp	Wed Feb 04 16:33:16 2009 +0000
    12.2 +++ b/xml-vym.cpp	Fri Mar 06 15:02:58 2009 +0000
    12.3 @@ -182,7 +182,9 @@
    12.4  			// selection==lmo==NULL
    12.5  			// Treat it like ImportAdd then...
    12.6  			loadMode=ImportAdd;
    12.7 -			lmo=model->first()->getLMO();		
    12.8 +			// FIXME lmo=model->first()->getLMO();		
    12.9 +			// Do we really have no MCO when loading?????
   12.10 +			cout << "xml-vym aborted\n";
   12.11  		}	
   12.12  		if (lmo && ( (typeid(*lmo) == typeid(BranchObj) ) 
   12.13  				|| (typeid(*lmo) == typeid(MapCenterObj) ) ) )