diff options
author | Alexander Volkov <avolkov@astralinux.ru> | 2018-09-25 18:09:28 +0300 |
---|---|---|
committer | Alexander Volkov <avolkov@astralinux.ru> | 2021-01-12 15:33:10 +0300 |
commit | 376e3bd8ecf40881685714f6f19e12d68e92127e (patch) | |
tree | 8a137b8cea51115b405202ef6c0cffdf6fe78192 /src/gui/text/qtextdocument.h | |
parent | 9e09677c1dd4da92735736a0fbcb703416bf4d6d (diff) |
Introduce QUrlResourceProvider to load resources for HTML
QTextDocument and the text editor classes suggest to override
their loadResource() methods to provide data associated with
a text document. This approach has the following drawbacks:
- it requires subclassing
- there is no way to set a global resource provider
- QLabel is missing virtual loadResource() method and
it can't be added without breaking ABI
QUrlResourceProvider is designed to solve these issues.
One should create a derived class that implements
QUrlResourceProvider::resource(). The objects of the derived
class then can be set for any text document.
The default resource provider can be set with
QUrlResourceProvider::setDefaultProvider().
This change also adds QLabel::setResourceProvider(),
which doesn't break ABI.
[ChangeLog][QtGui][Text] Introduced QUrlResourceProvider that allows to
load resources for HTML. It is intended to replace the use of
QTextDocument::loadResource().
Change-Id: Iaf19b229f522a73508f20715257450fe58f68daf
Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src/gui/text/qtextdocument.h')
-rw-r--r-- | src/gui/text/qtextdocument.h | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/gui/text/qtextdocument.h b/src/gui/text/qtextdocument.h index 23fffc4771..ea57b697a8 100644 --- a/src/gui/text/qtextdocument.h +++ b/src/gui/text/qtextdocument.h @@ -68,6 +68,7 @@ class QVariant; class QRectF; class QTextOption; class QTextCursor; +class QUrlResourceProvider; namespace Qt @@ -239,6 +240,9 @@ public: QVariant resource(int type, const QUrl &name) const; void addResource(int type, const QUrl &name, const QVariant &resource); + QUrlResourceProvider *resourceProvider() const; + void setResourceProvider(QUrlResourceProvider *provider); + QList<QTextFormat> allFormats() const; void markContentsDirty(int from, int length); |