branchitem.cpp
changeset 822 c2ce9944148c
parent 819 8f987e376035
child 823 0bba81dde1bc
     1.1 --- a/branchitem.cpp	Thu Jan 21 11:56:57 2010 +0000
     1.2 +++ b/branchitem.cpp	Wed Feb 10 13:48:42 2010 +0000
     1.3 @@ -1,3 +1,4 @@
     1.4 +#include "attributeitem.h"
     1.5  #include "branchitem.h"
     1.6  #include "branchobj.h"
     1.7  #include "vymmodel.h"
     1.8 @@ -118,7 +119,7 @@
     1.9  		+getMapAttr()
    1.10  		+getGeneralAttr()
    1.11  		+scrolledAttr 
    1.12 -	//	+areaAttr	// FIXME-2
    1.13 +	//	+areaAttr	// FIXME-4 not needed anymore. Wait until end of 2010 before removing...
    1.14  		+idAttr 
    1.15  		+getIncludeImageAttr() 
    1.16  		);
    1.17 @@ -290,7 +291,7 @@
    1.18  	return result;
    1.19  }
    1.20  
    1.21 -void BranchItem::sortChildren()
    1.22 +void BranchItem::sortChildren(bool inverse)
    1.23  {
    1.24  	int childCount=branchCounter; 
    1.25  	int curChildIndex;
    1.26 @@ -298,15 +299,28 @@
    1.27  	do
    1.28  	{
    1.29  		madeChanges=false;
    1.30 -		for(curChildIndex=1;curChildIndex<childCount;curChildIndex++){
    1.31 -			BranchItem* curChild =getBranchNum(curChildIndex);
    1.32 -			BranchItem* prevChild=getBranchNum(curChildIndex-1);
    1.33 -			if(prevChild->getHeading().compare(curChild->getHeading())>0)
    1.34 +		if (inverse)
    1.35 +			for(curChildIndex=1;curChildIndex<childCount;curChildIndex++)
    1.36  			{
    1.37 -				model->moveUp(curChild);
    1.38 -				madeChanges=true;
    1.39 +				BranchItem* curChild =getBranchNum(curChildIndex);
    1.40 +				BranchItem* prevChild=getBranchNum(curChildIndex-1);
    1.41 +				if (prevChild->getHeading().compare(curChild->getHeading())<0)
    1.42 +				{
    1.43 +					model->moveUp (curChild);
    1.44 +					madeChanges=true;
    1.45 +				}	
    1.46 +			} 
    1.47 +		else
    1.48 +			for(curChildIndex=1;curChildIndex<childCount;curChildIndex++)
    1.49 +			{
    1.50 +				BranchItem* curChild =getBranchNum(curChildIndex);
    1.51 +				BranchItem* prevChild=getBranchNum(curChildIndex-1);
    1.52 +				if ( prevChild->getHeading().compare(curChild->getHeading())>0)
    1.53 +				{
    1.54 +					model->moveUp(curChild);
    1.55 +					madeChanges=true;
    1.56 +				}	
    1.57  			}
    1.58 -		}
    1.59  	}while(madeChanges);
    1.60  }
    1.61  
    1.62 @@ -387,7 +401,6 @@
    1.63  
    1.64  
    1.65  
    1.66 -
    1.67  TreeItem* BranchItem::findMapItem (QPointF p, TreeItem* excludeTI)
    1.68  {
    1.69  	// Search branches
    1.70 @@ -415,34 +428,24 @@
    1.71  			mo->isVisibleObj() 
    1.72  		) return ii;
    1.73  	}
    1.74 +
    1.75 +	// Search attributes
    1.76 +	AttributeItem *ai;
    1.77 +    for (int i=0; i<attributeCount(); ++i )
    1.78 +	{
    1.79 +		ai=getAttributeNum (i);
    1.80 +		LinkableMapObj *mo=ai->getLMO();
    1.81 +		if (mo && mo->isInClickBox(p) && 
    1.82 +			(ii != excludeTI) && 
    1.83 +			this!= excludeTI &&
    1.84 +			mo->isVisibleObj() 
    1.85 +		) return ai;
    1.86 +	}
    1.87 +
    1.88  	return NULL;
    1.89  }
    1.90 -/*
    1.91 -TreeItem* BranchItem::findID (QString sid)	//FIXME-3 move to TreeItem	//FIXME-4 search images
    1.92 -{
    1.93 -	// Search branches
    1.94 -    TreeItem *ti;
    1.95 -	for (int i=0; i<branchCount(); ++i)
    1.96 -    {	
    1.97 -		ti=getBranchNum(i)->findID (sid);
    1.98 -		if (ti != NULL) return ti;
    1.99 -    }
   1.100 -	
   1.101 -	// Search myself
   1.102 -	if (sid==objID) return this;
   1.103  
   1.104 -
   1.105 -	// Search float images 
   1.106 -    for (int i=0; i<floatimage.size(); ++i )
   1.107 -		if (floatimage.at(i)->inBox(p) && 
   1.108 -			(floatimage.at(i) != excludeLMO) && 
   1.109 -			floatimage.at(i)->getParObj()!= excludeLMO &&
   1.110 -			floatimage.at(i)->isVisibleObj() 
   1.111 -		) return floatimage.at(i);
   1.112 -    return NULL;
   1.113 -}
   1.114 -*/
   1.115 -void BranchItem::updateStyles()
   1.116 +void BranchItem::updateStyles(const bool &keepFrame)
   1.117  {
   1.118  	// FIXME-5 compare also MapItem::initLMO...
   1.119  
   1.120 @@ -452,7 +455,7 @@
   1.121  			lmo->setParObj ( ((MapItem*)parentItem)->getLMO() );
   1.122  		else
   1.123  			lmo->setParObj (NULL);
   1.124 -		((BranchObj*)lmo)->setDefAttr(BranchObj::MovedBranch);
   1.125 +		((BranchObj*)lmo)->setDefAttr(BranchObj::MovedBranch,keepFrame);
   1.126  	}
   1.127  }
   1.128