Qt 6.x
The Qt SDK
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 <QtQml/qqml.h>
23#include <QtCore/qlist.h>
24#include <private/qlazilyallocated_p.h>
25
26#include <limits>
27
29class QTextLayout;
32class QQuickTextNode;
34
35class Q_QUICK_PRIVATE_EXPORT QQuickTextEditPrivate : public QQuickImplicitSizeItemPrivate
36{
37public:
38 Q_DECLARE_PUBLIC(QQuickTextEdit)
39
41
42 struct Node {
43 explicit Node(int startPos = std::numeric_limits<int>::max(),
44 QQuickTextNode *node = nullptr)
45 : m_startPos(startPos), m_node(node), m_dirty(false) { }
46 QQuickTextNode* textNode() const { return m_node; }
47 void moveStartPos(int delta) { Q_ASSERT(m_startPos + delta > 0); m_startPos += delta; }
48 int startPos() const { return m_startPos; }
49 void setDirty() { m_dirty = true; }
50 bool dirty() const { return m_dirty; }
51
52 private:
53 int m_startPos;
54 QQuickTextNode* m_node;
55 bool m_dirty;
56
57#ifndef QT_NO_DEBUG_STREAM
58 friend QDebug Q_QUICK_PRIVATE_EXPORT operator<<(QDebug, const Node &);
59#endif
60 };
62
63 struct ExtraData {
64 ExtraData();
65
76 };
78
79
81 : color(QRgb(0xFF000000)), selectionColor(QRgb(0xFF000080)), selectedTextColor(QRgb(0xFFFFFFFF))
82 , textMargin(0.0), xoff(0), yoff(0)
83 , font(sourceFont), cursorComponent(nullptr), cursorItem(nullptr), document(nullptr), control(nullptr)
84 , quickDocument(nullptr), lastSelectionStart(0), lastSelectionEnd(0), lineCount(0)
85 , hAlign(QQuickTextEdit::AlignLeft), vAlign(QQuickTextEdit::AlignTop)
86 , format(QQuickTextEdit::PlainText), wrapMode(QQuickTextEdit::NoWrap)
87 , renderType(QQuickTextUtil::textRenderType<QQuickTextEdit>())
88 , contentDirection(Qt::LayoutDirectionAuto)
89 , mouseSelectionMode(QQuickTextEdit::SelectCharacters)
90#if QT_CONFIG(im)
91 , inputMethodHints(Qt::ImhNone)
92#endif
93 , updateType(UpdatePaintNode)
94 , dirty(false), richText(false), cursorVisible(false), cursorPending(false)
95 , focusOnPress(true), persistentSelection(false), requireImplicitWidth(false)
96 , selectByMouse(true), canPaste(false), canPasteValid(false), hAlignImplicit(true)
97 , textCached(true), inLayout(false), selectByKeyboard(false), selectByKeyboardSet(false)
98 , hadSelection(false), markdownText(false), inResize(false)
99 {
100 }
101
103 return static_cast<QQuickTextEditPrivate *>(QObjectPrivate::get(item)); }
104
105 void init();
106
107 void resetInputMethod();
108 void updateDefaultTextOption();
110 bool determineHorizontalAlignment();
111 bool setHAlign(QQuickTextEdit::HAlignment, bool forceAlign = false);
112 void mirrorChange() override;
113 bool transformChanged(QQuickItem *transformedItem) override;
114 qreal getImplicitWidth() const override;
115 Qt::LayoutDirection textDirection(const QString &text) const;
116 bool isLinkHoveredConnected();
117
118#if QT_CONFIG(cursor)
119 void updateMouseCursorShape();
120#endif
121
123 void handleFocusEvent(QFocusEvent *event);
124 void addCurrentTextNodeToRoot(QQuickTextNodeEngine *, QSGTransformNode *, QQuickTextNode*, TextNodeIterator&, int startPos);
126
127#if QT_CONFIG(im)
128 Qt::InputMethodHints effectiveInputMethodHints() const;
129#endif
130
131 inline qreal padding() const { return extra.isAllocated() ? extra->padding : 0.0; }
132 void setTopPadding(qreal value, bool reset = false);
133 void setLeftPadding(qreal value, bool reset = false);
134 void setRightPadding(qreal value, bool reset = false);
135 void setBottomPadding(qreal value, bool reset = false);
136
137 bool isImplicitResizeEnabled() const;
138 void setImplicitResizeEnabled(bool enabled);
139
143
145
149
154
161
165 int firstBlockInViewport = -1; // only for the autotest; can be wrong after scrolling sometimes
166 int firstBlockPastViewport = -1; // only for the autotest
168
173 UpdateAll
174 };
175
183#if QT_CONFIG(im)
184 Qt::InputMethodHints inputMethodHints;
185#endif
187
188 bool dirty : 1;
189 bool richText : 1;
192 bool focusOnPress : 1;
196 bool canPaste:1;
200 bool inLayout:1;
203 bool hadSelection : 1;
204 bool markdownText : 1;
205 bool inResize : 1;
206
207 static const int largeTextSizeThreshold;
208};
209
210#ifndef QT_NO_DEBUG_STREAM
211QDebug Q_QUICK_PRIVATE_EXPORT operator<<(QDebug debug, const QQuickTextEditPrivate::Node &);
212#endif
213
215
216#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:469
\reentrant
Definition qfont.h:20
bool isAllocated() const
Definition qlist.h:74
static QObjectPrivate * get(QObject *o)
Definition qobject_p.h:153
The QQmlComponent class encapsulates a QML component definition.
void init(QQuickItem *parent)
virtual bool transformChanged(QQuickItem *transformedItem)
virtual void mirrorChange()
virtual qreal getImplicitWidth() const
The QQuickItem class provides the most basic of all visual items in \l {Qt Quick}.
Definition qquickitem.h:64
The QQuickTextDocument class provides access to the QTextDocument of QQuickTextEdit....
QList< Node >::iterator TextNodeIterator
QQuickTextEdit::HAlignment hAlign
QQuickTextEdit::SelectionMode mouseSelectionMode
QQuickTextEdit::TextFormat format
QLazilyAllocated< ExtraData > extra
Qt::LayoutDirection contentDirection
static const int largeTextSizeThreshold
QQuickTextControl * control
QQuickTextDocumentWithImageResources * document
QQuickTextDocument * quickDocument
QQuickTextEdit::WrapMode wrapMode
QQuickTextEdit::VAlignment vAlign
QQuickTextEdit::RenderType renderType
QQmlComponent * cursorComponent
static QQuickTextEditPrivate * get(QQuickTextEdit *item)
\inmodule QtCore\reentrant
Definition qrect.h:483
The QSGTransformNode class implements transformations in the scene graph.
Definition qsgnode.h:244
\inmodule QtCore
Definition qsize.h:207
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:127
\reentrant
Definition qtextlayout.h:70
\inmodule QtCore
Definition qurl.h:94
QString text
Combined button and popup list for selecting options.
LayoutDirection
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
GLenum GLenum GLsizei const GLuint GLboolean enabled
GLint GLsizei GLsizei GLenum format
struct _cl_event * event
GLboolean reset
QDebug Q_QUICK_PRIVATE_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)
#define QT_CONFIG(feature)
double qreal
Definition qtypes.h:92
if(qFloatDistance(a, b)<(1<< 7))
[0]
QDataStream & operator<<(QDataStream &out, const MyClass &myObj)
[4]
QObject::connect nullptr
QGraphicsItem * item
Node(int startPos=std::numeric_limits< int >::max(), QQuickTextNode *node=nullptr)
QQuickTextNode * textNode() const