1/*
2 This file is part of libkabc.
3 Copyright (c) 2002 Tobias Koenig <tokoe@kde.org>
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
14
15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
19*/
20
21#ifndef KABC_SECRECY_H
22#define KABC_SECRECY_H
23
24#include "kabc_export.h"
25#include <QtCore/QList>
26#include <QtCore/QSharedDataPointer>
27
28namespace KABC {
29
30class KABC_EXPORT Secrecy
31{
32 friend KABC_EXPORT QDataStream &operator<<( QDataStream &, const Secrecy & );
33 friend KABC_EXPORT QDataStream &operator>>( QDataStream &, Secrecy & );
34
35 public:
36 /**
37 * Secrecy types
38 *
39 * @li Public - for public access
40 * @li Private - only private access
41 * @li Confidential - access for confidential persons
42 */
43 enum Type {
44 Public,
45 Private,
46 Confidential,
47 Invalid
48 };
49
50 /**
51 * List of secrecy types.
52 */
53 typedef QList<Type> TypeList;
54
55 /**
56 * Creates a new secrecy of the given type.
57 *
58 * @param type The secrecy type. @see Type
59 */
60 Secrecy( Type type = Invalid );
61
62 /**
63 * Copy constructor.
64 */
65 Secrecy( const Secrecy &other );
66
67 /**
68 * Destroys the secrecy.
69 */
70 ~Secrecy();
71
72 Secrecy &operator=( const Secrecy & );
73
74 bool operator==( const Secrecy & ) const;
75 bool operator!=( const Secrecy & ) const;
76
77 /**
78 * Returns if the Secrecy object has a valid value.
79 */
80 bool isValid() const;
81
82 /**
83 * Sets the @p type.
84 *
85 * @param type The #Type of secrecy
86 */
87 void setType( Type type );
88
89 /**
90 * Returns the type.
91 */
92 Type type() const;
93
94 /**
95 * Returns a list of all available secrecy types.
96 */
97 static TypeList typeList();
98
99 /**
100 * Returns a translated label for a given secrecy @p type.
101 */
102 static QString typeLabel( Type type );
103
104 /**
105 * Returns a string representation of the secrecy.
106 */
107 QString toString() const;
108
109 private:
110 class PrivateData;
111 QSharedDataPointer<PrivateData> d;
112};
113
114/**
115 * Serializes the @p secrecy object into the @p stream.
116 */
117KABC_EXPORT QDataStream &operator<<( QDataStream &stream, const Secrecy &secrecy );
118
119/**
120 * Initializes the @p secrecy object from the @p stream.
121 */
122KABC_EXPORT QDataStream &operator>>( QDataStream &stream, Secrecy &secrecy );
123
124}
125#endif
126