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
36QList<Syndication::ItemPtr> FeedRDFImpl::items() const
37{
38 const QList<Syndication::RDF::Item> entries = m_doc->items();
39
40 QList<ItemPtr> items;
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
50QList<Syndication::CategoryPtr> FeedRDFImpl::categories() const
51{
52 // TODO: check if it makes sense to map dc:subject to categories
54}
55
56QString FeedRDFImpl::title() const
57{
58 return m_doc->title();
59}
60
61QString FeedRDFImpl::link() const
62{
63 return m_doc->link();
64}
65
66QString FeedRDFImpl::description() const
67{
68 return m_doc->description();
69}
70
71QList<PersonPtr> FeedRDFImpl::authors() const
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
88QString FeedRDFImpl::language() const
89{
90 return m_doc->dc().language();
91}
92
93QString FeedRDFImpl::copyright() const
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
110QMultiMap<QString, QDomElement> FeedRDFImpl::additionalProperties() const
111{
113}
114
115} // namespace Syndication
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-2024 The KDE developers.
Generated on Fri May 17 2024 11:56:56 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.