summaryrefslogtreecommitdiffstats
path: root/demos/sub-attaq/pixmapitem.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'demos/sub-attaq/pixmapitem.cpp')
-rw-r--r--demos/sub-attaq/pixmapitem.cpp33
1 files changed, 25 insertions, 8 deletions
diff --git a/demos/sub-attaq/pixmapitem.cpp b/demos/sub-attaq/pixmapitem.cpp
index 9abf745..fcc7ce9 100644
--- a/demos/sub-attaq/pixmapitem.cpp
+++ b/demos/sub-attaq/pixmapitem.cpp
@@ -43,17 +43,34 @@
#include "pixmapitem.h"
//Qt
-#include <QtCore/QDir>
+#include <QPainter>
-PixmapItem::PixmapItem(const QString &fileName,GraphicsScene::Mode mode, QGraphicsItem * parent) : QGraphicsPixmapItem(parent),name(fileName)
+PixmapItem::PixmapItem(const QString &fileName,GraphicsScene::Mode mode, QGraphicsItem * parent) : QGraphicsObject(parent)
{
- loadPixmap(mode);
+ if (mode == GraphicsScene::Big)
+ pix = ":/big/" + fileName;
+ else
+ pix = ":/small/" + fileName;
}
-void PixmapItem::loadPixmap(GraphicsScene::Mode mode)
+PixmapItem::PixmapItem(const QString &fileName, QGraphicsScene *scene) : QGraphicsObject(), pix(fileName)
{
- if (mode == GraphicsScene::Big)
- setPixmap(":/big/" + name);
- else
- setPixmap(":/small/" + name);
+ scene->addItem(this);
}
+
+QSizeF PixmapItem::size() const
+{
+ return pix.size();
+}
+
+QRectF PixmapItem::boundingRect() const
+{
+ return QRectF(QPointF(0, 0), pix.size());
+}
+
+void PixmapItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *)
+{
+ painter->drawPixmap(0, 0, pix);
+}
+
+