Add missing NOTIFY signals and 'null' property to QPixmapItem and QImageItem
Reviewed-by: Marco Martin
This commit is contained in:
parent
650258aa88
commit
5fce412fe0
@ -37,10 +37,15 @@ QImageItem::~QImageItem()
|
|||||||
|
|
||||||
void QImageItem::setImage(const QImage &image)
|
void QImageItem::setImage(const QImage &image)
|
||||||
{
|
{
|
||||||
|
bool oldImageNull = m_image.isNull();
|
||||||
m_image = image;
|
m_image = image;
|
||||||
update();
|
update();
|
||||||
emit nativeWidthChanged();
|
emit nativeWidthChanged();
|
||||||
emit nativeHeightChanged();
|
emit nativeHeightChanged();
|
||||||
|
emit imageChanged();
|
||||||
|
if (oldImageNull != m_image.isNull()) {
|
||||||
|
emit nullChanged();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QImage QImageItem::image() const
|
QImage QImageItem::image() const
|
||||||
@ -143,5 +148,9 @@ void QImageItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option
|
|||||||
painter->restore();
|
painter->restore();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool QImageItem::isNull() const
|
||||||
|
{
|
||||||
|
return m_image.isNull();
|
||||||
|
}
|
||||||
|
|
||||||
#include "qimageitem.moc"
|
#include "qimageitem.moc"
|
||||||
|
@ -26,11 +26,12 @@ class QImageItem : public QDeclarativeItem
|
|||||||
{
|
{
|
||||||
Q_OBJECT
|
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(bool smooth READ smooth WRITE setSmooth)
|
||||||
Q_PROPERTY(int nativeWidth READ nativeWidth NOTIFY nativeWidthChanged)
|
Q_PROPERTY(int nativeWidth READ nativeWidth NOTIFY nativeWidthChanged)
|
||||||
Q_PROPERTY(int nativeHeight READ nativeHeight NOTIFY nativeHeightChanged)
|
Q_PROPERTY(int nativeHeight READ nativeHeight NOTIFY nativeHeightChanged)
|
||||||
Q_PROPERTY(FillMode fillMode READ fillMode WRITE setFillMode NOTIFY fillModeChanged)
|
Q_PROPERTY(FillMode fillMode READ fillMode WRITE setFillMode NOTIFY fillModeChanged)
|
||||||
|
Q_PROPERTY(bool null READ isNull NOTIFY nullChanged)
|
||||||
Q_ENUMS(FillMode)
|
Q_ENUMS(FillMode)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -60,10 +61,14 @@ public:
|
|||||||
|
|
||||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
||||||
|
|
||||||
|
bool isNull() const;
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void nativeWidthChanged();
|
void nativeWidthChanged();
|
||||||
void nativeHeightChanged();
|
void nativeHeightChanged();
|
||||||
void fillModeChanged();
|
void fillModeChanged();
|
||||||
|
void imageChanged();
|
||||||
|
void nullChanged();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QImage m_image;
|
QImage m_image;
|
||||||
|
@ -37,10 +37,15 @@ QPixmapItem::~QPixmapItem()
|
|||||||
|
|
||||||
void QPixmapItem::setPixmap(const QPixmap &pixmap)
|
void QPixmapItem::setPixmap(const QPixmap &pixmap)
|
||||||
{
|
{
|
||||||
|
bool oldPixmapNull = m_pixmap.isNull();
|
||||||
m_pixmap = pixmap;
|
m_pixmap = pixmap;
|
||||||
update();
|
update();
|
||||||
emit nativeWidthChanged();
|
emit nativeWidthChanged();
|
||||||
emit nativeHeightChanged();
|
emit nativeHeightChanged();
|
||||||
|
emit pixmapChanged();
|
||||||
|
if (oldPixmapNull != m_pixmap.isNull()) {
|
||||||
|
emit nullChanged();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QPixmap QPixmapItem::pixmap() const
|
QPixmap QPixmapItem::pixmap() const
|
||||||
@ -143,5 +148,9 @@ void QPixmapItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *optio
|
|||||||
painter->restore();
|
painter->restore();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool QPixmapItem::isNull() const
|
||||||
|
{
|
||||||
|
return m_pixmap.isNull();
|
||||||
|
}
|
||||||
|
|
||||||
#include "qpixmapitem.moc"
|
#include "qpixmapitem.moc"
|
||||||
|
@ -26,11 +26,12 @@ class QPixmapItem : public QDeclarativeItem
|
|||||||
{
|
{
|
||||||
Q_OBJECT
|
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(bool smooth READ smooth WRITE setSmooth)
|
||||||
Q_PROPERTY(int nativeWidth READ nativeWidth NOTIFY nativeWidthChanged)
|
Q_PROPERTY(int nativeWidth READ nativeWidth NOTIFY nativeWidthChanged)
|
||||||
Q_PROPERTY(int nativeHeight READ nativeHeight NOTIFY nativeHeightChanged)
|
Q_PROPERTY(int nativeHeight READ nativeHeight NOTIFY nativeHeightChanged)
|
||||||
Q_PROPERTY(FillMode fillMode READ fillMode WRITE setFillMode NOTIFY fillModeChanged)
|
Q_PROPERTY(FillMode fillMode READ fillMode WRITE setFillMode NOTIFY fillModeChanged)
|
||||||
|
Q_PROPERTY(bool null READ isNull NOTIFY nullChanged)
|
||||||
Q_ENUMS(FillMode)
|
Q_ENUMS(FillMode)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -60,10 +61,14 @@ public:
|
|||||||
|
|
||||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
||||||
|
|
||||||
|
bool isNull() const;
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void nativeWidthChanged();
|
void nativeWidthChanged();
|
||||||
void nativeHeightChanged();
|
void nativeHeightChanged();
|
||||||
void fillModeChanged();
|
void fillModeChanged();
|
||||||
|
void pixmapChanged();
|
||||||
|
void nullChanged();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QPixmap m_pixmap;
|
QPixmap m_pixmap;
|
||||||
|
Loading…
Reference in New Issue
Block a user