-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathqtdeclarative.patch
50 lines (48 loc) · 1.82 KB
/
qtdeclarative.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
diff --git a/src/quick/items/qquicktextedit.cpp b/src/quick/items/qquicktextedit.cpp
index 247d8abc3c..fe42ee0dfb 100644
--- a/src/quick/items/qquicktextedit.cpp
+++ b/src/quick/items/qquicktextedit.cpp
@@ -2850,6 +2850,33 @@ void QQuickTextEdit::insert(int position, const QString &text)
d->control->updateCursorRectangle(false);
}
+/*!
+ \qmlmethod QtQuick::TextEdit::replace(int start, int end, string text)
+
+ Removes the section of text that is between the \a start and \a end positions from the TextEdit
+ and replaces it with the \a text.
+*/
+void QQuickTextEdit::replace(int start, int end, const QString &text)
+{
+ Q_D(QQuickTextEdit);
+ start = qBound(0, start, d->document->characterCount() - 1);
+ end = qBound(0, end, d->document->characterCount() - 1);
+ QTextCursor cursor(d->document);
+ cursor.setPosition(start, QTextCursor::MoveAnchor);
+ cursor.setPosition(end, QTextCursor::KeepAnchor);
+ d->richText = d->richText || (d->format == AutoText && Qt::mightBeRichText(text));
+ if (d->richText) {
+#if QT_CONFIG(texthtmlparser)
+ cursor.insertHtml(text);
+#else
+ cursor.insertText(text);
+#endif
+ } else {
+ cursor.insertText(text);
+ }
+ d->control->updateCursorRectangle(false);
+}
+
/*!
\qmlmethod string QtQuick::TextEdit::remove(int start, int end)
diff --git a/src/quick/items/qquicktextedit_p.h b/src/quick/items/qquicktextedit_p.h
index 227d8cbf51..8ae7490f55 100644
--- a/src/quick/items/qquicktextedit_p.h
+++ b/src/quick/items/qquicktextedit_p.h
@@ -362,6 +362,7 @@ public Q_SLOTS:
void undo();
void redo();
void insert(int position, const QString &text);
+ void replace(int start, int end, const QString &text);
void remove(int start, int end);
Q_REVISION(2) void append(const QString &text);
Q_REVISION(7) void clear();