1 | /* |
2 | This file is part of the syndication library |
3 | SPDX-FileCopyrightText: 2005 Frank Osterfeld <osterfeld@kde.org> |
4 | |
5 | SPDX-License-Identifier: LGPL-2.0-or-later |
6 | */ |
7 | |
8 | #include "image.h" |
9 | |
10 | #include <QString> |
11 | |
12 | namespace Syndication |
13 | { |
14 | namespace RSS2 |
15 | { |
16 | Image::() |
17 | : ElementWrapper() |
18 | { |
19 | } |
20 | |
21 | Image::(const QDomElement &element) |
22 | : ElementWrapper(element) |
23 | { |
24 | } |
25 | |
26 | QString Image::() const |
27 | { |
28 | return extractElementTextNS(namespaceURI: QString(), QStringLiteral("url" )); |
29 | } |
30 | |
31 | QString Image::() const |
32 | { |
33 | return extractElementTextNS(namespaceURI: QString(), QStringLiteral("title" )); |
34 | } |
35 | |
36 | QString Image::() const |
37 | { |
38 | return extractElementTextNS(namespaceURI: QString(), QStringLiteral("link" )); |
39 | } |
40 | |
41 | uint Image::() const |
42 | { |
43 | QString text; |
44 | bool ok; |
45 | uint c; |
46 | |
47 | text = extractElementTextNS(namespaceURI: QString(), QStringLiteral("width" )); |
48 | c = text.toUInt(ok: &ok); |
49 | return ok ? c : 88; // set to default if not parsable |
50 | } |
51 | |
52 | uint Image::() const |
53 | { |
54 | QString text; |
55 | bool ok; |
56 | uint c; |
57 | |
58 | text = extractElementTextNS(namespaceURI: QString(), QStringLiteral("height" )); |
59 | c = text.toUInt(ok: &ok); |
60 | return ok ? c : 31; // set to default if not parsable |
61 | } |
62 | |
63 | QString Image::() const |
64 | { |
65 | return extractElementTextNS(namespaceURI: QString(), QStringLiteral("description" )); |
66 | } |
67 | |
68 | QString Image::() const |
69 | { |
70 | QString info = QLatin1String("### Image: ###################\n" ); |
71 | if (!title().isNull()) { |
72 | info += QLatin1String("title: #" ) + title() + QLatin1String("#\n" ); |
73 | } |
74 | if (!link().isNull()) { |
75 | info += QLatin1String("link: #" ) + link() + QLatin1String("#\n" ); |
76 | } |
77 | if (!description().isNull()) { |
78 | info += QLatin1String("description: #" ) + description() + QLatin1String("#\n" ); |
79 | } |
80 | if (!url().isNull()) { |
81 | info += QLatin1String("url: #" ) + url() + QLatin1String("#\n" ); |
82 | } |
83 | info += QLatin1String("width: #" ) + QString::number(width()) + QLatin1String("#\n" ); |
84 | info += QLatin1String("height: #" ) + QString::number(height()) + QLatin1String("#\n" ); |
85 | info += QLatin1String("### Image end ################\n" ); |
86 | return info; |
87 | } |
88 | |
89 | } // namespace RSS2 |
90 | } // namespace Syndication |
91 | |