Speed up TextInput and TextEdit creation.
authorAndrew den Exter <andrew.den-exter@nokia.com>
Tue, 3 Jan 2012 00:37:26 +0000 (10:37 +1000)
committerQt by Nokia <qt-info@nokia.com>
Wed, 4 Jan 2012 00:19:14 +0000 (01:19 +0100)
Update the canPaste property directly when changing the read-only
property instead of connecting to the readOnlyChanged signal.

Change-Id: Ic6f6ba66f6b94448045703f7d2a66218548190dd
Reviewed-by: Martin Jones <martin.jones@nokia.com>
src/quick/items/qquicktextedit.cpp
src/quick/items/qquicktextinput.cpp

index c25f305..9977f60 100644 (file)
@@ -1160,6 +1160,7 @@ void QQuickTextEdit::setReadOnly(bool r)
     if (!r)
         d->control->moveCursor(QTextCursor::End);
 
+    q_canPasteChanged();
     emit readOnlyChanged(r);
 }
 
@@ -1658,7 +1659,6 @@ void QQuickTextEditPrivate::init()
     QObject::connect(control, SIGNAL(cursorRectangleChanged()), q, SLOT(moveCursorDelegate()));
     QObject::connect(control, SIGNAL(linkActivated(QString)), q, SIGNAL(linkActivated(QString)));
 #ifndef QT_NO_CLIPBOARD
-    QObject::connect(q, SIGNAL(readOnlyChanged(bool)), q, SLOT(q_canPasteChanged()));
     QObject::connect(QGuiApplication::clipboard(), SIGNAL(dataChanged()), q, SLOT(q_canPasteChanged()));
 #endif
 
index c271b77..2d5f5af 100644 (file)
@@ -533,7 +533,7 @@ void QQuickTextInput::setReadOnly(bool ro)
     d->m_readOnly = ro;
     if (!ro)
         d->setCursorPosition(d->end());
-
+    q_canPasteChanged();
     emit readOnlyChanged(ro);
 }
 
@@ -2044,8 +2044,6 @@ void QQuickTextInputPrivate::init()
     q->setFlag(QQuickItem::ItemAcceptsInputMethod);
     q->setFlag(QQuickItem::ItemHasContents);
 #ifndef QT_NO_CLIPBOARD
-    q->connect(q, SIGNAL(readOnlyChanged(bool)),
-            q, SLOT(q_canPasteChanged()));
     q->connect(QGuiApplication::clipboard(), SIGNAL(dataChanged()),
             q, SLOT(q_canPasteChanged()));
 #endif // QT_NO_CLIPBOARD