diff -r 96402b172173 -r 716a777c1c98 treeitem.cpp --- a/treeitem.cpp Wed Oct 29 17:42:34 2008 +0000 +++ b/treeitem.cpp Fri Jan 30 09:14:12 2009 +0000 @@ -7,6 +7,10 @@ parentItem = parent; itemData = data; lmo=NULL; + + branchOffset=0; + branchCount=0; + lastSelectedBranchNum=-1; } TreeItem::~TreeItem() @@ -17,6 +21,12 @@ void TreeItem::appendChild(TreeItem *item) { childItems.append(item); + if (item->type == Branch) + { + if (branchCount==0) + branchOffset=childItems.count()-1; + branchCount++; + } } void TreeItem::removeChild(int row) @@ -99,6 +109,50 @@ } } +TreeItem* TreeItem::getChildNum(const int &n) +{ + if (n>=0 && n0) + return getBranchNum (branchOffset); + else + return NULL; +} + +TreeItem* TreeItem::getLastBranch() +{ + if (branchCount>0) + return getBranchNum (branchOffset + branchCount-1); + else + return NULL; +} + + +TreeItem* TreeItem::getBranchNum(const int &n) +{ + if (branchCount>0) + return getChildNum (branchOffset + n); + else + return NULL; +} + +void TreeItem::setLastSelectedBranch() +{ + if (parentItem) + parentItem->lastSelectedBranchNum=parentItem->childItems.indexOf(this); +} + +TreeItem* TreeItem::getLastSelectedBranch() +{ + return getBranchNum (lastSelectedBranchNum); +} + LinkableMapObj* TreeItem::getLMO() // FIXME VM should be unnecessary in the end { return lmo;