1/*
2 * This file is part of the syndication library
3 *
4 * Copyright (C) 2006 Frank Osterfeld <osterfeld@kde.org>
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
15 *
16 * You should have received a copy of the GNU Library General Public License
17 * along with this library; see the file COPYING.LIB. If not, write to
18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 * Boston, MA 02110-1301, USA.
20 *
21 */
22
23#include "item.h"
24#include "category.h"
25#include "enclosure.h"
26#include "person.h"
27#include "tools.h"
28
29#include <QtCore/QList>
30#include <QtCore/QString>
31
32namespace Syndication {
33
34Item::~Item()
35{
36}
37
38QString Item::debugInfo() const
39{
40 QString info;
41
42 info += QLatin1String("# Item begin ######################\n");
43
44 QString did = id();
45 if (!did.isNull())
46 info += QLatin1String("id: #") + did + QLatin1String("#\n");
47
48 QString dtitle = title();
49 if (!dtitle.isNull())
50 info += QLatin1String("title: #") + dtitle + QLatin1String("#\n");
51
52 QString dlink = link();
53 if (!dlink.isNull())
54 info += QLatin1String("link: #") + dlink + QLatin1String("#\n");
55
56 QString ddescription = description();
57 if (!ddescription.isNull())
58 info += QLatin1String("description: #") + ddescription + QLatin1String("#\n");
59
60 QString dcontent = content();
61 if (!dcontent.isNull())
62 info += QLatin1String("content: #") + dcontent + QLatin1String("#\n");
63
64 QString pubdate = dateTimeToString(datePublished());
65 if (!pubdate.isNull())
66 info += QLatin1String("datePublished: #") + pubdate + QLatin1String("#\n");
67
68 QString update = dateTimeToString(dateUpdated());
69 if (!update.isNull())
70 info += QLatin1String("dateUpdated: #") + update + QLatin1String("#\n");
71
72 QString dlanguage = language();
73 if (!dlanguage.isNull())
74 info += QLatin1String("language: #") + dlanguage + QLatin1String("#\n");
75
76 QList<PersonPtr> dauthors = authors();
77 QList<PersonPtr>::ConstIterator itp = dauthors.constBegin();
78 QList<PersonPtr>::ConstIterator endp = dauthors.constEnd();
79
80 for ( ; itp != endp; ++itp)
81 info += (*itp)->debugInfo();
82
83 QList<CategoryPtr> dcategories = categories();
84 QList<CategoryPtr>::ConstIterator itc = dcategories.constBegin();
85 QList<CategoryPtr>::ConstIterator endc = dcategories.constEnd();
86
87 for ( ; itc != endc; ++itc)
88 info += (*itc)->debugInfo();
89
90 QList<EnclosurePtr> denclosures = enclosures();
91 QList<EnclosurePtr>::ConstIterator ite = denclosures.constBegin();
92 QList<EnclosurePtr>::ConstIterator ende = denclosures.constEnd();
93
94 for ( ; ite != ende; ++ite)
95 info += (*ite)->debugInfo();
96
97 int dcommentsCount = commentsCount();
98 if (dcommentsCount != -1)
99 {
100 info+= QLatin1String("commentsCount: #") + QString::number(dcommentsCount) + QLatin1String("#\n");
101 }
102
103 QString dcommentsLink = commentsLink();
104 if (!dcommentsLink.isNull())
105 info+= QLatin1String("commentsLink: #") + dcommentsLink + QLatin1String("#\n");
106
107 QString dcommentsFeed = commentsFeed();
108 if (!dcommentsFeed.isNull())
109 info+= QLatin1String("commentsFeed: #") + dcommentsFeed + QLatin1String("#\n");
110
111 QString dcommentPostUri = commentPostUri();
112 if (!dcommentPostUri.isNull())
113 info+= QLatin1String("commentPostUri: #") + dcommentPostUri + QLatin1String("#\n");
114
115 info += QLatin1String("# Item end ########################\n");
116
117 return info;
118}
119
120} // namespace Syndication
121