Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/quick/items/qquicktextedit_p.h |
Source code | Switch to Preprocessed file |
Line | Source | Count |
---|---|---|
1 | /**************************************************************************** | - |
2 | ** | - |
3 | ** Copyright (C) 2016 The Qt Company Ltd. | - |
4 | ** Contact: https://www.qt.io/licensing/ | - |
5 | ** | - |
6 | ** This file is part of the QtQuick module of the Qt Toolkit. | - |
7 | ** | - |
8 | ** $QT_BEGIN_LICENSE:LGPL$ | - |
9 | ** Commercial License Usage | - |
10 | ** Licensees holding valid commercial Qt licenses may use this file in | - |
11 | ** accordance with the commercial license agreement provided with the | - |
12 | ** Software or, alternatively, in accordance with the terms contained in | - |
13 | ** a written agreement between you and The Qt Company. For licensing terms | - |
14 | ** and conditions see https://www.qt.io/terms-conditions. For further | - |
15 | ** information use the contact form at https://www.qt.io/contact-us. | - |
16 | ** | - |
17 | ** GNU Lesser General Public License Usage | - |
18 | ** Alternatively, this file may be used under the terms of the GNU Lesser | - |
19 | ** General Public License version 3 as published by the Free Software | - |
20 | ** Foundation and appearing in the file LICENSE.LGPL3 included in the | - |
21 | ** packaging of this file. Please review the following information to | - |
22 | ** ensure the GNU Lesser General Public License version 3 requirements | - |
23 | ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. | - |
24 | ** | - |
25 | ** GNU General Public License Usage | - |
26 | ** Alternatively, this file may be used under the terms of the GNU | - |
27 | ** General Public License version 2.0 or (at your option) the GNU General | - |
28 | ** Public license version 3 or any later version approved by the KDE Free | - |
29 | ** Qt Foundation. The licenses are as published by the Free Software | - |
30 | ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 | - |
31 | ** included in the packaging of this file. Please review the following | - |
32 | ** information to ensure the GNU General Public License requirements will | - |
33 | ** be met: https://www.gnu.org/licenses/gpl-2.0.html and | - |
34 | ** https://www.gnu.org/licenses/gpl-3.0.html. | - |
35 | ** | - |
36 | ** $QT_END_LICENSE$ | - |
37 | ** | - |
38 | ****************************************************************************/ | - |
39 | - | |
40 | #ifndef QQUICKTEXTEDIT_P_H | - |
41 | #define QQUICKTEXTEDIT_P_H | - |
42 | - | |
43 | // | - |
44 | // W A R N I N G | - |
45 | // ------------- | - |
46 | // | - |
47 | // This file is not part of the Qt API. It exists purely as an | - |
48 | // implementation detail. This header file may change from version to | - |
49 | // version without notice, or even be removed. | - |
50 | // | - |
51 | // We mean it. | - |
52 | // | - |
53 | - | |
54 | #include "qquickimplicitsizeitem_p.h" | - |
55 | - | |
56 | #include <QtGui/qtextoption.h> | - |
57 | - | |
58 | QT_BEGIN_NAMESPACE | - |
59 | - | |
60 | class QQuickTextDocument; | - |
61 | class QQuickTextEditPrivate; | - |
62 | class QTextBlock; | - |
63 | - | |
64 | class Q_QUICK_PRIVATE_EXPORT QQuickTextEdit : public QQuickImplicitSizeItem | - |
65 | { | - |
66 | Q_OBJECT | - |
67 | - | |
68 | Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged) | - |
69 | Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged) | - |
70 | Q_PROPERTY(QColor selectionColor READ selectionColor WRITE setSelectionColor NOTIFY selectionColorChanged) | - |
71 | Q_PROPERTY(QColor selectedTextColor READ selectedTextColor WRITE setSelectedTextColor NOTIFY selectedTextColorChanged) | - |
72 | Q_PROPERTY(QFont font READ font WRITE setFont NOTIFY fontChanged) | - |
73 | Q_PROPERTY(HAlignment horizontalAlignment READ hAlign WRITE setHAlign RESET resetHAlign NOTIFY horizontalAlignmentChanged) | - |
74 | Q_PROPERTY(HAlignment effectiveHorizontalAlignment READ effectiveHAlign NOTIFY effectiveHorizontalAlignmentChanged) | - |
75 | Q_PROPERTY(VAlignment verticalAlignment READ vAlign WRITE setVAlign NOTIFY verticalAlignmentChanged) | - |
76 | Q_PROPERTY(WrapMode wrapMode READ wrapMode WRITE setWrapMode NOTIFY wrapModeChanged) | - |
77 | Q_PROPERTY(int lineCount READ lineCount NOTIFY lineCountChanged) | - |
78 | Q_PROPERTY(int length READ length NOTIFY textChanged) | - |
79 | Q_PROPERTY(qreal contentWidth READ contentWidth NOTIFY contentSizeChanged) | - |
80 | Q_PROPERTY(qreal contentHeight READ contentHeight NOTIFY contentSizeChanged) | - |
81 | Q_PROPERTY(qreal paintedWidth READ contentWidth NOTIFY contentSizeChanged) // Compatibility | - |
82 | Q_PROPERTY(qreal paintedHeight READ contentHeight NOTIFY contentSizeChanged) | - |
83 | Q_PROPERTY(TextFormat textFormat READ textFormat WRITE setTextFormat NOTIFY textFormatChanged) | - |
84 | Q_PROPERTY(bool readOnly READ isReadOnly WRITE setReadOnly NOTIFY readOnlyChanged) | - |
85 | Q_PROPERTY(bool cursorVisible READ isCursorVisible WRITE setCursorVisible NOTIFY cursorVisibleChanged) | - |
86 | Q_PROPERTY(int cursorPosition READ cursorPosition WRITE setCursorPosition NOTIFY cursorPositionChanged) | - |
87 | Q_PROPERTY(QRectF cursorRectangle READ cursorRectangle NOTIFY cursorRectangleChanged) | - |
88 | Q_PROPERTY(QQmlComponent* cursorDelegate READ cursorDelegate WRITE setCursorDelegate NOTIFY cursorDelegateChanged) | - |
89 | Q_PROPERTY(bool overwriteMode READ overwriteMode WRITE setOverwriteMode NOTIFY overwriteModeChanged) | - |
90 | Q_PROPERTY(int selectionStart READ selectionStart NOTIFY selectionStartChanged) | - |
91 | Q_PROPERTY(int selectionEnd READ selectionEnd NOTIFY selectionEndChanged) | - |
92 | Q_PROPERTY(QString selectedText READ selectedText NOTIFY selectedTextChanged) | - |
93 | Q_PROPERTY(bool activeFocusOnPress READ focusOnPress WRITE setFocusOnPress NOTIFY activeFocusOnPressChanged) | - |
94 | Q_PROPERTY(bool persistentSelection READ persistentSelection WRITE setPersistentSelection NOTIFY persistentSelectionChanged) | - |
95 | Q_PROPERTY(qreal textMargin READ textMargin WRITE setTextMargin NOTIFY textMarginChanged) | - |
96 | Q_PROPERTY(Qt::InputMethodHints inputMethodHints READ inputMethodHints WRITE setInputMethodHints NOTIFY inputMethodHintsChanged) | - |
97 | Q_PROPERTY(bool selectByKeyboard READ selectByKeyboard WRITE setSelectByKeyboard NOTIFY selectByKeyboardChanged REVISION 1) | - |
98 | Q_PROPERTY(bool selectByMouse READ selectByMouse WRITE setSelectByMouse NOTIFY selectByMouseChanged) | - |
99 | Q_PROPERTY(SelectionMode mouseSelectionMode READ mouseSelectionMode WRITE setMouseSelectionMode NOTIFY mouseSelectionModeChanged) | - |
100 | Q_PROPERTY(bool canPaste READ canPaste NOTIFY canPasteChanged) | - |
101 | Q_PROPERTY(bool canUndo READ canUndo NOTIFY canUndoChanged) | - |
102 | Q_PROPERTY(bool canRedo READ canRedo NOTIFY canRedoChanged) | - |
103 | Q_PROPERTY(bool inputMethodComposing READ isInputMethodComposing NOTIFY inputMethodComposingChanged) | - |
104 | Q_PROPERTY(QUrl baseUrl READ baseUrl WRITE setBaseUrl RESET resetBaseUrl NOTIFY baseUrlChanged) | - |
105 | Q_PROPERTY(RenderType renderType READ renderType WRITE setRenderType NOTIFY renderTypeChanged) | - |
106 | Q_PROPERTY(QQuickTextDocument *textDocument READ textDocument CONSTANT FINAL REVISION 1) | - |
107 | Q_PROPERTY(QString hoveredLink READ hoveredLink NOTIFY linkHovered REVISION 2) | - |
108 | Q_PROPERTY(qreal padding READ padding WRITE setPadding RESET resetPadding NOTIFY paddingChanged REVISION 6) | - |
109 | Q_PROPERTY(qreal topPadding READ topPadding WRITE setTopPadding RESET resetTopPadding NOTIFY topPaddingChanged REVISION 6) | - |
110 | Q_PROPERTY(qreal leftPadding READ leftPadding WRITE setLeftPadding RESET resetLeftPadding NOTIFY leftPaddingChanged REVISION 6) | - |
111 | Q_PROPERTY(qreal rightPadding READ rightPadding WRITE setRightPadding RESET resetRightPadding NOTIFY rightPaddingChanged REVISION 6) | - |
112 | Q_PROPERTY(qreal bottomPadding READ bottomPadding WRITE setBottomPadding RESET resetBottomPadding NOTIFY bottomPaddingChanged REVISION 6) | - |
113 | Q_PROPERTY(QString preeditText READ preeditText NOTIFY preeditTextChanged REVISION 7) | - |
114 | Q_PROPERTY(qreal tabStopDistance READ tabStopDistance WRITE setTabStopDistance NOTIFY tabStopDistanceChanged REVISION 10) | - |
115 | - | |
116 | public: | - |
117 | QQuickTextEdit(QQuickItem *parent=nullptr); | - |
118 | - | |
119 | enum HAlignment { | - |
120 | AlignLeft = Qt::AlignLeft, | - |
121 | AlignRight = Qt::AlignRight, | - |
122 | AlignHCenter = Qt::AlignHCenter, | - |
123 | AlignJustify = Qt::AlignJustify | - |
124 | }; | - |
125 | Q_ENUM(HAlignment) | - |
126 | - | |
127 | enum VAlignment { | - |
128 | AlignTop = Qt::AlignTop, | - |
129 | AlignBottom = Qt::AlignBottom, | - |
130 | AlignVCenter = Qt::AlignVCenter | - |
131 | }; | - |
132 | Q_ENUM(VAlignment) | - |
133 | - | |
134 | enum TextFormat { | - |
135 | PlainText = Qt::PlainText, | - |
136 | RichText = Qt::RichText, | - |
137 | AutoText = Qt::AutoText | - |
138 | }; | - |
139 | Q_ENUM(TextFormat) | - |
140 | - | |
141 | enum WrapMode { NoWrap = QTextOption::NoWrap, | - |
142 | WordWrap = QTextOption::WordWrap, | - |
143 | WrapAnywhere = QTextOption::WrapAnywhere, | - |
144 | WrapAtWordBoundaryOrAnywhere = QTextOption::WrapAtWordBoundaryOrAnywhere, // COMPAT | - |
145 | Wrap = QTextOption::WrapAtWordBoundaryOrAnywhere | - |
146 | }; | - |
147 | Q_ENUM(WrapMode) | - |
148 | - | |
149 | enum SelectionMode { | - |
150 | SelectCharacters, | - |
151 | SelectWords | - |
152 | }; | - |
153 | Q_ENUM(SelectionMode) | - |
154 | - | |
155 | enum RenderType { QtRendering, | - |
156 | NativeRendering | - |
157 | }; | - |
158 | Q_ENUM(RenderType) | - |
159 | - | |
160 | QString text() const; | - |
161 | void setText(const QString &); | - |
162 | - | |
163 | Q_REVISION(7) QString preeditText() const; | - |
164 | - | |
165 | TextFormat textFormat() const; | - |
166 | void setTextFormat(TextFormat format); | - |
167 | - | |
168 | QFont font() const; | - |
169 | void setFont(const QFont &font); | - |
170 | - | |
171 | QColor color() const; | - |
172 | void setColor(const QColor &c); | - |
173 | - | |
174 | QColor selectionColor() const; | - |
175 | void setSelectionColor(const QColor &c); | - |
176 | - | |
177 | QColor selectedTextColor() const; | - |
178 | void setSelectedTextColor(const QColor &c); | - |
179 | - | |
180 | HAlignment hAlign() const; | - |
181 | void setHAlign(HAlignment align); | - |
182 | void resetHAlign(); | - |
183 | HAlignment effectiveHAlign() const; | - |
184 | - | |
185 | VAlignment vAlign() const; | - |
186 | void setVAlign(VAlignment align); | - |
187 | - | |
188 | WrapMode wrapMode() const; | - |
189 | void setWrapMode(WrapMode w); | - |
190 | - | |
191 | int lineCount() const; | - |
192 | - | |
193 | int length() const; | - |
194 | - | |
195 | bool isCursorVisible() const; | - |
196 | void setCursorVisible(bool on); | - |
197 | - | |
198 | int cursorPosition() const; | - |
199 | void setCursorPosition(int pos); | - |
200 | - | |
201 | QQmlComponent* cursorDelegate() const; | - |
202 | void setCursorDelegate(QQmlComponent*); | - |
203 | - | |
204 | bool overwriteMode() const; | - |
205 | void setOverwriteMode(bool overwrite); | - |
206 | - | |
207 | int selectionStart() const; | - |
208 | int selectionEnd() const; | - |
209 | - | |
210 | QString selectedText() const; | - |
211 | - | |
212 | bool focusOnPress() const; | - |
213 | void setFocusOnPress(bool on); | - |
214 | - | |
215 | bool persistentSelection() const; | - |
216 | void setPersistentSelection(bool on); | - |
217 | - | |
218 | qreal textMargin() const; | - |
219 | void setTextMargin(qreal margin); | - |
220 | - | |
221 | Qt::InputMethodHints inputMethodHints() const; | - |
222 | void setInputMethodHints(Qt::InputMethodHints hints); | - |
223 | - | |
224 | bool selectByKeyboard() const; | - |
225 | void setSelectByKeyboard(bool); | - |
226 | - | |
227 | bool selectByMouse() const; | - |
228 | void setSelectByMouse(bool); | - |
229 | - | |
230 | SelectionMode mouseSelectionMode() const; | - |
231 | void setMouseSelectionMode(SelectionMode mode); | - |
232 | - | |
233 | bool canPaste() const; | - |
234 | - | |
235 | bool canUndo() const; | - |
236 | bool canRedo() const; | - |
237 | - | |
238 | void componentComplete() override; | - |
239 | - | |
240 | /* FROM EDIT */ | - |
241 | void setReadOnly(bool); | - |
242 | bool isReadOnly() const; | - |
243 | - | |
244 | QRectF cursorRectangle() const; | - |
245 | - | |
246 | #if QT_CONFIG(im) | - |
247 | QVariant inputMethodQuery(Qt::InputMethodQuery property) const override; | - |
248 | Q_REVISION(4) Q_INVOKABLE QVariant inputMethodQuery(Qt::InputMethodQuery query, QVariant argument) const; | - |
249 | #endif | - |
250 | - | |
251 | qreal contentWidth() const; | - |
252 | qreal contentHeight() const; | - |
253 | - | |
254 | QUrl baseUrl() const; | - |
255 | void setBaseUrl(const QUrl &url); | - |
256 | void resetBaseUrl(); | - |
257 | - | |
258 | Q_INVOKABLE QRectF positionToRectangle(int) const; | - |
259 | Q_INVOKABLE int positionAt(qreal x, qreal y) const; | - |
260 | Q_INVOKABLE void moveCursorSelection(int pos); | - |
261 | Q_INVOKABLE void moveCursorSelection(int pos, SelectionMode mode); | - |
262 | - | |
263 | QRectF boundingRect() const override; | - |
264 | QRectF clipRect() const override; | - |
265 | - | |
266 | bool isInputMethodComposing() const; | - |
267 | - | |
268 | RenderType renderType() const; | - |
269 | void setRenderType(RenderType renderType); | - |
270 | - | |
271 | Q_INVOKABLE QString getText(int start, int end) const; | - |
272 | Q_INVOKABLE QString getFormattedText(int start, int end) const; | - |
273 | - | |
274 | QQuickTextDocument *textDocument(); | - |
275 | - | |
276 | QString hoveredLink() const; | - |
277 | - | |
278 | Q_REVISION(3) Q_INVOKABLE QString linkAt(qreal x, qreal y) const; | - |
279 | - | |
280 | qreal padding() const; | - |
281 | void setPadding(qreal padding); | - |
282 | void resetPadding(); | - |
283 | - | |
284 | qreal topPadding() const; | - |
285 | void setTopPadding(qreal padding); | - |
286 | void resetTopPadding(); | - |
287 | - | |
288 | qreal leftPadding() const; | - |
289 | void setLeftPadding(qreal padding); | - |
290 | void resetLeftPadding(); | - |
291 | - | |
292 | qreal rightPadding() const; | - |
293 | void setRightPadding(qreal padding); | - |
294 | void resetRightPadding(); | - |
295 | - | |
296 | qreal bottomPadding() const; | - |
297 | void setBottomPadding(qreal padding); | - |
298 | void resetBottomPadding(); | - |
299 | - | |
300 | int tabStopDistance() const; | - |
301 | void setTabStopDistance(qreal distance); | - |
302 | - | |
303 | Q_SIGNALS: | - |
304 | void textChanged(); | - |
305 | Q_REVISION(7) void preeditTextChanged(); | - |
306 | void contentSizeChanged(); | - |
307 | void cursorPositionChanged(); | - |
308 | void cursorRectangleChanged(); | - |
309 | void selectionStartChanged(); | - |
310 | void selectionEndChanged(); | - |
311 | void selectedTextChanged(); | - |
312 | void colorChanged(const QColor &color); | - |
313 | void selectionColorChanged(const QColor &color); | - |
314 | void selectedTextColorChanged(const QColor &color); | - |
315 | void fontChanged(const QFont &font); | - |
316 | void horizontalAlignmentChanged(QQuickTextEdit::HAlignment alignment); | - |
317 | void verticalAlignmentChanged(QQuickTextEdit::VAlignment alignment); | - |
318 | void wrapModeChanged(); | - |
319 | void lineCountChanged(); | - |
320 | void textFormatChanged(QQuickTextEdit::TextFormat textFormat); | - |
321 | void readOnlyChanged(bool isReadOnly); | - |
322 | void cursorVisibleChanged(bool isCursorVisible); | - |
323 | void cursorDelegateChanged(); | - |
324 | void overwriteModeChanged(bool overwriteMode); | - |
325 | void activeFocusOnPressChanged(bool activeFocusOnPressed); | - |
326 | void persistentSelectionChanged(bool isPersistentSelection); | - |
327 | void textMarginChanged(qreal textMargin); | - |
328 | Q_REVISION(1) void selectByKeyboardChanged(bool selectByKeyboard); | - |
329 | void selectByMouseChanged(bool selectByMouse); | - |
330 | void mouseSelectionModeChanged(QQuickTextEdit::SelectionMode mode); | - |
331 | void linkActivated(const QString &link); | - |
332 | Q_REVISION(2) void linkHovered(const QString &link); | - |
333 | void canPasteChanged(); | - |
334 | void canUndoChanged(); | - |
335 | void canRedoChanged(); | - |
336 | void inputMethodComposingChanged(); | - |
337 | void effectiveHorizontalAlignmentChanged(); | - |
338 | void baseUrlChanged(); | - |
339 | void inputMethodHintsChanged(); | - |
340 | void renderTypeChanged(); | - |
341 | Q_REVISION(6) void editingFinished(); | - |
342 | Q_REVISION(6) void paddingChanged(); | - |
343 | Q_REVISION(6) void topPaddingChanged(); | - |
344 | Q_REVISION(6) void leftPaddingChanged(); | - |
345 | Q_REVISION(6) void rightPaddingChanged(); | - |
346 | Q_REVISION(6) void bottomPaddingChanged(); | - |
347 | Q_REVISION(10) void tabStopDistanceChanged(qreal distance); | - |
348 | - | |
349 | public Q_SLOTS: | - |
350 | void selectAll(); | - |
351 | void selectWord(); | - |
352 | void select(int start, int end); | - |
353 | void deselect(); | - |
354 | bool isRightToLeft(int start, int end); | - |
355 | #if QT_CONFIG(clipboard) | - |
356 | void cut(); | - |
357 | void copy(); | - |
358 | void paste(); | - |
359 | #endif | - |
360 | void undo(); | - |
361 | void redo(); | - |
362 | void insert(int position, const QString &text); | - |
363 | void remove(int start, int end); | - |
364 | Q_REVISION(2) void append(const QString &text); | - |
365 | Q_REVISION(7) void clear(); | - |
366 | - | |
367 | private Q_SLOTS: | - |
368 | void q_textChanged(); | - |
369 | void q_contentsChange(int, int, int); | - |
370 | void updateSelection(); | - |
371 | void moveCursorDelegate(); | - |
372 | void createCursor(); | - |
373 | void q_canPasteChanged(); | - |
374 | void updateWholeDocument(); | - |
375 | void invalidateBlock(const QTextBlock &block); | - |
376 | void updateCursor(); | - |
377 | void q_updateAlignment(); | - |
378 | void updateSize(); | - |
379 | void triggerPreprocess(); | - |
380 | - | |
381 | private: | - |
382 | void markDirtyNodesForRange(int start, int end, int charDelta); | - |
383 | void updateTotalLines(); | - |
384 | void invalidateFontCaches(); | - |
385 | - | |
386 | protected: | - |
387 | QQuickTextEdit(QQuickTextEditPrivate &dd, QQuickItem *parent = nullptr); | - |
388 | - | |
389 | void geometryChanged(const QRectF &newGeometry, | - |
390 | const QRectF &oldGeometry) override; | - |
391 | - | |
392 | bool event(QEvent *) override; | - |
393 | void keyPressEvent(QKeyEvent *) override; | - |
394 | void keyReleaseEvent(QKeyEvent *) override; | - |
395 | void focusInEvent(QFocusEvent *event) override; | - |
396 | void focusOutEvent(QFocusEvent *event) override; | - |
397 | - | |
398 | void hoverEnterEvent(QHoverEvent *event) override; | - |
399 | void hoverMoveEvent(QHoverEvent *event) override; | - |
400 | void hoverLeaveEvent(QHoverEvent *event) override; | - |
401 | - | |
402 | // mouse filter? | - |
403 | void mousePressEvent(QMouseEvent *event) override; | - |
404 | void mouseReleaseEvent(QMouseEvent *event) override; | - |
405 | void mouseDoubleClickEvent(QMouseEvent *event) override; | - |
406 | void mouseMoveEvent(QMouseEvent *event) override; | - |
407 | #if QT_CONFIG(im) | - |
408 | void inputMethodEvent(QInputMethodEvent *e) override; | - |
409 | #endif | - |
410 | QSGNode *updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *updatePaintNodeData) override; | - |
411 | void updatePolish() override; | - |
412 | - | |
413 | friend class QQuickTextUtil; | - |
414 | friend class QQuickTextDocument; | - |
415 | - | |
416 | private: | - |
417 | Q_DISABLE_COPY(QQuickTextEdit) | - |
418 | Q_DECLARE_PRIVATE(QQuickTextEdit) executed 72500 times by 6 tests: return reinterpret_cast<QQuickTextEditPrivate *>(qGetPtrHelper(d_ptr)); Executed by:
executed 87092 times by 6 tests: return reinterpret_cast<const QQuickTextEditPrivate *>(qGetPtrHelper(d_ptr)); Executed by:
| 72500-87092 |
419 | }; | - |
420 | - | |
421 | QT_END_NAMESPACE | - |
422 | - | |
423 | QML_DECLARE_TYPE(QQuickTextEdit) | - |
424 | - | |
425 | #endif // QQUICKTEXTEDIT_P_H | - |
Source code | Switch to Preprocessed file |