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();
129 void updateMouseCursorShape();
132 void setNativeCursorEnabled(
bool) {}
133#if QT_VERSION < QT_VERSION_CHECK(7
, 0
, 0
)
134 bool handleContextMenuEvent(QContextMenuEvent *event) override;
136 void handleFocusEvent(QFocusEvent *event);
137 void addCurrentTextNodeToRoot(QQuickTextNodeEngine *, QSGTransformNode *, QSGInternalTextNode *, TextNodeIterator&,
int startPos);
138 QSGInternalTextNode* createTextNode();
141 Qt::InputMethodHints effectiveInputMethodHints()
const;
144#if QT_CONFIG(accessibility)
145 void accessibilityActiveChanged(
bool active) override;
146 QAccessible::Role accessibleRole()
const override;
149 inline qreal padding()
const {
return extra.isAllocated() ? extra->padding : 0.0; }
150 void setTopPadding(qreal value,
bool reset =
false);
151 void setLeftPadding(qreal value,
bool reset =
false);
152 void setRightPadding(qreal value,
bool reset =
false);
153 void setBottomPadding(qreal value,
bool reset =
false);
155 bool isImplicitResizeEnabled()
const;
156 void setImplicitResizeEnabled(
bool enabled);
158 QColor color = QRgb(0xFF000000);
159 QColor selectionColor = QRgb(0xFF000080);
160 QColor selectedTextColor = QRgb(0xFFFFFFFF);
164 qreal textMargin = 0;
173 QQmlComponent* cursorComponent =
nullptr;
174 QQuickItem* cursorItem =
nullptr;
175 QTextDocument *document =
nullptr;
176 QQuickTextControl *control =
nullptr;
177 QQuickTextDocument *quickDocument =
nullptr;
178 mutable QQuickTextSelection *cursorSelection =
nullptr;
179 QList<Node> textNodeMap;
180 QList<QQuickPixmap *> pixmapsInProgress;
182 int lastSelectionStart = 0;
183 int lastSelectionEnd = 0;
185 int firstBlockInViewport = -1;
186 int firstBlockPastViewport = -1;
187 int renderedBlockCount = -1;
188 QRectF renderedRegion;
192 UpdateOnlyPreprocess,
197 QQuickTextEdit::HAlignment hAlign = QQuickTextEdit::AlignLeft;
198 QQuickTextEdit::VAlignment vAlign = QQuickTextEdit::AlignTop;
199 QQuickTextEdit::TextFormat format = QQuickTextEdit::PlainText;
200 QQuickTextEdit::WrapMode wrapMode = QQuickTextEdit::NoWrap;
201 QQuickTextEdit::RenderType renderType = QQuickTextUtil::textRenderType<QQuickTextEdit>();
202 Qt::LayoutDirection contentDirection = Qt::LayoutDirectionAuto;
203 QQuickTextEdit::SelectionMode mouseSelectionMode = QQuickTextEdit::SelectCharacters;
205 Qt::InputMethodHints inputMethodHints = Qt::ImhNone;
207 UpdateType updateType = UpdatePaintNode;
211 bool cursorVisible : 1;
212 bool cursorPending : 1;
213 bool focusOnPress : 1;
214 bool persistentSelection : 1;
215 bool requireImplicitWidth:1;
216 bool selectByMouse:1;
218 bool canPasteValid:1;
219 bool hAlignImplicit:1;
222 bool selectByKeyboard:1;
223 bool selectByKeyboardSet:1;
224 bool hadSelection : 1;
225 bool markdownText : 1;
227 bool ownsDocument : 1;
228 bool containsUnscalableGlyphs : 1;
230 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