23 #include <rss2/item.h>
24 #include <rss2/category.h>
25 #include <rss2/enclosure.h>
26 #include <rss2/source.h>
27 #include <rss2/tools_p.h>
28 #include <constants.h>
29 #include <specificitem.h>
30 #include <specificitemvisitor.h>
33 #include <QtXml/QDomElement>
34 #include <QtCore/QString>
35 #include <QtCore/QList>
37 namespace Syndication {
40 class Item::ItemPrivate
44 boost::shared_ptr<Document> doc;
47 Item::Item(boost::shared_ptr<Document> doc) : ElementWrapper(), d(new ItemPrivate)
52 Item::Item(
const QDomElement& element, boost::shared_ptr<Document> doc) : ElementWrapper(element), d(new ItemPrivate)
61 Item::Item(
const Item& other) : ElementWrapper(other), SpecificItem(other)
66 Item& Item::operator=(
const Item& other)
68 ElementWrapper::operator=(other);
69 SpecificItem::operator=(other);
77 return originalTitle();
80 bool containsMarkup =
false;
81 d->doc->getItemTitleFormatInfo(&isCDATA, &containsMarkup);
83 return normalize(originalTitle(), isCDATA, containsMarkup);
87 QString Item::originalDescription()
const
92 QString Item::originalTitle()
const
106 if (d->doc->link().isEmpty()) {
111 QString baseUrl = d->doc->link();
113 return baseUrl + url;
119 QString Item::description()
const
122 return originalDescription();
124 bool isCDATA =
false;
125 bool containsMarkup =
false;
126 d->doc->getItemDescriptionFormatInfo(&isCDATA, &containsMarkup);
128 return normalize(originalDescription(), isCDATA, containsMarkup);
145 for ( ; it != cats.
constEnd(); ++it)
147 categories.
append(Category(*it));
167 return extractElementTextNS(dublinCoreNamespace(),
181 for ( ; it != encs.
constEnd(); ++it)
183 enclosures.
append(Enclosure(*it));
193 bool Item::guidIsPermaLink()
const
195 bool guidIsPermaLink =
true;
204 guidIsPermaLink =
false;
208 return guidIsPermaLink;
211 time_t Item::pubDate()
const
217 return parseDate(str, RFCDate);
221 str = extractElementTextNS(dublinCoreNamespace(),
QLatin1String(
"date"));
222 return parseDate(str, ISODate);
225 time_t Item::expirationDate()
const
228 return parseDate(str, RFCDate);
231 Source Item::source()
const
241 QString Item::debugInfo()
const
245 if (!title().isNull())
247 if (!link().isNull())
249 if (!description().isNull())
251 if (!content().isNull())
253 if (!author().isNull())
255 if (!comments().isNull())
257 QString dpubdate = dateTimeToString(pubDate());
260 if (!guid().isNull())
262 if (guidIsPermaLink())
264 if (!source().isNull())
265 info += source().debugInfo();
269 info += (*it).debugInfo();
272 info += (*it).debugInfo();
297 for (
int i = 0; i < children.
size(); ++i)
310 bool Item::accept(SpecificItemVisitor* visitor)
312 return visitor->visitRSS2Item(
this);
QString attribute(const QString &name, const QString &defValue) const
QString namespaceURI() const
QDomElement toElement() const
void append(const T &value)
QString localName() const
bool startsWith(const QString &s, Qt::CaseSensitivity cs) const
bool endsWith(const QString &s, Qt::CaseSensitivity cs) const
bool contains(const T &value) const
const_iterator constEnd() const
const_iterator constBegin() const
QDomNode at(int index) const