diff options
author | Marco Bubke <marco.bubke@nokia.com> | 2010-01-07 17:44:28 (GMT) |
---|---|---|
committer | Marco Bubke <marco.bubke@nokia.com> | 2010-01-07 17:44:28 (GMT) |
commit | 8954497f9f43150aeb6367fcd50f54e97e376008 (patch) | |
tree | 2f29ccb294913be0b1f8551ece909fc5155e6624 | |
parent | 7fea1d69bef9ec3627fd86b81ac37da808b9a6c4 (diff) | |
download | Qt-8954497f9f43150aeb6367fcd50f54e97e376008.zip Qt-8954497f9f43150aeb6367fcd50f54e97e376008.tar.gz Qt-8954497f9f43150aeb6367fcd50f54e97e376008.tar.bz2 |
Add notifier for QmlGraphicsInput
Bauhaus needs the notifier to track changes in the items.
Task-number: BAUHAUS-243
Reviewed-by: Thomas Hartmann
-rw-r--r-- | src/declarative/graphicsitems/qmlgraphicstextinput.cpp | 41 | ||||
-rw-r--r-- | src/declarative/graphicsitems/qmlgraphicstextinput_p.h | 41 |
2 files changed, 68 insertions, 14 deletions
diff --git a/src/declarative/graphicsitems/qmlgraphicstextinput.cpp b/src/declarative/graphicsitems/qmlgraphicstextinput.cpp index ff6c32c..6068e93 100644 --- a/src/declarative/graphicsitems/qmlgraphicstextinput.cpp +++ b/src/declarative/graphicsitems/qmlgraphicstextinput.cpp @@ -116,6 +116,9 @@ QFont QmlGraphicsTextInput::font() const void QmlGraphicsTextInput::setFont(const QFont &font) { Q_D(QmlGraphicsTextInput); + if (d->font == font) + return; + d->font = font; d->control->setFont(d->font); @@ -124,6 +127,7 @@ void QmlGraphicsTextInput::setFont(const QFont &font) moveCursor(); } updateSize(); + emit fontChanged(d->font); } /*! @@ -165,6 +169,7 @@ void QmlGraphicsTextInput::setSelectionColor(const QColor &color) QPalette p = d->control->palette(); p.setColor(QPalette::Highlight, d->selectionColor); d->control->setPalette(p); + emit selectionColorChanged(color); } /*! @@ -188,6 +193,7 @@ void QmlGraphicsTextInput::setSelectedTextColor(const QColor &color) QPalette p = d->control->palette(); p.setColor(QPalette::HighlightedText, d->selectedTextColor); d->control->setPalette(p); + emit selectedTextColorChanged(color); } /*! @@ -217,6 +223,7 @@ void QmlGraphicsTextInput::setHAlign(HAlignment align) if(align == d->hAlign) return; d->hAlign = align; + emit horizontalAlignmentChanged(d->hAlign); } bool QmlGraphicsTextInput::isReadOnly() const @@ -228,7 +235,12 @@ bool QmlGraphicsTextInput::isReadOnly() const void QmlGraphicsTextInput::setReadOnly(bool ro) { Q_D(QmlGraphicsTextInput); + if (d->control->isReadOnly() == ro) + return; + d->control->setReadOnly(ro); + + emit readOnlyChanged(ro); } int QmlGraphicsTextInput::maxLength() const @@ -240,7 +252,12 @@ int QmlGraphicsTextInput::maxLength() const void QmlGraphicsTextInput::setMaxLength(int ml) { Q_D(QmlGraphicsTextInput); + if (d->control->maxLength() == ml) + return; + d->control->setMaxLength(ml); + + emit maximumLengthChanged(ml); } /*! @@ -283,6 +300,7 @@ void QmlGraphicsTextInput::setCursorVisible(bool on) d->cursorVisible = on; d->control->setCursorBlinkPeriod(on?QApplication::cursorFlashTime():0); //d->control should emit the cursor update regions + emit cursorVisibleChanged(d->cursorVisible); } /*! @@ -403,7 +421,12 @@ bool QmlGraphicsTextInput::focusOnPress() const void QmlGraphicsTextInput::setFocusOnPress(bool b) { Q_D(QmlGraphicsTextInput); + if (d->focusOnPress == b) + return; + d->focusOnPress = b; + + emit focusOnPressChanged(d->focusOnPress); } /*! @@ -426,11 +449,16 @@ QValidator* QmlGraphicsTextInput::validator() const void QmlGraphicsTextInput::setValidator(QValidator* v) { Q_D(QmlGraphicsTextInput); + if (d->control->validator() == v) + return; + d->control->setValidator(v); if(!d->control->hasAcceptableInput()){ d->oldValidity = false; emit acceptableInputChanged(); } + + emit validatorChanged(); } /*! @@ -451,7 +479,11 @@ QString QmlGraphicsTextInput::inputMask() const void QmlGraphicsTextInput::setInputMask(const QString &im) { Q_D(QmlGraphicsTextInput); + if (d->control->inputMask() == im) + return; + d->control->setInputMask(im); + emit inputMaskChanged(d->control->inputMask()); } /*! @@ -487,7 +519,11 @@ QmlGraphicsTextInput::EchoMode QmlGraphicsTextInput::echoMode() const void QmlGraphicsTextInput::setEchoMode(QmlGraphicsTextInput::EchoMode echo) { Q_D(QmlGraphicsTextInput); + if (echoMode() == echo) + return; + d->control->setEchoMode((uint)echo); + emit echoModeChanged(echoMode()); } /*! @@ -512,6 +548,9 @@ QmlComponent* QmlGraphicsTextInput::cursorDelegate() const void QmlGraphicsTextInput::setCursorDelegate(QmlComponent* c) { Q_D(QmlGraphicsTextInput); + if (d->cursorComponent == c) + return; + d->cursorComponent = c; if(!c){ //note that the components are owned by something else @@ -521,6 +560,8 @@ void QmlGraphicsTextInput::setCursorDelegate(QmlComponent* c) }else{ d->startCreatingCursor(); } + + emit cursorDelegateChanged(); } void QmlGraphicsTextInputPrivate::startCreatingCursor() diff --git a/src/declarative/graphicsitems/qmlgraphicstextinput_p.h b/src/declarative/graphicsitems/qmlgraphicstextinput_p.h index 85b8beb..24e473d 100644 --- a/src/declarative/graphicsitems/qmlgraphicstextinput_p.h +++ b/src/declarative/graphicsitems/qmlgraphicstextinput_p.h @@ -63,27 +63,27 @@ class Q_DECLARATIVE_EXPORT QmlGraphicsTextInput : public QmlGraphicsPaintedItem Q_ENUMS(EchoMode) Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged) - Q_PROPERTY(QColor color READ color WRITE setColor) - Q_PROPERTY(QColor selectionColor READ selectionColor WRITE setSelectionColor) - Q_PROPERTY(QColor selectedTextColor READ selectedTextColor WRITE setSelectedTextColor) - Q_PROPERTY(QFont font READ font WRITE setFont) - Q_PROPERTY(HAlignment horizontalAlignment READ hAlign WRITE setHAlign) - - Q_PROPERTY(bool readOnly READ isReadOnly WRITE setReadOnly) - Q_PROPERTY(bool cursorVisible READ isCursorVisible WRITE setCursorVisible) + Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged) + Q_PROPERTY(QColor selectionColor READ selectionColor WRITE setSelectionColor NOTIFY selectionColorChanged) + Q_PROPERTY(QColor selectedTextColor READ selectedTextColor WRITE setSelectedTextColor NOTIFY selectedTextColorChanged) + Q_PROPERTY(QFont font READ font WRITE setFont NOTIFY fontChanged) + Q_PROPERTY(HAlignment horizontalAlignment READ hAlign WRITE setHAlign NOTIFY horizontalAlignmentChanged) + + Q_PROPERTY(bool readOnly READ isReadOnly WRITE setReadOnly NOTIFY readOnlyChanged) + Q_PROPERTY(bool cursorVisible READ isCursorVisible WRITE setCursorVisible NOTIFY cursorVisibleChanged) Q_PROPERTY(int cursorPosition READ cursorPosition WRITE setCursorPosition NOTIFY cursorPositionChanged) Q_PROPERTY(QRect cursorRect READ cursorRect NOTIFY cursorPositionChanged) - Q_PROPERTY(QmlComponent *cursorDelegate READ cursorDelegate WRITE setCursorDelegate) + Q_PROPERTY(QmlComponent *cursorDelegate READ cursorDelegate WRITE setCursorDelegate NOTIFY cursorDelegateChanged) Q_PROPERTY(int selectionStart READ selectionStart WRITE setSelectionStart NOTIFY selectionStartChanged) Q_PROPERTY(int selectionEnd READ selectionEnd WRITE setSelectionEnd NOTIFY selectionEndChanged) Q_PROPERTY(QString selectedText READ selectedText NOTIFY selectedTextChanged) - Q_PROPERTY(int maximumLength READ maxLength WRITE setMaxLength) - Q_PROPERTY(QValidator* validator READ validator WRITE setValidator) - Q_PROPERTY(QString inputMask READ inputMask WRITE setInputMask) + Q_PROPERTY(int maximumLength READ maxLength WRITE setMaxLength NOTIFY maximumLengthChanged) + Q_PROPERTY(QValidator* validator READ validator WRITE setValidator NOTIFY validatorChanged) + Q_PROPERTY(QString inputMask READ inputMask WRITE setInputMask NOTIFY inputMaskChanged) Q_PROPERTY(bool acceptableInput READ hasAcceptableInput NOTIFY acceptableInputChanged) - Q_PROPERTY(EchoMode echoMode READ echoMode WRITE setEchoMode) - Q_PROPERTY(bool focusOnPress READ focusOnPress WRITE setFocusOnPress) + Q_PROPERTY(EchoMode echoMode READ echoMode WRITE setEchoMode NOTIFY echoModeChanged) + Q_PROPERTY(bool focusOnPress READ focusOnPress WRITE setFocusOnPress NOTIFY focusOnPressChanged) public: QmlGraphicsTextInput(QmlGraphicsItem* parent=0); @@ -172,6 +172,19 @@ Q_SIGNALS: void selectedTextChanged(); void accepted(); void acceptableInputChanged(); + void colorChanged(const QColor &color); + void selectionColorChanged(const QColor &color); + void selectedTextColorChanged(const QColor &color); + void fontChanged(const QFont &font); + void horizontalAlignmentChanged(HAlignment alignment); + void readOnlyChanged(bool isReadOnly); + void cursorVisibleChanged(bool isCursorVisible); + void cursorDelegateChanged(); + void maximumLengthChanged(int maximumLength); + void validatorChanged(); + void inputMaskChanged(const QString &inputMask); + void echoModeChanged(EchoMode echoMode); + void focusOnPressChanged(bool focusOnPress); protected: virtual void geometryChanged(const QRectF &newGeometry, |