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 <rdf/dublincore.h>
13 #include <rdf/item.h>
14 #include <category.h>
15 #include <personimpl.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 
27 FeedRDFImpl::FeedRDFImpl(Syndication::RDF::DocumentPtr doc) : m_doc(doc)
28 {
29 }
30 
31 Syndication::SpecificDocumentPtr FeedRDFImpl::specificDocument() const
32 {
33  return m_doc;
34 }
35 
37 {
39  QList<Syndication::RDF::Item> entries = m_doc->items();
42  items.reserve(entries.count());
43 
44  for (; it != end; ++it) {
45  ItemRDFImplPtr item(new ItemRDFImpl(*it));
46  items.append(item);
47  }
48 
49  return items;
50 }
51 
53 {
54  // TODO: check if it makes sense to map dc:subject to categories
56 }
57 
59 {
60  return m_doc->title();
61 }
62 
64 {
65  return m_doc->link();
66 }
67 
69 {
70  return m_doc->description();
71 }
72 
74 {
75  QList<PersonPtr> list;
76 
77  QStringList people = m_doc->dc().creators();
78  people += m_doc->dc().contributors();
80  QStringList::ConstIterator end = people.constEnd();
81 
82  for (; it != end; ++it) {
83  PersonPtr ptr = personFromString(*it);
84  if (!ptr->isNull()) {
85  list.append(ptr);
86  }
87  }
88 
89  return list;
90 }
91 
93 {
94  return m_doc->dc().language();
95 }
96 
98 {
99  return m_doc->dc().rights();
100 }
101 
103 {
104  ImageRDFImplPtr ptr(new ImageRDFImpl(m_doc->image()));
105  return ptr;
106 }
107 
109 {
110  ImageRDFImplPtr ptr(new ImageRDFImpl({}));
111  return ptr;
112 }
113 
115 {
117 }
118 
119 } // namespace Syndication
120 
121 
QString language() const override
The language used in the feed.
Definition: feedrdfimpl.cpp:92
QList< PersonPtr > authors() const override
returns a list of persons who created the feed content.
Definition: feedrdfimpl.cpp:73
void reserve(int alloc)
ImagePtr image() const override
returns an image associated with this item.
QString copyright() const override
returns copyright information about the feed
Definition: feedrdfimpl.cpp:97
QList< ItemPtr > items() const override
A list of items, in the order they were parsed from the feed source.
Definition: feedrdfimpl.cpp:36
Syndication::SpecificDocumentPtr specificDocument() const override
returns the format-specific document this abstraction wraps.
Definition: feedrdfimpl.cpp:31
ImagePtr icon() const override
returns an icon associated with this item.
int count(const T &value) const const
void append(const T &value)
QList< CategoryPtr > categories() const override
returns a list of categories this feed is associated with.
Definition: feedrdfimpl.cpp:52
QString title() const override
The title of the feed.
Definition: feedrdfimpl.cpp:58
QString description() const override
A description of the feed.
Definition: feedrdfimpl.cpp:68
typedef ConstIterator
QString link() const override
returns a link pointing to a website associated with this channel.
Definition: feedrdfimpl.cpp:63
QMultiMap< QString, QDomElement > additionalProperties() const override
returns a list of feed metadata not covered by this class.
QList::const_iterator constEnd() const const
Definition: feed.h:18
QList::const_iterator constBegin() const const
QList< Syndication::ItemPtr > items() const override
A list of items, in the order they were parsed from the feed source.
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Aug 10 2020 23:06:40 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.