1 #include "floatimageobj.h"
7 /////////////////////////////////////////////////////////////////
9 /////////////////////////////////////////////////////////////////
11 uint FloatImageObj::saveCounter=0; // make instance
14 FloatImageObj::FloatImageObj ():FloatObj()
16 // cout << "Const FloatImageObj ()\n";
22 FloatImageObj::FloatImageObj (Q3Canvas* c):FloatObj(c)
24 // cout << "Const FloatImageObj (c) called from MapCenterObj (c)\n";
30 FloatImageObj::FloatImageObj (Q3Canvas* c, OrnamentedObj* p):FloatObj(c,p)
32 // cout << "Const FloatImageObj (c,p)\n";
36 FloatImageObj::~FloatImageObj ()
38 // cout << "Destr FloatImageObj "<<this<<"\n";
42 void FloatImageObj::init ()
44 icon=new ImageObj (canvas);
45 icon->move (absPos.x(), absPos.y() );
46 icon->setVisibility (true);
48 bbox.setSize (QSize(icon->size().width(), icon->size().height()));
49 clickBox.setSize (QSize(icon->size().width(), icon->size().height()));
51 originalFilename="no original name available";
57 systemFlags->setShowFlags(false);
60 void FloatImageObj::copy (FloatImageObj* other)
62 FloatObj::copy (other);
63 icon->copy (other->icon);
64 filetype=other->filetype;
65 filename=other->filename;
66 originalFilename=other->originalFilename;
67 saveInMap=other->saveInMap;
71 void FloatImageObj::setZ (const int &i)
77 int FloatImageObj::z ()
79 return qRound (icon->z());
82 void FloatImageObj::load (const QPixmap &pixmap)
85 bbox.setSize (QSize(icon->size().width()+8, icon->size().height()+8));
86 clickBox.setSize (QSize(icon->size().width()+8, icon->size().height()+8));
89 filename="noname.png";
92 bool FloatImageObj::load (const QString &fn)
96 bbox.setSize (QSize(icon->size().width()+8, icon->size().height()+8));
99 //FIXME QT3 was filetype=QPixmap::imageFormat (fn);
100 setOriginalFilename (fn);
107 void FloatImageObj::save (const QString &fn, const QString &format)
109 icon->save (fn,qPrintable (format));
112 void FloatImageObj::setOriginalFilename(const QString & fn)
116 // Set short name, too. Search from behind:
117 int i=originalFilename.findRev("/");
118 if (i>=0) originalFilename=originalFilename.remove (0,i+1);
121 QString FloatImageObj::getOriginalFilename()
123 return originalFilename;
126 void FloatImageObj::setVisibility(bool v)
128 OrnamentedObj::setVisibility(v);
130 icon->setVisibility(true);
132 icon->setVisibility(false);
135 void FloatImageObj::move (double x, double y)
138 icon->move (x+4,y+4);
142 void FloatImageObj::move (QPoint p)
147 void FloatImageObj::positionBBox()
152 void FloatImageObj::calcBBoxSize()
157 QString FloatImageObj::saveToDir (const QString &tmpdir,const QString &prefix, const QPoint &p)
159 if (hidden) return "";
163 QString useOrientAttr;
165 useOrientAttr=attribut ("useOrientation","true");
167 useOrientAttr=attribut ("useOrientation","false");
169 QString saveInMapAttr;
171 saveInMapAttr=attribut ("saveInMap","true");
174 saveInMapAttr=attribut ("saveInMap","false");
178 exportAttr=attribut ("floatExport","true");
180 exportAttr=attribut ("floatExport","false");
182 QString zAttr=attribut ("zPlane",QString().setNum(zPlane));
185 url="images/"+prefix+"image-" + QString().number(saveCounter,10) + "." +filetype;
187 // And really save the image
188 icon->save (tmpdir + "/" + url, "PNG");
190 QString nameAttr=attribut ("orgName",originalFilename);
192 return singleElement ("floatimage",
198 +attribut ("href",QString ("file:")+url)
203 void FloatImageObj::resetSaveCounter()
209 QRect FloatImageObj::getTotalBBox()
214 QRect FloatImageObj::getBBoxSizeWithChilds()
216 //FIXME abstract in linkablemapobj.h, not calculated
220 void FloatImageObj::calcBBoxSizeWithChilds()
222 //FIXME abstract in linkablemapobj.h
225 QString FloatImageObj::getSelectString()
230 if (parObj->getDepth()==0)
231 s= "fi:" + QString("%1").arg( ((BranchObj*)(parObj))->getFloatImageNum(this));
233 s= ((BranchObj*)(parObj))->getSelectString() + ",fi:" + QString("%1").arg( ((BranchObj*)(parObj))->getFloatImageNum(this));