summaryrefslogtreecommitdiffstats
path: root/src/declarative/graphicsitems/qdeclarativetextedit.cpp
diff options
context:
space:
mode:
authorAlan Alpert <alan.alpert@nokia.com>2011-01-17 04:07:33 (GMT)
committerAlan Alpert <alan.alpert@nokia.com>2011-01-17 04:07:33 (GMT)
commit8b6674e55118896dfecbcdc1960418dc2064f632 (patch)
tree243889d8c43b7a0bd294866e904b079e0a0b90c0 /src/declarative/graphicsitems/qdeclarativetextedit.cpp
parent62087b2ec0afad240d61a61c7a2972d021e01695 (diff)
downloadQt-8b6674e55118896dfecbcdc1960418dc2064f632.zip
Qt-8b6674e55118896dfecbcdc1960418dc2064f632.tar.gz
Qt-8b6674e55118896dfecbcdc1960418dc2064f632.tar.bz2
Add canPaste property to TextInput and TextEdit
Task-number: QTBUG-16190 Reviewed-by: Martin Jones
Diffstat (limited to 'src/declarative/graphicsitems/qdeclarativetextedit.cpp')
-rw-r--r--src/declarative/graphicsitems/qdeclarativetextedit.cpp28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/declarative/graphicsitems/qdeclarativetextedit.cpp b/src/declarative/graphicsitems/qdeclarativetextedit.cpp
index 1539998..4a421b4 100644
--- a/src/declarative/graphicsitems/qdeclarativetextedit.cpp
+++ b/src/declarative/graphicsitems/qdeclarativetextedit.cpp
@@ -1342,6 +1342,21 @@ void QDeclarativeTextEdit::updateImgCache(const QRectF &rf)
filtering at the beginning of the animation and reenable it at the conclusion.
*/
+/*!
+ \qmlproperty bool TextEdit::canPaste
+
+ Returns true if the TextEdit is writable and the content of the clipboard is
+ suitable for pasting into the TextEdit.
+
+ \since QtQuick 1.1
+*/
+
+bool QDeclarativeTextEdit::canPaste() const
+{
+ Q_D(const QDeclarativeTextEdit);
+ return d->canPaste;
+}
+
void QDeclarativeTextEditPrivate::init()
{
Q_Q(QDeclarativeTextEdit);
@@ -1374,6 +1389,10 @@ void QDeclarativeTextEditPrivate::init()
QObject::connect(control, SIGNAL(cursorPositionChanged()), q, SIGNAL(cursorPositionChanged()));
QObject::connect(control, SIGNAL(cursorPositionChanged()), q, SIGNAL(cursorRectangleChanged()));
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()));
+#endif
document = control->document();
document->setDefaultFont(font);
@@ -1648,4 +1667,13 @@ void QDeclarativeTextEdit::focusInEvent(QFocusEvent *event)
QDeclarativePaintedItem::focusInEvent(event);
}
+void QDeclarativeTextEdit::q_canPasteChanged()
+{
+ Q_D(QDeclarativeTextEdit);
+ bool old = d->canPaste;
+ d->canPaste = d->control->canPaste();
+ if(old!=d->canPaste)
+ emit canPasteChanged();
+}
+
QT_END_NAMESPACE