Syndication

feedrdfimpl.cpp
1 /*
2  This file is part of the syndication library
3  SPDX-FileCopyrightText: 2006 Frank Osterfeld <[email protected]>
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 
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 
75  QList<PersonPtr> list;
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 
99 {
100  ImageRDFImplPtr ptr(new ImageRDFImpl(m_doc->image()));
101  return ptr;
102 }
103 
105 {
106  ImageRDFImplPtr ptr(new ImageRDFImpl({}));
107  return ptr;
108 }
109 
111 {
113 }
114 
115 } // namespace Syndication
void append(const T &value)
Definition: feed.h:20
QString description() const override
A description of the feed.
Definition: feedrdfimpl.cpp:66
QList< CategoryPtr > categories() const override
returns a list of categories this feed is associated with.
Definition: feedrdfimpl.cpp:50
int count(const T &value) const const
void reserve(int alloc)
QString title() const override
The title of the feed.
Definition: feedrdfimpl.cpp:56
int size() const const
QMultiMap< QString, QDomElement > additionalProperties() const override
returns a list of feed metadata not covered by this class.
QList< PersonPtr > authors() const override
returns a list of persons who created the feed content.
Definition: feedrdfimpl.cpp:71
QString language() const override
The language used in the feed.
Definition: feedrdfimpl.cpp:88
QList::const_iterator cend() const const
QString link() const override
returns a link pointing to a website associated with this channel.
Definition: feedrdfimpl.cpp:61
QString copyright() const override
returns copyright information about the feed
Definition: feedrdfimpl.cpp:93
QList::const_iterator cbegin() const const
Syndication::SpecificDocumentPtr specificDocument() const override
returns the format-specific document this abstraction wraps.
Definition: feedrdfimpl.cpp:31
ImagePtr image() const override
returns an image associated with this item.
Definition: feedrdfimpl.cpp:98
QList< ItemPtr > items() const override
A list of items, in the order they were parsed from the feed source.
Definition: feedrdfimpl.cpp:36
ImagePtr icon() const override
returns an icon associated with this item.
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Wed Sep 27 2023 03:48:37 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.