1.7.6 New features for floatimages and fixes
authorinsilmaril
Tue Jan 03 09:44:41 2006 +0000 (2006-01-03)
changeset 173309609406650
parent 172 fbb8c8560551
child 174 3674e9236634
1.7.6 New features for floatimages and fixes
flagrowobj.cpp
floatimageobj.cpp
floatimageobj.h
floatobj.cpp
floatobj.h
headingobj.cpp
     1.1 --- a/flagrowobj.cpp	Tue Jan 03 09:44:41 2006 +0000
     1.2 +++ b/flagrowobj.cpp	Tue Jan 03 09:44:41 2006 +0000
     1.3 @@ -86,8 +86,8 @@
     1.4  
     1.5  void FlagRowObj::positionBBox()
     1.6  {
     1.7 -    bbox.setX (absPos.x() );
     1.8 -    bbox.setY (absPos.y() );
     1.9 +    bbox.moveTopLeft(absPos );
    1.10 +    clickBox.moveTopLeft(absPos );
    1.11  }
    1.12  
    1.13  void FlagRowObj::calcBBoxSize()
    1.14 @@ -104,15 +104,19 @@
    1.15  		if (size.height() > boxsize.height() ) 
    1.16  			boxsize.setHeight(size.height() );
    1.17  	}
    1.18 -	bbox.setSize (QSize(boxsize.width(), boxsize.height() ));
    1.19 +	bbox.setSize (boxsize);
    1.20 +	clickBox.setSize (boxsize);
    1.21  }
    1.22  
    1.23  QString FlagRowObj::getFlagName (const QPoint &p)
    1.24  {
    1.25 -	if (!inBBox (p)) return "";
    1.26 +	if (!inBox (p)) return "";
    1.27  	FlagObj *fo;
    1.28  	for (fo=flag.first();fo; fo=flag.next() )
    1.29 -		if (fo->inBBox (p)) return fo->getName();
    1.30 +	{	
    1.31 +		cout << " "<<fo->getName()<<endl;
    1.32 +		if (fo->inBox (p)) return fo->getName();
    1.33 +	}	
    1.34  	return "";	
    1.35  
    1.36  	
    1.37 @@ -178,7 +182,6 @@
    1.38  				fo->activate();
    1.39  				fo->setVisibility (visible);
    1.40  				calcBBoxSize();
    1.41 -				positionBBox();
    1.42  			} else
    1.43  				qWarning ("FlagRowObj ("+name+")::activate ("+foname+")  failed - could not find it in parentRow");
    1.44  		}	
     2.1 --- a/floatimageobj.cpp	Tue Jan 03 09:44:41 2006 +0000
     2.2 +++ b/floatimageobj.cpp	Tue Jan 03 09:44:41 2006 +0000
     2.3 @@ -6,7 +6,7 @@
     2.4  // FloatImageObj
     2.5  /////////////////////////////////////////////////////////////////
     2.6  
     2.7 -int FloatImageObj::counter=0;		// make instance 
     2.8 +uint FloatImageObj::saveCounter=0;		// make instance 
     2.9  
    2.10  
    2.11  FloatImageObj::FloatImageObj ():FloatObj()
    2.12 @@ -43,6 +43,7 @@
    2.13  	icon->move (absPos.x(), absPos.y() );
    2.14  	icon->setVisibility (true);
    2.15  	bbox.setSize (QSize(icon->size().width(), icon->size().height()));
    2.16 +	clickBox.setSize (QSize(icon->size().width(), icon->size().height()));
    2.17  	filename="";
    2.18  	originalFilename="no original name available";
    2.19  	filetype="";
    2.20 @@ -53,7 +54,9 @@
    2.21  {					
    2.22  	FloatObj::copy (other);
    2.23  	icon->copy (other->icon);
    2.24 +	filetype=other->filetype;
    2.25  	filename=other->filename;
    2.26 +	originalFilename=other->originalFilename;
    2.27  	saveInMap=other->saveInMap;
    2.28      positionBBox();
    2.29  }
    2.30 @@ -73,6 +76,7 @@
    2.31  {
    2.32    icon->load(pixmap);
    2.33    bbox.setSize (QSize(icon->size().width()+8, icon->size().height()+8));
    2.34 +  clickBox.setSize (QSize(icon->size().width()+8, icon->size().height()+8));
    2.35    positionBBox();
    2.36    filetype="PNG";
    2.37    filename="noname.png";
    2.38 @@ -130,7 +134,7 @@
    2.39  
    2.40  void FloatImageObj::positionBBox()
    2.41  {
    2.42 -	// TODO
    2.43 +	clickBox=bbox;
    2.44  }
    2.45  
    2.46  void FloatImageObj::calcBBoxSize()
    2.47 @@ -140,12 +144,14 @@
    2.48  
    2.49  QString FloatImageObj::saveToDir (const QString &tmpdir,const QString &prefix, const QPoint &p)
    2.50  {
    2.51 -	counter++;
    2.52 +	saveCounter++;
    2.53  
    2.54  	QString posAttr=
    2.55  		attribut("relPosX",QString().setNum(relPos.x(),10)) +
    2.56  		attribut("relPosY",QString().setNum(relPos.y(),10)); 
    2.57  
    2.58 +	QString linkAttr=getLinkAttr();
    2.59 +	
    2.60  	QString useOrientAttr;
    2.61  	if (useOrientation)
    2.62  		useOrientAttr=attribut ("useOrientation","true");
    2.63 @@ -172,13 +178,14 @@
    2.64  	if (filetype=="GIF")
    2.65  		filetype="PNG";
    2.66  		
    2.67 -	url="images/"+prefix+"image-" + QString().number(counter,10) + "." +filetype;
    2.68 +	url="images/"+prefix+"image-" + QString().number(saveCounter,10) + "." +filetype;
    2.69  
    2.70  	// And really save the image
    2.71  	icon->save (tmpdir + "/" + url, filetype);
    2.72  
    2.73      return singleElement ("floatimage",  
    2.74  		posAttr + 
    2.75 +		linkAttr +
    2.76  		useOrientAttr + 
    2.77  		saveInMapAttr + 
    2.78  		exportAttr + 
    2.79 @@ -189,7 +196,7 @@
    2.80  
    2.81  void FloatImageObj::resetSaveCounter()
    2.82  {
    2.83 -	counter=0;
    2.84 +	saveCounter=0;
    2.85  }
    2.86  
    2.87  
     3.1 --- a/floatimageobj.h	Tue Jan 03 09:44:41 2006 +0000
     3.2 +++ b/floatimageobj.h	Tue Jan 03 09:44:41 2006 +0000
     3.3 @@ -36,7 +36,7 @@
     3.4  protected:
     3.5  	ImageObj *icon;
     3.6  	bool saveInMap;
     3.7 -	static int counter;			// numerate the files during saveToDir
     3.8 +	static uint saveCounter;	// numerate the files during saveToDir
     3.9  	QString filetype;
    3.10  	QString filename;
    3.11  	QString originalFilename;
     4.1 --- a/floatobj.cpp	Tue Jan 03 09:44:41 2006 +0000
     4.2 +++ b/floatobj.cpp	Tue Jan 03 09:44:41 2006 +0000
     4.3 @@ -66,11 +66,25 @@
     4.4  	else
     4.5  		relPos.setX (absPos.x() - parObj->x() );
     4.6  	relPos.setY (absPos.y() - parObj->y() );
     4.7 +	if (parObj)
     4.8 +	{	
     4.9 +		parObj->calcBBoxSize();
    4.10 +		parObj->requestReposition();
    4.11 +	}	
    4.12  }
    4.13  
    4.14  void FloatObj::setRelPos(const QPoint &p)
    4.15  {
    4.16  	relPos=p;
    4.17 +	if (parObj)
    4.18 +	{	parObj->calcBBoxSize();
    4.19 +		parObj->requestReposition();
    4.20 +	}	
    4.21 +}
    4.22 +
    4.23 +QPoint FloatObj::getRelPos ()
    4.24 +{
    4.25 +	return relPos;
    4.26  }
    4.27  
    4.28  void FloatObj::setZ(const int &i)
    4.29 @@ -141,12 +155,7 @@
    4.30  void FloatObj::select()
    4.31  {
    4.32      LinkableMapObj::select();
    4.33 -	// Temporary draw the link while FO is selected
    4.34 -	if (style==StyleUndef) 
    4.35 -	{
    4.36 -		setLinkStyle(getDefLinkStyle());
    4.37 -		setLinkColor(parObj->getLinkColor());
    4.38 -	}	
    4.39 +	setLinkColor(parObj->getLinkColor());
    4.40  
    4.41  	// Update FloatExport switch in context menu
    4.42  	if (floatExport)
    4.43 @@ -160,6 +169,5 @@
    4.44  void FloatObj::unselect()
    4.45  {
    4.46  	LinkableMapObj::unselect();
    4.47 -	setLinkStyle (StyleUndef);
    4.48  }
    4.49  
     5.1 --- a/floatobj.h	Tue Jan 03 09:44:41 2006 +0000
     5.2 +++ b/floatobj.h	Tue Jan 03 09:44:41 2006 +0000
     5.3 @@ -15,6 +15,7 @@
     5.4  	virtual bool load (const QString&)=0;
     5.5  	virtual void setRelPos();				// set relPos to current parentPos
     5.6  	virtual void setRelPos(const QPoint&);	
     5.7 +	virtual QPoint getRelPos();
     5.8  	virtual void setZ(const int&);		// set zPlane
     5.9  	virtual int z();
    5.10  	virtual void setUseOrientation (const bool &);
     6.1 --- a/headingobj.cpp	Tue Jan 03 09:44:41 2006 +0000
     6.2 +++ b/headingobj.cpp	Tue Jan 03 09:44:41 2006 +0000
     6.3 @@ -40,8 +40,10 @@
     6.4  void HeadingObj::move(double x, double y)
     6.5  {
     6.6      MapObj::move(x,y);
     6.7 +
     6.8      int h;	// height of a textline
     6.9      int ho;	// offset of height while drawing all lines
    6.10 +
    6.11      if (textline.first() )
    6.12  		h=textline.first()->boundingRect().height();
    6.13      else
    6.14 @@ -185,6 +187,7 @@
    6.15  		}		    
    6.16      }
    6.17  	setVisibility (visible);
    6.18 +	move (absPos.x(),absPos.y());
    6.19  	calcBBoxSize();
    6.20  }
    6.21