Syndication

dublincore.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 "dublincore.h"
9 #include "dublincorevocab.h"
10 #include "property.h"
11 #include "statement.h"
12 
13 #include <tools.h>
14 
15 #include <QList>
16 #include <QString>
17 
18 namespace Syndication
19 {
20 namespace RDF
21 {
23  : ResourceWrapper(resource)
24 {
25 }
26 
28 {
29 }
30 
32 {
33  return resource()->property(DublinCoreVocab::self()->contributor())->asString();
34 }
35 
37 {
38  QStringList res;
39  QList<StatementPtr> list = resource()->properties(DublinCoreVocab::self()->contributor());
42  for (; it != end; ++it) {
43  const QString str = (*it)->asString();
44  if (!str.isNull()) {
45  res.append(str);
46  }
47  }
48  return res;
49 }
50 
52 {
53  return resource()->property(DublinCoreVocab::self()->coverage())->asString();
54 }
55 
57 {
58  return resource()->property(DublinCoreVocab::self()->creator())->asString();
59 }
60 
62 {
63  QStringList res;
64  QList<StatementPtr> list = resource()->properties(DublinCoreVocab::self()->creator());
67  for (; it != end; ++it) {
68  const QString str = (*it)->asString();
69  if (!str.isNull()) {
70  res.append(str);
71  }
72  }
73  return res;
74 }
75 
76 time_t DublinCore::date() const
77 {
78  QString str = resource()->property(DublinCoreVocab::self()->date())->asString();
79  return parseDate(str, ISODate);
80 }
81 
83 {
84  return resource()->property(DublinCoreVocab::self()->description())->asString();
85 }
86 
88 {
89  return resource()->property(DublinCoreVocab::self()->format())->asString();
90 }
91 
93 {
94  return resource()->property(DublinCoreVocab::self()->identifier())->asString();
95 }
96 
98 {
99  return resource()->property(DublinCoreVocab::self()->language())->asString();
100 }
101 
103 {
104  return resource()->property(DublinCoreVocab::self()->publisher())->asString();
105 }
106 
108 {
109  return resource()->property(DublinCoreVocab::self()->relation())->asString();
110 }
111 
113 {
114  return resource()->property(DublinCoreVocab::self()->rights())->asString();
115 }
116 
118 {
119  return resource()->property(DublinCoreVocab::self()->source())->asString();
120 }
121 
123 {
124  return resource()->property(DublinCoreVocab::self()->subject())->asString();
125 }
126 
128 {
129  QStringList res;
130  QList<StatementPtr> list = resource()->properties(DublinCoreVocab::self()->subject());
133  for (; it != end; ++it) {
134  QString str = (*it)->asString();
135  if (!str.isNull()) {
136  res.append(str);
137  }
138  }
139  return res;
140 }
141 
143 {
144  return resource()->property(DublinCoreVocab::self()->title())->asString();
145 }
146 
148 {
149  return resource()->property(DublinCoreVocab::self()->type())->asString();
150 }
151 
153 {
154  QString info;
155  if (!contributor().isNull()) {
156  info += QStringLiteral("dc:contributor: #%1#\n").arg(contributor());
157  }
158  if (!coverage().isNull()) {
159  info += QStringLiteral("dc:coverage: #%1#\n").arg(coverage());
160  }
161  if (!creator().isNull()) {
162  info += QStringLiteral("dc:creator: #%1#\n").arg(creator());
163  }
164 
165  const QString ddate = dateTimeToString(date());
166  if (!ddate.isNull()) {
167  info += QStringLiteral("dc:date: #%1#\n").arg(ddate);
168  }
169 
170  if (!description().isNull()) {
171  info += QStringLiteral("dc:description: #%1#\n").arg(description());
172  }
173  if (!format().isNull()) {
174  info += QStringLiteral("dc:format: #%1#\n").arg(format());
175  }
176  if (!identifier().isNull()) {
177  info += QStringLiteral("dc:identifier: #%1#\n").arg(identifier());
178  }
179  if (!language().isNull()) {
180  info += QStringLiteral("dc:language: #%1#\n").arg(language());
181  }
182  if (!publisher().isNull()) {
183  info += QStringLiteral("dc:publisher: #%1#\n").arg(publisher());
184  }
185  if (!relation().isNull()) {
186  info += QStringLiteral("dc:relation: #%1#\n").arg(relation());
187  }
188  if (!rights().isNull()) {
189  info += QStringLiteral("dc:rights: #%1#\n").arg(rights());
190  }
191  if (!source().isNull()) {
192  info += QStringLiteral("dc:source: #%1#\n").arg(source());
193  }
194  if (!subject().isNull()) {
195  info += QStringLiteral("dc:subject: #%1#\n").arg(subject());
196  }
197  if (!title().isNull()) {
198  info += QStringLiteral("dc:title: #%1#\n").arg(title());
199  }
200  if (!type().isNull()) {
201  info += QStringLiteral("dc:type: #%1#\n").arg(type());
202  }
203  return info;
204 }
205 
206 } // namespace RDF
207 } // namespace Syndication
void append(const T &value)
bool isNull() const const
QStringList subjects() const
like subject(), but returns all dc:subject properties, not only one.
Definition: dublincore.cpp:127
QString format() const
"The physical or digital manifestation of the resource.
Definition: dublincore.cpp:87
~DublinCore() override
virtual destructor
Definition: dublincore.cpp:27
time_t date() const
"A date associated with an event in the life cycle of the resource.
Definition: dublincore.cpp:76
QString rights() const
"Information about rights held in and over the resource.
Definition: dublincore.cpp:112
QString coverage() const
"The extent or scope of the content of the resource.
Definition: dublincore.cpp:51
QString description() const
"An account of the content of the resource.
Definition: dublincore.cpp:82
QList::const_iterator constBegin() const const
QString creator() const
"An entity primarily responsible for making the content of the resource.
Definition: dublincore.cpp:56
QString type() const
"The nature or genre of the content of the resource.
Definition: dublincore.cpp:147
QString language() const
"A language of the intellectual content of the resource.
Definition: dublincore.cpp:97
QString contributor() const
"An entity responsible for making contributions to the content of the resource.
Definition: dublincore.cpp:31
QString subject() const
"The topic of the content of the resource.
Definition: dublincore.cpp:122
QString debugInfo() const
returns a debug string describing the available DC metadata for debugging purposes
Definition: dublincore.cpp:152
QString relation() const
"A reference to a related resource.
Definition: dublincore.cpp:107
DublinCore(ResourcePtr resource)
creates a dublin core convenience wrapper for a resource
Definition: dublincore.cpp:22
QStringList creators() const
like creator(), but returns all dc:creator properties, not only one.
Definition: dublincore.cpp:61
KCALUTILS_EXPORT QString dateTimeToString(const QDateTime &date, bool dateOnly=false, bool shortfmt=true)
QString identifier() const
"An unambiguous reference to the resource within a given context.
Definition: dublincore.cpp:92
QList::const_iterator constEnd() const const
QString arg(qlonglong a, int fieldWidth, int base, QChar fillChar) const const
QString publisher() const
"An entity responsible for making the resource available.
Definition: dublincore.cpp:102
QString source() const
A Reference to a resource from which the present resource is derived.
Definition: dublincore.cpp:117
QStringList contributors() const
like contributor(), but returns all dc:contributor properties, not only one.
Definition: dublincore.cpp:36
QString title() const
A name given to the resource.
Definition: dublincore.cpp:142
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon May 8 2023 03:57:11 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.