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 | #ifndef SYNDICATION_ATOM_CATEGORY_H |
9 | #define SYNDICATION_ATOM_CATEGORY_H |
10 | |
11 | #include <syndication/elementwrapper.h> |
12 | |
13 | class QDomElement; |
14 | class QString; |
15 | |
16 | namespace Syndication |
17 | { |
18 | namespace Atom |
19 | { |
20 | /** |
21 | * A category for categorizing items or whole feeds. |
22 | * A category can be an informal string set by the feed author ("General", |
23 | * "Stuff I like"), a tag assigned by readers, as known from flickr.com |
24 | * or de.licio.us ("KDE", "funny"), or a term from a formally defined ontology. |
25 | * |
26 | * To represent the category in a user interface, use label() (or term() as |
27 | * fallback). To create a key for e.g. storage purposes, use scheme() + term(). |
28 | * |
29 | * @author Frank Osterfeld |
30 | */ |
31 | class SYNDICATION_EXPORT Category : public ElementWrapper |
32 | { |
33 | public: |
34 | /** |
35 | * creates a null category object. |
36 | */ |
37 | Category(); |
38 | |
39 | /** |
40 | * creates a Category object wrapping an atom:category element. |
41 | * @param element a DOM element, should be a atom:category element |
42 | * (although not enforced), otherwise this object will not parse |
43 | * anything useful |
44 | */ |
45 | explicit Category(const QDomElement &element); |
46 | |
47 | /** |
48 | * a term describing the category. (required) |
49 | * |
50 | * @return the category term as plain text (no HTML, "&", "<" etc. are |
51 | * unescaped!) |
52 | */ |
53 | Q_REQUIRED_RESULT QString term() const; |
54 | |
55 | /** |
56 | * naming scheme the category term is part of. (optional) |
57 | * A term is unique in its scheme (like in C++ identifiers are |
58 | * unique in their namespaces) |
59 | * |
60 | * @return a URI representing the scheme, or a null string |
61 | * if not specified |
62 | */ |
63 | Q_REQUIRED_RESULT QString scheme() const; |
64 | |
65 | /** |
66 | * Label of the category (optional). |
67 | * If specified, this string should be used to represent this category |
68 | * in a user interface. |
69 | * If not specified, use term() instead. |
70 | * |
71 | * @return the label as plain text (no HTML, "&", "<" etc. are |
72 | * unescaped!), or a null string if not specified |
73 | */ |
74 | Q_REQUIRED_RESULT QString label() const; |
75 | |
76 | /** |
77 | * description of this category object for debugging purposes |
78 | * |
79 | * @return debug string |
80 | */ |
81 | Q_REQUIRED_RESULT QString debugInfo() const; |
82 | }; |
83 | |
84 | } // namespace Atom |
85 | } // namespace Syndication |
86 | |
87 | #endif // SYNDICATION_ATOM_CATEGORY_H |
88 | |