9#include <rss2/category.h>
10#include <rss2/enclosure.h>
12#include <rss2/source.h>
13#include <rss2/tools_p.h>
14#include <specificitem.h>
15#include <specificitemvisitor.h>
28class SYNDICATION_NO_EXPORT
Item::ItemPrivate
42 : ElementWrapper(element)
52Item::Item(
const Item &other)
53 : ElementWrapper(other)
59Item &Item::operator=(
const Item &other)
61 ElementWrapper::operator=(other);
62 SpecificItem::operator=(other);
70 return originalTitle();
74 bool containsMarkup =
false;
75 d->doc->getItemTitleFormatInfo(&isCDATA, &containsMarkup);
77 return normalize(originalTitle(), isCDATA, containsMarkup);
80QString Item::originalDescription()
const
82 return extractElementTextNS(
QString(), QStringLiteral(
"description"));
85QString Item::originalTitle()
const
87 return extractElementTextNS(
QString(), QStringLiteral(
"title"));
92 QString url = extractElementTextNS(
QString(), QStringLiteral(
"link"));
99 if (d->doc->link().isEmpty()) {
104 QString baseUrl = d->doc->link();
106 return baseUrl + url;
112QString Item::description()
const
115 return originalDescription();
118 bool isCDATA =
false;
119 bool containsMarkup =
false;
120 d->doc->getItemDescriptionFormatInfo(&isCDATA, &containsMarkup);
122 return normalize(originalDescription(), isCDATA, containsMarkup);
128 return extractContent(*
this);
138 std::transform(cats.
cbegin(), cats.
cend(), std::back_inserter(categories), [](
const QDomElement &element) {
139 return Category(element);
147 return extractElementTextNS(
QString(), QStringLiteral(
"comments"));
152 QString a = extractElementTextNS(
QString(), QStringLiteral(
"author"));
157 return extractElementTextNS(dublinCoreNamespace(), QStringLiteral(
"creator"));
168 std::transform(encs.
cbegin(), encs.
cend(), std::back_inserter(enclosures), [](
const QDomElement &element) {
169 return Enclosure(element);
177 return extractElementTextNS(
QString(), QStringLiteral(
"guid"));
180bool Item::guidIsPermaLink()
const
182 bool guidIsPermaLink =
true;
187 guidIsPermaLink =
false;
191 return guidIsPermaLink;
194time_t Item::pubDate()
const
196 QString str = extractElementTextNS(
QString(), QStringLiteral(
"pubDate"));
199 return parseDate(str, RFCDate);
203 str = extractElementTextNS(dublinCoreNamespace(), QStringLiteral(
"date"));
204 return parseDate(str, ISODate);
207time_t Item::expirationDate()
const
209 QString str = extractElementTextNS(
QString(), QStringLiteral(
"expirationDate"));
210 return parseDate(str, RFCDate);
213Source Item::source()
const
215 return Source(firstElementByTagNameNS(
QString(), QStringLiteral(
"source")));
220 return extractElementTextNS(
QString(), QStringLiteral(
"rating"));
226 if (!title().isNull()) {
229 if (!
link().isNull()) {
232 if (!description().isNull()) {
235 if (!content().isNull()) {
238 if (!author().isNull()) {
248 if (!guid().isNull()) {
251 if (guidIsPermaLink()) {
254 if (!source().isNull()) {
255 info += source().debugInfo();
259 for (
const auto &c : cats) {
260 info += c.debugInfo();
264 for (
const auto &e : encs) {
265 info += e.debugInfo();
275 static std::vector<ElementType> handled;
276 if (handled.empty()) {
278 handled.push_back(ElementType(QStringLiteral(
"title")));
279 handled.push_back(ElementType(QStringLiteral(
"link")));
280 handled.push_back(ElementType(QStringLiteral(
"description")));
281 handled.push_back(ElementType(QStringLiteral(
"pubDate")));
282 handled.push_back(ElementType(QStringLiteral(
"expirationDate")));
283 handled.push_back(ElementType(QStringLiteral(
"rating")));
284 handled.push_back(ElementType(QStringLiteral(
"source")));
285 handled.push_back(ElementType(QStringLiteral(
"guid")));
286 handled.push_back(ElementType(QStringLiteral(
"comments")));
287 handled.push_back(ElementType(QStringLiteral(
"author")));
288 handled.push_back(ElementType(QStringLiteral(
"date"), dublinCoreNamespace()));
295 for (
int i = 0; i < numChildren; ++i) {
298 && std::find(handled.cbegin(), handled.cend(), ElementType(el.
localName(), el.
namespaceURI())) == handled.cend()) {
306bool Item::accept(SpecificItemVisitor *visitor)
308 return visitor->visitRSS2Item(
this);
KIOCORE_EXPORT CopyJob * link(const QList< QUrl > &src, const QUrl &destDir, JobFlags flags=DefaultFlags)
QString normalize(QStringView str)
KEDUVOCDOCUMENT_EXPORT QStringList comments(const QString &language=QString())
QString attribute(const QString &name, const QString &defValue) const const
bool isNull() const const
QString localName() const const
QString namespaceURI() const const
QDomElement toElement() const const
void append(QList< T > &&value)
const_iterator cbegin() const const
const_iterator cend() const const
qsizetype count() const const
void reserve(qsizetype size)
const QObjectList & children() const const
bool endsWith(QChar c, Qt::CaseSensitivity cs) const const
bool isEmpty() const const
bool isNull() const const
bool startsWith(QChar c, Qt::CaseSensitivity cs) const const