25 #include "constants.h"
27 #include "generator.h"
30 #include "atomtools.h"
32 #include <documentvisitor.h>
35 #include <QtXml/QDomElement>
36 #include <QtCore/QList>
37 #include <QtCore/QString>
39 namespace Syndication {
52 return visitor->visitAtomFeedDocument(
this);
57 QList<QDomElement> a =
59 QLatin1String(
"author"));
62 QList<QDomElement>::ConstIterator it = a.constBegin();
63 QList<QDomElement>::ConstIterator end = a.constEnd();
66 for ( ; it != end; ++it)
76 QList<QDomElement> a =
78 QLatin1String(
"contributor"));
81 QList<QDomElement>::ConstIterator it = a.constBegin();
82 QList<QDomElement>::ConstIterator end = a.constEnd();
85 for ( ; it != end; ++it)
95 QList<QDomElement> a =
97 QLatin1String(
"category"));
100 QList<QDomElement>::ConstIterator it = a.constBegin();
101 QList<QDomElement>::ConstIterator end = a.constEnd();
104 for ( ; it != end; ++it)
115 QLatin1String(
"generator")));
121 QLatin1String(
"icon")));
128 QLatin1String(
"logo")));
134 QLatin1String(
"id"));
156 QLatin1String(
"updated"));
157 return parseDate(upd, ISODate);
162 QList<QDomElement> a =
164 QLatin1String(
"link"));
167 QList<QDomElement>::ConstIterator it = a.constBegin();
168 QList<QDomElement>::ConstIterator end = a.constEnd();
171 for ( ; it != end; ++it)
173 list.append(
Link(*it));
181 QList<QDomElement> a =
183 QLatin1String(
"entry"));
186 QList<QDomElement>::ConstIterator it = a.constBegin();
187 QList<QDomElement>::ConstIterator end = a.constEnd();
190 for ( ; it != end; ++it)
192 list.append(
Entry(*it));
201 QList<ElementType> handled;
202 handled.append(ElementType(QLatin1String(
"author"),
atom1Namespace()));
203 handled.append(ElementType(QLatin1String(
"contributor"),
atom1Namespace()));
204 handled.append(ElementType(QLatin1String(
"category"),
atom1Namespace()));
205 handled.append(ElementType(QLatin1String(
"generator"),
atom1Namespace()));
206 handled.append(ElementType(QLatin1String(
"icon"),
atom1Namespace()));
207 handled.append(ElementType(QLatin1String(
"logo"),
atom1Namespace()));
208 handled.append(ElementType(QLatin1String(
"id"),
atom1Namespace()));
209 handled.append(ElementType(QLatin1String(
"rights"),
atom1Namespace()));
210 handled.append(ElementType(QLatin1String(
"title"),
atom1Namespace()));
211 handled.append(ElementType(QLatin1String(
"subtitle"),
atom1Namespace()));
212 handled.append(ElementType(QLatin1String(
"updated"),
atom1Namespace()));
213 handled.append(ElementType(QLatin1String(
"link"),
atom1Namespace()));
214 handled.append(ElementType(QLatin1String(
"entry"),
atom1Namespace()));
216 QList<QDomElement> notHandled;
218 QDomNodeList children = element().childNodes();
219 for (
int i = 0; i < children.size(); ++i)
221 QDomElement el = children.at(i).toElement();
223 && !handled.contains(ElementType(el.localName(), el.namespaceURI())))
225 notHandled.append(el);
240 info += QLatin1String(
"### FeedDocument: ###################\n");
241 if (!
title().isEmpty())
242 info += QLatin1String(
"title: #") +
title() + QLatin1String(
"#\n");
244 info += QLatin1String(
"subtitle: #") +
subtitle() + QLatin1String(
"#\n");
246 info += QLatin1String(
"id: #") +
id() + QLatin1String(
"#\n");
249 info += QLatin1String(
"rights: #") +
rights() + QLatin1String(
"#\n");
250 if (!
icon().isEmpty())
251 info += QLatin1String(
"icon: #") +
icon() + QLatin1String(
"#\n");
252 if (!
logo().isEmpty())
253 info += QLatin1String(
"logo: #") +
logo() + QLatin1String(
"#\n");
258 QString dupdated = dateTimeToString(
updated());
259 if (!dupdated.isNull())
260 info += QLatin1String(
"updated: #") + dupdated + QLatin1String(
"#\n");
262 QList<Link> dlinks =
links();
263 QList<Link>::ConstIterator endlinks = dlinks.constEnd();
264 for (QList<Link>::ConstIterator it = dlinks.constBegin(); it != endlinks; ++it)
265 info += (*it).debugInfo();
268 QList<Category>::ConstIterator endcats = dcats.constEnd();
269 for (QList<Category>::ConstIterator it = dcats.constBegin(); it != endcats; ++it)
270 info += (*it).debugInfo();
272 info += QLatin1String(
"### Authors: ###################\n");
274 QList<Person> dauthors =
authors();
275 QList<Person>::ConstIterator endauthors = dauthors.constEnd();
276 for (QList<Person>::ConstIterator it = dauthors.constBegin(); it != endauthors; ++it)
277 info += (*it).debugInfo();
279 info += QLatin1String(
"### Contributors: ###################\n");
282 QList<Person>::ConstIterator endcontri = dcontri.constEnd();
283 for (QList<Person>::ConstIterator it = dcontri.constBegin(); it != endcontri; ++it)
284 info += (*it).debugInfo();
286 QList<Entry> dentries =
entries();
287 QList<Entry>::ConstIterator endentries = dentries.constEnd();
288 for (QList<Entry>::ConstIterator it = dentries.constBegin(); it != endentries; ++it)
289 info += (*it).debugInfo();
291 info += QLatin1String(
"### FeedDocument end ################\n");
306 return visitor->visitAtomEntryDocument(
this);
311 return Entry(element());
323 info += QLatin1String(
"### EntryDocument: ##################\n");
326 if (!dentry.isNull())
329 info += QLatin1String(
"### EntryDocument end ###############\n");
A category for categorizing items or whole feeds.
A link, pointing to webpages, media files on the web ("podcast"), related content, etc.
Description of the agent used to generate the feed.
QString rights() const
copyright information (optional)
QList< Person > authors() const
a list of persons who are the authors of this feed.
QList< Category > categories() const
a list of categories this feed is assigned to (optional)
QList< Link > links() const
a list of links.
QString debugInfo() const
a description of this generator for debugging purposes.
QString title() const
feed title (required).
QString atom1Namespace()
namespace used by Atom 1.0 elements
FeedDocument()
default constructor, creates a null feed, which is invalid.
QList< Entry > entries() const
a list of the entries (items) in this feed.
EntryDocument()
default constructor, creates a null document, which is invalid.
bool accept(DocumentVisitor *visitor)
Used by visitors for double dispatch.
QString logo() const
URL of an image serving as a feed logo (optional)
QList< QDomElement > unhandledElements() const
returns all child elements of this feed not covered by this class.
QString extractAtomText(const Syndication::ElementWrapper &parent, const QString &tagname)
extracts the content of an atomTextConstruct.
QString icon() const
URL of an image serving as a feed icon (optional)
bool isValid() const
returns whether this document is valid or not.
an Atom entry, equivalent to the "items" in the RSS world.
QString debugInfo() const
returns a description of this feed document for debugging purposes.
QString subtitle() const
description or subtitle of the feed (optional).
QString id() const
a string that unambigously identifies the feed (required)
describes a person, with name and optional URI and e-mail address.
bool accept(DocumentVisitor *visitor)
Used by visitors for double dispatch.
QString debugInfo() const
returns a description of this entry for debugging purposes
Generator generator() const
description of the agent used to generate the feed.
Entry entry() const
returns the single entry described in the source.
QList< Person > contributors() const
a list of persons who contribute to this feed.
bool isValid() const
returns whether this document is valid or not.
time_t updated() const
The datetime of the last modification of the feed content.
QString debugInfo() const
returns a description of this entry document for debugging purposes.