| 1 | /* |
|---|---|
| 2 | This file is part of the syndication library |
| 3 | SPDX-FileCopyrightText: 2006 Frank Osterfeld <osterfeld@kde.org> |
| 4 | |
| 5 | SPDX-License-Identifier: LGPL-2.0-or-later |
| 6 | */ |
| 7 | |
| 8 | #include "feedrdfimpl.h" |
| 9 | #include "imagerdfimpl.h" |
| 10 | #include "itemrdfimpl.h" |
| 11 | |
| 12 | #include <category.h> |
| 13 | #include <personimpl.h> |
| 14 | #include <rdf/dublincore.h> |
| 15 | #include <rdf/item.h> |
| 16 | #include <tools.h> |
| 17 | |
| 18 | #include <QDomElement> |
| 19 | #include <QList> |
| 20 | #include <QMultiMap> |
| 21 | #include <QString> |
| 22 | #include <QStringList> |
| 23 | |
| 24 | namespace Syndication |
| 25 | { |
| 26 | FeedRDFImpl::FeedRDFImpl(Syndication::RDF::DocumentPtr doc) |
| 27 | : m_doc(doc) |
| 28 | { |
| 29 | } |
| 30 | |
| 31 | Syndication::SpecificDocumentPtr FeedRDFImpl::specificDocument() const |
| 32 | { |
| 33 | return m_doc; |
| 34 | } |
| 35 | |
| 36 | QList<Syndication::ItemPtr> FeedRDFImpl::items() const |
| 37 | { |
| 38 | const QList<Syndication::RDF::Item> entries = m_doc->items(); |
| 39 | |
| 40 | QList<ItemPtr> items; |
| 41 | items.reserve(asize: entries.count()); |
| 42 | |
| 43 | std::transform(first: entries.cbegin(), last: entries.cend(), result: std::back_inserter(x&: items), unary_op: [](const Syndication::RDF::Item &entry) { |
| 44 | return ItemRDFImplPtr(new ItemRDFImpl(entry)); |
| 45 | }); |
| 46 | |
| 47 | return items; |
| 48 | } |
| 49 | |
| 50 | QList<Syndication::CategoryPtr> FeedRDFImpl::categories() const |
| 51 | { |
| 52 | // TODO: check if it makes sense to map dc:subject to categories |
| 53 | return QList<Syndication::CategoryPtr>(); |
| 54 | } |
| 55 | |
| 56 | QString FeedRDFImpl::title() const |
| 57 | { |
| 58 | return m_doc->title(); |
| 59 | } |
| 60 | |
| 61 | QString FeedRDFImpl::link() const |
| 62 | { |
| 63 | return m_doc->link(); |
| 64 | } |
| 65 | |
| 66 | QString FeedRDFImpl::description() const |
| 67 | { |
| 68 | return m_doc->description(); |
| 69 | } |
| 70 | |
| 71 | QList<PersonPtr> FeedRDFImpl::authors() const |
| 72 | { |
| 73 | const QStringList people = m_doc->dc().creators() + m_doc->dc().contributors(); |
| 74 | |
| 75 | QList<PersonPtr> list; |
| 76 | list.reserve(asize: people.size()); |
| 77 | |
| 78 | for (const auto &person : people) { |
| 79 | PersonPtr ptr = personFromString(str: person); |
| 80 | if (!ptr->isNull()) { |
| 81 | list.append(t: ptr); |
| 82 | } |
| 83 | } |
| 84 | |
| 85 | return list; |
| 86 | } |
| 87 | |
| 88 | QString FeedRDFImpl::language() const |
| 89 | { |
| 90 | return m_doc->dc().language(); |
| 91 | } |
| 92 | |
| 93 | QString FeedRDFImpl::copyright() const |
| 94 | { |
| 95 | return m_doc->dc().rights(); |
| 96 | } |
| 97 | |
| 98 | ImagePtr FeedRDFImpl::image() const |
| 99 | { |
| 100 | ImageRDFImplPtr ptr(new ImageRDFImpl(m_doc->image())); |
| 101 | return ptr; |
| 102 | } |
| 103 | |
| 104 | ImagePtr FeedRDFImpl::icon() const |
| 105 | { |
| 106 | ImageRDFImplPtr ptr(new ImageRDFImpl({})); |
| 107 | return ptr; |
| 108 | } |
| 109 | |
| 110 | QMultiMap<QString, QDomElement> FeedRDFImpl::additionalProperties() const |
| 111 | { |
| 112 | return QMultiMap<QString, QDomElement>(); |
| 113 | } |
| 114 | |
| 115 | } // namespace Syndication |
| 116 |
