diff options
author | Marco Bubke <marco.bubke@nokia.com> | 2010-01-06 14:13:10 (GMT) |
---|---|---|
committer | Marco Bubke <marco.bubke@nokia.com> | 2010-01-06 14:13:10 (GMT) |
commit | 19fbfaa5aa7173a46fdf9fe765836d02a4a7b721 (patch) | |
tree | ff50dc35fc6467bfea633315ee42ed73d3207797 /src/declarative/graphicsitems | |
parent | 82639859d2fa69c8d7c464a29a8f9cd5d284bb9d (diff) | |
download | Qt-19fbfaa5aa7173a46fdf9fe765836d02a4a7b721.zip Qt-19fbfaa5aa7173a46fdf9fe765836d02a4a7b721.tar.gz Qt-19fbfaa5aa7173a46fdf9fe765836d02a4a7b721.tar.bz2 |
Add notifier for QmlGraphicsText
Bauhaus needs the notifier to track changes in the items.
Task-number: BAUHAUS-243
Reviewed-by: Kai Koehne
Diffstat (limited to 'src/declarative/graphicsitems')
-rw-r--r-- | src/declarative/graphicsitems/qmlgraphicstext.cpp | 19 | ||||
-rw-r--r-- | src/declarative/graphicsitems/qmlgraphicstext_p.h | 27 |
2 files changed, 37 insertions, 9 deletions
diff --git a/src/declarative/graphicsitems/qmlgraphicstext.cpp b/src/declarative/graphicsitems/qmlgraphicstext.cpp index ce86b8f..854ef45 100644 --- a/src/declarative/graphicsitems/qmlgraphicstext.cpp +++ b/src/declarative/graphicsitems/qmlgraphicstext.cpp @@ -142,10 +142,14 @@ QFont QmlGraphicsText::font() const void QmlGraphicsText::setFont(const QFont &font) { Q_D(QmlGraphicsText); + if (d->font == font) + return; + d->font = font; d->updateLayout(); d->markImgDirty(); + emit fontChanged(d->font); } void QmlGraphicsText::setText(const QString &n) @@ -194,6 +198,7 @@ void QmlGraphicsText::setColor(const QColor &color) d->color = color; d->markImgDirty(); + emit colorChanged(d->color); } /*! @@ -248,6 +253,7 @@ void QmlGraphicsText::setStyle(QmlGraphicsText::TextStyle style) d->style = style; d->markImgDirty(); + emit styleChanged(d->style); } void QmlGraphicsText::setStyleColor(const QColor &color) @@ -258,6 +264,7 @@ void QmlGraphicsText::setStyleColor(const QColor &color) d->styleColor = color; d->markImgDirty(); + emit styleColorChanged(d->styleColor); } /*! @@ -295,7 +302,11 @@ QmlGraphicsText::HAlignment QmlGraphicsText::hAlign() const void QmlGraphicsText::setHAlign(HAlignment align) { Q_D(QmlGraphicsText); + if (d->hAlign == align) + return; + d->hAlign = align; + emit horizontalAlignmentChanged(align); } QmlGraphicsText::VAlignment QmlGraphicsText::vAlign() const @@ -307,7 +318,11 @@ QmlGraphicsText::VAlignment QmlGraphicsText::vAlign() const void QmlGraphicsText::setVAlign(VAlignment align) { Q_D(QmlGraphicsText); + if (d->vAlign == align) + return; + d->vAlign = align; + emit verticalAlignmentChanged(align); } /*! @@ -339,6 +354,7 @@ void QmlGraphicsText::setWrap(bool w) d->updateLayout(); d->markImgDirty(); + emit wrapChanged(d->wrap); } /*! @@ -405,6 +421,8 @@ void QmlGraphicsText::setTextFormat(TextFormat format) d->updateLayout(); d->markImgDirty(); } + + emit textFormatChanged(d->format); } /*! @@ -439,6 +457,7 @@ void QmlGraphicsText::setElideMode(QmlGraphicsText::TextElideMode mode) d->updateLayout(); d->markImgDirty(); + emit elideModeChanged(d->elideMode); } void QmlGraphicsText::geometryChanged(const QRectF &newGeometry, diff --git a/src/declarative/graphicsitems/qmlgraphicstext_p.h b/src/declarative/graphicsitems/qmlgraphicstext_p.h index 717fcb4..8fa2e65 100644 --- a/src/declarative/graphicsitems/qmlgraphicstext_p.h +++ b/src/declarative/graphicsitems/qmlgraphicstext_p.h @@ -60,15 +60,15 @@ class Q_DECLARATIVE_EXPORT QmlGraphicsText : public QmlGraphicsItem Q_ENUMS(TextElideMode) Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged) - Q_PROPERTY(QFont font READ font WRITE setFont) - Q_PROPERTY(QColor color READ color WRITE setColor) - Q_PROPERTY(TextStyle style READ style WRITE setStyle) - Q_PROPERTY(QColor styleColor READ styleColor WRITE setStyleColor) - Q_PROPERTY(HAlignment horizontalAlignment READ hAlign WRITE setHAlign) - Q_PROPERTY(VAlignment verticalAlignment READ vAlign WRITE setVAlign) - Q_PROPERTY(bool wrap READ wrap WRITE setWrap) //### there are several wrap modes in Qt - Q_PROPERTY(TextFormat textFormat READ textFormat WRITE setTextFormat) - Q_PROPERTY(TextElideMode elide READ elideMode WRITE setElideMode) //### elideMode? + Q_PROPERTY(QFont font READ font WRITE setFont NOTIFY fontChanged) + Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged) + Q_PROPERTY(TextStyle style READ style WRITE setStyle NOTIFY styleChanged) + Q_PROPERTY(QColor styleColor READ styleColor WRITE setStyleColor NOTIFY styleColorChanged) + Q_PROPERTY(HAlignment horizontalAlignment READ hAlign WRITE setHAlign NOTIFY horizontalAlignmentChanged) + Q_PROPERTY(VAlignment verticalAlignment READ vAlign WRITE setVAlign NOTIFY verticalAlignmentChanged) + Q_PROPERTY(bool wrap READ wrap WRITE setWrap NOTIFY wrapChanged) //### there are several wrap modes in Qt + Q_PROPERTY(TextFormat textFormat READ textFormat WRITE setTextFormat NOTIFY textFormatChanged) + Q_PROPERTY(TextElideMode elide READ elideMode WRITE setElideMode NOTIFY elideModeChanged) //### elideMode? public: QmlGraphicsText(QmlGraphicsItem *parent=0); @@ -130,6 +130,15 @@ public: Q_SIGNALS: void textChanged(const QString &text); void linkActivated(const QString &link); + void fontChanged(const QFont &font); + void colorChanged(const QColor &color); + void styleChanged(TextStyle style); + void styleColorChanged(const QColor &color); + void horizontalAlignmentChanged(HAlignment alignment); + void verticalAlignmentChanged(VAlignment alignment); + void wrapChanged(bool wrap); + void textFormatChanged(TextFormat textFormat); + void elideModeChanged(TextElideMode mode); protected: void mousePressEvent(QGraphicsSceneMouseEvent *event); |