| 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 QTEXTEDIT_P_H |
| 5 | #define QTEXTEDIT_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 <QtWidgets/private/qtwidgetsglobal_p.h> |
| 19 | #include "private/qabstractscrollarea_p.h" |
| 20 | #include "QtGui/qtextdocumentfragment.h" |
| 21 | #if QT_CONFIG(scrollbar) |
| 22 | #include "QtWidgets/qscrollbar.h" |
| 23 | #endif |
| 24 | #include "QtGui/qtextcursor.h" |
| 25 | #include "QtGui/qtextformat.h" |
| 26 | #if QT_CONFIG(menu) |
| 27 | #include "QtWidgets/qmenu.h" |
| 28 | #endif |
| 29 | #include "QtGui/qabstracttextdocumentlayout.h" |
| 30 | #include "QtCore/qbasictimer.h" |
| 31 | #include "QtCore/qurl.h" |
| 32 | #include "qtextedit.h" |
| 33 | |
| 34 | #include "private/qwidgettextcontrol_p.h" |
| 35 | |
| 36 | #include <array> |
| 37 | |
| 38 | QT_REQUIRE_CONFIG(textedit); |
| 39 | |
| 40 | QT_BEGIN_NAMESPACE |
| 41 | |
| 42 | class QMimeData; |
| 43 | class QTextEditPrivate : public QAbstractScrollAreaPrivate |
| 44 | { |
| 45 | Q_DECLARE_PUBLIC(QTextEdit) |
| 46 | public: |
| 47 | QTextEditPrivate(); |
| 48 | ~QTextEditPrivate(); |
| 49 | |
| 50 | void init(const QString &html = QString()); |
| 51 | void paint(QPainter *p, QPaintEvent *e); |
| 52 | void repaintContents(const QRectF &contentsRect); |
| 53 | |
| 54 | inline QPoint mapToContents(const QPoint &point) const |
| 55 | { return QPoint(point.x() + horizontalOffset(), point.y() + verticalOffset()); } |
| 56 | |
| 57 | void adjustScrollbars(); |
| 58 | void ensureVisible(const QRectF &rect); |
| 59 | void relayoutDocument(); |
| 60 | |
| 61 | void createAutoBulletList(); |
| 62 | void pageUpDown(QTextCursor::MoveOperation op, QTextCursor::MoveMode moveMode); |
| 63 | |
| 64 | inline int horizontalOffset() const |
| 65 | { return q_func()->isRightToLeft() ? (hbar->maximum() - hbar->value()) : hbar->value(); } |
| 66 | inline int verticalOffset() const |
| 67 | { return vbar->value(); } |
| 68 | |
| 69 | inline void sendControlEvent(QEvent *e) |
| 70 | { control->processEvent(e, coordinateOffset: QPointF(horizontalOffset(), verticalOffset()), contextWidget: viewport); } |
| 71 | |
| 72 | void cursorPositionChanged(); |
| 73 | void hoveredBlockWithMarkerChanged(const QTextBlock &block); |
| 74 | |
| 75 | void updateDefaultTextOption(); |
| 76 | |
| 77 | // re-implemented by QTextBrowser, called by QTextDocument::loadResource |
| 78 | virtual QUrl resolveUrl(const QUrl &url) const |
| 79 | { return url; } |
| 80 | |
| 81 | QWidgetTextControl *control; |
| 82 | |
| 83 | QTextEdit::AutoFormatting autoFormatting; |
| 84 | bool tabChangesFocus; |
| 85 | |
| 86 | QBasicTimer autoScrollTimer; |
| 87 | QPoint autoScrollDragPos; |
| 88 | |
| 89 | QTextEdit::LineWrapMode lineWrap; |
| 90 | int lineWrapColumnOrWidth; |
| 91 | QTextOption::WrapMode wordWrap; |
| 92 | |
| 93 | uint ignoreAutomaticScrollbarAdjustment : 1; |
| 94 | uint preferRichText : 1; |
| 95 | uint showCursorOnInitialShow : 1; |
| 96 | uint inDrag : 1; |
| 97 | uint clickCausedFocus : 1; |
| 98 | |
| 99 | QString anchorToScrollToWhenVisible; |
| 100 | |
| 101 | QString placeholderText; |
| 102 | |
| 103 | Qt::CursorShape cursorToRestoreAfterHover = Qt::IBeamCursor; |
| 104 | |
| 105 | std::array<QMetaObject::Connection, 13> connections; |
| 106 | |
| 107 | #ifdef QT_KEYPAD_NAVIGATION |
| 108 | QBasicTimer deleteAllTimer; |
| 109 | #endif |
| 110 | }; |
| 111 | |
| 112 | QT_END_NAMESPACE |
| 113 | |
| 114 | #endif // QTEXTEDIT_P_H |
| 115 | |