File indexing completed on 2024-04-28 11:49:05

0001 /*
0002     This file is part of the syndication library
0003     SPDX-FileCopyrightText: 2006 Frank Osterfeld <osterfeld@kde.org>
0004 
0005     SPDX-License-Identifier: LGPL-2.0-or-later
0006 */
0007 
0008 #ifndef SYNDICATION_ATOM_CATEGORY_H
0009 #define SYNDICATION_ATOM_CATEGORY_H
0010 
0011 #include <syndication/elementwrapper.h>
0012 
0013 class QDomElement;
0014 class QString;
0015 
0016 namespace Syndication
0017 {
0018 namespace Atom
0019 {
0020 /**
0021  * A category for categorizing items or whole feeds.
0022  * A category can be an informal string set by the feed author ("General",
0023  * "Stuff I like"), a tag assigned by readers, as known from flickr.com
0024  * or de.licio.us ("KDE", "funny"), or a term from a formally defined ontology.
0025  *
0026  * To represent the category in a user interface, use label() (or term() as
0027  * fallback). To create a key for e.g. storage purposes, use scheme() + term().
0028  *
0029  * @author Frank Osterfeld
0030  */
0031 class SYNDICATION_EXPORT Category : public ElementWrapper
0032 {
0033 public:
0034     /**
0035      * creates a null category object.
0036      */
0037     Category();
0038 
0039     /**
0040      * creates a Category object wrapping an atom:category element.
0041      * @param element a DOM element, should be a atom:category element
0042      * (although not enforced), otherwise this object will not parse
0043      * anything useful
0044      */
0045     explicit Category(const QDomElement &element);
0046 
0047     /**
0048      * a term describing the category. (required)
0049      *
0050      * @return the category term as plain text (no HTML, "&", "<" etc. are
0051      * unescaped!)
0052      */
0053     Q_REQUIRED_RESULT QString term() const;
0054 
0055     /**
0056      * naming scheme the category term is part of. (optional)
0057      * A term is unique in its scheme (like in C++ identifiers are
0058      * unique in their namespaces)
0059      *
0060      * @return a URI representing the scheme, or a null string
0061      * if not specified
0062      */
0063     Q_REQUIRED_RESULT QString scheme() const;
0064 
0065     /**
0066      * Label of the category (optional).
0067      * If specified, this string should be used to represent this category
0068      * in a user interface.
0069      * If not specified, use term() instead.
0070      *
0071      * @return the label as plain text (no HTML, "&", "<" etc. are
0072      * unescaped!), or a null string if not specified
0073      */
0074     Q_REQUIRED_RESULT QString label() const;
0075 
0076     /**
0077      * description of this category object for debugging purposes
0078      *
0079      * @return debug string
0080      */
0081     Q_REQUIRED_RESULT QString debugInfo() const;
0082 };
0083 
0084 } // namespace Atom
0085 } // namespace Syndication
0086 
0087 #endif // SYNDICATION_ATOM_CATEGORY_H