1/*
2 This file is part of the KContacts framework.
3 SPDX-FileCopyrightText: 2002 Tobias Koenig <tokoe@kde.org>
4
5 SPDX-License-Identifier: LGPL-2.0-or-later
6*/
7
8#ifndef KCONTACTS_SECRECY_H
9#define KCONTACTS_SECRECY_H
10
11#include "kcontacts_export.h"
12#include <QList>
13#include <QSharedDataPointer>
14
15namespace KContacts
16{
17/*!
18 * \class KContacts::Secrecy
19 * \inheaderfile KContacts/Secrecy
20 * \inmodule KContacts
21 *
22 * \brief Describes the confidentiality of an addressee.
23 */
24class KCONTACTS_EXPORT Secrecy
25{
26 friend KCONTACTS_EXPORT QDataStream &operator<<(QDataStream &, const Secrecy &);
27 friend KCONTACTS_EXPORT QDataStream &operator>>(QDataStream &, Secrecy &);
28
29public:
30 /*!
31 * Secrecy types
32 *
33 * \value Public for public access
34 * \value Private only private access
35 * \value Confidential access for confidential persons
36 * \value Invalid
37 */
38 enum Type {
39 Public,
40 Private,
41 Confidential,
42 Invalid,
43 };
44
45 /*!
46 * List of secrecy types.
47 */
48 typedef QList<Type> TypeList;
49
50 /*!
51 * Creates a new secrecy of the given type.
52 *
53 * \a type The secrecy type
54 */
55 Secrecy(Type type = Invalid);
56
57 Secrecy(const Secrecy &other);
58
59 ~Secrecy();
60
61 Secrecy &operator=(const Secrecy &other);
62
63 /*!
64 */
65 Q_REQUIRED_RESULT bool operator==(const Secrecy &other) const;
66
67 /*!
68 */
69 Q_REQUIRED_RESULT bool operator!=(const Secrecy &other) const;
70
71 /*!
72 * Returns if the Secrecy object has a valid value.
73 */
74 Q_REQUIRED_RESULT bool isValid() const;
75
76 /*!
77 * Sets the \a type.
78 *
79 * \a type The Type of secrecy
80 */
81 void setType(Type type);
82
83 /*!
84 * Returns the type.
85 */
86 Q_REQUIRED_RESULT Type type() const;
87
88 /*!
89 * Returns a list of all available secrecy types.
90 */
91 Q_REQUIRED_RESULT static TypeList typeList();
92
93 /*!
94 * Returns a translated label for a given secrecy \a type.
95 */
96 Q_REQUIRED_RESULT static QString typeLabel(Type type);
97
98 /*!
99 * Returns a string representation of the secrecy.
100 */
101 Q_REQUIRED_RESULT QString toString() const;
102
103private:
104 class PrivateData;
105 QSharedDataPointer<PrivateData> d;
106};
107
108/*!
109 * \relates KContacts::Secrecy
110 *
111 * Serializes the \a secrecy object into the \a stream.
112 */
113KCONTACTS_EXPORT QDataStream &operator<<(QDataStream &stream, const Secrecy &secrecy);
114
115/*!
116 * \relates KContacts::Secrecy
117 *
118 * Initializes the \a secrecy object from the \a stream.
119 */
120KCONTACTS_EXPORT QDataStream &operator>>(QDataStream &stream, Secrecy &secrecy);
121}
122Q_DECLARE_TYPEINFO(KContacts::Secrecy, Q_RELOCATABLE_TYPE);
123#endif
124

source code of kcontacts/src/secrecy.h