treemodel.cpp
changeset 776 25e634a7e1dc
parent 773 340bc29da9a0
child 788 78ba80b54bc4
     1.1 --- a/treemodel.cpp	Wed Jun 03 20:37:17 2009 +0000
     1.2 +++ b/treemodel.cpp	Mon Jun 08 11:36:56 2009 +0000
     1.3 @@ -5,6 +5,7 @@
     1.4  
     1.5  #include "branchitem.h"
     1.6  #include "treeitem.h"
     1.7 +#include "imageitem.h"
     1.8  #include "treemodel.h"
     1.9  
    1.10  TreeModel::TreeModel(QObject *parent)
    1.11 @@ -108,6 +109,12 @@
    1.12  
    1.13  BranchItem* TreeModel::next(BranchItem* &current, BranchItem* &previous, BranchItem* start)
    1.14  {
    1.15 +/*FIXME-3	cout << "TM::next \n"; 
    1.16 +	std::string ch="()"; if (current) ch=current->getHeadingStd();
    1.17 +	std::string ph="()"; if (previous) ph=previous->getHeadingStd();
    1.18 +	cout << "  cur="<<ch << " prev="<<ph<<endl;
    1.19 +*/
    1.20 +
    1.21  	// Walk through map beginning at current with previous==0
    1.22  	// Start at root, if current==NULL
    1.23  	if (!current) current=(BranchItem*)rootItem;
    1.24 @@ -121,32 +128,42 @@
    1.25  		return current;
    1.26  	}
    1.27  
    1.28 -	//std::cout << " cur="<<current->getHeading().toStdString();
    1.29 -	//std::cout << " prev="<<previous->getHeading().toStdString()<<std::endl;
    1.30 -
    1.31  	// Going up or down (deeper)?
    1.32  	if (current->depth() > previous->depth() )
    1.33  	{	
    1.34  		// Coming from above
    1.35  		// Trying  to go down deeper
    1.36 +//		cout << "  trying to go deeper\n";
    1.37  		if (current->branchCount() >0 )
    1.38  		{
    1.39 +//			cout << "  yes, going deeper\n";
    1.40  			previous=current;
    1.41  			current=current->getFirstBranch();
    1.42  			return current;
    1.43  		}	
    1.44  		// turn around and go up again
    1.45 +//		cout << "  sorry, turn around\n";
    1.46 +		BranchItem *bi=current;
    1.47 +		current=previous;
    1.48 +		previous=bi;
    1.49  	}	
    1.50  
    1.51 +/*
    1.52 +	cout << "  coming from below\n";
    1.53 +	ch="()"; if (current) ch=current->getHeadingStd();
    1.54 +	ph="()"; if (previous) ph=previous->getHeadingStd();
    1.55 +	cout << "  cur="<<ch << " prev="<<ph<<endl;
    1.56 +*/	
    1.57  	// Coming from below
    1.58 -
    1.59  	// Trying to go down again to siblings
    1.60  
    1.61  	BranchItem *sibling=current->getBranchNum (previous->num()+1);
    1.62 +//	cout <<"    prev->num()="<<previous->num()<<endl;
    1.63  
    1.64  	if (sibling)
    1.65  	{	
    1.66  		// Found sibling of previous, go there
    1.67 +//		cout << "  sib=cur="<<sibling->getHeadingStd()<<endl;
    1.68  		previous=current;
    1.69  		current=sibling;
    1.70  		return current;
    1.71 @@ -156,6 +173,7 @@
    1.72  	if (start==current) return NULL;
    1.73  
    1.74  	// Go up and try to find siblings of current
    1.75 +//	cout <<"  going up again...\n";
    1.76  	previous=current;
    1.77  	current=(BranchItem*)current->parent();
    1.78  
    1.79 @@ -186,6 +204,9 @@
    1.80  			case TreeItem::Branch:
    1.81  				delete (BranchItem*)ti; 
    1.82  				break;
    1.83 +			case TreeItem::Image:
    1.84 +				delete (ImageItem*)ti; 
    1.85 +				break;
    1.86  			default:
    1.87  				delete ti;
    1.88  				break;