summaryrefslogtreecommitdiffstats
path: root/src/declarative/graphicsitems/qdeclarativetextedit.cpp
diff options
context:
space:
mode:
authorAndrew den Exter <andrew.den.exter@jollamobile.com>2012-11-22 11:11:29 +1000
committerThe Qt Project <gerrit-noreply@qt-project.org>2012-11-23 00:08:56 +0100
commitb2165ea510293f9841570ed9572512ca3f048ae0 (patch)
tree8daa8f32164e63af09dcb32ce7b8a51ea07003a8 /src/declarative/graphicsitems/qdeclarativetextedit.cpp
parent497978e6c2d7602448ca6fd8dd8da32813c6705b (diff)
Port TextInput/TextEdit clipboard optimizations from QtQuick 2.0
Don't check if the clipboard has content until necessary as the check can block for an extended period. Port of 3db5afa71443533eee6825a5fb0da29498f96b94 from qtdeclarative. Change-Id: I606af79cbf10b147aa1bb6c182b0a84aabbc5257 Reviewed-by: Martin Jones <martin.jones@jollamobile.com>
Diffstat (limited to 'src/declarative/graphicsitems/qdeclarativetextedit.cpp')
-rw-r--r--src/declarative/graphicsitems/qdeclarativetextedit.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/declarative/graphicsitems/qdeclarativetextedit.cpp b/src/declarative/graphicsitems/qdeclarativetextedit.cpp
index 07ae0e95..ed65c8e8 100644
--- a/src/declarative/graphicsitems/qdeclarativetextedit.cpp
+++ b/src/declarative/graphicsitems/qdeclarativetextedit.cpp
@@ -1139,6 +1139,7 @@ void QDeclarativeTextEdit::setReadOnly(bool r)
if (!r)
d->control->moveCursor(QTextCursor::End);
+ q_canPasteChanged();
emit readOnlyChanged(r);
}
@@ -1508,6 +1509,10 @@ void QDeclarativeTextEdit::updateImgCache(const QRectF &rf)
bool QDeclarativeTextEdit::canPaste() const
{
Q_D(const QDeclarativeTextEdit);
+ if (!d->canPasteValid) {
+ d->canPaste = d->control->canPaste();
+ d->canPasteValid = true;
+ }
return d->canPaste;
}
@@ -1565,9 +1570,7 @@ void QDeclarativeTextEditPrivate::init()
QObject::connect(control, SIGNAL(microFocusChanged()), 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(QApplication::clipboard(), SIGNAL(dataChanged()), q, SLOT(q_canPasteChanged()));
- canPaste = control->canPaste();
#endif
document = control->document();
@@ -1888,7 +1891,9 @@ void QDeclarativeTextEdit::q_canPasteChanged()
Q_D(QDeclarativeTextEdit);
bool old = d->canPaste;
d->canPaste = d->control->canPaste();
- if(old!=d->canPaste)
+ bool changed = old != d->canPaste || !d->canPasteValid;
+ d->canPasteValid = true;
+ if (changed)
emit canPasteChanged();
}