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> 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<Person> feedAuthors =
authors();
187 QList<QDomElement>::ConstIterator it = a.constBegin();
188 QList<QDomElement>::ConstIterator end = a.constEnd();
191 for ( ; it != end; ++it)
204 QList<ElementType> handled;
205 handled.append(ElementType(QLatin1String(
"author"),
atom1Namespace()));
206 handled.append(ElementType(QLatin1String(
"contributor"),
atom1Namespace()));
207 handled.append(ElementType(QLatin1String(
"category"),
atom1Namespace()));
208 handled.append(ElementType(QLatin1String(
"generator"),
atom1Namespace()));
209 handled.append(ElementType(QLatin1String(
"icon"),
atom1Namespace()));
210 handled.append(ElementType(QLatin1String(
"logo"),
atom1Namespace()));
211 handled.append(ElementType(QLatin1String(
"id"),
atom1Namespace()));
212 handled.append(ElementType(QLatin1String(
"rights"),
atom1Namespace()));
213 handled.append(ElementType(QLatin1String(
"title"),
atom1Namespace()));
214 handled.append(ElementType(QLatin1String(
"subtitle"),
atom1Namespace()));
215 handled.append(ElementType(QLatin1String(
"updated"),
atom1Namespace()));
216 handled.append(ElementType(QLatin1String(
"link"),
atom1Namespace()));
217 handled.append(ElementType(QLatin1String(
"entry"),
atom1Namespace()));
219 QList<QDomElement> notHandled;
221 QDomNodeList children = element().childNodes();
222 for (
int i = 0; i < children.size(); ++i)
224 QDomElement el = children.at(i).toElement();
226 && !handled.contains(ElementType(el.localName(), el.namespaceURI())))
228 notHandled.append(el);
243 info += QLatin1String(
"### FeedDocument: ###################\n");
244 if (!
title().isEmpty())
245 info += QLatin1String(
"title: #") +
title() + QLatin1String(
"#\n");
247 info += QLatin1String(
"subtitle: #") +
subtitle() + QLatin1String(
"#\n");
249 info += QLatin1String(
"id: #") +
id() + QLatin1String(
"#\n");
252 info += QLatin1String(
"rights: #") +
rights() + QLatin1String(
"#\n");
253 if (!
icon().isEmpty())
254 info += QLatin1String(
"icon: #") +
icon() + QLatin1String(
"#\n");
255 if (!
logo().isEmpty())
256 info += QLatin1String(
"logo: #") +
logo() + QLatin1String(
"#\n");
261 QString dupdated = dateTimeToString(
updated());
262 if (!dupdated.isNull())
263 info += QLatin1String(
"updated: #") + dupdated + QLatin1String(
"#\n");
265 QList<Link> dlinks =
links();
266 QList<Link>::ConstIterator endlinks = dlinks.constEnd();
267 for (QList<Link>::ConstIterator it = dlinks.constBegin(); it != endlinks; ++it)
268 info += (*it).debugInfo();
271 QList<Category>::ConstIterator endcats = dcats.constEnd();
272 for (QList<Category>::ConstIterator it = dcats.constBegin(); it != endcats; ++it)
273 info += (*it).debugInfo();
275 info += QLatin1String(
"### Authors: ###################\n");
277 QList<Person> dauthors =
authors();
278 QList<Person>::ConstIterator endauthors = dauthors.constEnd();
279 for (QList<Person>::ConstIterator it = dauthors.constBegin(); it != endauthors; ++it)
280 info += (*it).debugInfo();
282 info += QLatin1String(
"### Contributors: ###################\n");
285 QList<Person>::ConstIterator endcontri = dcontri.constEnd();
286 for (QList<Person>::ConstIterator it = dcontri.constBegin(); it != endcontri; ++it)
287 info += (*it).debugInfo();
289 QList<Entry> dentries =
entries();
290 QList<Entry>::ConstIterator endentries = dentries.constEnd();
291 for (QList<Entry>::ConstIterator it = dentries.constBegin(); it != endentries; ++it)
292 info += (*it).debugInfo();
294 info += QLatin1String(
"### FeedDocument end ################\n");
309 return visitor->visitAtomEntryDocument(
this);
314 return Entry(element());
326 info += QLatin1String(
"### EntryDocument: ##################\n");
329 if (!dentry.isNull())
332 info += QLatin1String(
"### EntryDocument end ###############\n");
A category for categorizing items or whole feeds.
Generator generator() const
description of the agent used to generate the feed.
A link, pointing to webpages, media files on the web ("podcast"), related content, etc.
Description of the agent used to generate the feed.
QList< Person > authors() const
a list of persons who are the authors of this feed.
QString rights() const
copyright information (optional)
Entry entry() const
returns the single entry described in the source.
bool isValid() const
returns whether this document is valid or not.
QString title() const
feed title (required).
QString debugInfo() const
returns a description of this entry for debugging purposes
QList< Person > contributors() const
a list of persons who contribute to this feed.
QString atom1Namespace()
namespace used by Atom 1.0 elements
FeedDocument()
default constructor, creates a null feed, which is invalid.
QString id() const
a string that unambigously identifies the feed (required)
EntryDocument()
default constructor, creates a null document, which is invalid.
bool accept(DocumentVisitor *visitor)
Used by visitors for double dispatch.
void setFeedAuthors(const QList< Person > &feedAuthors)
Sets the list of the containing feed's authors, which will be used as a fallback in authors() in case...
QString icon() const
URL of an image serving as a feed icon (optional)
QString extractAtomText(const Syndication::ElementWrapper &parent, const QString &tagname)
extracts the content of an atomTextConstruct.
QList< Link > links() const
a list of links.
QString debugInfo() const
a description of this generator for debugging purposes.
QString subtitle() const
description or subtitle of the feed (optional).
an Atom entry, equivalent to the "items" in the RSS world.
QString debugInfo() const
returns a description of this entry document for debugging purposes.
QList< QDomElement > unhandledElements() const
returns all child elements of this feed not covered by this class.
describes a person, with name and optional URI and e-mail address.
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.
bool accept(DocumentVisitor *visitor)
Used by visitors for double dispatch.
QList< Entry > entries() const
a list of the entries (items) in this feed.
QString logo() const
URL of an image serving as a feed logo (optional)
QString debugInfo() const
returns a description of this feed document for debugging purposes.
QList< Category > categories() const
a list of categories this feed is assigned to (optional)