44#if QT_CONFIG(accessibility)
45 ,
public QAccessible::ActivationObserver
49 Q_DECLARE_PUBLIC(QQuickTextEdit)
51 typedef QQuickTextEdit Public;
54 explicit Node(
int startPos = std::numeric_limits<
int>::max(),
55 QSGInternalTextNode *node =
nullptr)
56 : m_node(node), m_startPos(startPos) { }
57 QSGInternalTextNode *textNode()
const {
return m_node; }
58 void moveStartPos(
int delta) { Q_ASSERT(m_startPos + delta > 0); m_startPos += delta; }
59 int startPos()
const {
return m_startPos; }
60 void setDirty() { m_dirty =
true; }
61 bool dirty()
const {
return m_dirty; }
64 QSGInternalTextNode *m_node;
68#ifndef QT_NO_DEBUG_STREAM
69 friend QDebug Q_QUICK_EXPORT operator<<(QDebug,
const Node &);
72 typedef QList<Node>::iterator TextNodeIterator;
79 qreal leftPadding = 0;
80 qreal rightPadding = 0;
81 qreal bottomPadding = 0;
82 bool explicitTopPadding : 1;
83 bool explicitLeftPadding : 1;
84 bool explicitRightPadding : 1;
85 bool explicitBottomPadding : 1;
86 bool implicitResize : 1;
88 QLazilyAllocated<ExtraData> extra;
91 QQuickTextEditPrivate()
92 : dirty(
false), richText(
false), cursorVisible(
false), cursorPending(
false)
93 , focusOnPress(
true), persistentSelection(
false), requireImplicitWidth(
false)
94 , selectByMouse(
true), canPaste(
false), canPasteValid(
false), hAlignImplicit(
true)
95 , textCached(
true), inLayout(
false), selectByKeyboard(
false), selectByKeyboardSet(
false)
96 , hadSelection(
false), markdownText(
false), inResize(
false), ownsDocument(
false)
97 , containsUnscalableGlyphs(
false)
99#if QT_CONFIG(accessibility)
100 QAccessible::installActivationObserver(
this);
104 ~QQuickTextEditPrivate()
106#if QT_CONFIG(accessibility)
107 QAccessible::removeActivationObserver(
this);
111 static QQuickTextEditPrivate *get(QQuickTextEdit *item) {
112 return static_cast<QQuickTextEditPrivate *>(QObjectPrivate::get(item)); }
116 void resetInputMethod();
117 void updateDefaultTextOption();
118 void onDocumentStatusChanged();
119 void relayoutDocument();
120 bool determineHorizontalAlignment();
121 bool setHAlign(QQuickTextEdit::HAlignment,
bool forceAlign =
false);
122 void mirrorChange() override;
123 bool transformChanged(QQuickItem *transformedItem) override;
124 qreal getImplicitWidth()
const override;
125 Qt::LayoutDirection textDirection(
const QString &text)
const;
126 bool isLinkHoveredConnected();
127 bool isHoveredToolTipChangedConnected();
128 bool isHoveredSignalConnected();
131 void updateMouseCursorShape();
134 void setNativeCursorEnabled(
bool) {}
135#if QT_VERSION < QT_VERSION_CHECK(7
, 0
, 0
)
136 bool handleContextMenuEvent(QContextMenuEvent *event) override;
138 void handleFocusEvent(QFocusEvent *event);
139 void addCurrentTextNodeToRoot(QQuickTextNodeEngine *, QSGTransformNode *, QSGInternalTextNode *, TextNodeIterator&,
int startPos);
140 QSGInternalTextNode* createTextNode();
143 Qt::InputMethodHints effectiveInputMethodHints()
const;
146#if QT_CONFIG(accessibility)
147 void accessibilityActiveChanged(
bool active) override;
148 QAccessible::Role accessibleRole()
const override;
151 inline qreal padding()
const {
return extra.isAllocated() ? extra->padding : 0.0; }
152 void setTopPadding(qreal value,
bool reset =
false);
153 void setLeftPadding(qreal value,
bool reset =
false);
154 void setRightPadding(qreal value,
bool reset =
false);
155 void setBottomPadding(qreal value,
bool reset =
false);
157 bool isImplicitResizeEnabled()
const;
158 void setImplicitResizeEnabled(
bool enabled);
160 QColor color = QRgb(0xFF000000);
161 QColor selectionColor = QRgb(0xFF000080);
162 QColor selectedTextColor = QRgb(0xFFFFFFFF);
166 qreal textMargin = 0;
175 QQmlComponent* cursorComponent =
nullptr;
176 QQuickItem* cursorItem =
nullptr;
177 QTextDocument *document =
nullptr;
178 QQuickTextControl *control =
nullptr;
179 QQuickTextDocument *quickDocument =
nullptr;
180 mutable QQuickTextSelection *cursorSelection =
nullptr;
181 QList<Node> textNodeMap;
182 QList<QQuickPixmap *> pixmapsInProgress;
184 int lastSelectionStart = 0;
185 int lastSelectionEnd = 0;
187 int firstBlockInViewport = -1;
188 int firstBlockPastViewport = -1;
189 int renderedBlockCount = -1;
190 QRectF renderedRegion;
194 UpdateOnlyPreprocess,
199 QQuickTextEdit::HAlignment hAlign = QQuickTextEdit::AlignLeft;
200 QQuickTextEdit::VAlignment vAlign = QQuickTextEdit::AlignTop;
201 QQuickTextEdit::TextFormat format = QQuickTextEdit::PlainText;
202 QQuickTextEdit::WrapMode wrapMode = QQuickTextEdit::NoWrap;
203 QQuickTextEdit::RenderType renderType = QQuickTextUtil::textRenderType<QQuickTextEdit>();
204 Qt::LayoutDirection contentDirection = Qt::LayoutDirectionAuto;
205 QQuickTextEdit::SelectionMode mouseSelectionMode = QQuickTextEdit::SelectCharacters;
207 Qt::InputMethodHints inputMethodHints = Qt::ImhNone;
209 UpdateType updateType = UpdatePaintNode;
213 bool cursorVisible : 1;
214 bool cursorPending : 1;
215 bool focusOnPress : 1;
216 bool persistentSelection : 1;
217 bool requireImplicitWidth:1;
218 bool selectByMouse:1;
220 bool canPasteValid:1;
221 bool hAlignImplicit:1;
224 bool selectByKeyboard:1;
225 bool selectByKeyboardSet:1;
226 bool hadSelection : 1;
227 bool markdownText : 1;
229 bool ownsDocument : 1;
230 bool containsUnscalableGlyphs : 1;
232 static const int largeTextSizeThreshold;
void setTextColor(const QColor &textColor)
void setSelectionColor(const QColor &selectionColor)
void setSelectedTextColor(const QColor &selectedTextColor)
#define QQUICKTEXT_LARGETEXT_THRESHOLD
static bool operator<(const TextNode &n1, const TextNode &n2)
void resetEngine(QQuickTextNodeEngine *engine, const QColor &textColor, const QColor &selectedTextColor, const QColor &selectionColor, qreal dpr)
static const int nodeBreakingSize
\qmlsignal QtQuick::TextEdit::linkActivated(string link)
static void updateNodeTransform(QSGInternalTextNode *node, const QPointF &topLeft)
QQuickTextEditPrivate::Node TextNode