Syndication

feedrdfimpl.cpp
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
24namespace Syndication
25{
26FeedRDFImpl::FeedRDFImpl(Syndication::RDF::DocumentPtr doc)
27 : m_doc(doc)
28{
29}
30
31Syndication::SpecificDocumentPtr FeedRDFImpl::specificDocument() const
32{
33 return m_doc;
34}
35
37{
38 const QList<Syndication::RDF::Item> entries = m_doc->items();
39
41 items.reserve(entries.count());
42
43 std::transform(entries.cbegin(), entries.cend(), std::back_inserter(items), [](const Syndication::RDF::Item &entry) {
44 return ItemRDFImplPtr(new ItemRDFImpl(entry));
45 });
46
47 return items;
48}
49
51{
52 // TODO: check if it makes sense to map dc:subject to categories
54}
55
57{
58 return m_doc->title();
59}
60
62{
63 return m_doc->link();
64}
65
67{
68 return m_doc->description();
69}
70
72{
73 const QStringList people = m_doc->dc().creators() + m_doc->dc().contributors();
74
76 list.reserve(people.size());
77
78 for (const auto &person : people) {
79 PersonPtr ptr = personFromString(person);
80 if (!ptr->isNull()) {
81 list.append(ptr);
82 }
83 }
84
85 return list;
86}
87
89{
90 return m_doc->dc().language();
91}
92
94{
95 return m_doc->dc().rights();
96}
97
98ImagePtr FeedRDFImpl::image() const
99{
100 ImageRDFImplPtr ptr(new ImageRDFImpl(m_doc->image()));
101 return ptr;
102}
103
104ImagePtr FeedRDFImpl::icon() const
105{
106 ImageRDFImplPtr ptr(new ImageRDFImpl({}));
107 return ptr;
108}
109
114
115} // namespace Syndication
QList< CategoryPtr > categories() const override
returns a list of categories this feed is associated with.
QString title() const override
The title of the feed.
QString description() const override
A description of the feed.
QMultiMap< QString, QDomElement > additionalProperties() const override
returns a list of feed metadata not covered by this class.
QList< ItemPtr > items() const override
A list of items, in the order they were parsed from the feed source.
QList< PersonPtr > authors() const override
returns a list of persons who created the feed content.
ImagePtr image() const override
returns an image associated with this item.
ImagePtr icon() const override
returns an icon associated with this item.
QString language() const override
The language used in the feed.
QString link() const override
returns a link pointing to a website associated with this channel.
QString copyright() const override
returns copyright information about the feed
Syndication::SpecificDocumentPtr specificDocument() const override
returns the format-specific document this abstraction wraps.
An RSS 1.0 item.
Definition rdf/item.h:37
void append(QList< T > &&value)
const_iterator cbegin() const const
const_iterator cend() const const
qsizetype count() const const
void reserve(qsizetype size)
qsizetype size() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2025 The KDE developers.
Generated on Fri Jan 24 2025 11:48:38 by doxygen 1.13.2 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.