Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/QtWidgets/qtextedit.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 // Copyright (C) 2019 The Qt Company Ltd.
0002 // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
0003 
0004 #ifndef QTEXTEDIT_H
0005 #define QTEXTEDIT_H
0006 
0007 #include <QtWidgets/qtwidgetsglobal.h>
0008 #include <QtWidgets/qabstractscrollarea.h>
0009 #include <QtGui/qtextdocument.h>
0010 #include <QtGui/qtextoption.h>
0011 #include <QtGui/qtextcursor.h>
0012 #include <QtGui/qtextformat.h>
0013 
0014 QT_REQUIRE_CONFIG(textedit);
0015 
0016 QT_BEGIN_NAMESPACE
0017 
0018 class QStyleSheet;
0019 class QTextDocument;
0020 class QMenu;
0021 class QTextEditPrivate;
0022 class QMimeData;
0023 class QPagedPaintDevice;
0024 class QRegularExpression;
0025 
0026 class Q_WIDGETS_EXPORT QTextEdit : public QAbstractScrollArea
0027 {
0028     Q_OBJECT
0029     Q_DECLARE_PRIVATE(QTextEdit)
0030     Q_PROPERTY(AutoFormatting autoFormatting READ autoFormatting WRITE setAutoFormatting)
0031     Q_PROPERTY(bool tabChangesFocus READ tabChangesFocus WRITE setTabChangesFocus)
0032     Q_PROPERTY(QString documentTitle READ documentTitle WRITE setDocumentTitle)
0033     Q_PROPERTY(bool undoRedoEnabled READ isUndoRedoEnabled WRITE setUndoRedoEnabled)
0034     Q_PROPERTY(LineWrapMode lineWrapMode READ lineWrapMode WRITE setLineWrapMode)
0035     QDOC_PROPERTY(QTextOption::WrapMode wordWrapMode READ wordWrapMode WRITE setWordWrapMode)
0036     Q_PROPERTY(int lineWrapColumnOrWidth READ lineWrapColumnOrWidth WRITE setLineWrapColumnOrWidth)
0037     Q_PROPERTY(bool readOnly READ isReadOnly WRITE setReadOnly)
0038 #if QT_CONFIG(textmarkdownreader) && QT_CONFIG(textmarkdownwriter)
0039     Q_PROPERTY(QString markdown READ toMarkdown WRITE setMarkdown NOTIFY textChanged)
0040 #endif
0041 #ifndef QT_NO_TEXTHTMLPARSER
0042     Q_PROPERTY(QString html READ toHtml WRITE setHtml NOTIFY textChanged USER true)
0043 #endif
0044     Q_PROPERTY(QString plainText READ toPlainText WRITE setPlainText DESIGNABLE false)
0045     Q_PROPERTY(bool overwriteMode READ overwriteMode WRITE setOverwriteMode)
0046     Q_PROPERTY(qreal tabStopDistance READ tabStopDistance WRITE setTabStopDistance)
0047     Q_PROPERTY(bool acceptRichText READ acceptRichText WRITE setAcceptRichText)
0048     Q_PROPERTY(int cursorWidth READ cursorWidth WRITE setCursorWidth)
0049     Q_PROPERTY(Qt::TextInteractionFlags textInteractionFlags READ textInteractionFlags
0050                WRITE setTextInteractionFlags)
0051     Q_PROPERTY(QTextDocument *document READ document WRITE setDocument DESIGNABLE false)
0052     Q_PROPERTY(QString placeholderText READ placeholderText WRITE setPlaceholderText)
0053 public:
0054     enum LineWrapMode {
0055         NoWrap,
0056         WidgetWidth,
0057         FixedPixelWidth,
0058         FixedColumnWidth
0059     };
0060     Q_ENUM(LineWrapMode)
0061 
0062     enum AutoFormattingFlag {
0063         AutoNone = 0,
0064         AutoBulletList = 0x00000001,
0065         AutoAll = 0xffffffff
0066     };
0067 
0068     Q_DECLARE_FLAGS(AutoFormatting, AutoFormattingFlag)
0069     Q_FLAG(AutoFormatting)
0070 
0071     explicit QTextEdit(QWidget *parent = nullptr);
0072     explicit QTextEdit(const QString &text, QWidget *parent = nullptr);
0073     virtual ~QTextEdit();
0074 
0075     void setDocument(QTextDocument *document);
0076     QTextDocument *document() const;
0077 
0078     void setPlaceholderText(const QString &placeholderText);
0079     QString placeholderText() const;
0080 
0081     void setTextCursor(const QTextCursor &cursor);
0082     QTextCursor textCursor() const;
0083 
0084     bool isReadOnly() const;
0085     void setReadOnly(bool ro);
0086 
0087     void setTextInteractionFlags(Qt::TextInteractionFlags flags);
0088     Qt::TextInteractionFlags textInteractionFlags() const;
0089 
0090     qreal fontPointSize() const;
0091     QString fontFamily() const;
0092     int fontWeight() const;
0093     bool fontUnderline() const;
0094     bool fontItalic() const;
0095     QColor textColor() const;
0096     QColor textBackgroundColor() const;
0097     QFont currentFont() const;
0098     Qt::Alignment alignment() const;
0099 
0100     void mergeCurrentCharFormat(const QTextCharFormat &modifier);
0101 
0102     void setCurrentCharFormat(const QTextCharFormat &format);
0103     QTextCharFormat currentCharFormat() const;
0104 
0105     AutoFormatting autoFormatting() const;
0106     void setAutoFormatting(AutoFormatting features);
0107 
0108     bool tabChangesFocus() const;
0109     void setTabChangesFocus(bool b);
0110 
0111     inline void setDocumentTitle(const QString &title)
0112     { document()->setMetaInformation(QTextDocument::DocumentTitle, title); }
0113     inline QString documentTitle() const
0114     { return document()->metaInformation(QTextDocument::DocumentTitle); }
0115 
0116     inline bool isUndoRedoEnabled() const
0117     { return document()->isUndoRedoEnabled(); }
0118     inline void setUndoRedoEnabled(bool enable)
0119     { document()->setUndoRedoEnabled(enable); }
0120 
0121     LineWrapMode lineWrapMode() const;
0122     void setLineWrapMode(LineWrapMode mode);
0123 
0124     int lineWrapColumnOrWidth() const;
0125     void setLineWrapColumnOrWidth(int w);
0126 
0127     QTextOption::WrapMode wordWrapMode() const;
0128     void setWordWrapMode(QTextOption::WrapMode policy);
0129 
0130     bool find(const QString &exp, QTextDocument::FindFlags options = QTextDocument::FindFlags());
0131 #if QT_CONFIG(regularexpression)
0132     bool find(const QRegularExpression &exp, QTextDocument::FindFlags options = QTextDocument::FindFlags());
0133 #endif
0134 
0135     QString toPlainText() const;
0136 #ifndef QT_NO_TEXTHTMLPARSER
0137     QString toHtml() const;
0138 #endif
0139 #if QT_CONFIG(textmarkdownwriter)
0140     QString toMarkdown(QTextDocument::MarkdownFeatures features = QTextDocument::MarkdownDialectGitHub) const;
0141 #endif
0142 
0143     void ensureCursorVisible();
0144 
0145     Q_INVOKABLE virtual QVariant loadResource(int type, const QUrl &name);
0146 #ifndef QT_NO_CONTEXTMENU
0147     QMenu *createStandardContextMenu();
0148     QMenu *createStandardContextMenu(const QPoint &position);
0149 #endif
0150 
0151     QTextCursor cursorForPosition(const QPoint &pos) const;
0152     QRect cursorRect(const QTextCursor &cursor) const;
0153     QRect cursorRect() const;
0154 
0155     QString anchorAt(const QPoint& pos) const;
0156 
0157     bool overwriteMode() const;
0158     void setOverwriteMode(bool overwrite);
0159 
0160     qreal tabStopDistance() const;
0161     void setTabStopDistance(qreal distance);
0162 
0163     int cursorWidth() const;
0164     void setCursorWidth(int width);
0165 
0166     bool acceptRichText() const;
0167     void setAcceptRichText(bool accept);
0168 
0169     struct ExtraSelection
0170     {
0171         QTextCursor cursor;
0172         QTextCharFormat format;
0173     };
0174     void setExtraSelections(const QList<ExtraSelection> &selections);
0175     QList<ExtraSelection> extraSelections() const;
0176 
0177     void moveCursor(QTextCursor::MoveOperation operation, QTextCursor::MoveMode mode = QTextCursor::MoveAnchor);
0178 
0179     bool canPaste() const;
0180 
0181     void print(QPagedPaintDevice *printer) const;
0182 
0183     QVariant inputMethodQuery(Qt::InputMethodQuery property) const override;
0184     Q_INVOKABLE QVariant inputMethodQuery(Qt::InputMethodQuery query, QVariant argument) const;
0185 
0186 public Q_SLOTS:
0187     void setFontPointSize(qreal s);
0188     void setFontFamily(const QString &fontFamily);
0189     void setFontWeight(int w);
0190     void setFontUnderline(bool b);
0191     void setFontItalic(bool b);
0192     void setTextColor(const QColor &c);
0193     void setTextBackgroundColor(const QColor &c);
0194     void setCurrentFont(const QFont &f);
0195     void setAlignment(Qt::Alignment a);
0196 
0197     void setPlainText(const QString &text);
0198 #ifndef QT_NO_TEXTHTMLPARSER
0199     void setHtml(const QString &text);
0200 #endif
0201 #if QT_CONFIG(textmarkdownreader)
0202     void setMarkdown(const QString &markdown);
0203 #endif
0204     void setText(const QString &text);
0205 
0206 #ifndef QT_NO_CLIPBOARD
0207     void cut();
0208     void copy();
0209     void paste();
0210 #endif
0211 
0212     void undo();
0213     void redo();
0214 
0215     void clear();
0216     void selectAll();
0217 
0218     void insertPlainText(const QString &text);
0219 #ifndef QT_NO_TEXTHTMLPARSER
0220     void insertHtml(const QString &text);
0221 #endif // QT_NO_TEXTHTMLPARSER
0222 
0223     void append(const QString &text);
0224 
0225     void scrollToAnchor(const QString &name);
0226 
0227     void zoomIn(int range = 1);
0228     void zoomOut(int range = 1);
0229 
0230 Q_SIGNALS:
0231     void textChanged();
0232     void undoAvailable(bool b);
0233     void redoAvailable(bool b);
0234     void currentCharFormatChanged(const QTextCharFormat &format);
0235     void copyAvailable(bool b);
0236     void selectionChanged();
0237     void cursorPositionChanged();
0238 
0239 protected:
0240     virtual bool event(QEvent *e) override;
0241     virtual void timerEvent(QTimerEvent *e) override;
0242     virtual void keyPressEvent(QKeyEvent *e) override;
0243     virtual void keyReleaseEvent(QKeyEvent *e) override;
0244     virtual void resizeEvent(QResizeEvent *e) override;
0245     virtual void paintEvent(QPaintEvent *e) override;
0246     virtual void mousePressEvent(QMouseEvent *e) override;
0247     virtual void mouseMoveEvent(QMouseEvent *e) override;
0248     virtual void mouseReleaseEvent(QMouseEvent *e) override;
0249     virtual void mouseDoubleClickEvent(QMouseEvent *e) override;
0250     virtual bool focusNextPrevChild(bool next) override;
0251 #ifndef QT_NO_CONTEXTMENU
0252     virtual void contextMenuEvent(QContextMenuEvent *e) override;
0253 #endif
0254 #if QT_CONFIG(draganddrop)
0255     virtual void dragEnterEvent(QDragEnterEvent *e) override;
0256     virtual void dragLeaveEvent(QDragLeaveEvent *e) override;
0257     virtual void dragMoveEvent(QDragMoveEvent *e) override;
0258     virtual void dropEvent(QDropEvent *e) override;
0259 #endif
0260     virtual void focusInEvent(QFocusEvent *e) override;
0261     virtual void focusOutEvent(QFocusEvent *e) override;
0262     virtual void showEvent(QShowEvent *) override;
0263     virtual void changeEvent(QEvent *e) override;
0264 #if QT_CONFIG(wheelevent)
0265     virtual void wheelEvent(QWheelEvent *e) override;
0266 #endif
0267 
0268     virtual QMimeData *createMimeDataFromSelection() const;
0269     virtual bool canInsertFromMimeData(const QMimeData *source) const;
0270     virtual void insertFromMimeData(const QMimeData *source);
0271 
0272     virtual void inputMethodEvent(QInputMethodEvent *) override;
0273 
0274     QTextEdit(QTextEditPrivate &dd, QWidget *parent);
0275 
0276     virtual void scrollContentsBy(int dx, int dy) override;
0277     virtual void doSetTextCursor(const QTextCursor &cursor);
0278 
0279     void zoomInF(float range);
0280 
0281 private:
0282     Q_DISABLE_COPY(QTextEdit)
0283     friend class QTextEditControl;
0284     friend class QTextDocument;
0285     friend class QWidgetTextControl;
0286 };
0287 
0288 Q_DECLARE_OPERATORS_FOR_FLAGS(QTextEdit::AutoFormatting)
0289 
0290 QT_END_NAMESPACE
0291 
0292 #endif // QTEXTEDIT_H