aboutsummaryrefslogtreecommitdiffstats
path: root/src/declarative
diff options
context:
space:
mode:
Diffstat (limited to 'src/declarative')
-rw-r--r--src/declarative/items/qquicktextedit.cpp19
-rw-r--r--src/declarative/items/qquicktextedit_p.h3
2 files changed, 22 insertions, 0 deletions
diff --git a/src/declarative/items/qquicktextedit.cpp b/src/declarative/items/qquicktextedit.cpp
index 2e799200e6..51231e17de 100644
--- a/src/declarative/items/qquicktextedit.cpp
+++ b/src/declarative/items/qquicktextedit.cpp
@@ -636,6 +636,25 @@ int QQuickTextEdit::lineCount() const
}
/*!
+ \qmlproperty int QtQuick2::TextEdit::length
+
+ Returns the total number of plain text characters in the TextEdit item.
+
+ As this number doesn't include any formatting markup it may not be the same as the
+ length of the string returned by the \l text property.
+
+ This property can be faster than querying the length the \l text property as it doesn't
+ require any copying or conversion of the TextEdit's internal string data.
+*/
+
+int QQuickTextEdit::length() const
+{
+ Q_D(const QQuickTextEdit);
+ // QTextDocument::characterCount() includes the terminating null character.
+ return qMax(0, d->document->characterCount() - 1);
+}
+
+/*!
\qmlproperty real QtQuick2::TextEdit::paintedWidth
Returns the width of the text, including the width past the width
diff --git a/src/declarative/items/qquicktextedit_p.h b/src/declarative/items/qquicktextedit_p.h
index 66b68ffd85..25988959f6 100644
--- a/src/declarative/items/qquicktextedit_p.h
+++ b/src/declarative/items/qquicktextedit_p.h
@@ -73,6 +73,7 @@ class Q_AUTOTEST_EXPORT QQuickTextEdit : public QQuickImplicitSizeItem
Q_PROPERTY(VAlignment verticalAlignment READ vAlign WRITE setVAlign NOTIFY verticalAlignmentChanged)
Q_PROPERTY(WrapMode wrapMode READ wrapMode WRITE setWrapMode NOTIFY wrapModeChanged)
Q_PROPERTY(int lineCount READ lineCount NOTIFY lineCountChanged)
+ Q_PROPERTY(int length READ length NOTIFY textChanged)
Q_PROPERTY(qreal paintedWidth READ paintedWidth NOTIFY paintedSizeChanged)
Q_PROPERTY(qreal paintedHeight READ paintedHeight NOTIFY paintedSizeChanged)
Q_PROPERTY(TextFormat textFormat READ textFormat WRITE setTextFormat NOTIFY textFormatChanged)
@@ -161,6 +162,8 @@ public:
int lineCount() const;
+ int length() const;
+
bool isCursorVisible() const;
void setCursorVisible(bool on);