aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/items/qquicktextedit_p_p.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/quick/items/qquicktextedit_p_p.h')
-rw-r--r--src/quick/items/qquicktextedit_p_p.h188
1 files changed, 94 insertions, 94 deletions
diff --git a/src/quick/items/qquicktextedit_p_p.h b/src/quick/items/qquicktextedit_p_p.h
index be555d44fd..da01be47c2 100644
--- a/src/quick/items/qquicktextedit_p_p.h
+++ b/src/quick/items/qquicktextedit_p_p.h
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtQuick module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef QQUICKTEXTEDIT_P_P_H
#define QQUICKTEXTEDIT_P_P_H
@@ -55,20 +19,30 @@
#include "qquickimplicitsizeitem_p_p.h"
#include "qquicktextutil_p.h"
+#include <QtQuick/private/qquicktextselection_p.h>
+
#include <QtQml/qqml.h>
#include <QtCore/qlist.h>
#include <private/qlazilyallocated_p.h>
+#include <private/qquicktextdocument_p.h>
+
+#if QT_CONFIG(accessibility)
+#include <QtGui/qaccessible.h>
+#endif
#include <limits>
QT_BEGIN_NAMESPACE
class QTextLayout;
-class QQuickTextDocumentWithImageResources;
+class QQuickPixmap;
class QQuickTextControl;
-class QQuickTextNode;
+class QSGInternalTextNode;
class QQuickTextNodeEngine;
-class Q_QUICK_PRIVATE_EXPORT QQuickTextEditPrivate : public QQuickImplicitSizeItemPrivate
+class Q_QUICK_EXPORT QQuickTextEditPrivate : public QQuickImplicitSizeItemPrivate
+#if QT_CONFIG(accessibility)
+ , public QAccessible::ActivationObserver
+#endif
{
public:
Q_DECLARE_PUBLIC(QQuickTextEdit)
@@ -77,29 +51,33 @@ public:
struct Node {
explicit Node(int startPos = std::numeric_limits<int>::max(),
- QQuickTextNode *node = nullptr)
- : m_startPos(startPos), m_node(node), m_dirty(false) { }
- QQuickTextNode* textNode() const { return m_node; }
+ QSGInternalTextNode *node = nullptr)
+ : m_node(node), m_startPos(startPos) { }
+ QSGInternalTextNode *textNode() const { return m_node; }
void moveStartPos(int delta) { Q_ASSERT(m_startPos + delta > 0); m_startPos += delta; }
int startPos() const { return m_startPos; }
void setDirty() { m_dirty = true; }
bool dirty() const { return m_dirty; }
private:
+ QSGInternalTextNode *m_node;
int m_startPos;
- QQuickTextNode* m_node;
- bool m_dirty;
+ bool m_dirty = false;
+
+#ifndef QT_NO_DEBUG_STREAM
+ friend QDebug Q_QUICK_EXPORT operator<<(QDebug, const Node &);
+#endif
};
typedef QList<Node>::iterator TextNodeIterator;
struct ExtraData {
ExtraData();
- qreal padding;
- qreal topPadding;
- qreal leftPadding;
- qreal rightPadding;
- qreal bottomPadding;
+ qreal padding = 0;
+ qreal topPadding = 0;
+ qreal leftPadding = 0;
+ qreal rightPadding = 0;
+ qreal bottomPadding = 0;
bool explicitTopPadding : 1;
bool explicitLeftPadding : 1;
bool explicitRightPadding : 1;
@@ -110,25 +88,22 @@ public:
QQuickTextEditPrivate()
- : color(QRgb(0xFF000000)), selectionColor(QRgb(0xFF000080)), selectedTextColor(QRgb(0xFFFFFFFF))
- , textMargin(0.0), xoff(0), yoff(0)
- , font(sourceFont), cursorComponent(nullptr), cursorItem(nullptr), document(nullptr), control(nullptr)
- , quickDocument(nullptr), lastSelectionStart(0), lastSelectionEnd(0), lineCount(0)
- , hAlign(QQuickTextEdit::AlignLeft), vAlign(QQuickTextEdit::AlignTop)
- , format(QQuickTextEdit::PlainText), wrapMode(QQuickTextEdit::NoWrap)
- , renderType(QQuickTextUtil::textRenderType<QQuickTextEdit>())
- , contentDirection(Qt::LayoutDirectionAuto)
- , mouseSelectionMode(QQuickTextEdit::SelectCharacters)
-#if QT_CONFIG(im)
- , inputMethodHints(Qt::ImhNone)
-#endif
- , updateType(UpdatePaintNode)
- , dirty(false), richText(false), cursorVisible(false), cursorPending(false)
+ : dirty(false), richText(false), cursorVisible(false), cursorPending(false)
, focusOnPress(true), persistentSelection(false), requireImplicitWidth(false)
- , selectByMouse(false), canPaste(false), canPasteValid(false), hAlignImplicit(true)
+ , selectByMouse(true), canPaste(false), canPasteValid(false), hAlignImplicit(true)
, textCached(true), inLayout(false), selectByKeyboard(false), selectByKeyboardSet(false)
- , hadSelection(false), markdownText(false)
+ , hadSelection(false), markdownText(false), inResize(false), ownsDocument(false)
+ {
+#if QT_CONFIG(accessibility)
+ QAccessible::installActivationObserver(this);
+#endif
+ }
+
+ ~QQuickTextEditPrivate()
{
+#if QT_CONFIG(accessibility)
+ QAccessible::removeActivationObserver(this);
+#endif
}
static QQuickTextEditPrivate *get(QQuickTextEdit *item) {
@@ -138,23 +113,34 @@ public:
void resetInputMethod();
void updateDefaultTextOption();
+ void onDocumentStatusChanged();
void relayoutDocument();
bool determineHorizontalAlignment();
bool setHAlign(QQuickTextEdit::HAlignment, bool forceAlign = false);
void mirrorChange() override;
+ bool transformChanged(QQuickItem *transformedItem) override;
qreal getImplicitWidth() const override;
Qt::LayoutDirection textDirection(const QString &text) const;
bool isLinkHoveredConnected();
+#if QT_CONFIG(cursor)
+ void updateMouseCursorShape();
+#endif
+
void setNativeCursorEnabled(bool) {}
void handleFocusEvent(QFocusEvent *event);
- void addCurrentTextNodeToRoot(QQuickTextNodeEngine *, QSGTransformNode *, QQuickTextNode*, TextNodeIterator&, int startPos);
- QQuickTextNode* createTextNode();
+ void addCurrentTextNodeToRoot(QQuickTextNodeEngine *, QSGTransformNode *, QSGInternalTextNode *, TextNodeIterator&, int startPos);
+ QSGInternalTextNode* createTextNode();
#if QT_CONFIG(im)
Qt::InputMethodHints effectiveInputMethodHints() const;
#endif
+#if QT_CONFIG(accessibility)
+ void accessibilityActiveChanged(bool active) override;
+ QAccessible::Role accessibleRole() const override;
+#endif
+
inline qreal padding() const { return extra.isAllocated() ? extra->padding : 0.0; }
void setTopPadding(qreal value, bool reset = false);
void setLeftPadding(qreal value, bool reset = false);
@@ -164,50 +150,56 @@ public:
bool isImplicitResizeEnabled() const;
void setImplicitResizeEnabled(bool enabled);
- QColor color;
- QColor selectionColor;
- QColor selectedTextColor;
+ QColor color = QRgb(0xFF000000);
+ QColor selectionColor = QRgb(0xFF000080);
+ QColor selectedTextColor = QRgb(0xFFFFFFFF);
QSizeF contentSize;
- qreal textMargin;
- qreal xoff;
- qreal yoff;
+ qreal textMargin = 0;
+ qreal xoff = 0;
+ qreal yoff = 0;
QString text;
QUrl baseUrl;
QFont sourceFont;
QFont font;
- QQmlComponent* cursorComponent;
- QQuickItem* cursorItem;
- QQuickTextDocumentWithImageResources *document;
- QQuickTextControl *control;
- QQuickTextDocument *quickDocument;
+ QQmlComponent* cursorComponent = nullptr;
+ QQuickItem* cursorItem = nullptr;
+ QTextDocument *document = nullptr;
+ QQuickTextControl *control = nullptr;
+ QQuickTextDocument *quickDocument = nullptr;
+ mutable QQuickTextSelection *cursorSelection = nullptr;
QList<Node> textNodeMap;
+ QList<QQuickPixmap *> pixmapsInProgress;
- int lastSelectionStart;
- int lastSelectionEnd;
- int lineCount;
+ int lastSelectionStart = 0;
+ int lastSelectionEnd = 0;
+ int lineCount = 0;
+ int firstBlockInViewport = -1; // can be wrong after scrolling sometimes
+ int firstBlockPastViewport = -1; // only for the autotest
+ int renderedBlockCount = -1; // only for the autotest
+ QRectF renderedRegion;
enum UpdateType {
UpdateNone,
UpdateOnlyPreprocess,
- UpdatePaintNode
+ UpdatePaintNode,
+ UpdateAll
};
- QQuickTextEdit::HAlignment hAlign;
- QQuickTextEdit::VAlignment vAlign;
- QQuickTextEdit::TextFormat format;
- QQuickTextEdit::WrapMode wrapMode;
- QQuickTextEdit::RenderType renderType;
- Qt::LayoutDirection contentDirection;
- QQuickTextEdit::SelectionMode mouseSelectionMode;
+ QQuickTextEdit::HAlignment hAlign = QQuickTextEdit::AlignLeft;
+ QQuickTextEdit::VAlignment vAlign = QQuickTextEdit::AlignTop;
+ QQuickTextEdit::TextFormat format = QQuickTextEdit::PlainText;
+ QQuickTextEdit::WrapMode wrapMode = QQuickTextEdit::NoWrap;
+ QQuickTextEdit::RenderType renderType = QQuickTextUtil::textRenderType<QQuickTextEdit>();
+ Qt::LayoutDirection contentDirection = Qt::LayoutDirectionAuto;
+ QQuickTextEdit::SelectionMode mouseSelectionMode = QQuickTextEdit::SelectCharacters;
#if QT_CONFIG(im)
- Qt::InputMethodHints inputMethodHints;
+ Qt::InputMethodHints inputMethodHints = Qt::ImhNone;
#endif
- UpdateType updateType;
- Qt::CursorShape cursorToRestoreAfterHover = Qt::IBeamCursor;
+ UpdateType updateType = UpdatePaintNode;
bool dirty : 1;
bool richText : 1;
@@ -226,8 +218,16 @@ public:
bool selectByKeyboardSet:1;
bool hadSelection : 1;
bool markdownText : 1;
+ bool inResize : 1;
+ bool ownsDocument : 1;
+
+ static const int largeTextSizeThreshold;
};
+#ifndef QT_NO_DEBUG_STREAM
+QDebug Q_QUICK_EXPORT operator<<(QDebug debug, const QQuickTextEditPrivate::Node &);
+#endif
+
QT_END_NAMESPACE
#endif // QQUICKTEXTEDIT_P_P_H