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 QTEXTDOCUMENTFRAGMENT_H
5#define QTEXTDOCUMENTFRAGMENT_H
6
7#include <QtGui/qtguiglobal.h>
8#include <QtGui/qtextdocument.h>
9#include <QtCore/qstring.h>
10
11QT_BEGIN_NAMESPACE
12
13
14class QTextStream;
15class QTextDocumentFragmentPrivate;
16class QTextCursor;
17
18class Q_GUI_EXPORT QTextDocumentFragment
19{
20public:
21 QTextDocumentFragment();
22 explicit QTextDocumentFragment(const QTextDocument *document);
23 explicit QTextDocumentFragment(const QTextCursor &range);
24 QTextDocumentFragment(const QTextDocumentFragment &rhs);
25 QTextDocumentFragment &operator=(const QTextDocumentFragment &rhs);
26 ~QTextDocumentFragment();
27
28 bool isEmpty() const;
29
30 QString toPlainText() const;
31 QString toRawText() const;
32#ifndef QT_NO_TEXTHTMLPARSER
33 QString toHtml() const;
34#endif // QT_NO_TEXTHTMLPARSER
35#if QT_CONFIG(textmarkdownwriter)
36 QString toMarkdown(QTextDocument::MarkdownFeatures features = QTextDocument::MarkdownDialectGitHub) const;
37#endif
38
39 static QTextDocumentFragment fromPlainText(const QString &plainText);
40#ifndef QT_NO_TEXTHTMLPARSER
41 static QTextDocumentFragment fromHtml(const QString &html, const QTextDocument *resourceProvider = nullptr);
42#endif // QT_NO_TEXTHTMLPARSER
43#if QT_CONFIG(textmarkdownreader)
44 static QTextDocumentFragment fromMarkdown(const QString &markdown,
45 QTextDocument::MarkdownFeatures features = QTextDocument::MarkdownDialectGitHub);
46#endif
47
48private:
49 QTextDocumentFragmentPrivate *d;
50 friend class QTextCursor;
51 friend class QTextDocumentWriter;
52};
53
54QT_END_NAMESPACE
55
56#endif // QTEXTDOCUMENTFRAGMENT_H
57

source code of qtbase/src/gui/text/qtextdocumentfragment.h