diff -r e3f722759c7e -r 340bc29da9a0 treemodel.cpp --- a/treemodel.cpp Wed May 20 15:40:14 2009 +0000 +++ b/treemodel.cpp Tue May 26 11:23:44 2009 +0000 @@ -106,7 +106,7 @@ return rootItem->columnCount(); } -BranchItem* TreeModel::next(BranchItem* ¤t, BranchItem* &previous, int &d0) +BranchItem* TreeModel::next(BranchItem* ¤t, BranchItem* &previous, BranchItem* start) { // Walk through map beginning at current with previous==0 // Start at root, if current==NULL @@ -115,8 +115,8 @@ // Are we just beginning to walk the map? if (!previous) { + if (!start) start=current; previous=current; - d0=current->depth(); current=current->getFirstBranch(); return current; } @@ -138,7 +138,8 @@ // turn around and go up again } - // Coming from below, + // Coming from below + // Trying to go down again to siblings BranchItem *sibling=current->getBranchNum (previous->num()+1); @@ -151,6 +152,9 @@ return current; } + // If we only needed to go through subtree, we are done now + if (start==current) return NULL; + // Go up and try to find siblings of current previous=current; current=(BranchItem*)current->parent(); @@ -159,27 +163,11 @@ if (!current) return current; while (current && current->depth() < previous->depth() ) - next (current,previous,d0); + current=next (current,previous,start); return current; } -/* -bool TreeModel::insertRows ( int row, int count, const QModelIndex & parent) -{ - std::cout << "TreeModel insertRows()\n"; - int last=row+count-1; - beginInsertRows (parent,row,last); - - for (int i=row; i<=last; i++) - { - std::cout << "TreeModel::insertRows inserting i="<