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 QtGui 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 QQUICKTEXTCONTROL_P_P_H
41#define QQUICKTEXTCONTROL_P_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 "QtGui/qtextdocumentfragment.h"
55#include "QtGui/qtextcursor.h"
56#include "QtGui/qtextformat.h"
57#include "QtGui/qtextobject.h"
58#include "QtGui/qabstracttextdocumentlayout.h"
59#include "QtCore/qbasictimer.h"
60#include "QtCore/qpointer.h"
61#include "private/qobject_p.h"
62
63QT_BEGIN_NAMESPACE
64
65class QMimeData;
66class QAbstractScrollArea;
67
68class QQuickTextControlPrivate : public QObjectPrivate
69{
70 Q_DECLARE_PUBLIC(QQuickTextControl)
71public:
72 QQuickTextControlPrivate();
73
74 bool cursorMoveKeyEvent(QKeyEvent *e);
75
76 void updateCurrentCharFormat();
77
78 void setContent(Qt::TextFormat format, const QString &text);
79
80 void paste(const QMimeData *source);
81
82 void setCursorPosition(const QPointF &pos);
83 void setCursorPosition(int pos, QTextCursor::MoveMode mode = QTextCursor::MoveAnchor);
84
85 void repaintCursor();
86 inline void repaintSelection()
87 { repaintOldAndNewSelection(QTextCursor()); }
88 void repaintOldAndNewSelection(const QTextCursor &oldSelection);
89
90 void selectionChanged(bool forceEmitSelectionChanged = false);
91
92 void _q_updateCurrentCharFormatAndSelection();
93
94#if QT_CONFIG(clipboard)
95 void setClipboardSelection();
96#endif
97
98 void _q_updateCursorPosChanged(const QTextCursor &someCursor);
99
100 void setBlinkingCursorEnabled(bool enable);
101 void updateCursorFlashTime();
102
103 void extendWordwiseSelection(int suggestedNewPosition, qreal mouseXPosition);
104 void extendBlockwiseSelection(int suggestedNewPosition);
105
106 void _q_setCursorAfterUndoRedo(int undoPosition, int charsAdded, int charsRemoved);
107
108 QRectF rectForPosition(int position) const;
109
110 void keyPressEvent(QKeyEvent *e);
111 void keyReleaseEvent(QKeyEvent *e);
112 void mousePressEvent(QMouseEvent *event, const QPointF &pos);
113 void mouseMoveEvent(QMouseEvent *event, const QPointF &pos);
114 void mouseReleaseEvent(QMouseEvent *event, const QPointF &pos);
115 void mouseDoubleClickEvent(QMouseEvent *event, const QPointF &pos);
116 bool sendMouseEventToInputContext(QMouseEvent *event, const QPointF &pos);
117 void focusEvent(QFocusEvent *e);
118#if QT_CONFIG(im)
119 void inputMethodEvent(QInputMethodEvent *);
120#endif
121 void hoverEvent(QHoverEvent *e, const QPointF &pos);
122
123 void activateLinkUnderCursor(QString href = QString());
124
125#if QT_CONFIG(im)
126 bool isPreediting() const;
127 void commitPreedit();
128 void cancelPreedit();
129#endif
130
131 QPointF tripleClickPoint;
132 QPointF mousePressPos;
133
134 QTextCharFormat lastCharFormat;
135
136 QTextDocument *doc;
137 QTextCursor cursor;
138 QTextCursor selectedWordOnDoubleClick;
139 QTextCursor selectedBlockOnTripleClick;
140 QString anchorOnMousePress;
141 QString linkToCopy;
142 QString hoveredLink;
143 QTextBlock blockWithMarkerUnderMousePress;
144
145 QBasicTimer cursorBlinkTimer;
146 QBasicTimer tripleClickTimer;
147
148#if QT_CONFIG(im)
149 int preeditCursor;
150#endif
151
152 Qt::TextInteractionFlags interactionFlags;
153
154 bool cursorOn : 1;
155 bool cursorIsFocusIndicator : 1;
156 bool mousePressed : 1;
157 bool lastSelectionState : 1;
158 bool ignoreAutomaticScrollbarAdjustement : 1;
159 bool overwriteMode : 1;
160 bool acceptRichText : 1;
161 bool cursorVisible : 1; // used to hide the cursor in the preedit area
162 bool cursorBlinkingEnabled : 1;
163 bool hasFocus : 1;
164 bool hadSelectionOnMousePress : 1;
165 bool wordSelectionEnabled : 1;
166 bool hasImState : 1;
167 bool cursorRectangleChanged : 1;
168 bool hoveredMarker: 1;
169
170 int lastSelectionStart;
171 int lastSelectionEnd;
172
173 void _q_copyLink();
174};
175
176QT_END_NAMESPACE
177
178#endif // QQuickTextControl_P_H
179