syndication/atom
27 #include <QtCore/QByteArray>
28 #include <QtXml/QDomElement>
29 #include <QtCore/QString>
30 #include <QtCore/QStringList>
32 namespace Syndication {
35 class Content::ContentPrivate
39 ContentPrivate() : formatIdentified(false)
43 mutable bool formatIdentified;
50 Content::Content(
const QDomElement& element) : ElementWrapper(element), d(new ContentPrivate)
64 ElementWrapper::operator=(other);
71 return attribute(QLatin1String(
"type"));
76 return completeURI(attribute(QLatin1String(
"src")));
83 return QByteArray::fromBase64(text().trimmed().toLatin1());
87 static QStringList xmltypes;
96 if (
type.isNull() &&
src.isEmpty())
97 type = QLatin1String(
"text");
99 if (
type == QLatin1String(
"html")
100 ||
type == QLatin1String(
"text/html"))
103 if (
type == QLatin1String(
"text")
104 || (
type.startsWith(QLatin1String(
"text/"), Qt::CaseInsensitive)
105 && !
type.startsWith(QLatin1String(
"text/xml"), Qt::CaseInsensitive))
109 if (xmltypes.isEmpty())
111 xmltypes.append(QLatin1String(
"xhtml"));
112 xmltypes.append(QLatin1String(
"application/xhtml+xml"));
114 xmltypes.append(QLatin1String(
"text/xml"));
115 xmltypes.append(QLatin1String(
"application/xml"));
116 xmltypes.append(QLatin1String(
"text/xml-external-parsed-entity"));
117 xmltypes.append(QLatin1String(
"application/xml-external-parsed-entity"));
118 xmltypes.append(QLatin1String(
"application/xml-dtd"));
119 xmltypes.append(QLatin1String(
"text/x-dtd"));
122 if (xmltypes.contains(
type)
123 ||
type.endsWith(QLatin1String(
"+xml"), Qt::CaseInsensitive)
124 ||
type.endsWith(QLatin1String(
"/xml"), Qt::CaseInsensitive))
132 if (d->formatIdentified ==
false)
135 d->formatIdentified =
true;
147 return src().isEmpty();
171 return plainTextToHtml(text()).trimmed();
175 return text().trimmed();
179 return childNodesAsXML().trimmed();
188 info += QLatin1String(
"### Content: ###################\n");
189 info += QLatin1String(
"type: #") +
type() + QLatin1String(
"#\n");
191 info += QLatin1String(
"src: #") +
src() + QLatin1String(
"#\n");
193 info += QLatin1String(
"content: #") +
asString() + QLatin1String(
"#\n");
196 info += QLatin1String(
"binary length: #") + QString::number(
asByteArray().size()) + QLatin1String(
"#\n");
198 info += QLatin1String(
"### Content end ################\n");
Format
format of the content.
bool isXML() const
returns whether the content is embedded XML.
QString asString() const
returns the content as string.
Content()
creates a null content object.
bool isContained() const
returns whether the content is contained in the feed source, or not.
@ EscapedHTML
the content is escaped HTML, (i.e., "<", ">" etc.
@ XML
the content is embedded XML
static Format mapTypeToFormat(const QString &type, const QString &src=QString())
maps a mimetype to Format enum according to the Atom 1.0 specification
The content element either contains or links the content of an entry.
QString type() const
the type of the content.
@ PlainText
the content is plain text (i.e.
QString debugInfo() const
returns a description of the content object for debugging purposes
@ Binary
the content is base64-encoded binary content
QByteArray asByteArray() const
returns binary content as byte array.
bool isEscapedHTML() const
returns whether the content is escaped HTML or not Use asString() to access it
bool isBinary() const
returns whether the content is binary content or not.
Content & operator=(const Content &other)
assigns another content objecct
Format format() const
returns the content format
bool isPlainText() const
returns whether the content is plain text or not.
QString src() const
If src() is set, the content of this entry is not contained in the feed source, but available on the ...
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Wed Jan 29 2020 00:00:00 by
doxygen 1.8.17 written
by
Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.