Add missing NOTIFY signals and 'null' property to QPixmapItem and QImageItem

Reviewed-by: Marco Martin
This commit is contained in:
Martin Klapetek 2012-08-14 19:58:21 +02:00
parent 650258aa88
commit 5fce412fe0
4 changed files with 30 additions and 2 deletions

View File

@ -37,10 +37,15 @@ QImageItem::~QImageItem()
void QImageItem::setImage(const QImage &image)
{
bool oldImageNull = m_image.isNull();
m_image = image;
update();
emit nativeWidthChanged();
emit nativeHeightChanged();
emit imageChanged();
if (oldImageNull != m_image.isNull()) {
emit nullChanged();
}
}
QImage QImageItem::image() const
@ -143,5 +148,9 @@ void QImageItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option
painter->restore();
}
bool QImageItem::isNull() const
{
return m_image.isNull();
}
#include "qimageitem.moc"

View File

@ -26,11 +26,12 @@ class QImageItem : public QDeclarativeItem
{
Q_OBJECT
Q_PROPERTY(QImage image READ image WRITE setImage)
Q_PROPERTY(QImage image READ image WRITE setImage NOTIFY imageChanged)
Q_PROPERTY(bool smooth READ smooth WRITE setSmooth)
Q_PROPERTY(int nativeWidth READ nativeWidth NOTIFY nativeWidthChanged)
Q_PROPERTY(int nativeHeight READ nativeHeight NOTIFY nativeHeightChanged)
Q_PROPERTY(FillMode fillMode READ fillMode WRITE setFillMode NOTIFY fillModeChanged)
Q_PROPERTY(bool null READ isNull NOTIFY nullChanged)
Q_ENUMS(FillMode)
public:
@ -60,10 +61,14 @@ public:
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
bool isNull() const;
Q_SIGNALS:
void nativeWidthChanged();
void nativeHeightChanged();
void fillModeChanged();
void imageChanged();
void nullChanged();
private:
QImage m_image;

View File

@ -37,10 +37,15 @@ QPixmapItem::~QPixmapItem()
void QPixmapItem::setPixmap(const QPixmap &pixmap)
{
bool oldPixmapNull = m_pixmap.isNull();
m_pixmap = pixmap;
update();
emit nativeWidthChanged();
emit nativeHeightChanged();
emit pixmapChanged();
if (oldPixmapNull != m_pixmap.isNull()) {
emit nullChanged();
}
}
QPixmap QPixmapItem::pixmap() const
@ -143,5 +148,9 @@ void QPixmapItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *optio
painter->restore();
}
bool QPixmapItem::isNull() const
{
return m_pixmap.isNull();
}
#include "qpixmapitem.moc"

View File

@ -26,11 +26,12 @@ class QPixmapItem : public QDeclarativeItem
{
Q_OBJECT
Q_PROPERTY(QPixmap pixmap READ pixmap WRITE setPixmap)
Q_PROPERTY(QPixmap pixmap READ pixmap WRITE setPixmap NOTIFY pixmapChanged)
Q_PROPERTY(bool smooth READ smooth WRITE setSmooth)
Q_PROPERTY(int nativeWidth READ nativeWidth NOTIFY nativeWidthChanged)
Q_PROPERTY(int nativeHeight READ nativeHeight NOTIFY nativeHeightChanged)
Q_PROPERTY(FillMode fillMode READ fillMode WRITE setFillMode NOTIFY fillModeChanged)
Q_PROPERTY(bool null READ isNull NOTIFY nullChanged)
Q_ENUMS(FillMode)
public:
@ -60,10 +61,14 @@ public:
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
bool isNull() const;
Q_SIGNALS:
void nativeWidthChanged();
void nativeHeightChanged();
void fillModeChanged();
void pixmapChanged();
void nullChanged();
private:
QPixmap m_pixmap;