Syndication

rdf/item.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 "item.h"
9#include "contentvocab.h"
10#include "document.h"
11#include "dublincore.h"
12#include "model.h"
13#include "rssvocab.h"
14#include "statement.h"
15
16#include <specificitemvisitor.h>
17#include <tools.h>
18
19#include <QString>
20
21namespace Syndication
22{
23namespace RDF
24{
25class SYNDICATION_NO_EXPORT Item::Private
26{
27public:
28 DocumentPtr doc;
29};
30
33 , d(new Private)
34{
35}
36
37Item::Item(ResourcePtr resource, DocumentPtr doc)
38 : ResourceWrapper(resource)
39 , d(new Private)
40{
41 d->doc = doc;
42}
43
44Item::Item(const Item &other)
45 : ResourceWrapper(other)
46 , SpecificItem(other)
47 , d(new Private)
48{
49 *d = *(other.d);
50}
51
52Item::~Item() = default;
53
55{
57 *d = *(other.d);
58 return *this;
59}
60
61bool Item::operator==(const Item &other) const
62{
63 return ResourceWrapper::operator==(other);
64}
65
67{
68 if (!d->doc) {
69 return originalTitle();
70 }
71
72 bool containsMarkup = false;
73 d->doc->getItemTitleFormatInfo(&containsMarkup);
74
75 return normalize(originalTitle(), false, containsMarkup);
76}
77
79{
80 if (!d->doc) {
81 return originalDescription();
82 }
83
84 bool containsMarkup = false;
85 d->doc->getItemDescriptionFormatInfo(&containsMarkup);
86
87 return normalize(originalDescription(), false, containsMarkup);
88}
89
91{
92 return resource()->property(RSSVocab::self()->link())->asString();
93}
94
96{
97 return DublinCore(resource());
98}
99
101{
102 return resource()->property(ContentVocab::self()->encoded())->asString();
103}
104
105QString Item::originalTitle() const
106{
107 return resource()->property(RSSVocab::self()->title())->asString();
108}
109
110QString Item::originalDescription() const
111{
112 return resource()->property(RSSVocab::self()->description())->asString();
113}
114
116{
117 QString info = QLatin1String("### Item: ###################\n");
118 info += QLatin1String("title: #") + title() + QLatin1String("#\n");
119 info += QLatin1String("link: #") + link() + QLatin1String("#\n");
120 info += QLatin1String("description: #") + description() + QLatin1String("#\n");
121 info += QLatin1String("content:encoded: #") + encodedContent() + QLatin1String("#\n");
122 info += dc().debugInfo();
123 info += QLatin1String("### Item end ################\n");
124 return info;
125}
126
128{
129 return visitor->visitRDFItem(this);
130}
131
132} // namespace RDF
133} // namespace Syndication
static ContentVocab * self()
returns the singleton instance
A resource wrapper providing convenient access to Dublin Core metadata.
Definition dublincore.h:36
QString debugInfo() const
returns a debug string describing the available DC metadata for debugging purposes
An RSS 1.0 item.
Definition rdf/item.h:37
~Item() override
virtual destructor
QString link() const
The item's URL, usually pointing to a website containing the full content (news article,...
Definition rdf/item.cpp:90
QString title() const
The item's title (required).
Definition rdf/item.cpp:66
Item()
creates an item object wrapping a null resource, isNull() is true.
Definition rdf/item.cpp:31
DublinCore dc() const
returns a dublin core description of this item (including metadata such as item author or subject)
Definition rdf/item.cpp:95
bool operator==(const Item &other) const
compares two item instances.
Definition rdf/item.cpp:61
QString debugInfo() const
/** Returns a description of the item for debugging purposes.
Definition rdf/item.cpp:115
Item & operator=(const Item &other)
assigns another item
Definition rdf/item.cpp:54
QString encodedContent() const
returns content (content:encoded) as HTML.
Definition rdf/item.cpp:100
bool accept(SpecificItemVisitor *visitor) override
interface for item visitors.
Definition rdf/item.cpp:127
QString description() const
A brief description/abstract of the item.
Definition rdf/item.cpp:78
static RSSVocab * self()
returns the singleton instance
Definition rssvocab.cpp:63
A wrapper for RDF resources.
ResourceWrapper & operator=(const ResourceWrapper &other)
Assignment oeprator Due to the shared d pointer, this is a cheap operation.
bool operator==(const ResourceWrapper &other) const
compares two resource wrapper instances.
ResourcePtr resource() const
returns the wrapped resource.
Visitor interface, following the Visitor design pattern.
virtual bool visitRDFItem(Syndication::RDF::Item *item)
reimplement this method to handle RDF items.
Interface for all format-specific item-like classes, such as RSS2/RDF items, and Atom entries.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:09:18 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.