3 #include "branchitem.h"
4 #include "mapobj.h" // z-values
10 ImageItem::ImageItem()
15 ImageItem::ImageItem (const QList<QVariant> &data, TreeItem *parent):MapItem (data,parent)
20 ImageItem::~ImageItem()
22 //cout <<"Destr ImageItem\n";
26 void ImageItem::init()
30 hideLinkUnselected=true;
31 originalFilename="no original name available";
36 ImageItem::ImageType ImageItem::getImageType()
41 void ImageItem::load(const QPixmap &pm)
44 if (lmo) ((FloatImageObj*)lmo)->load (pixmap);
47 bool ImageItem::load(const QString &fname)
49 bool ok=pixmap.load (fname);
52 setOriginalFilename (fname);
53 setHeading (originalFilename);
54 ((FloatImageObj*)lmo)->load (pixmap);
59 FloatImageObj* ImageItem::createMapObj(QGraphicsScene *scene)
61 FloatImageObj *fio=new FloatImageObj (scene,this);
63 fio->setParObj ( ((MapItem*)parentItem)->getLMO());
64 if (((BranchItem*)parentItem)->isScrolled() || !((MapItem*)parentItem)->getLMO()->isVisibleObj() )
65 fio->setVisibility (false);
67 fio->setZValue(zValue);
69 //cout << "II::createMO fio="<<fio<<" tI="<<fio->getTreeItem()<<endl;
73 void ImageItem::setZValue(int z)
76 if (lmo) ((FloatImageObj*)lmo)->setZValue(z);
79 void ImageItem::setOriginalFilename(const QString & fn)
83 // Set short name. Search from behind:
84 int i=originalFilename.findRev("/");
85 if (i>=0) originalFilename=originalFilename.remove (0,i+1);
86 setHeading (originalFilename);
89 QString ImageItem::getOriginalFilename()
91 return originalFilename;
94 void ImageItem::save(const QString &fn, const QString &format)
96 pixmap.save (fn,qPrintable (format));
99 QString ImageItem::saveToDir (const QString &tmpdir,const QString &prefix)
101 if (hidden) return "";
103 QString zAttr=attribut ("zValue",QString().setNum(zValue));
106 ulong n=reinterpret_cast <ulong> (this);
108 url="images/"+prefix+"image-" + QString().number(n,10) + ".png" ;
110 // And really save the image
111 pixmap.save (tmpdir +"/"+ url, "PNG");
113 QString nameAttr=attribut ("originalName",originalFilename);
115 return singleElement ("floatimage",
119 +attribut ("href",QString ("file:")+url)