Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qquicktextdocument_p.h
Go to the documentation of this file.
1// Copyright (C) 2018 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 QQUICKTEXTDOCUMENT_P_H
5#define QQUICKTEXTDOCUMENT_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
19
20#include <QtGui/qabstracttextdocumentlayout.h>
21#include <QtGui/qtextdocument.h>
22#include <QtGui/qtextdocumentfragment.h>
23#include <QtGui/qtextformat.h>
24#include <QtCore/qrect.h>
25#include <QtCore/private/qobject_p_p.h>
26
27#if QT_CONFIG(mimetype)
28#include <QtCore/qmimedatabase.h>
29#endif
30
32
33class QQuickPixmap;
34class QQuickTextEdit;
35
36/*! \internal
37 QTextImageHandler would attempt to resolve relative paths, and load the
38 image itself if the document returns an invalid image from loadResource().
39 We replace it with this version instead, because Qt Quick's text resources
40 are resolved against the Text item's context, and because we override
41 intrinsicSize(). drawObject() is empty because we don't need to use this
42 handler to paint images: they get put into scene graph nodes instead.
43*/
45{
46 Q_OBJECT
47 Q_INTERFACES(QTextObjectInterface)
48public:
51 QSizeF intrinsicSize(QTextDocument *doc, int posInDocument, const QTextFormat &format) override;
52 void drawObject(QPainter *, const QRectF &, QTextDocument *, int, const QTextFormat &) override { }
53};
54
56{
57 Q_DECLARE_PUBLIC(QQuickTextDocument)
58public:
60 static const QQuickTextDocumentPrivate *get(const QQuickTextDocument *doc) { return doc->d_func(); }
61
62 void load();
63 void writeTo(const QUrl &fileUrl);
64 QTextDocument *document() const;
65 void setDocument(QTextDocument *doc);
66 void setStatus(QQuickTextDocument::Status s, const QString &err);
67
68 // so far the QQuickItem given to the QQuickTextDocument ctor is always a QQuickTextEdit
69 QQuickTextEdit *editor = nullptr;
72 Qt::TextFormat detectedFormat = Qt::AutoText; // url's extension, independent of TextEdit.textFormat
73 std::optional<QStringConverter::Encoding> encoding; // only relevant for HTML (Qt::RichText)
75};
76
77namespace QtPrivate {
79{
80public:
82 {
83 return format(pos);
84 }
85};
86} // namespace QtPrivate
87
88QT_END_NAMESPACE
89
90#endif // QQUICKTEXTDOCUMENT_P_H
QTextDocument * document() const
std::optional< QStringConverter::Encoding > encoding
void setStatus(QQuickTextDocument::Status s, const QString &err)
void setDocument(QTextDocument *doc)
void writeTo(const QUrl &fileUrl)
~QQuickTextImageHandler() override=default
void drawObject(QPainter *, const QRectF &, QTextDocument *, int, const QTextFormat &) override
Draws this text object using the specified painter.
QSizeF intrinsicSize(QTextDocument *doc, int posInDocument, const QTextFormat &format) override
The intrinsicSize() function returns the size of the text object represented by format in the given d...
QTextCharFormat formatAccessor(int pos)
Combined button and popup list for selecting options.