}
/*!
+ \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
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)
int lineCount() const;
+ int length() const;
+
bool isCursorVisible() const;
void setCursorVisible(bool on);
QVERIFY(textEditObject != 0);
QCOMPARE(textEditObject->text(), QString(""));
+ QCOMPARE(textEditObject->length(), 0);
}
for (int i = 0; i < standard.size(); i++)
QVERIFY(textEditObject != 0);
QCOMPARE(textEditObject->text(), standard.at(i));
+ QCOMPARE(textEditObject->length(), standard.at(i).length());
}
for (int i = 0; i < richText.size(); i++)
actual.replace(QRegExp("(<[^>]*>)+"),"<>");
expected.replace(QRegExp("(<[^>]*>)+"),"<>");
QCOMPARE(actual.simplified(),expected.simplified());
+
+ expected.replace("<>", " ");
+ QCOMPARE(textEditObject->length(), expected.simplified().length());
}
}
QCOMPARE(textEdit->getText(0, expectedText.length()), expectedText);
} else {
QCOMPARE(textEdit->text(), expectedText);
+
}
+ QCOMPARE(textEdit->length(), expectedText.length());
QCOMPARE(textEdit->selectionStart(), expectedSelectionStart);
QCOMPARE(textEdit->selectionEnd(), expectedSelectionEnd);
QEXPECT_FAIL("into reversed selection", "selectionChanged signal isn't emitted on edits within selection", Continue);
QCOMPARE(selectionSpy.count() > 0, selectionChanged);
QCOMPARE(selectionStartSpy.count() > 0, selectionStart != expectedSelectionStart);
- QEXPECT_FAIL("into reversed selection", "yeah I don't know", Continue);
+ QEXPECT_FAIL("into reversed selection", "selectionEndChanged signal not emitted", Continue);
QCOMPARE(selectionEndSpy.count() > 0, selectionEnd != expectedSelectionEnd);
QCOMPARE(textSpy.count() > 0, text != expectedText);
QCOMPARE(cursorPositionSpy.count() > 0, cursorPositionChanged);
} else {
QCOMPARE(textEdit->text(), expectedText);
}
+ QCOMPARE(textEdit->length(), expectedText.length());
if (selectionStart > selectionEnd) //
qSwap(selectionStart, selectionEnd);