File indexing completed on 2024-03-24 15:42:43

0001 /*
0002     This file is part of the syndication library
0003     SPDX-FileCopyrightText: 2006 Frank Osterfeld <osterfeld@kde.org>
0004 
0005     SPDX-License-Identifier: LGPL-2.0-or-later
0006 */
0007 
0008 #include "item.h"
0009 #include "category.h"
0010 #include "enclosure.h"
0011 #include "person.h"
0012 #include "tools.h"
0013 
0014 #include <QList>
0015 
0016 namespace Syndication
0017 {
0018 Item::~Item()
0019 {
0020 }
0021 
0022 QString Item::debugInfo() const
0023 {
0024     QString info = QLatin1String("# Item begin ######################\n");
0025 
0026     QString did = id();
0027     if (!did.isNull()) {
0028         info += QLatin1String("id: #") + did + QLatin1String("#\n");
0029     }
0030 
0031     QString dtitle = title();
0032     if (!dtitle.isNull()) {
0033         info += QLatin1String("title: #") + dtitle + QLatin1String("#\n");
0034     }
0035 
0036     QString dlink = link();
0037     if (!dlink.isNull()) {
0038         info += QLatin1String("link: #") + dlink + QLatin1String("#\n");
0039     }
0040 
0041     QString ddescription = description();
0042     if (!ddescription.isNull()) {
0043         info += QLatin1String("description: #") + ddescription + QLatin1String("#\n");
0044     }
0045 
0046     QString dcontent = content();
0047     if (!dcontent.isNull()) {
0048         info += QLatin1String("content: #") + dcontent + QLatin1String("#\n");
0049     }
0050 
0051     QString pubdate = dateTimeToString(datePublished());
0052     if (!pubdate.isNull()) {
0053         info += QLatin1String("datePublished: #") + pubdate + QLatin1String("#\n");
0054     }
0055 
0056     QString update = dateTimeToString(dateUpdated());
0057     if (!update.isNull()) {
0058         info += QLatin1String("dateUpdated: #") + update + QLatin1String("#\n");
0059     }
0060 
0061     QString dlanguage = language();
0062     if (!dlanguage.isNull()) {
0063         info += QLatin1String("language: #") + dlanguage + QLatin1String("#\n");
0064     }
0065 
0066     const QList<PersonPtr> dauthors = authors();
0067     for (const auto &author : dauthors) {
0068         info += author->debugInfo();
0069     }
0070 
0071     const QList<CategoryPtr> dcategories = categories();
0072     for (const auto &cat : dcategories) {
0073         info += cat->debugInfo();
0074     }
0075 
0076     const QList<EnclosurePtr> denclosures = enclosures();
0077     for (const auto &e : denclosures) {
0078         info += e->debugInfo();
0079     }
0080 
0081     int dcommentsCount = commentsCount();
0082     if (dcommentsCount != -1) {
0083         info += QLatin1String("commentsCount: #") + QString::number(dcommentsCount) + QLatin1String("#\n");
0084     }
0085 
0086     QString dcommentsLink = commentsLink();
0087     if (!dcommentsLink.isNull()) {
0088         info += QLatin1String("commentsLink: #") + dcommentsLink + QLatin1String("#\n");
0089     }
0090 
0091     QString dcommentsFeed = commentsFeed();
0092     if (!dcommentsFeed.isNull()) {
0093         info += QLatin1String("commentsFeed: #") + dcommentsFeed + QLatin1String("#\n");
0094     }
0095 
0096     QString dcommentPostUri = commentPostUri();
0097     if (!dcommentPostUri.isNull()) {
0098         info += QLatin1String("commentPostUri: #") + dcommentPostUri + QLatin1String("#\n");
0099     }
0100 
0101     info += QLatin1String("# Item end ########################\n");
0102 
0103     return info;
0104 }
0105 
0106 } // namespace Syndication