branchobj.cpp
changeset 785 5987f9f15bac
parent 779 1fb50e79661c
child 786 6269016c9905
     1.1 --- a/branchobj.cpp	Mon Jul 27 12:53:17 2009 +0000
     1.2 +++ b/branchobj.cpp	Mon Aug 03 10:42:12 2009 +0000
     1.3 @@ -86,18 +86,12 @@
     1.4  		absPos=getRandPos();
     1.5  		absPos+=parObj->getChildPos();
     1.6  	}
     1.7 -
     1.8 -	includeImagesVer=false;
     1.9 -	includeImagesHor=false;
    1.10  }
    1.11  
    1.12  void BranchObj::copy (BranchObj* other)
    1.13  {
    1.14      OrnamentedObj::copy(other);
    1.15  
    1.16 -	for (int i=0; i<other->floatimage.size(); ++i)
    1.17 -		addFloatImage  (other->floatimage.at(i));
    1.18 -	
    1.19  	setVisibility (other->visible);
    1.20  
    1.21  	angle=other->angle;
    1.22 @@ -109,9 +103,6 @@
    1.23  {
    1.24  	//setVisibility (true); //FIXME-4 needed?
    1.25  
    1.26 -	while (!floatimage.isEmpty())
    1.27 -		delete floatimage.takeFirst();
    1.28 -
    1.29  	while (!xlink.isEmpty())
    1.30  		delete xlink.takeFirst();
    1.31  }
    1.32 @@ -218,15 +209,15 @@
    1.33  		standardFlags->setVisibility(v);
    1.34  		LinkableMapObj::setVisibility (v);
    1.35  		int i;
    1.36 -		for (i=0; i<floatimage.size(); ++i)
    1.37 -			floatimage.at(i)->setVisibility (v);
    1.38 +		for (i=0; i<treeItem->imageCount(); ++i)
    1.39 +			treeItem->getImageObjNum(i)->setVisibility (v);
    1.40  		for (i=0; i<xlink.size(); ++i)	
    1.41  			xlink.at(i)->setVisibility ();	
    1.42  
    1.43  		// Only change children, if I am not scrolled
    1.44  		if (! bi->isScrolled() && (bi->depth() < toDepth))
    1.45  		{
    1.46 -			// Now go recursivly through all children
    1.47 +			// Now go recursivly through all children //FIXME-3 are there multiple calls for lower level items???
    1.48  			for (i=0; i<treeItem->branchCount(); ++i)
    1.49  				treeItem->getBranchObjNum(i)->setVisibility (v,toDepth);	
    1.50  		}
    1.51 @@ -264,8 +255,8 @@
    1.52  
    1.53  void BranchObj::positionContents()
    1.54  {
    1.55 -    for (int i=0; i<floatimage.size(); ++i )
    1.56 -		floatimage.at(i)->reposition();
    1.57 +	for (int i=0; i<treeItem->imageCount(); ++i)
    1.58 +		treeItem->getImageObjNum(i)->reposition();
    1.59  	OrnamentedObj::positionContents();
    1.60  }
    1.61  
    1.62 @@ -344,37 +335,38 @@
    1.63  	QPointF rp;
    1.64  
    1.65  	topPad=botPad=leftPad=rightPad=0;
    1.66 -	if (includeImagesVer || includeImagesHor)
    1.67 +	bool incV=((BranchItem*)treeItem)->getIncludeImagesVer();
    1.68 +	bool incH=((BranchItem*)treeItem)->getIncludeImagesHor();
    1.69 +	if (incH || incV)
    1.70  	{
    1.71 -		if (treeItem->imageCount()>0)
    1.72 +		FloatImageObj *fio;
    1.73 +		for (int i=0; i<treeItem->imageCount(); ++i )	
    1.74  		{
    1.75 -			for (int i=0; i<floatimage.size(); ++i )
    1.76 +			fio=treeItem->getImageObjNum(i);
    1.77 +			rp=fio->getRelPos();
    1.78 +			if (incV)
    1.79  			{
    1.80 -				rp=floatimage.at(i)->getRelPos();
    1.81 -				if (includeImagesVer)
    1.82 +				if (rp.y() < 0) 
    1.83 +					topPad=max (topPad,-rp.y()-h);
    1.84 +				if (rp.y()+fio->height() > 0)
    1.85 +					botPad=max (botPad,rp.y()+fio->height());
    1.86 +			}		
    1.87 +			if (incH)
    1.88 +			{
    1.89 +				if (orientation==LinkableMapObj::RightOfCenter)
    1.90  				{
    1.91 -					if (rp.y() < 0) 
    1.92 -						topPad=max (topPad,-rp.y()-h);
    1.93 -					if (rp.y()+floatimage.at(i)->height() > 0)
    1.94 -						botPad=max (botPad,rp.y()+floatimage.at(i)->height());
    1.95 -				}		
    1.96 -				if (includeImagesHor)
    1.97 +					if (-rp.x()-w > 0) 
    1.98 +						leftPad=max (leftPad,-rp.x()-w);
    1.99 +					if (rp.x()+fio->width() > 0)
   1.100 +						rightPad=max (rightPad,rp.x()+fio->width());
   1.101 +				} else
   1.102  				{
   1.103 -					if (orientation==LinkableMapObj::RightOfCenter)
   1.104 -					{
   1.105 -						if (-rp.x()-w > 0) 
   1.106 -							leftPad=max (leftPad,-rp.x()-w);
   1.107 -						if (rp.x()+floatimage.at(i)->width() > 0)
   1.108 -							rightPad=max (rightPad,rp.x()+floatimage.at(i)->width());
   1.109 -					} else
   1.110 -					{
   1.111 -						if (rp.x()< 0) 
   1.112 -							leftPad=max (leftPad,-rp.x());
   1.113 -						if (rp.x()+floatimage.at(i)->width() > w)
   1.114 -							rightPad=max (rightPad,rp.x()+floatimage.at(i)->width()-w);
   1.115 -					}
   1.116 -				}		
   1.117 -			}	
   1.118 +					if (rp.x()< 0) 
   1.119 +						leftPad=max (leftPad,-rp.x());
   1.120 +					if (rp.x()+fio->width() > w)
   1.121 +						rightPad=max (rightPad,rp.x()+fio->width()-w);
   1.122 +				}
   1.123 +			}		
   1.124  		}	
   1.125  		h+=topPad+botPad;
   1.126  		w+=leftPad+rightPad;
   1.127 @@ -478,9 +470,7 @@
   1.128  			changed=true;
   1.129  		}	
   1.130  	}
   1.131 -
   1.132 -	if (changed)
   1.133 -		updateContentSize();
   1.134 +	updateContentSize();
   1.135  }
   1.136  
   1.137  
   1.138 @@ -523,47 +513,9 @@
   1.139  	return NULL;
   1.140  }
   1.141  
   1.142 -void BranchObj::setIncludeImagesVer(bool b)
   1.143 -{
   1.144 -	includeImagesVer=b;
   1.145 -	calcBBoxSize();
   1.146 -	positionBBox();
   1.147 -	requestReposition();
   1.148 -}
   1.149 -
   1.150 -bool BranchObj::getIncludeImagesVer()
   1.151 -{
   1.152 -	return includeImagesVer;
   1.153 -}
   1.154 -
   1.155 -void BranchObj::setIncludeImagesHor(bool b)
   1.156 -{
   1.157 -	includeImagesHor=b;
   1.158 -	calcBBoxSize();
   1.159 -	positionBBox();
   1.160 -	requestReposition();
   1.161 -}
   1.162 -
   1.163 -bool BranchObj::getIncludeImagesHor()
   1.164 -{
   1.165 -	return includeImagesHor;
   1.166 -}
   1.167 -
   1.168 -QString BranchObj::getIncludeImageAttr()
   1.169 -{
   1.170 -	QString a;
   1.171 -	if (includeImagesVer)
   1.172 -		a=attribut ("incImgV","true");
   1.173 -	else
   1.174 -		a=attribut ("incImgV","false");
   1.175 -	if (includeImagesHor)
   1.176 -		a+=attribut ("incImgH","true");
   1.177 -	else
   1.178 -		a+=attribut ("incImgH","false");
   1.179 -	return a;	
   1.180 -}
   1.181 -
   1.182 -FloatImageObj* BranchObj::addFloatImage ()
   1.183 + 
   1.184 +// FIXME-3 FloatImageObj* BranchObj::addFloatImage ()
   1.185 +/*
   1.186  {
   1.187  	FloatImageObj *newfi=new FloatImageObj (scene,this);
   1.188  	floatimage.append (newfi);
   1.189 @@ -571,15 +523,15 @@
   1.190  		newfi->setVisibility (false);
   1.191  	else	
   1.192  		newfi->setVisibility(visible);
   1.193 -		/*
   1.194 -	calcBBoxSize();
   1.195 -	positionBBox();
   1.196 -	*/
   1.197 +	//calcBBoxSize();
   1.198 +	//positionBBox();
   1.199  	requestReposition();
   1.200  	return newfi;
   1.201  }
   1.202 +*/
   1.203  
   1.204 -FloatImageObj* BranchObj::addFloatImage (FloatImageObj *fio)
   1.205 +//FIXME-3 FloatImageObj* BranchObj::addFloatImage (FloatImageObj *fio)
   1.206 +/*
   1.207  {
   1.208  	FloatImageObj *newfi=new FloatImageObj (scene,this);
   1.209  	floatimage.append (newfi);
   1.210 @@ -588,15 +540,14 @@
   1.211  		newfi->setVisibility (false);
   1.212  	else	
   1.213  		newfi->setVisibility(visible);
   1.214 -		/*
   1.215 -	calcBBoxSize();
   1.216 -	positionBBox();
   1.217 -	*/
   1.218 +	//calcBBoxSize();
   1.219 +	//positionBBox();
   1.220  	requestReposition();
   1.221  	return newfi;
   1.222  }
   1.223 +*/
   1.224  
   1.225 -FloatImageObj* BranchObj::getFirstFloatImage ()
   1.226 +/* FIXME-3 FloatImageObj* BranchObj::getFirstFloatImage ()
   1.227  {
   1.228      return floatimage.first();
   1.229  }
   1.230 @@ -606,7 +557,7 @@
   1.231      return floatimage.last();
   1.232  }
   1.233  
   1.234 -FloatImageObj* BranchObj::getFloatImageNum (const uint &i)
   1.235 +FIXME -3 FloatImageObj* BranchObj::getFloatImageNum (const uint &i)
   1.236  {
   1.237      return floatimage.at(i);
   1.238  }
   1.239 @@ -619,6 +570,7 @@
   1.240  	positionBBox();
   1.241  	requestReposition();
   1.242  }
   1.243 +*/
   1.244  
   1.245  void BranchObj::savePosInAngle ()
   1.246  {
   1.247 @@ -849,11 +801,9 @@
   1.248  			(have been NULL at least in calcBBoxSizeWithChilds...)
   1.249  */			
   1.250  
   1.251 -/*
   1.252 -	FIXME-3 for (int i=0; i<floatimage.size(); ++i)
   1.253 -		if (!floatimage.at(i)->isHidden())
   1.254 -			r=addBBox(floatimage.at(i)->getTotalBBox(),r);
   1.255 -	*/	
   1.256 +	for (int i=0; i<treeItem->imageCount(); ++i)
   1.257 +		if (!treeItem->isHidden())
   1.258 +			r=addBBox(treeItem->getImageObjNum(i)->getTotalBBox(),r);
   1.259  	return r;
   1.260  }
   1.261