File indexing completed on 2024-04-28 05:19:26
0001 /* 0002 ktnefpropertyset.h 0003 0004 SPDX-FileCopyrightText: 2002 Michael Goffioul <kdeprint@swing.be> 0005 0006 This file is part of KTNEF, the KDE TNEF support library/program. 0007 0008 SPDX-License-Identifier: LGPL-2.0-or-later 0009 */ 0010 /** 0011 * @file 0012 * This file is part of the API for handling TNEF data and 0013 * defines the KTNEFPropertySet class. 0014 * 0015 * @author Michael Goffioul 0016 */ 0017 0018 #pragma once 0019 0020 #include "ktnef_export.h" 0021 #include <QMap> 0022 #include <QVariant> 0023 #include <memory> 0024 class KTNEFPropertySetPrivate; 0025 namespace KTnef 0026 { 0027 class KTNEFProperty; 0028 } 0029 0030 namespace KTnef 0031 { 0032 /** 0033 * @brief 0034 * Interface for setting @acronym MAPI properties and @acronym TNEF attributes. 0035 */ 0036 class KTNEF_EXPORT KTNEFPropertySet 0037 { 0038 public: 0039 /** 0040 Constructor. 0041 */ 0042 KTNEFPropertySet(); 0043 0044 /** 0045 Destructor. 0046 */ 0047 ~KTNEFPropertySet(); 0048 0049 /** 0050 Adds a @acronym MAPI property. 0051 0052 @param key is the property key. 0053 @param type is the property type. 0054 @param value is the property value. 0055 @param name is the property name. 0056 @param overwrite if true, then remove the property if it already exists. 0057 */ 0058 void addProperty(int key, int type, const QVariant &value, const QVariant &name = QVariant(), bool overwrite = false); 0059 0060 /** 0061 Finds a property by @p key, returning a formatted value. 0062 0063 @param key is the property key. 0064 @param fallback is the fallback formatted value to use if the @p key 0065 is not found. 0066 @param convertToUpper if true, then return the formatted value in all 0067 upper case characters. 0068 0069 @return a formatted value string. 0070 */ 0071 [[nodiscard]] QString findProp(int key, const QString &fallback = QString(), bool convertToUpper = false) const; 0072 0073 /** 0074 Finds a property by @p name, returning a formatted value. 0075 0076 @param name is the property name. 0077 @param fallback is the fallback formatted value to use if the @p name 0078 is not found. 0079 @param convertToUpper if true, then return the formatted value in all 0080 upper case characters. 0081 0082 @return a formatted value string. 0083 */ 0084 [[nodiscard]] QString findNamedProp(const QString &name, const QString &fallback = QString(), bool convertToUpper = false) const; 0085 0086 /** 0087 Returns a #QMap of all (key,@acronym MAPI) properties 0088 */ 0089 QMap<int, KTNEFProperty *> &properties(); 0090 0091 /** 0092 Returns a #QMap of all (key,@acronym MAPI) properties 0093 */ 0094 const QMap<int, KTNEFProperty *> &properties() const; // krazy:exclude=constref 0095 0096 /** 0097 Returns the property associated with the specified @p key. 0098 0099 @param key is the property key. 0100 0101 @return the property.q 0102 */ 0103 [[nodiscard]] QVariant property(int key) const; 0104 0105 /** 0106 Adds a @acronym TNEF attribute. 0107 0108 @param key is the attribute key. 0109 @param type is the attribute type. 0110 @param value is the attribute value. 0111 @param overwrite if true, then remove the attribute if it already exists. 0112 */ 0113 void addAttribute(int key, int type, const QVariant &value, bool overwrite = false); 0114 0115 /** 0116 Returns a #QMap of all (key,@acronym TNEF) attributes. 0117 */ 0118 [[nodiscard]] QMap<int, KTNEFProperty *> &attributes(); 0119 0120 /** 0121 Returns a #QMap of all (key,@acronym TNEF) attributes. 0122 */ 0123 const QMap<int, KTNEFProperty *> &attributes() const; // krazy:exclude=constref 0124 0125 /** 0126 Returns the attribute associated with the specified @p key. 0127 0128 @param key is the @acronym TNEF key. 0129 0130 @return the attribute associated with the key. 0131 */ 0132 [[nodiscard]] QVariant attribute(int key) const; 0133 0134 /** 0135 Clears the @acronym MAPI and @acronym TNEF maps. 0136 0137 @param deleteAll if true, delete the map memory as well. 0138 */ 0139 void clear(bool deleteAll = false); 0140 0141 private: 0142 //@cond PRIVATE 0143 std::unique_ptr<KTNEFPropertySetPrivate> const d; 0144 //@endcond 0145 0146 Q_DISABLE_COPY(KTNEFPropertySet) 0147 }; 0148 0149 }