1.1 --- a/floatimageobj.cpp Sun Jan 30 12:58:47 2005 +0000
1.2 +++ b/floatimageobj.cpp Tue Jun 06 14:58:11 2006 +0000
1.3 @@ -1,13 +1,14 @@
1.4 #include "floatimageobj.h"
1.5 #include "branchobj.h"
1.6 -#include <math.h>
1.7 +//Added by qt3to4:
1.8 +#include <QPixmap>
1.9
1.10
1.11 /////////////////////////////////////////////////////////////////
1.12 // FloatImageObj
1.13 /////////////////////////////////////////////////////////////////
1.14
1.15 -int FloatImageObj::counter=0; // make instance
1.16 +uint FloatImageObj::saveCounter=0; // make instance
1.17
1.18
1.19 FloatImageObj::FloatImageObj ():FloatObj()
1.20 @@ -18,7 +19,7 @@
1.21 depth=-1;
1.22 }
1.23
1.24 -FloatImageObj::FloatImageObj (QCanvas* c):FloatObj(c)
1.25 +FloatImageObj::FloatImageObj (Q3Canvas* c):FloatObj(c)
1.26 {
1.27 // cout << "Const FloatImageObj (c) called from MapCenterObj (c)\n";
1.28 setParObj (this);
1.29 @@ -26,7 +27,7 @@
1.30 depth=-1;
1.31 }
1.32
1.33 -FloatImageObj::FloatImageObj (QCanvas* c, LinkableMapObj* p):FloatObj(c,p)
1.34 +FloatImageObj::FloatImageObj (Q3Canvas* c, OrnamentedObj* p):FloatObj(c,p)
1.35 {
1.36 // cout << "Const FloatImageObj (c,p)\n";
1.37 init();
1.38 @@ -43,18 +44,26 @@
1.39 icon=new ImageObj (canvas);
1.40 icon->move (absPos.x(), absPos.y() );
1.41 icon->setVisibility (true);
1.42 + setZ (Z_FLOATIMG);
1.43 bbox.setSize (QSize(icon->size().width(), icon->size().height()));
1.44 + clickBox.setSize (QSize(icon->size().width(), icon->size().height()));
1.45 filename="";
1.46 originalFilename="no original name available";
1.47 filetype="";
1.48 saveInMap=true;
1.49 + useRelPos=true;
1.50 +
1.51 + //Hide flags
1.52 + systemFlags->setShowFlags(false);
1.53 }
1.54
1.55 void FloatImageObj::copy (FloatImageObj* other)
1.56 {
1.57 FloatObj::copy (other);
1.58 icon->copy (other->icon);
1.59 + filetype=other->filetype;
1.60 filename=other->filename;
1.61 + originalFilename=other->originalFilename;
1.62 saveInMap=other->saveInMap;
1.63 positionBBox();
1.64 }
1.65 @@ -67,7 +76,17 @@
1.66
1.67 int FloatImageObj::z ()
1.68 {
1.69 - return lrint (icon->z());
1.70 + return qRound (icon->z());
1.71 +}
1.72 +
1.73 +void FloatImageObj::load (const QPixmap &pixmap)
1.74 +{
1.75 + icon->load(pixmap);
1.76 + bbox.setSize (QSize(icon->size().width()+8, icon->size().height()+8));
1.77 + clickBox.setSize (QSize(icon->size().width()+8, icon->size().height()+8));
1.78 + positionBBox();
1.79 + filetype="PNG";
1.80 + filename="noname.png";
1.81 }
1.82
1.83 bool FloatImageObj::load (const QString &fn)
1.84 @@ -77,7 +96,8 @@
1.85 bbox.setSize (QSize(icon->size().width()+8, icon->size().height()+8));
1.86 positionBBox();
1.87 filename=fn;
1.88 - filetype=QPixmap::imageFormat (fn);
1.89 +//FIXME QT3 was filetype=QPixmap::imageFormat (fn);
1.90 + setOriginalFilename (fn);
1.91 return true;
1.92 } else
1.93 return false;
1.94 @@ -92,6 +112,10 @@
1.95 void FloatImageObj::setOriginalFilename(const QString & fn)
1.96 {
1.97 originalFilename=fn;
1.98 +
1.99 + // Set short name, too. Search from behind:
1.100 + int i=originalFilename.findRev("/");
1.101 + if (i>=0) originalFilename=originalFilename.remove (0,i+1);
1.102 }
1.103
1.104 QString FloatImageObj::getOriginalFilename()
1.105 @@ -101,7 +125,7 @@
1.106
1.107 void FloatImageObj::setVisibility(bool v)
1.108 {
1.109 - LinkableMapObj::setVisibility(v);
1.110 + OrnamentedObj::setVisibility(v);
1.111 if (v)
1.112 icon->setVisibility(true);
1.113 else
1.114 @@ -122,7 +146,7 @@
1.115
1.116 void FloatImageObj::positionBBox()
1.117 {
1.118 - // TODO
1.119 + clickBox=bbox;
1.120 }
1.121
1.122 void FloatImageObj::calcBBoxSize()
1.123 @@ -130,14 +154,12 @@
1.124 // TODO
1.125 }
1.126
1.127 -QString FloatImageObj::saveToDir (const QString &tmpdir,const QString &prefix)
1.128 +QString FloatImageObj::saveToDir (const QString &tmpdir,const QString &prefix, const QPoint &p)
1.129 {
1.130 - counter++;
1.131 + if (hidden) return "";
1.132
1.133 - QString posAttr=
1.134 - attribut("relPosX",QString().setNum(relPos.x(),10)) +
1.135 - attribut("relPosY",QString().setNum(relPos.y(),10));
1.136 -
1.137 + saveCounter++;
1.138 +
1.139 QString useOrientAttr;
1.140 if (useOrientation)
1.141 useOrientAttr=attribut ("useOrientation","true");
1.142 @@ -164,24 +186,27 @@
1.143 if (filetype=="GIF")
1.144 filetype="PNG";
1.145
1.146 - url="images/"+prefix+"image-" + QString().number(counter,10) + "." +filetype;
1.147 + url="images/"+prefix+"image-" + QString().number(saveCounter,10) + "." +filetype;
1.148
1.149 // And really save the image
1.150 icon->save (tmpdir + "/" + url, filetype);
1.151 +
1.152 + QString nameAttr=attribut ("orgName",originalFilename);
1.153
1.154 return singleElement ("floatimage",
1.155 - posAttr +
1.156 - useOrientAttr +
1.157 - saveInMapAttr +
1.158 - exportAttr +
1.159 - zAttr +
1.160 - attribut ("href",QString ("file:")+url)
1.161 + getOrnAttr()
1.162 + +useOrientAttr
1.163 + +saveInMapAttr
1.164 + +exportAttr
1.165 + +zAttr
1.166 + +attribut ("href",QString ("file:")+url)
1.167 + +nameAttr
1.168 );
1.169 }
1.170
1.171 void FloatImageObj::resetSaveCounter()
1.172 {
1.173 - counter=0;
1.174 + saveCounter=0;
1.175 }
1.176
1.177