imageobj.cpp
author insilmaril
Wed Apr 09 07:14:13 2008 +0000 (2008-04-09)
changeset 686 d6cc3365c8b8
parent 421 5522d1da7e37
permissions -rw-r--r--
Removed unfinished attribute access for now
     1 #include "imageobj.h"
     2 #include "mapobj.h"
     3 
     4 /////////////////////////////////////////////////////////////////
     5 // ImageObj
     6 /////////////////////////////////////////////////////////////////
     7 ImageObj::ImageObj( QGraphicsScene *scene) : QGraphicsPixmapItem (NULL,scene )
     8 {
     9 //	cout << "Const ImageObj (scene)\n";
    10 
    11 	setShapeMode (QGraphicsPixmapItem::BoundingRectShape);
    12     setZValue(Z_ICON);	
    13 	mapScene=scene;
    14 	hide();
    15 }
    16 
    17 ImageObj::~ImageObj()
    18 {
    19  //  cout << "Destr ImageObj\n";
    20 }
    21 
    22 void ImageObj::copy(ImageObj* other)
    23 {
    24 	prepareGeometryChange();
    25 	setVisibility (other->isVisible() );
    26 	setPixmap (other->QGraphicsPixmapItem::pixmap());	
    27 	setPos (other->pos());
    28 }
    29 
    30 void ImageObj::setVisibility (bool v)
    31 {
    32 	if (v)	
    33 		show();
    34 	else
    35 		hide();
    36 }
    37 
    38 void ImageObj::save(const QString &fn, const char *format)
    39 {
    40 	pixmap().save (fn,format,100);
    41 }
    42 
    43 bool ImageObj::load (const QString &fn)
    44 {
    45 	QPixmap pixmap;
    46     if (pixmap.load (fn)) 
    47 	{
    48 		prepareGeometryChange();
    49 		setPixmap (pixmap);
    50 		return true;
    51 	}	
    52 	return false;
    53 }
    54 
    55 bool ImageObj::load (const QPixmap &pm)
    56 {
    57 	prepareGeometryChange();
    58 	setPixmap (pm);
    59 	return true;
    60 }
    61 
    62