File indexing completed on 2024-04-28 05:19:26
0001 /* 0002 ktnefproperty.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 KTNEFProperty class. 0014 * 0015 * @author Michael Goffioul 0016 */ 0017 0018 #pragma once 0019 0020 #include "ktnef_export.h" 0021 #include <QString> 0022 #include <QVariant> 0023 #include <memory> 0024 class KTNEFPropertyPrivate; 0025 namespace KTnef 0026 { 0027 /** 0028 * @brief 0029 * Interface for setting @acronym MAPI properties. 0030 */ 0031 class KTNEF_EXPORT KTNEFProperty 0032 { 0033 public: 0034 /** 0035 * The different @acronym MAPI types. 0036 */ 0037 enum MAPIType { 0038 UInt16 = 0x0002, /**< 16-bit unsigned integer */ 0039 ULong = 0x0003, /**< unsigned long integer */ 0040 Float = 0x0004, /**< single precision floating point */ 0041 Double = 0x0005, /**< double precision floating point */ 0042 Boolean = 0x000B, /**< a boolean value */ 0043 Object = 0x000D, /**< an object */ 0044 Time = 0x0040, /**< a time value */ 0045 String8 = 0x001E, /**< a string of 8 characters */ 0046 UString = 0x001F, /**< a string of characters */ 0047 Binary = 0x0102 /**< a binary value */ 0048 }; 0049 0050 /** 0051 * Constructs a @acronym TNEF property. 0052 */ 0053 KTNEFProperty(); 0054 0055 /** 0056 * Constructs a @acronym TNEF property initialized with specified settings. 0057 * 0058 * @param key_ is the property key. 0059 * @param type_ is the property type. 0060 * @param value_ is the property value. 0061 * @param name_ is the property name. 0062 */ 0063 KTNEFProperty(int key_, int type_, const QVariant &value_, const QVariant &name_ = QVariant()); 0064 0065 /** 0066 * Constructs a @acronym TNEF property with settings from another property. 0067 * 0068 * @param p is a #KTNEFProperty. 0069 */ 0070 KTNEFProperty(const KTNEFProperty &p); 0071 0072 /** 0073 * Destroys the property. 0074 */ 0075 ~KTNEFProperty(); 0076 0077 KTNEFProperty &operator=(const KTNEFProperty &other); 0078 0079 /** 0080 * Returns the key string of the property. 0081 * 0082 * @return the key string. 0083 */ 0084 [[nodiscard]] QString keyString() const; 0085 0086 /** 0087 * Returns the value string of the property. 0088 * 0089 * @return the value string. 0090 */ 0091 [[nodiscard]] QString valueString() const; 0092 0093 /** 0094 * Creates a formatted string from the value of the property. 0095 * 0096 * @param v is the property value. 0097 * @param beautify if true uses a prettier format 0098 * 0099 * @return the formatted value string. 0100 */ 0101 [[nodiscard]] static QString formatValue(const QVariant &v, bool beautify = true); 0102 0103 /** 0104 * Returns the integer key of the property. 0105 * 0106 * @return the property key. 0107 */ 0108 [[nodiscard]] int key() const; 0109 0110 /** 0111 * Returns the integer type of the property. 0112 * 0113 * @return the property type. 0114 */ 0115 [[nodiscard]] int type() const; 0116 0117 /** 0118 * Returns the value of the property. 0119 * 0120 * @return the property value. 0121 */ 0122 [[nodiscard]] QVariant value() const; 0123 0124 /** 0125 * Returns the name of the property. 0126 * 0127 * @return the property name. 0128 */ 0129 [[nodiscard]] QVariant name() const; 0130 0131 /** 0132 * Determines if the property is a vector type. 0133 * 0134 * @returns true if the property is a vector type; otherwise false. 0135 */ 0136 [[nodiscard]] bool isVector() const; 0137 0138 private: 0139 //@cond PRIVATE 0140 std::unique_ptr<KTNEFPropertyPrivate> const d; 0141 //@endcond 0142 }; 0143 0144 }