diff options
author | Michael Brasser <michael.brasser@nokia.com> | 2010-03-08 12:28:32 +1000 |
---|---|---|
committer | Michael Brasser <michael.brasser@nokia.com> | 2010-03-08 12:32:41 +1000 |
commit | 4ffb2a7a27ef5f06672e5f668e46d1657fa3e7ca (patch) | |
tree | fae95703c8451d7674c735ba926aec151fabaa8e /src/declarative | |
parent | 23440d84ddf78755e77cea75956cd7445647230a (diff) | |
download | qt4-tools-4ffb2a7a27ef5f06672e5f668e46d1657fa3e7ca.tar.gz |
Optimize Rectangle, Image, and Text creation.
Diffstat (limited to 'src/declarative')
9 files changed, 30 insertions, 24 deletions
diff --git a/src/declarative/graphicsitems/qdeclarativeimage.cpp b/src/declarative/graphicsitems/qdeclarativeimage.cpp index 2739ab8c95..a20d6bcc78 100644 --- a/src/declarative/graphicsitems/qdeclarativeimage.cpp +++ b/src/declarative/graphicsitems/qdeclarativeimage.cpp @@ -127,7 +127,6 @@ QT_BEGIN_NAMESPACE QDeclarativeImage::QDeclarativeImage(QDeclarativeItem *parent) : QDeclarativeImageBase(*(new QDeclarativeImagePrivate), parent) { - connect(this, SIGNAL(pixmapChanged()), this, SLOT(updatePaintedGeometry())); } QDeclarativeImage::QDeclarativeImage(QDeclarativeImagePrivate &dd, QDeclarativeItem *parent) @@ -172,7 +171,7 @@ void QDeclarativeImagePrivate::setPixmap(const QPixmap &pixmap) status = pix.isNull() ? QDeclarativeImageBase::Null : QDeclarativeImageBase::Ready; q->update(); - emit q->pixmapChanged(); + q->pixmapChange(); } /*! @@ -384,4 +383,10 @@ void QDeclarativeImage::paint(QPainter *p, const QStyleOptionGraphicsItem *, QWi } } +void QDeclarativeImage::pixmapChange() +{ + updatePaintedGeometry(); + QDeclarativeImageBase::pixmapChange(); +} + QT_END_NAMESPACE diff --git a/src/declarative/graphicsitems/qdeclarativeimage_p.h b/src/declarative/graphicsitems/qdeclarativeimage_p.h index fb77ac9fa5..7394774616 100644 --- a/src/declarative/graphicsitems/qdeclarativeimage_p.h +++ b/src/declarative/graphicsitems/qdeclarativeimage_p.h @@ -85,6 +85,7 @@ Q_SIGNALS: protected: QDeclarativeImage(QDeclarativeImagePrivate &dd, QDeclarativeItem *parent); void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry); + void pixmapChange(); protected Q_SLOTS: void updatePaintedGeometry(); diff --git a/src/declarative/graphicsitems/qdeclarativeimagebase.cpp b/src/declarative/graphicsitems/qdeclarativeimagebase.cpp index a8cce3f79f..0e9638d558 100644 --- a/src/declarative/graphicsitems/qdeclarativeimagebase.cpp +++ b/src/declarative/graphicsitems/qdeclarativeimagebase.cpp @@ -52,7 +52,6 @@ QT_BEGIN_NAMESPACE QDeclarativeImageBase::QDeclarativeImageBase(QDeclarativeImageBasePrivate &dd, QDeclarativeItem *parent) : QDeclarativeItem(dd, parent) { - setFlag(QGraphicsItem::ItemHasNoContents, false); } QDeclarativeImageBase::~QDeclarativeImageBase() @@ -131,7 +130,7 @@ void QDeclarativeImageBase::load() setImplicitWidth(0); setImplicitHeight(0); emit statusChanged(d->status); - emit pixmapChanged(); + pixmapChange(); update(); } else { d->status = Loading; @@ -173,7 +172,7 @@ void QDeclarativeImageBase::load() d->progress = 1.0; emit statusChanged(d->status); emit progressChanged(d->progress); - emit pixmapChanged(); + pixmapChange(); update(); } } @@ -197,7 +196,7 @@ void QDeclarativeImageBase::requestFinished() d->progress = 1.0; emit statusChanged(d->status); emit progressChanged(1.0); - emit pixmapChanged(); + pixmapChange(); update(); } @@ -218,4 +217,9 @@ void QDeclarativeImageBase::componentComplete() load(); } +void QDeclarativeImageBase::pixmapChange() +{ + emit pixmapChanged(); +} + QT_END_NAMESPACE diff --git a/src/declarative/graphicsitems/qdeclarativeimagebase_p.h b/src/declarative/graphicsitems/qdeclarativeimagebase_p.h index c8c50acb61..cfebdca7f3 100644 --- a/src/declarative/graphicsitems/qdeclarativeimagebase_p.h +++ b/src/declarative/graphicsitems/qdeclarativeimagebase_p.h @@ -81,6 +81,7 @@ Q_SIGNALS: protected: virtual void load(); virtual void componentComplete(); + virtual void pixmapChange(); QDeclarativeImageBase(QDeclarativeImageBasePrivate &dd, QDeclarativeItem *parent); private Q_SLOTS: diff --git a/src/declarative/graphicsitems/qdeclarativeimagebase_p_p.h b/src/declarative/graphicsitems/qdeclarativeimagebase_p_p.h index 2e062a8e69..c4a61f34cc 100644 --- a/src/declarative/graphicsitems/qdeclarativeimagebase_p_p.h +++ b/src/declarative/graphicsitems/qdeclarativeimagebase_p_p.h @@ -71,6 +71,7 @@ public: pendingPixmapCache(false), async(false) { + QGraphicsItemPrivate::flags = QGraphicsItemPrivate::flags & ~QGraphicsItem::ItemHasNoContents; } QPixmap pix; diff --git a/src/declarative/graphicsitems/qdeclarativerectangle.cpp b/src/declarative/graphicsitems/qdeclarativerectangle.cpp index 05fe0f75de..207d05e6c4 100644 --- a/src/declarative/graphicsitems/qdeclarativerectangle.cpp +++ b/src/declarative/graphicsitems/qdeclarativerectangle.cpp @@ -180,9 +180,6 @@ void QDeclarativeGradient::doUpdate() QDeclarativeRectangle::QDeclarativeRectangle(QDeclarativeItem *parent) : QDeclarativeItem(*(new QDeclarativeRectanglePrivate), parent) { - Q_D(QDeclarativeRectangle); - d->init(); - setFlag(QGraphicsItem::ItemHasNoContents, false); } void QDeclarativeRectangle::doUpdate() diff --git a/src/declarative/graphicsitems/qdeclarativerectangle_p_p.h b/src/declarative/graphicsitems/qdeclarativerectangle_p_p.h index b87c57fca6..6bae219072 100644 --- a/src/declarative/graphicsitems/qdeclarativerectangle_p_p.h +++ b/src/declarative/graphicsitems/qdeclarativerectangle_p_p.h @@ -67,6 +67,7 @@ public: QDeclarativeRectanglePrivate() : color(Qt::white), gradient(0), pen(0), radius(0), paintmargin(0) { + QGraphicsItemPrivate::flags = QGraphicsItemPrivate::flags & ~QGraphicsItem::ItemHasNoContents; } ~QDeclarativeRectanglePrivate() @@ -74,13 +75,13 @@ public: delete pen; } - void init() - { - } - - QColor getColor(); QColor color; QDeclarativeGradient *gradient; + QDeclarativePen *pen; + qreal radius; + qreal paintmargin; + QPixmap rectImage; + QDeclarativePen *getPen() { if (!pen) { Q_Q(QDeclarativeRectangle); @@ -89,10 +90,6 @@ public: } return pen; } - QDeclarativePen *pen; - qreal radius; - qreal paintmargin; - QPixmap rectImage; void setPaintMargin(qreal margin) { diff --git a/src/declarative/graphicsitems/qdeclarativetext.cpp b/src/declarative/graphicsitems/qdeclarativetext.cpp index ca253df32c..05139f6c21 100644 --- a/src/declarative/graphicsitems/qdeclarativetext.cpp +++ b/src/declarative/graphicsitems/qdeclarativetext.cpp @@ -110,8 +110,6 @@ QT_BEGIN_NAMESPACE QDeclarativeText::QDeclarativeText(QDeclarativeItem *parent) : QDeclarativeItem(*(new QDeclarativeTextPrivate), parent) { - setAcceptedMouseButtons(Qt::LeftButton); - setFlag(QGraphicsItem::ItemHasNoContents, false); } QDeclarativeText::~QDeclarativeText() diff --git a/src/declarative/graphicsitems/qdeclarativetext_p_p.h b/src/declarative/graphicsitems/qdeclarativetext_p_p.h index a0c8abeef6..0d9a0a6d25 100644 --- a/src/declarative/graphicsitems/qdeclarativetext_p_p.h +++ b/src/declarative/graphicsitems/qdeclarativetext_p_p.h @@ -70,14 +70,16 @@ class QDeclarativeTextPrivate : public QDeclarativeItemPrivate Q_DECLARE_PUBLIC(QDeclarativeText) public: QDeclarativeTextPrivate() - : color((QRgb)0), style(QDeclarativeText::Normal), imgDirty(true), + : color((QRgb)0), style(QDeclarativeText::Normal), hAlign(QDeclarativeText::AlignLeft), vAlign(QDeclarativeText::AlignTop), elideMode(QDeclarativeText::ElideNone), - dirty(true), wrap(false), richText(false), singleline(false), cache(true), doc(0), + imgDirty(true), dirty(true), wrap(false), richText(false), singleline(false), cache(true), doc(0), format(QDeclarativeText::AutoText) { #if defined(QML_NO_TEXT_CACHE) cache = false; #endif + QGraphicsItemPrivate::acceptedMouseButtons = Qt::LeftButton; + QGraphicsItemPrivate::flags = QGraphicsItemPrivate::flags & ~QGraphicsItem::ItemHasNoContents; } ~QDeclarativeTextPrivate(); @@ -106,12 +108,12 @@ public: QDeclarativeText::TextStyle style; QColor styleColor; QString activeLink; - bool imgDirty; QPixmap imgCache; QPixmap imgStyleCache; QDeclarativeText::HAlignment hAlign; QDeclarativeText::VAlignment vAlign; - QDeclarativeText::TextElideMode elideMode; + QDeclarativeText::TextElideMode elideMode; + bool imgDirty:1; bool dirty:1; bool wrap:1; bool richText:1; |