Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qquicktextedit_p_p.h
Go to the documentation of this file.
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 QQUICKTEXTEDIT_P_P_H
5#define QQUICKTEXTEDIT_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 "qquicktextedit_p.h"
20#include "qquicktextutil_p.h"
21
22#include <QtQuick/private/qquicktextselection_p.h>
23
24#include <QtQml/qqml.h>
25#include <QtCore/qlist.h>
26#include <private/qlazilyallocated_p.h>
27#include <private/qquicktextdocument_p.h>
28
29#if QT_CONFIG(accessibility)
30#include <QtGui/qaccessible.h>
31#endif
32
33#include <limits>
34
36class QTextLayout;
37class QQuickPixmap;
41
43#if QT_CONFIG(accessibility)
44 , public QAccessible::ActivationObserver
45#endif
46{
47public:
48 Q_DECLARE_PUBLIC(QQuickTextEdit)
49
51
52 struct Node {
53 explicit Node(int startPos = std::numeric_limits<int>::max(),
54 QSGInternalTextNode *node = nullptr)
55 : m_node(node), m_startPos(startPos) { }
56 QSGInternalTextNode *textNode() const { return m_node; }
57 void moveStartPos(int delta) { Q_ASSERT(m_startPos + delta > 0); m_startPos += delta; }
58 int startPos() const { return m_startPos; }
59 void setDirty() { m_dirty = true; }
60 bool dirty() const { return m_dirty; }
61
62 private:
63 QSGInternalTextNode *m_node;
64 int m_startPos;
65 bool m_dirty = false;
66
67#ifndef QT_NO_DEBUG_STREAM
68 friend QDebug Q_QUICK_EXPORT operator<<(QDebug, const Node &);
69#endif
70 };
72
73 struct ExtraData {
74 ExtraData();
75
76 qreal padding = 0;
77 qreal topPadding = 0;
78 qreal leftPadding = 0;
79 qreal rightPadding = 0;
80 qreal bottomPadding = 0;
86 };
87 QLazilyAllocated<ExtraData> extra;
88
89
91 : dirty(false), richText(false), cursorVisible(false), cursorPending(false)
92 , focusOnPress(true), persistentSelection(false), requireImplicitWidth(false)
93 , selectByMouse(true), canPaste(false), canPasteValid(false), hAlignImplicit(true)
94 , textCached(true), inLayout(false), selectByKeyboard(false), selectByKeyboardSet(false)
95 , hadSelection(false), markdownText(false), inResize(false), ownsDocument(false)
96 {
97#if QT_CONFIG(accessibility)
98 QAccessible::installActivationObserver(this);
99#endif
100 }
101
103 {
104#if QT_CONFIG(accessibility)
105 QAccessible::removeActivationObserver(this);
106#endif
107 }
108
111
112 void init();
113
114 void resetInputMethod();
115 void updateDefaultTextOption();
116 void onDocumentStatusChanged();
118 bool determineHorizontalAlignment();
119 bool setHAlign(QQuickTextEdit::HAlignment, bool forceAlign = false);
120 void mirrorChange() override;
121 bool transformChanged(QQuickItem *transformedItem) override;
122 qreal getImplicitWidth() const override;
123 Qt::LayoutDirection textDirection(const QString &text) const;
124 bool isLinkHoveredConnected();
125
126#if QT_CONFIG(cursor)
127 void updateMouseCursorShape();
128#endif
129
131 void handleFocusEvent(QFocusEvent *event);
132 void addCurrentTextNodeToRoot(QQuickTextNodeEngine *, QSGTransformNode *, QSGInternalTextNode *, TextNodeIterator&, int startPos);
134
135#if QT_CONFIG(im)
136 Qt::InputMethodHints effectiveInputMethodHints() const;
137#endif
138
139#if QT_CONFIG(accessibility)
140 void accessibilityActiveChanged(bool active) override;
141 QAccessible::Role accessibleRole() const override;
142#endif
143
144 inline qreal padding() const { return extra.isAllocated() ? extra->padding : 0.0; }
145 void setTopPadding(qreal value, bool reset = false);
146 void setLeftPadding(qreal value, bool reset = false);
147 void setRightPadding(qreal value, bool reset = false);
148 void setBottomPadding(qreal value, bool reset = false);
149
150 bool isImplicitResizeEnabled() const;
151 void setImplicitResizeEnabled(bool enabled);
152
153 QColor color = QRgb(0xFF000000);
154 QColor selectionColor = QRgb(0xFF000080);
155 QColor selectedTextColor = QRgb(0xFFFFFFFF);
156
158
159 qreal textMargin = 0;
160 qreal xoff = 0;
161 qreal yoff = 0;
162
167
168 QQmlComponent* cursorComponent = nullptr;
169 QQuickItem* cursorItem = nullptr;
170 QTextDocument *document = nullptr;
171 QQuickTextControl *control = nullptr;
172 QQuickTextDocument *quickDocument = nullptr;
173 mutable QQuickTextSelection *cursorSelection = nullptr;
174 QList<Node> textNodeMap;
175 QList<QQuickPixmap *> pixmapsInProgress;
176
177 int lastSelectionStart = 0;
178 int lastSelectionEnd = 0;
179 int lineCount = 0;
180 int firstBlockInViewport = -1; // can be wrong after scrolling sometimes
181 int firstBlockPastViewport = -1; // only for the autotest
182 int renderedBlockCount = -1; // only for the autotest
184
191
196 QQuickTextEdit::RenderType renderType = QQuickTextUtil::textRenderType<QQuickTextEdit>();
199#if QT_CONFIG(im)
200 Qt::InputMethodHints inputMethodHints = Qt::ImhNone;
201#endif
202 UpdateType updateType = UpdatePaintNode;
203
204 bool dirty : 1;
205 bool richText : 1;
208 bool focusOnPress : 1;
212 bool canPaste:1;
216 bool inLayout:1;
219 bool hadSelection : 1;
220 bool markdownText : 1;
221 bool inResize : 1;
222 bool ownsDocument : 1;
223
224 static const int largeTextSizeThreshold;
225};
226
227#ifndef QT_NO_DEBUG_STREAM
229#endif
230
232
233#endif // QQUICKTEXTEDIT_P_P_H
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition qcolor.h:31
\inmodule QtCore
The QFocusEvent class contains event parameters for widget focus events.
Definition qevent.h:470
\reentrant
Definition qfont.h:22
static QObjectPrivate * get(QObject *o)
Definition qobject_p.h:150
The QQmlComponent class encapsulates a QML component definition.
The QQuickItem class provides the most basic of all visual items in \l {Qt Quick}.
Definition qquickitem.h:63
\qmltype TextDocument \instantiates QQuickTextDocument \inqmlmodule QtQuick
QList< Node >::iterator TextNodeIterator
QLazilyAllocated< ExtraData > extra
static const int largeTextSizeThreshold
QList< QQuickPixmap * > pixmapsInProgress
static QQuickTextEditPrivate * get(QQuickTextEdit *item)
\inmodule QtCore\reentrant
Definition qrect.h:484
The QSGTransformNode class implements transformations in the scene graph.
Definition qsgnode.h:241
\inmodule QtCore
Definition qsize.h:208
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
\reentrant \inmodule QtGui
\reentrant
Definition qtextlayout.h:70
\inmodule QtCore
Definition qurl.h:94
QString text
Combined button and popup list for selecting options.
LayoutDirection
@ LayoutDirectionAuto
@ ImhNone
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
GLenum GLenum GLsizei const GLuint GLboolean enabled
GLuint color
[2]
GLint GLsizei GLsizei GLenum format
struct _cl_event * event
GLboolean reset
QDebug Q_QUICK_EXPORT operator<<(QDebug debug, const QQuickTextEditPrivate::Node &)
#define Q_ASSERT(cond)
Definition qrandom.cpp:47
QT_BEGIN_NAMESPACE typedef unsigned int QRgb
Definition qrgb.h:13
static QSvgNode * createTextNode(QSvgNode *parent, const QXmlStreamAttributes &attributes, QSvgHandler *handler)
static QT_BEGIN_NAMESPACE void init(QTextBoundaryFinder::BoundaryType type, QStringView str, QCharAttributes *attributes)
double qreal
Definition qtypes.h:187
QDataStream & operator<<(QDataStream &out, const MyClass &myObj)
[4]
QGraphicsItem * item
Node(int startPos=std::numeric_limits< int >::max(), QSGInternalTextNode *node=nullptr)
QSGInternalTextNode * textNode() const