File indexing completed on 2025-01-19 10:04:33
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_RDF_ITEM_H 0009 #define SYNDICATION_RDF_ITEM_H 0010 0011 #include <syndication/rdf/document.h> 0012 #include <syndication/rdf/resourcewrapper.h> 0013 0014 #include <syndication/specificitem.h> 0015 0016 class QString; 0017 0018 namespace Syndication 0019 { 0020 class SpecificItemVisitor; 0021 0022 namespace RDF 0023 { 0024 class DublinCore; 0025 class Item; 0026 0027 /** 0028 * An RSS 1.0 item. 0029 * (It is a convenience wrapper for the 0030 * underlying RDF resource, which can be accessed via resource()). 0031 * 0032 * @author Frank Osterfeld 0033 */ 0034 class SYNDICATION_EXPORT Item : public ResourceWrapper, public SpecificItem 0035 { 0036 public: 0037 /** 0038 * creates an item object wrapping a null resource, isNull() is 0039 * @c true. 0040 */ 0041 Item(); 0042 0043 /** 0044 * Creates an item wrapping the given resource 0045 * @param resource resource to wrap, should be of type 0046 * of rss1:item, otherwise the wrapper will not return useful 0047 * information. 0048 * @param doc the document this item is part of. Used by Document 0049 */ 0050 explicit Item(ResourcePtr resource, DocumentPtr doc = DocumentPtr()); 0051 0052 /** 0053 * copies an item 0054 * 0055 * @param other item to copy 0056 */ 0057 Item(const Item &other); 0058 0059 /** 0060 * virtual destructor 0061 */ 0062 ~Item() override; 0063 0064 /** 0065 * assigns another item 0066 * 0067 * @param other the item to assign 0068 */ 0069 Item &operator=(const Item &other); 0070 0071 /** 0072 * compares two item instances. Two instances are equal, 0073 * if the wrapped resources are equal. See ResourceWrapper::operator==() 0074 * for details. 0075 * 0076 * @param other the item to compare this item to 0077 */ 0078 bool operator==(const Item &other) const; 0079 0080 /** 0081 * interface for item visitors. See SpecificItemVisitor for 0082 * more information. 0083 * 0084 * @param visitor a visitor visiting this object 0085 */ 0086 bool accept(SpecificItemVisitor *visitor) override; 0087 0088 /** 0089 * The item's title (required). 0090 * 0091 * @return The item's title as HTML, or a null string if not specified 0092 */ 0093 QString title() const; 0094 0095 /** 0096 * A brief description/abstract of the item. 0097 * if encodedContent() is not provided, this can also contain the full 0098 * content. 0099 * 0100 * @return description as HTML, or a null string if not specified 0101 */ 0102 QString description() const; 0103 0104 /** 0105 * The item's URL, usually pointing to a website containing the 0106 * full content (news article, blog entry etc.). 0107 * 0108 * @return the link 0109 */ 0110 QString link() const; 0111 0112 /** 0113 * returns a dublin core description of this 0114 * item (including metadata such as item author 0115 * or subject) 0116 */ 0117 DublinCore dc() const; 0118 0119 /** 0120 * returns content (@c content:encoded) as HTML. 0121 * 0122 * @return content as HTML, or a null string if not specified 0123 */ 0124 QString encodedContent() const; 0125 0126 //@cond PRIVATE 0127 /** 0128 * @internal 0129 * returns the title unmodified 0130 * used by Document 0131 */ 0132 QString originalTitle() const; 0133 0134 /** 0135 * @internal 0136 * returns the description unmodified 0137 * used by Document 0138 */ 0139 QString originalDescription() const; 0140 0141 //@endcond 0142 0143 /** 0144 * Returns a description of the item for debugging purposes. 0145 * 0146 * @return debug string 0147 */ 0148 QString debugInfo() const; 0149 0150 private: 0151 class Private; 0152 Private *const d; 0153 }; 0154 0155 } // namespace RDF 0156 } // namespace Syndication 0157 0158 #endif // SYNDICATION_RDF_ITEM_H