22#include <tqdatetime.h>
31struct Article::Private :
public Shared
44 TQValueList<Category> categories;
47Article::Article() : d(new Private)
56Enclosure Article::enclosure()
const
67Article::Article(
const TQDomNode &node, Format format, Version version) : d(new Private)
73 if (!(elemText = extractTitle(node)).isNull())
79 for (n = node.firstChild(); !n.isNull(); n = n.nextSibling()) {
80 const TQDomElement e = n.toElement();
81 if ( (e.tagName()==TQString::fromLatin1(
"link")) &&
82 (e.attribute(TQString::fromLatin1(
"rel"), TQString::fromLatin1(
"alternate")) == TQString::fromLatin1(
"alternate")))
84 d->link=n.toElement().attribute(TQString::fromLatin1(
"href"));
91 if (!(elemText = extractNode(node, TQString::fromLatin1(
"link"))).isNull())
96 if (format == AtomFeed)
98 d->description = extractNode(node, TQString::fromLatin1(
"content"),
false);
102 d->description = extractElementTextNS(node, ContentNamespace, TQString::fromLatin1(
"encoded"),
false);
105 if (d->description.isEmpty())
107 if (!(elemText = extractNode(node, TQString::fromLatin1(
"body"),
false)).isNull())
108 d->description = elemText;
110 if (d->description.isEmpty())
112 if (!(elemText = extractNode(node, TQString::fromLatin1((format==AtomFeed)?
"summary" :
"description"),
false)).isNull())
113 d->description = elemText;
119 if (format == AtomFeed)
121 if (version == vAtom_1_0)
122 elemText = extractNode(node, TQString::fromLatin1(
"updated"));
124 elemText = extractNode(node, TQString::fromLatin1(
"issued"));
126 if (!elemText.isNull())
127 time = parseISO8601Date(elemText);
131 elemText = extractNode(node, TQString::fromLatin1(
"pubDate"));
132 if (!elemText.isNull())
133 time = KRFCDate::parseDate(elemText);
136 if (!(elemText = extractElementTextNS(node, DublinCoreNamespace, TQString::fromLatin1(
"date"))).isNull())
138 time = parseISO8601Date(elemText);
143 d->pubDate.setTime_t(time);
145 d->commentsLink = extractElementTextNS(node, CommentAPINamespace, TQString::fromLatin1(
"comment"));
146 d->numComments = extractElementTextNS(node, SlashNamespace, TQString::fromLatin1(
"comments")).toInt();
148 TQDomElement element = TQDomNode(node).toElement();
153 if (!element.isNull() && element.hasAttributeNS(RDFNamespace, TQString::fromLatin1(
"about")))
155 d->guid = element.attributeNS(RDFNamespace, TQString::fromLatin1(
"about"), TQString::null);
156 d->guidIsPermaLink =
false;
160 TQString tagName=(format==AtomFeed)? TQString::fromLatin1(
"id"): TQString::fromLatin1(
"guid");
161 TQDomNode n = node.namedItem(tagName);
164 d->guidIsPermaLink = (format==AtomFeed)?
false :
true;
165 if (n.toElement().attribute(TQString::fromLatin1(
"isPermaLink"),
"true") ==
"false") d->guidIsPermaLink =
false;
166 if (!(elemText = extractNode(node, tagName)).isNull())
171 if(d->guid.isEmpty()) {
172 d->guidIsPermaLink =
false;
176 md5Machine.update(d->title.utf8());
177 md5Machine.update(d->description.utf8());
178 d->guid = TQString(md5Machine.hexDigest().data());
179 d->meta[TQString::fromLatin1(
"guidIsHash")] = TQString::fromLatin1(
"true");
182 TQDomNode enclosure = element.namedItem(TQString::fromLatin1(
"enclosure"));
183 if (enclosure.isElement())
184 d->enclosure = Enclosure::fromXML(enclosure.toElement());
186 d->author = parseItemAuthor(element, format, version);
188 for (TQDomNode i = node.firstChild(); !i.isNull(); i = i.nextSibling())
192 if (i.toElement().tagName() == TQString::fromLatin1(
"metaInfo:meta"))
194 TQString type = i.toElement().attribute(TQString::fromLatin1(
"type"));
195 d->meta[type] = i.toElement().text();
197 else if (i.toElement().tagName() == TQString::fromLatin1(
"category"))
199 d->categories.append(Category::fromXML(i.toElement()));
228 return d->description;
238 return d->guidIsPermaLink;
246const KURL &Article::commentsLink()
const
248 return d->commentsLink;
251int Article::comments()
const
253 return d->numComments;
257TQString Article::meta(
const TQString &key)
const
264 KURLLabel *label =
new KURLLabel(d->link.url(), d->title, parent, name);
265 label->setUseTips(
true);
266 if (!d->description.isNull())
267 label->setTipText(d->description);
274 if (
this != &other) {
285 return d->guid == other.
guid();
Represents an article as stored in a RSS file.
Article & operator=(const Article &other)
Assignment operator.
TQString guid() const
RSS 2.0 and upwards.
TQValueList< Category > categories() const
returns a list of categories this article is assigned to.
bool operator==(const Article &other) const
Compares two articles.
KURLLabel * widget(TQWidget *parent=0, const char *name=0) const
TQString title() const
RSS 0.90 and upwards.
virtual ~Article()
Destructor.
bool guidIsPermaLink() const
RSS 2.0 and upwards.
TQString author() const
a string desribing the author of the item.
Article()
Default constructor.
const TQDateTime & pubDate() const
RSS 2.0 and upwards.
const KURL & link() const
RSS 0.90 and upwards.
TQString description() const
RSS 0.91 and upwards.