treeitem.cpp
changeset 738 716a777c1c98
parent 727 96402b172173
child 739 3d43b46a8564
     1.1 --- a/treeitem.cpp	Thu Jan 22 15:40:08 2009 +0000
     1.2 +++ b/treeitem.cpp	Fri Jan 30 09:14:12 2009 +0000
     1.3 @@ -7,6 +7,10 @@
     1.4      parentItem = parent;
     1.5      itemData = data;
     1.6  	lmo=NULL;
     1.7 +
     1.8 +	branchOffset=0;
     1.9 +	branchCount=0;
    1.10 +	lastSelectedBranchNum=-1;
    1.11  }
    1.12  
    1.13  TreeItem::~TreeItem()
    1.14 @@ -17,6 +21,12 @@
    1.15  void TreeItem::appendChild(TreeItem *item)
    1.16  {
    1.17      childItems.append(item);
    1.18 +	if (item->type == Branch)
    1.19 +	{
    1.20 +		if (branchCount==0)
    1.21 +			branchOffset=childItems.count()-1;
    1.22 +		branchCount++;
    1.23 +	}
    1.24  }
    1.25  
    1.26  void TreeItem::removeChild(int row)
    1.27 @@ -99,6 +109,50 @@
    1.28  	}
    1.29  }
    1.30  
    1.31 +TreeItem* TreeItem::getChildNum(const int &n)
    1.32 +{
    1.33 +	if (n>=0 && n<childItems.count() )
    1.34 +		return childItems.at(n);
    1.35 +	else
    1.36 +		return NULL;
    1.37 +}
    1.38 +
    1.39 +TreeItem* TreeItem::getFirstBranch()
    1.40 +{
    1.41 +	if (branchCount>0)
    1.42 +		return getBranchNum (branchOffset);
    1.43 +	else
    1.44 +		return NULL;
    1.45 +}
    1.46 +
    1.47 +TreeItem* TreeItem::getLastBranch()
    1.48 +{
    1.49 +	if (branchCount>0)
    1.50 +		return getBranchNum (branchOffset + branchCount-1);
    1.51 +	else
    1.52 +		return NULL;
    1.53 +}
    1.54 +
    1.55 +
    1.56 +TreeItem* TreeItem::getBranchNum(const int &n)
    1.57 +{
    1.58 +	if (branchCount>0)
    1.59 +		return getChildNum (branchOffset + n);
    1.60 +	else
    1.61 +		return NULL;
    1.62 +}
    1.63 +
    1.64 +void TreeItem::setLastSelectedBranch()
    1.65 +{
    1.66 +	if (parentItem)
    1.67 +		parentItem->lastSelectedBranchNum=parentItem->childItems.indexOf(this);
    1.68 +}
    1.69 +
    1.70 +TreeItem* TreeItem::getLastSelectedBranch()
    1.71 +{
    1.72 +	return getBranchNum (lastSelectedBranchNum);
    1.73 +}
    1.74 +
    1.75  LinkableMapObj* TreeItem::getLMO()	// FIXME VM should be unnecessary in the end
    1.76  {
    1.77  	return lmo;