Syndication

feedrss2impl.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 "feedrss2impl.h"
9#include "categoryrss2impl.h"
10#include "imagerss2impl.h"
11#include "itemrss2impl.h"
12#include <personimpl.h>
13#include <rss2/category.h>
14#include <rss2/item.h>
15
16#include <QDomElement>
17#include <QList>
18#include <QMultiMap>
19#include <QString>
20
21namespace Syndication
22{
23FeedRSS2Impl::FeedRSS2Impl(Syndication::RSS2::DocumentPtr doc)
24 : m_doc(doc)
25{
26}
27
28Syndication::SpecificDocumentPtr FeedRSS2Impl::specificDocument() const
29{
30 return m_doc;
31}
32
34{
35 const QList<Syndication::RSS2::Item> entries = m_doc->items();
36
38 items.reserve(entries.count());
39
40 std::transform(entries.cbegin(), entries.cend(), std::back_inserter(items), [](const Syndication::RSS2::Item &entry) {
41 return ItemRSS2ImplPtr(new ItemRSS2Impl(entry));
42 });
43
44 return items;
45}
46
48{
49 const QList<Syndication::RSS2::Category> entries = m_doc->categories();
50
52 categories.reserve(entries.count());
53
54 std::transform(entries.cbegin(), entries.cend(), std::back_inserter(categories), [](const Syndication::RSS2::Category &entry) {
55 return CategoryRSS2ImplPtr(new CategoryRSS2Impl(entry));
56 });
57
58 return categories;
59}
60
62{
63 return m_doc->title();
64}
65
67{
68 return m_doc->link();
69}
70
72{
73 return m_doc->description();
74}
75
80
82{
83 return m_doc->language();
84}
85
87{
88 return m_doc->copyright();
89}
90
91ImagePtr FeedRSS2Impl::image() const
92{
93 ImageRSS2ImplPtr ptr(new ImageRSS2Impl(m_doc->image()));
94 return ptr;
95}
96
98{
100
101 const auto unhandledElements = m_doc->unhandledElements();
102 for (const QDomElement &i : unhandledElements) {
103 ret.insert(i.namespaceURI() + i.localName(), i);
104 }
105
106 return ret;
107}
108
109ImagePtr FeedRSS2Impl::icon() const
110{
111 ImageRSS2ImplPtr ptr(new ImageRSS2Impl({}));
112 return ptr;
113}
114
115} // namespace Syndication
QMultiMap< QString, QDomElement > additionalProperties() const override
returns a list of feed metadata not covered by this class.
Syndication::SpecificDocumentPtr specificDocument() const override
returns the format-specific document this abstraction wraps.
QString copyright() const override
returns copyright information about the feed
QList< PersonPtr > authors() const override
returns a list of persons who created the feed content.
QList< ItemPtr > items() const override
A list of items, in the order they were parsed from the feed source.
ImagePtr image() const override
returns an image 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.
QList< CategoryPtr > categories() const override
returns a list of categories this feed is associated with.
ImagePtr icon() const override
returns an icon associated with this item.
QString title() const override
The title of the feed.
QString description() const override
A description of the feed.
A category which can be assigned to items or whole feeds.
const_iterator cbegin() const const
const_iterator cend() const const
qsizetype count() const const
iterator insert(const Key &key, const T &value)
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.