1 | /* |
2 | This file is part of the kcal library. |
3 | |
4 | Copyright (c) 2001-2003 Cornelius Schumacher <schumacher@kde.org> |
5 | Copyright (C) 2003-2004 Reinhold Kainhofer <reinhold@kainhofer.com> |
6 | |
7 | This library is free software; you can redistribute it and/or |
8 | modify it under the terms of the GNU Library General Public |
9 | License as published by the Free Software Foundation; either |
10 | version 2 of the License, or (at your option) any later version. |
11 | |
12 | This library is distributed in the hope that it will be useful, |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
15 | Library General Public License for more details. |
16 | |
17 | You should have received a copy of the GNU Library General Public License |
18 | along with this library; see the file COPYING.LIB. If not, write to |
19 | the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
20 | Boston, MA 02110-1301, USA. |
21 | */ |
22 | /** |
23 | @file |
24 | This file is part of the API for handling calendar data and |
25 | defines the Person class. |
26 | |
27 | @author Cornelius Schumacher \<schumacher@kde.org\> |
28 | @author Reinhold Kainhofer \<reinhold@kainhofer.com\> |
29 | */ |
30 | |
31 | #ifndef KCAL_PERSON_H |
32 | #define KCAL_PERSON_H |
33 | |
34 | #include <QtCore/QString> |
35 | #include <QtCore/QHash> |
36 | |
37 | #include "kcal_export.h" |
38 | |
39 | namespace KCal { |
40 | |
41 | /** |
42 | @brief |
43 | Represents a person, by name ane email address. |
44 | |
45 | This class represents a person, with a name and an email address. |
46 | It supports the "FirstName LastName\ <mail@domain\>" format. |
47 | */ |
48 | class KCAL_DEPRECATED_EXPORT Person |
49 | { |
50 | public: |
51 | /** |
52 | Constructs a blank person. |
53 | */ |
54 | Person(); |
55 | |
56 | /** |
57 | Constructs a person with name and email address taken from @p fullName. |
58 | |
59 | @param fullName is the name and email of the person in |
60 | the form "FirstName LastName \<mail@domain\>". |
61 | */ |
62 | static Person fromFullName( const QString &fullName ); |
63 | |
64 | /** |
65 | Constructs a person with name and email address taken from @p fullName. |
66 | |
67 | @param fullName is the name and email of the person in |
68 | the form "FirstName LastName \<mail@domain\>". |
69 | |
70 | @deprecated use fromFullName() instead. |
71 | */ |
72 | KCAL_DEPRECATED explicit Person( const QString &fullName ); |
73 | |
74 | /** |
75 | Constructs a person with the name @p name and email address @p email. |
76 | |
77 | @param name is the name of this person. |
78 | @param email is the email address of this person. |
79 | */ |
80 | Person( const QString &name, const QString &email ); |
81 | |
82 | /** |
83 | Constructs a person as a copy of another person object. |
84 | |
85 | @param person is the person to copy. |
86 | */ |
87 | Person( const Person &person ); |
88 | |
89 | /** |
90 | Destroys a person. |
91 | */ |
92 | ~Person(); |
93 | |
94 | /** |
95 | Returns true if the person name and email address are empty. |
96 | */ |
97 | bool isEmpty() const; |
98 | |
99 | /** |
100 | Returns the full name of this person. |
101 | */ |
102 | QString fullName( ) const; |
103 | |
104 | /** |
105 | Sets the name of the person to @p name. |
106 | |
107 | @param name is the name of this person. |
108 | |
109 | @see name() |
110 | */ |
111 | void setName( const QString &name ); |
112 | |
113 | /** |
114 | Returns the person name string. |
115 | |
116 | @see setName() |
117 | */ |
118 | QString name() const; |
119 | |
120 | /** |
121 | Sets the email address for this person to @p email. |
122 | |
123 | @param email is the email address for this person. |
124 | |
125 | @see email() |
126 | */ |
127 | void setEmail( const QString &email ); |
128 | |
129 | /** |
130 | Returns the email address for this person. |
131 | |
132 | @see setEmail() |
133 | */ |
134 | QString email() const; |
135 | |
136 | /** |
137 | Compares this with @p person for equality. |
138 | |
139 | @param person is the person to compare. |
140 | */ |
141 | //KDE5: make const for all |
142 | #if defined(Q_CC_MSVC) |
143 | bool operator==( const Person &person ) const; |
144 | #else |
145 | bool operator==( const Person &person ); //krazy:exclude=operators |
146 | #endif |
147 | /** |
148 | Sets this person equal to @p person. |
149 | |
150 | @param person is the person to copy. |
151 | */ |
152 | Person &operator=( const Person &person ); |
153 | |
154 | private: |
155 | //@cond PRIVATE |
156 | class Private; |
157 | Private *const d; |
158 | //@endcond |
159 | }; |
160 | |
161 | } |
162 | |
163 | /* |
164 | Return a hash value for a Person argument. |
165 | @param key is a Person. |
166 | @since 4.4 |
167 | */ |
168 | inline uint qHash( const KCal::Person &key ) //krazy:exclude=inline |
169 | { |
170 | return qHash( key.fullName() ); |
171 | } |
172 | |
173 | #endif |
174 | |