1 #include <QImageReader>
4 #include "floatimageobj.h"
7 /////////////////////////////////////////////////////////////////
9 /////////////////////////////////////////////////////////////////
11 FloatImageObj::FloatImageObj (QGraphicsScene* s,TreeItem *ti):FloatObj(s,ti)
13 //cout << "Const FloatImageObj s="<<s<<" ti="<<ti<<endl;
18 FloatImageObj::~FloatImageObj ()
20 // cout << "Destr FloatImageObj "<<this<<"\n";
24 void FloatImageObj::init ()
26 icon=new ImageObj (scene);
27 icon->setPos (absPos.x(), absPos.y() );
28 icon->setVisibility (true);
29 setZValue (Z_FLOATIMG);
30 bbox.setSize (QSizeF(icon->boundingRect().width(), icon->boundingRect().height()));
31 clickBox.setSize (QSizeF(icon->boundingRect().width(), icon->boundingRect().height()));filename="";
32 originalFilename="no original name available";
37 systemFlags->setShowFlags(false);
40 void FloatImageObj::copy (FloatImageObj* other)
42 FloatObj::copy (other);
43 icon->copy (other->icon);
44 filetype=other->filetype;
45 filename=other->filename;
46 originalFilename=other->originalFilename;
50 void FloatImageObj::setZValue (const int &i)
56 int FloatImageObj::z ()
58 return qRound (icon->zValue());
61 void FloatImageObj::load (const QPixmap &pixmap)
64 bbox.setSize (QSizeF(icon->boundingRect().width()+8, icon->boundingRect().height()+8));
65 clickBox.setSize (QSizeF(icon->boundingRect().width()+8, icon->boundingRect().height()+8));
68 filename="No filename given";
71 bool FloatImageObj::load (const QString &fn)
73 QImageReader reader (fn);
76 if( reader.read (&img))
78 icon->setPixmap(QPixmap::fromImage(img));
79 bbox.setSize (QSizeF(icon->boundingRect().width()+8, icon->boundingRect().height()+8));
82 filetype=reader.format();
83 setOriginalFilename (fn);
90 void FloatImageObj::save (const QString &fn, const QString &format)
92 icon->save (fn,qPrintable (format));
95 void FloatImageObj::setOriginalFilename(const QString & fn)
99 // Set short name, too. Search from behind:
100 int i=originalFilename.findRev("/");
101 if (i>=0) originalFilename=originalFilename.remove (0,i+1);
104 QString FloatImageObj::getOriginalFilename()
106 return originalFilename;
109 void FloatImageObj::setVisibility(bool v)
111 OrnamentedObj::setVisibility(v);
113 icon->setVisibility(true);
115 icon->setVisibility(false);
118 void FloatImageObj::move (double x, double y)
121 icon->setPos (x+4,y+4);
125 void FloatImageObj::move (QPointF p)
127 OrnamentedObj::move (p.x(),p.y());
130 void FloatImageObj::positionBBox()
135 void FloatImageObj::calcBBoxSize()
140 QRectF FloatImageObj::getBBoxSizeWithChildren()
142 //TODO abstract in linkablemapobj.h, not calculated
146 void FloatImageObj::calcBBoxSizeWithChildren()
148 //TODO abstract in linkablemapobj.h