File indexing completed on 2024-12-01 06:43:38
0001 /* 0002 This file is part of the KContacts framework. 0003 SPDX-FileCopyrightText: 2002 Tobias Koenig <tokoe@kde.org> 0004 0005 SPDX-License-Identifier: LGPL-2.0-or-later 0006 */ 0007 0008 #ifndef KCONTACTS_SECRECY_H 0009 #define KCONTACTS_SECRECY_H 0010 0011 #include "kcontacts_export.h" 0012 #include <QList> 0013 #include <QSharedDataPointer> 0014 0015 namespace KContacts 0016 { 0017 /** Describes the confidentiality of an addressee. */ 0018 class KCONTACTS_EXPORT Secrecy 0019 { 0020 friend KCONTACTS_EXPORT QDataStream &operator<<(QDataStream &, const Secrecy &); 0021 friend KCONTACTS_EXPORT QDataStream &operator>>(QDataStream &, Secrecy &); 0022 0023 public: 0024 /** 0025 * Secrecy types 0026 * 0027 * @li Public - for public access 0028 * @li Private - only private access 0029 * @li Confidential - access for confidential persons 0030 */ 0031 enum Type { 0032 Public, 0033 Private, 0034 Confidential, 0035 Invalid, 0036 }; 0037 0038 /** 0039 * List of secrecy types. 0040 */ 0041 typedef QList<Type> TypeList; 0042 0043 /** 0044 * Creates a new secrecy of the given type. 0045 * 0046 * @param type The secrecy type. @see Type 0047 */ 0048 Secrecy(Type type = Invalid); 0049 0050 /** 0051 * Copy constructor. 0052 */ 0053 Secrecy(const Secrecy &other); 0054 0055 /** 0056 * Destroys the secrecy. 0057 */ 0058 ~Secrecy(); 0059 0060 Secrecy &operator=(const Secrecy &other); 0061 0062 Q_REQUIRED_RESULT bool operator==(const Secrecy &other) const; 0063 Q_REQUIRED_RESULT bool operator!=(const Secrecy &other) const; 0064 0065 /** 0066 * Returns if the Secrecy object has a valid value. 0067 */ 0068 Q_REQUIRED_RESULT bool isValid() const; 0069 0070 /** 0071 * Sets the @p type. 0072 * 0073 * @param type The #Type of secrecy 0074 */ 0075 void setType(Type type); 0076 0077 /** 0078 * Returns the type. 0079 */ 0080 Q_REQUIRED_RESULT Type type() const; 0081 0082 /** 0083 * Returns a list of all available secrecy types. 0084 */ 0085 Q_REQUIRED_RESULT static TypeList typeList(); 0086 0087 /** 0088 * Returns a translated label for a given secrecy @p type. 0089 */ 0090 Q_REQUIRED_RESULT static QString typeLabel(Type type); 0091 0092 /** 0093 * Returns a string representation of the secrecy. 0094 */ 0095 Q_REQUIRED_RESULT QString toString() const; 0096 0097 private: 0098 class PrivateData; 0099 QSharedDataPointer<PrivateData> d; 0100 }; 0101 0102 /** 0103 * Serializes the @p secrecy object into the @p stream. 0104 */ 0105 KCONTACTS_EXPORT QDataStream &operator<<(QDataStream &stream, const Secrecy &secrecy); 0106 0107 /** 0108 * Initializes the @p secrecy object from the @p stream. 0109 */ 0110 KCONTACTS_EXPORT QDataStream &operator>>(QDataStream &stream, Secrecy &secrecy); 0111 } 0112 Q_DECLARE_TYPEINFO(KContacts::Secrecy, Q_RELOCATABLE_TYPE); 0113 #endif