1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QQUICKTEXTCONTROL_P_P_H
5#define QQUICKTEXTCONTROL_P_P_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include "QtGui/qtextdocumentfragment.h"
19#include "QtGui/qtextcursor.h"
20#include "QtGui/qtextformat.h"
21#include "QtGui/qtextobject.h"
22#include "QtGui/qabstracttextdocumentlayout.h"
23#include "QtCore/qbasictimer.h"
24#include "QtCore/qpointer.h"
25#include "private/qobject_p.h"
26
27QT_BEGIN_NAMESPACE
28
29class QMimeData;
30class QAbstractScrollArea;
31
32class QQuickTextControlPrivate : public QObjectPrivate
33{
34public:
35 Q_DECLARE_PUBLIC(QQuickTextControl)
36 QQuickTextControlPrivate();
37
38 bool cursorMoveKeyEvent(QKeyEvent *e);
39
40 void updateCurrentCharFormat();
41
42 void setContent(Qt::TextFormat format, const QString &text);
43
44 void paste(const QMimeData *source);
45
46 void setCursorPosition(const QPointF &pos);
47 void setCursorPosition(int pos, QTextCursor::MoveMode mode = QTextCursor::MoveAnchor);
48
49 void repaintCursor();
50 inline void repaintSelection()
51 { repaintOldAndNewSelection(oldSelection: QTextCursor()); }
52 void repaintOldAndNewSelection(const QTextCursor &oldSelection);
53
54 void selectionChanged(bool forceEmitSelectionChanged = false);
55
56 void _q_updateCurrentCharFormatAndSelection();
57
58#if QT_CONFIG(clipboard)
59 void setClipboardSelection();
60#endif
61
62 void _q_updateCursorPosChanged(const QTextCursor &someCursor);
63
64 void setBlinkingCursorEnabled(bool enable);
65 void updateCursorFlashTime();
66
67 void extendWordwiseSelection(int suggestedNewPosition, qreal mouseXPosition);
68 void extendBlockwiseSelection(int suggestedNewPosition);
69
70 void _q_setCursorAfterUndoRedo(int undoPosition, int charsAdded, int charsRemoved);
71
72 QRectF rectForPosition(int position) const;
73
74 void keyPressEvent(QKeyEvent *e);
75 void keyReleaseEvent(QKeyEvent *e);
76 void mousePressEvent(QMouseEvent *event, const QPointF &pos);
77 void mouseMoveEvent(QMouseEvent *event, const QPointF &pos);
78 void mouseReleaseEvent(QMouseEvent *event, const QPointF &pos);
79 void mouseDoubleClickEvent(QMouseEvent *event, const QPointF &pos);
80 bool sendMouseEventToInputContext(QMouseEvent *event, const QPointF &pos);
81 void focusEvent(QFocusEvent *e);
82#if QT_CONFIG(im)
83 void inputMethodEvent(QInputMethodEvent *);
84#endif
85 void hoverEvent(QHoverEvent *e, const QPointF &pos);
86
87 void activateLinkUnderCursor(QString href = QString());
88
89#if QT_CONFIG(im)
90 bool isPreediting() const;
91 void commitPreedit();
92 void cancelPreedit();
93#endif
94
95 QPointF tripleClickPoint;
96 QPointF mousePressPos;
97
98 QTextCharFormat lastCharFormat;
99
100 QTextDocument *doc;
101 QTextCursor cursor;
102 QTextCursor selectedWordOnDoubleClick;
103 QTextCursor selectedBlockOnTripleClick;
104 QString anchorOnMousePress;
105 QString linkToCopy;
106 QString hoveredLink;
107 QTextBlock blockWithMarkerUnderMousePress;
108
109 QBasicTimer cursorBlinkTimer;
110 ulong timestampAtLastDoubleClick = 0; // will only be set at a double click
111
112#if QT_CONFIG(im)
113 int preeditCursor;
114#endif
115
116 Qt::TextInteractionFlags interactionFlags;
117
118 bool cursorOn : 1;
119 bool cursorIsFocusIndicator : 1;
120 bool mousePressed : 1;
121 bool lastSelectionState : 1;
122 bool ignoreAutomaticScrollbarAdjustement : 1;
123 bool overwriteMode : 1;
124 bool acceptRichText : 1;
125 bool cursorVisible : 1; // used to hide the cursor in the preedit area
126 bool cursorBlinkingEnabled : 1;
127 bool hasFocus : 1;
128 bool hadSelectionOnMousePress : 1;
129 bool wordSelectionEnabled : 1;
130 bool hasImState : 1;
131 bool cursorRectangleChanged : 1;
132 bool hoveredMarker: 1;
133 bool selectByTouchDrag: 1;
134 bool imSelectionAfterPress: 1;
135
136 int lastSelectionStart;
137 int lastSelectionEnd;
138
139 void _q_copyLink();
140};
141
142QT_END_NAMESPACE
143
144#endif // QQuickTextControl_P_H
145

source code of qtdeclarative/src/quick/items/qquicktextcontrol_p_p.h