-rw-r--r-- | kabc/addressee.cpp | 16 | ||||
-rw-r--r-- | kabc/addressee.h | 1 |
2 files changed, 17 insertions, 0 deletions
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp index e571980..19a1845 100644 --- a/kabc/addressee.cpp +++ b/kabc/addressee.cpp | |||
@@ -1,1902 +1,1918 @@ | |||
1 | /*** Warning! This file has been generated by the script makeaddressee ***/ | 1 | /*** Warning! This file has been generated by the script makeaddressee ***/ |
2 | /* | 2 | /* |
3 | This file is part of libkabc. | 3 | This file is part of libkabc. |
4 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 4 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
5 | 5 | ||
6 | This library is free software; you can redistribute it and/or | 6 | This library is free software; you can redistribute it and/or |
7 | modify it under the terms of the GNU Library General Public | 7 | modify it under the terms of the GNU Library General Public |
8 | License as published by the Free Software Foundation; either | 8 | License as published by the Free Software Foundation; either |
9 | version 2 of the License, or (at your option) any later version. | 9 | version 2 of the License, or (at your option) any later version. |
10 | 10 | ||
11 | This library is distributed in the hope that it will be useful, | 11 | This library is distributed in the hope that it will be useful, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
14 | Library General Public License for more details. | 14 | Library General Public License for more details. |
15 | 15 | ||
16 | You should have received a copy of the GNU Library General Public License | 16 | You should have received a copy of the GNU Library General Public License |
17 | along with this library; see the file COPYING.LIB. If not, write to | 17 | along with this library; see the file COPYING.LIB. If not, write to |
18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
19 | Boston, MA 02111-1307, USA. | 19 | Boston, MA 02111-1307, USA. |
20 | */ | 20 | */ |
21 | 21 | ||
22 | /* | 22 | /* |
23 | Enhanced Version of the file for platform independent KDE tools. | 23 | Enhanced Version of the file for platform independent KDE tools. |
24 | Copyright (c) 2004 Ulf Schenk | 24 | Copyright (c) 2004 Ulf Schenk |
25 | 25 | ||
26 | $Id$ | 26 | $Id$ |
27 | */ | 27 | */ |
28 | 28 | ||
29 | #include <kconfig.h> | 29 | #include <kconfig.h> |
30 | 30 | ||
31 | #include <ksharedptr.h> | 31 | #include <ksharedptr.h> |
32 | #include <kdebug.h> | 32 | #include <kdebug.h> |
33 | #include <kapplication.h> | 33 | #include <kapplication.h> |
34 | #include <klocale.h> | 34 | #include <klocale.h> |
35 | #include <kidmanager.h> | 35 | #include <kidmanager.h> |
36 | //US | 36 | //US |
37 | #include <kstandarddirs.h> | 37 | #include <kstandarddirs.h> |
38 | #include <libkcal/syncdefines.h> | 38 | #include <libkcal/syncdefines.h> |
39 | 39 | ||
40 | //US #include "resource.h" | 40 | //US #include "resource.h" |
41 | #include "addressee.h" | 41 | #include "addressee.h" |
42 | 42 | ||
43 | using namespace KABC; | 43 | using namespace KABC; |
44 | 44 | ||
45 | static bool matchBinaryPattern( int value, int pattern ); | 45 | static bool matchBinaryPattern( int value, int pattern ); |
46 | static bool matchBinaryPatternA( int value, int pattern ); | 46 | static bool matchBinaryPatternA( int value, int pattern ); |
47 | static bool matchBinaryPatternP( int value, int pattern ); | 47 | static bool matchBinaryPatternP( int value, int pattern ); |
48 | 48 | ||
49 | struct Addressee::AddresseeData : public KShared | 49 | struct Addressee::AddresseeData : public KShared |
50 | { | 50 | { |
51 | QString uid; | 51 | QString uid; |
52 | QString name; | 52 | QString name; |
53 | QString formattedName; | 53 | QString formattedName; |
54 | QString familyName; | 54 | QString familyName; |
55 | QString givenName; | 55 | QString givenName; |
56 | QString additionalName; | 56 | QString additionalName; |
57 | QString prefix; | 57 | QString prefix; |
58 | QString suffix; | 58 | QString suffix; |
59 | QString nickName; | 59 | QString nickName; |
60 | QDateTime birthday; | 60 | QDateTime birthday; |
61 | QString mailer; | 61 | QString mailer; |
62 | TimeZone timeZone; | 62 | TimeZone timeZone; |
63 | Geo geo; | 63 | Geo geo; |
64 | QString title; | 64 | QString title; |
65 | QString role; | 65 | QString role; |
66 | QString organization; | 66 | QString organization; |
67 | QString note; | 67 | QString note; |
68 | QString productId; | 68 | QString productId; |
69 | QDateTime revision; | 69 | QDateTime revision; |
70 | QString sortString; | 70 | QString sortString; |
71 | QString externalUID; | 71 | QString externalUID; |
72 | QString originalExternalUID; | 72 | QString originalExternalUID; |
73 | KURL url; | 73 | KURL url; |
74 | Secrecy secrecy; | 74 | Secrecy secrecy; |
75 | Picture logo; | 75 | Picture logo; |
76 | Picture photo; | 76 | Picture photo; |
77 | Sound sound; | 77 | Sound sound; |
78 | Agent agent; | 78 | Agent agent; |
79 | QString mExternalId; | 79 | QString mExternalId; |
80 | PhoneNumber::List phoneNumbers; | 80 | PhoneNumber::List phoneNumbers; |
81 | Address::List addresses; | 81 | Address::List addresses; |
82 | Key::List keys; | 82 | Key::List keys; |
83 | QStringList emails; | 83 | QStringList emails; |
84 | QStringList categories; | 84 | QStringList categories; |
85 | QStringList custom; | 85 | QStringList custom; |
86 | int mTempSyncStat; | 86 | int mTempSyncStat; |
87 | Resource *resource; | 87 | Resource *resource; |
88 | 88 | ||
89 | bool empty :1; | 89 | bool empty :1; |
90 | bool changed :1; | 90 | bool changed :1; |
91 | }; | 91 | }; |
92 | 92 | ||
93 | Addressee::Addressee() | 93 | Addressee::Addressee() |
94 | { | 94 | { |
95 | mData = new AddresseeData; | 95 | mData = new AddresseeData; |
96 | mData->empty = true; | 96 | mData->empty = true; |
97 | mData->changed = false; | 97 | mData->changed = false; |
98 | mData->resource = 0; | 98 | mData->resource = 0; |
99 | mData->mExternalId = ":"; | 99 | mData->mExternalId = ":"; |
100 | mData->revision = QDateTime ( QDate( 2003,1,1)); | 100 | mData->revision = QDateTime ( QDate( 2003,1,1)); |
101 | mData->mTempSyncStat = SYNC_TEMPSTATE_INITIAL; | 101 | mData->mTempSyncStat = SYNC_TEMPSTATE_INITIAL; |
102 | } | 102 | } |
103 | 103 | ||
104 | Addressee::~Addressee() | 104 | Addressee::~Addressee() |
105 | { | 105 | { |
106 | } | 106 | } |
107 | 107 | ||
108 | Addressee::Addressee( const Addressee &a ) | 108 | Addressee::Addressee( const Addressee &a ) |
109 | { | 109 | { |
110 | mData = a.mData; | 110 | mData = a.mData; |
111 | } | 111 | } |
112 | 112 | ||
113 | Addressee &Addressee::operator=( const Addressee &a ) | 113 | Addressee &Addressee::operator=( const Addressee &a ) |
114 | { | 114 | { |
115 | mData = a.mData; | 115 | mData = a.mData; |
116 | return (*this); | 116 | return (*this); |
117 | } | 117 | } |
118 | 118 | ||
119 | Addressee Addressee::copy() | 119 | Addressee Addressee::copy() |
120 | { | 120 | { |
121 | Addressee a; | 121 | Addressee a; |
122 | *(a.mData) = *mData; | 122 | *(a.mData) = *mData; |
123 | return a; | 123 | return a; |
124 | } | 124 | } |
125 | 125 | ||
126 | void Addressee::detach() | 126 | void Addressee::detach() |
127 | { | 127 | { |
128 | if ( mData.count() == 1 ) return; | 128 | if ( mData.count() == 1 ) return; |
129 | *this = copy(); | 129 | *this = copy(); |
130 | } | 130 | } |
131 | 131 | ||
132 | bool Addressee::operator==( const Addressee &a ) const | 132 | bool Addressee::operator==( const Addressee &a ) const |
133 | { | 133 | { |
134 | if ( uid() != a.uid() ) return false; | 134 | if ( uid() != a.uid() ) return false; |
135 | if ( mData->name != a.mData->name ) return false; | 135 | if ( mData->name != a.mData->name ) return false; |
136 | if ( mData->formattedName != a.mData->formattedName ) return false; | 136 | if ( mData->formattedName != a.mData->formattedName ) return false; |
137 | if ( mData->familyName != a.mData->familyName ) return false; | 137 | if ( mData->familyName != a.mData->familyName ) return false; |
138 | if ( mData->givenName != a.mData->givenName ) return false; | 138 | if ( mData->givenName != a.mData->givenName ) return false; |
139 | if ( mData->additionalName != a.mData->additionalName ) return false; | 139 | if ( mData->additionalName != a.mData->additionalName ) return false; |
140 | if ( mData->prefix != a.mData->prefix ) return false; | 140 | if ( mData->prefix != a.mData->prefix ) return false; |
141 | if ( mData->suffix != a.mData->suffix ) return false; | 141 | if ( mData->suffix != a.mData->suffix ) return false; |
142 | if ( mData->nickName != a.mData->nickName ) return false; | 142 | if ( mData->nickName != a.mData->nickName ) return false; |
143 | if ( mData->birthday != a.mData->birthday ) return false; | 143 | if ( mData->birthday != a.mData->birthday ) return false; |
144 | if ( mData->mailer != a.mData->mailer ) return false; | 144 | if ( mData->mailer != a.mData->mailer ) return false; |
145 | if ( mData->timeZone != a.mData->timeZone ) return false; | 145 | if ( mData->timeZone != a.mData->timeZone ) return false; |
146 | if ( mData->geo != a.mData->geo ) return false; | 146 | if ( mData->geo != a.mData->geo ) return false; |
147 | if ( mData->title != a.mData->title ) return false; | 147 | if ( mData->title != a.mData->title ) return false; |
148 | if ( mData->role != a.mData->role ) return false; | 148 | if ( mData->role != a.mData->role ) return false; |
149 | if ( mData->organization != a.mData->organization ) return false; | 149 | if ( mData->organization != a.mData->organization ) return false; |
150 | if ( mData->note != a.mData->note ) return false; | 150 | if ( mData->note != a.mData->note ) return false; |
151 | if ( mData->productId != a.mData->productId ) return false; | 151 | if ( mData->productId != a.mData->productId ) return false; |
152 | //if ( mData->revision != a.mData->revision ) return false; | 152 | //if ( mData->revision != a.mData->revision ) return false; |
153 | if ( mData->sortString != a.mData->sortString ) return false; | 153 | if ( mData->sortString != a.mData->sortString ) return false; |
154 | if ( mData->secrecy != a.mData->secrecy ) return false; | 154 | if ( mData->secrecy != a.mData->secrecy ) return false; |
155 | if ( mData->logo != a.mData->logo ) return false; | 155 | if ( mData->logo != a.mData->logo ) return false; |
156 | if ( mData->photo != a.mData->photo ) return false; | 156 | if ( mData->photo != a.mData->photo ) return false; |
157 | if ( mData->sound != a.mData->sound ) return false; | 157 | if ( mData->sound != a.mData->sound ) return false; |
158 | if ( mData->agent != a.mData->agent ) return false; | 158 | if ( mData->agent != a.mData->agent ) return false; |
159 | if ( ( mData->url.isValid() || a.mData->url.isValid() ) && | 159 | if ( ( mData->url.isValid() || a.mData->url.isValid() ) && |
160 | ( mData->url != a.mData->url ) ) return false; | 160 | ( mData->url != a.mData->url ) ) return false; |
161 | if ( mData->phoneNumbers != a.mData->phoneNumbers ) return false; | 161 | if ( mData->phoneNumbers != a.mData->phoneNumbers ) return false; |
162 | if ( mData->addresses != a.mData->addresses ) return false; | 162 | if ( mData->addresses != a.mData->addresses ) return false; |
163 | if ( mData->keys != a.mData->keys ) return false; | 163 | if ( mData->keys != a.mData->keys ) return false; |
164 | if ( mData->emails != a.mData->emails ) return false; | 164 | if ( mData->emails != a.mData->emails ) return false; |
165 | if ( mData->categories != a.mData->categories ) return false; | 165 | if ( mData->categories != a.mData->categories ) return false; |
166 | if ( mData->custom != a.mData->custom ) return false; | 166 | if ( mData->custom != a.mData->custom ) return false; |
167 | 167 | ||
168 | return true; | 168 | return true; |
169 | } | 169 | } |
170 | 170 | ||
171 | bool Addressee::operator!=( const Addressee &a ) const | 171 | bool Addressee::operator!=( const Addressee &a ) const |
172 | { | 172 | { |
173 | return !( a == *this ); | 173 | return !( a == *this ); |
174 | } | 174 | } |
175 | 175 | ||
176 | bool Addressee::isEmpty() const | 176 | bool Addressee::isEmpty() const |
177 | { | 177 | { |
178 | return mData->empty; | 178 | return mData->empty; |
179 | } | 179 | } |
180 | ulong Addressee::getCsum4List( const QStringList & attList) | 180 | ulong Addressee::getCsum4List( const QStringList & attList) |
181 | { | 181 | { |
182 | int max = attList.count(); | 182 | int max = attList.count(); |
183 | ulong cSum = 0; | 183 | ulong cSum = 0; |
184 | int j,k,i; | 184 | int j,k,i; |
185 | int add; | 185 | int add; |
186 | for ( i = 0; i < max ; ++i ) { | 186 | for ( i = 0; i < max ; ++i ) { |
187 | QString s = attList[i]; | 187 | QString s = attList[i]; |
188 | if ( ! s.isEmpty() ){ | 188 | if ( ! s.isEmpty() ){ |
189 | j = s.length(); | 189 | j = s.length(); |
190 | for ( k = 0; k < j; ++k ) { | 190 | for ( k = 0; k < j; ++k ) { |
191 | int mul = k +1; | 191 | int mul = k +1; |
192 | add = s[k].unicode (); | 192 | add = s[k].unicode (); |
193 | if ( k < 16 ) | 193 | if ( k < 16 ) |
194 | mul = mul * mul; | 194 | mul = mul * mul; |
195 | int ii = i+1; | 195 | int ii = i+1; |
196 | add = add * mul *ii*ii*ii; | 196 | add = add * mul *ii*ii*ii; |
197 | cSum += add; | 197 | cSum += add; |
198 | } | 198 | } |
199 | } | 199 | } |
200 | 200 | ||
201 | } | 201 | } |
202 | //QString dump = attList.join(","); | 202 | //QString dump = attList.join(","); |
203 | //qDebug("csum: %d %s", cSum,dump.latin1()); | 203 | //qDebug("csum: %d %s", cSum,dump.latin1()); |
204 | 204 | ||
205 | return cSum; | 205 | return cSum; |
206 | 206 | ||
207 | } | 207 | } |
208 | void Addressee::computeCsum(const QString &dev) | 208 | void Addressee::computeCsum(const QString &dev) |
209 | { | 209 | { |
210 | QStringList l; | 210 | QStringList l; |
211 | if ( !mData->name.isEmpty() ) l.append(mData->name); | 211 | if ( !mData->name.isEmpty() ) l.append(mData->name); |
212 | if ( !mData->formattedName.isEmpty() ) l.append(mData->formattedName ); | 212 | if ( !mData->formattedName.isEmpty() ) l.append(mData->formattedName ); |
213 | if ( !mData->familyName.isEmpty() ) l.append( mData->familyName ); | 213 | if ( !mData->familyName.isEmpty() ) l.append( mData->familyName ); |
214 | if ( !mData->givenName.isEmpty() ) l.append(mData->givenName ); | 214 | if ( !mData->givenName.isEmpty() ) l.append(mData->givenName ); |
215 | if ( !mData->additionalName ) l.append( mData->additionalName ); | 215 | if ( !mData->additionalName ) l.append( mData->additionalName ); |
216 | if ( !mData->prefix.isEmpty() ) l.append( mData->prefix ); | 216 | if ( !mData->prefix.isEmpty() ) l.append( mData->prefix ); |
217 | if ( !mData->suffix.isEmpty() ) l.append( mData->suffix ); | 217 | if ( !mData->suffix.isEmpty() ) l.append( mData->suffix ); |
218 | if ( !mData->nickName.isEmpty() ) l.append( mData->nickName ); | 218 | if ( !mData->nickName.isEmpty() ) l.append( mData->nickName ); |
219 | if ( mData->birthday.isValid() ) l.append( mData->birthday.toString() ); | 219 | if ( mData->birthday.isValid() ) l.append( mData->birthday.toString() ); |
220 | if ( !mData->mailer.isEmpty() ) l.append( mData->mailer ); | 220 | if ( !mData->mailer.isEmpty() ) l.append( mData->mailer ); |
221 | if ( mData->timeZone.isValid() ) l.append( mData->timeZone.asString() ); | 221 | if ( mData->timeZone.isValid() ) l.append( mData->timeZone.asString() ); |
222 | if ( mData->geo.isValid() ) l.append( mData->geo.asString() ); | 222 | if ( mData->geo.isValid() ) l.append( mData->geo.asString() ); |
223 | if ( !mData->title .isEmpty() ) l.append( mData->title ); | 223 | if ( !mData->title .isEmpty() ) l.append( mData->title ); |
224 | if ( !mData->role.isEmpty() ) l.append( mData->role ); | 224 | if ( !mData->role.isEmpty() ) l.append( mData->role ); |
225 | if ( !mData->organization.isEmpty() ) l.append( mData->organization ); | 225 | if ( !mData->organization.isEmpty() ) l.append( mData->organization ); |
226 | if ( !mData->note.isEmpty() ) l.append( mData->note ); | 226 | if ( !mData->note.isEmpty() ) l.append( mData->note ); |
227 | if ( !mData->productId.isEmpty() ) l.append(mData->productId ); | 227 | if ( !mData->productId.isEmpty() ) l.append(mData->productId ); |
228 | if ( !mData->sortString.isEmpty() ) l.append( mData->sortString ); | 228 | if ( !mData->sortString.isEmpty() ) l.append( mData->sortString ); |
229 | if ( mData->secrecy.isValid() ) l.append( mData->secrecy.asString()); | 229 | if ( mData->secrecy.isValid() ) l.append( mData->secrecy.asString()); |
230 | // if ( !mData->logo.isEmpty() ) l.append( ); | 230 | // if ( !mData->logo.isEmpty() ) l.append( ); |
231 | //if ( !mData->photo.isEmpty() ) l.append( ); | 231 | //if ( !mData->photo.isEmpty() ) l.append( ); |
232 | //if ( !mData->sound.isEmpty() ) l.append( ); | 232 | //if ( !mData->sound.isEmpty() ) l.append( ); |
233 | //if ( !mData->agent.isEmpty() ) l.append( ); | 233 | //if ( !mData->agent.isEmpty() ) l.append( ); |
234 | //if ( mData->url.isValid() ) l.append( ); | 234 | //if ( mData->url.isValid() ) l.append( ); |
235 | #if 0 | 235 | #if 0 |
236 | if ( !mData->phoneNumbers.isEmpty() ) l.append( ); | 236 | if ( !mData->phoneNumbers.isEmpty() ) l.append( ); |
237 | if ( !mData->addresses.isEmpty() ) l.append( ); | 237 | if ( !mData->addresses.isEmpty() ) l.append( ); |
238 | //if ( !mData->keys.isEmpty() ) l.append( ); | 238 | //if ( !mData->keys.isEmpty() ) l.append( ); |
239 | if ( !mData->emails.isEmpty() ) l.append( ); | 239 | if ( !mData->emails.isEmpty() ) l.append( ); |
240 | if ( !mData->categories .isEmpty() ) l.append( ); | 240 | if ( !mData->categories .isEmpty() ) l.append( ); |
241 | if ( !mData->custom.isEmpty() ) l.append( ); | 241 | if ( !mData->custom.isEmpty() ) l.append( ); |
242 | #endif | 242 | #endif |
243 | KABC::PhoneNumber::List phoneNumbers; | 243 | KABC::PhoneNumber::List phoneNumbers; |
244 | KABC::PhoneNumber::List::Iterator phoneIter; | 244 | KABC::PhoneNumber::List::Iterator phoneIter; |
245 | 245 | ||
246 | QStringList t; | 246 | QStringList t; |
247 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); | 247 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); |
248 | ++phoneIter ) | 248 | ++phoneIter ) |
249 | t.append( ( *phoneIter ).number()+QString::number( ( *phoneIter ).type() ) ); | 249 | t.append( ( *phoneIter ).number()+QString::number( ( *phoneIter ).type() ) ); |
250 | t.sort(); | 250 | t.sort(); |
251 | uint iii; | 251 | uint iii; |
252 | for ( iii = 0; iii < t.count(); ++iii) | 252 | for ( iii = 0; iii < t.count(); ++iii) |
253 | l.append( t[iii] ); | 253 | l.append( t[iii] ); |
254 | t = mData->emails; | 254 | t = mData->emails; |
255 | t.sort(); | 255 | t.sort(); |
256 | for ( iii = 0; iii < t.count(); ++iii) | 256 | for ( iii = 0; iii < t.count(); ++iii) |
257 | l.append( t[iii] ); | 257 | l.append( t[iii] ); |
258 | t = mData->categories; | 258 | t = mData->categories; |
259 | t.sort(); | 259 | t.sort(); |
260 | for ( iii = 0; iii < t.count(); ++iii) | 260 | for ( iii = 0; iii < t.count(); ++iii) |
261 | l.append( t[iii] ); | 261 | l.append( t[iii] ); |
262 | t = mData->custom; | 262 | t = mData->custom; |
263 | t.sort(); | 263 | t.sort(); |
264 | for ( iii = 0; iii < t.count(); ++iii) | 264 | for ( iii = 0; iii < t.count(); ++iii) |
265 | l.append( t[iii] ); | 265 | l.append( t[iii] ); |
266 | KABC::Address::List::Iterator addressIter; | 266 | KABC::Address::List::Iterator addressIter; |
267 | for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); | 267 | for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); |
268 | ++addressIter ) { | 268 | ++addressIter ) { |
269 | t = (*addressIter).asList(); | 269 | t = (*addressIter).asList(); |
270 | t.sort(); | 270 | t.sort(); |
271 | for ( iii = 0; iii < t.count(); ++iii) | 271 | for ( iii = 0; iii < t.count(); ++iii) |
272 | l.append( t[iii] ); | 272 | l.append( t[iii] ); |
273 | } | 273 | } |
274 | uint cs = getCsum4List(l); | 274 | uint cs = getCsum4List(l); |
275 | // qDebug("CSUM computed %d %s %s", cs,QString::number (cs ).latin1(), uid().latin1() ); | 275 | // qDebug("CSUM computed %d %s %s", cs,QString::number (cs ).latin1(), uid().latin1() ); |
276 | setCsum( dev, QString::number (cs )); | 276 | setCsum( dev, QString::number (cs )); |
277 | } | 277 | } |
278 | 278 | ||
279 | void Addressee::mergeContact( const Addressee& ad ) | 279 | void Addressee::mergeContact( const Addressee& ad ) |
280 | { | 280 | { |
281 | 281 | ||
282 | detach(); | 282 | detach(); |
283 | if ( mData->name.isEmpty() ) mData->name = ad.mData->name; | 283 | if ( mData->name.isEmpty() ) mData->name = ad.mData->name; |
284 | if ( mData->formattedName.isEmpty() ) mData->formattedName = ad.mData->formattedName; | 284 | if ( mData->formattedName.isEmpty() ) mData->formattedName = ad.mData->formattedName; |
285 | if ( mData->familyName.isEmpty() ) mData->familyName = ad.mData->familyName; | 285 | if ( mData->familyName.isEmpty() ) mData->familyName = ad.mData->familyName; |
286 | if ( mData->givenName.isEmpty() ) mData->givenName = ad.mData->givenName ; | 286 | if ( mData->givenName.isEmpty() ) mData->givenName = ad.mData->givenName ; |
287 | if ( mData->additionalName ) mData->additionalName = ad.mData->additionalName; | 287 | if ( mData->additionalName ) mData->additionalName = ad.mData->additionalName; |
288 | if ( mData->prefix.isEmpty() ) mData->prefix = ad.mData->prefix; | 288 | if ( mData->prefix.isEmpty() ) mData->prefix = ad.mData->prefix; |
289 | if ( mData->suffix.isEmpty() ) mData->suffix = ad.mData->suffix; | 289 | if ( mData->suffix.isEmpty() ) mData->suffix = ad.mData->suffix; |
290 | if ( mData->nickName.isEmpty() ) mData->nickName = ad.mData->nickName; | 290 | if ( mData->nickName.isEmpty() ) mData->nickName = ad.mData->nickName; |
291 | if ( !mData->birthday.isValid() ) | 291 | if ( !mData->birthday.isValid() ) |
292 | if ( ad.mData->birthday.isValid()) | 292 | if ( ad.mData->birthday.isValid()) |
293 | mData->birthday = ad.mData->birthday; | 293 | mData->birthday = ad.mData->birthday; |
294 | if ( mData->mailer.isEmpty() ) mData->mailer = ad.mData->mailer; | 294 | if ( mData->mailer.isEmpty() ) mData->mailer = ad.mData->mailer; |
295 | if ( !mData->timeZone.isValid() ) mData->timeZone = ad.mData->timeZone; | 295 | if ( !mData->timeZone.isValid() ) mData->timeZone = ad.mData->timeZone; |
296 | if ( !mData->geo.isValid() ) mData->geo = ad.mData->geo; | 296 | if ( !mData->geo.isValid() ) mData->geo = ad.mData->geo; |
297 | if ( mData->title .isEmpty() ) mData->title = ad.mData->title ; | 297 | if ( mData->title .isEmpty() ) mData->title = ad.mData->title ; |
298 | if ( mData->role.isEmpty() ) mData->role = ad.mData->role ; | 298 | if ( mData->role.isEmpty() ) mData->role = ad.mData->role ; |
299 | if ( mData->organization.isEmpty() ) mData->organization = ad.mData->organization ; | 299 | if ( mData->organization.isEmpty() ) mData->organization = ad.mData->organization ; |
300 | if ( mData->note.isEmpty() ) mData->note = ad.mData->note ; | 300 | if ( mData->note.isEmpty() ) mData->note = ad.mData->note ; |
301 | if ( mData->productId.isEmpty() ) mData->productId = ad.mData->productId; | 301 | if ( mData->productId.isEmpty() ) mData->productId = ad.mData->productId; |
302 | if ( mData->sortString.isEmpty() ) mData->sortString = ad.mData->sortString; | 302 | if ( mData->sortString.isEmpty() ) mData->sortString = ad.mData->sortString; |
303 | if ( !mData->secrecy.isValid() ) mData->secrecy = ad.mData->secrecy; | 303 | if ( !mData->secrecy.isValid() ) mData->secrecy = ad.mData->secrecy; |
304 | if ( ( !mData->url.isValid() && ad.mData->url.isValid() ) ) mData->url = ad.mData->url ; | 304 | if ( ( !mData->url.isValid() && ad.mData->url.isValid() ) ) mData->url = ad.mData->url ; |
305 | 305 | ||
306 | // pending: | 306 | // pending: |
307 | // merging phonenumbers | 307 | // merging phonenumbers |
308 | // merging addresses | 308 | // merging addresses |
309 | // merging emails; | 309 | // merging emails; |
310 | // merging categories; | 310 | // merging categories; |
311 | // merging custom; | 311 | // merging custom; |
312 | // merging keys | 312 | // merging keys |
313 | qDebug("merge contact %s ", ad.uid().latin1()); | 313 | qDebug("merge contact %s ", ad.uid().latin1()); |
314 | setUid( ad.uid() ); | 314 | setUid( ad.uid() ); |
315 | setRevision( ad.revision() ); | 315 | setRevision( ad.revision() ); |
316 | } | 316 | } |
317 | 317 | ||
318 | void Addressee::simplifyAddresses() | ||
319 | { | ||
320 | if ( mData->addresses.count() < 3 ) return ; | ||
321 | int count = 0; | ||
322 | Address::List list; | ||
323 | Address::List::Iterator it; | ||
324 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { | ||
325 | if ( count > 1 ) | ||
326 | list.append( *it ); | ||
327 | ++count; | ||
328 | } | ||
329 | for( it = list.begin(); it != list.end(); ++it ) { | ||
330 | removeAddress( (*it) ); | ||
331 | } | ||
332 | } | ||
333 | |||
318 | // removes all emails but the first | 334 | // removes all emails but the first |
319 | // needed by phone sync | 335 | // needed by phone sync |
320 | void Addressee::simplifyEmails() | 336 | void Addressee::simplifyEmails() |
321 | { | 337 | { |
322 | if ( mData->emails.count() == 0 ) return ; | 338 | if ( mData->emails.count() == 0 ) return ; |
323 | QString email = mData->emails.first(); | 339 | QString email = mData->emails.first(); |
324 | detach(); | 340 | detach(); |
325 | mData->emails.clear(); | 341 | mData->emails.clear(); |
326 | mData->emails.append( email ); | 342 | mData->emails.append( email ); |
327 | } | 343 | } |
328 | 344 | ||
329 | void Addressee::simplifyPhoneNumbers() | 345 | void Addressee::simplifyPhoneNumbers() |
330 | { | 346 | { |
331 | KABC::PhoneNumber::List removeNumbers; | 347 | KABC::PhoneNumber::List removeNumbers; |
332 | KABC::PhoneNumber::List::Iterator phoneIter; | 348 | KABC::PhoneNumber::List::Iterator phoneIter; |
333 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); | 349 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); |
334 | ++phoneIter ) { | 350 | ++phoneIter ) { |
335 | if ( ! ( *phoneIter ).simplifyNumber() ) | 351 | if ( ! ( *phoneIter ).simplifyNumber() ) |
336 | removeNumbers.append( ( *phoneIter ) ); | 352 | removeNumbers.append( ( *phoneIter ) ); |
337 | } | 353 | } |
338 | for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end(); | 354 | for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end(); |
339 | ++phoneIter ) { | 355 | ++phoneIter ) { |
340 | removePhoneNumber(( *phoneIter )); | 356 | removePhoneNumber(( *phoneIter )); |
341 | } | 357 | } |
342 | } | 358 | } |
343 | void Addressee::simplifyPhoneNumberTypes() | 359 | void Addressee::simplifyPhoneNumberTypes() |
344 | { | 360 | { |
345 | KABC::PhoneNumber::List::Iterator phoneIter; | 361 | KABC::PhoneNumber::List::Iterator phoneIter; |
346 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); | 362 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); |
347 | ++phoneIter ) | 363 | ++phoneIter ) |
348 | ( *phoneIter ).simplifyType(); | 364 | ( *phoneIter ).simplifyType(); |
349 | } | 365 | } |
350 | void Addressee::removeID(const QString &prof) | 366 | void Addressee::removeID(const QString &prof) |
351 | { | 367 | { |
352 | detach(); | 368 | detach(); |
353 | mData->mExternalId = KIdManager::removeId ( mData->mExternalId, prof); | 369 | mData->mExternalId = KIdManager::removeId ( mData->mExternalId, prof); |
354 | 370 | ||
355 | } | 371 | } |
356 | void Addressee::setID( const QString & prof , const QString & id ) | 372 | void Addressee::setID( const QString & prof , const QString & id ) |
357 | { | 373 | { |
358 | detach(); | 374 | detach(); |
359 | mData->mExternalId = KIdManager::setId ( mData->mExternalId, prof, id ); | 375 | mData->mExternalId = KIdManager::setId ( mData->mExternalId, prof, id ); |
360 | //qDebug("setID2 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); | 376 | //qDebug("setID2 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); |
361 | } | 377 | } |
362 | void Addressee::setTempSyncStat( int id ) | 378 | void Addressee::setTempSyncStat( int id ) |
363 | { | 379 | { |
364 | if ( mData->mTempSyncStat == id ) return; | 380 | if ( mData->mTempSyncStat == id ) return; |
365 | detach(); | 381 | detach(); |
366 | mData->mTempSyncStat = id; | 382 | mData->mTempSyncStat = id; |
367 | } | 383 | } |
368 | int Addressee::tempSyncStat() const | 384 | int Addressee::tempSyncStat() const |
369 | { | 385 | { |
370 | return mData->mTempSyncStat; | 386 | return mData->mTempSyncStat; |
371 | } | 387 | } |
372 | 388 | ||
373 | QString Addressee::getID( const QString & prof) | 389 | QString Addressee::getID( const QString & prof) |
374 | { | 390 | { |
375 | return KIdManager::getId ( mData->mExternalId, prof ); | 391 | return KIdManager::getId ( mData->mExternalId, prof ); |
376 | } | 392 | } |
377 | 393 | ||
378 | void Addressee::setCsum( const QString & prof , const QString & id ) | 394 | void Addressee::setCsum( const QString & prof , const QString & id ) |
379 | { | 395 | { |
380 | detach(); | 396 | detach(); |
381 | //qDebug("setcsum1 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); | 397 | //qDebug("setcsum1 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); |
382 | mData->mExternalId = KIdManager::setCsum ( mData->mExternalId, prof, id ); | 398 | mData->mExternalId = KIdManager::setCsum ( mData->mExternalId, prof, id ); |
383 | //qDebug("setcsum2 %s ",mData->mExternalId.latin1() ); | 399 | //qDebug("setcsum2 %s ",mData->mExternalId.latin1() ); |
384 | } | 400 | } |
385 | 401 | ||
386 | QString Addressee::getCsum( const QString & prof) | 402 | QString Addressee::getCsum( const QString & prof) |
387 | { | 403 | { |
388 | return KIdManager::getCsum ( mData->mExternalId, prof ); | 404 | return KIdManager::getCsum ( mData->mExternalId, prof ); |
389 | } | 405 | } |
390 | 406 | ||
391 | void Addressee::setIDStr( const QString & s ) | 407 | void Addressee::setIDStr( const QString & s ) |
392 | { | 408 | { |
393 | detach(); | 409 | detach(); |
394 | mData->mExternalId = s; | 410 | mData->mExternalId = s; |
395 | } | 411 | } |
396 | 412 | ||
397 | QString Addressee::IDStr() const | 413 | QString Addressee::IDStr() const |
398 | { | 414 | { |
399 | return mData->mExternalId; | 415 | return mData->mExternalId; |
400 | } | 416 | } |
401 | 417 | ||
402 | void Addressee::setExternalUID( const QString &id ) | 418 | void Addressee::setExternalUID( const QString &id ) |
403 | { | 419 | { |
404 | if ( id == mData->externalUID ) return; | 420 | if ( id == mData->externalUID ) return; |
405 | detach(); | 421 | detach(); |
406 | mData->empty = false; | 422 | mData->empty = false; |
407 | mData->externalUID = id; | 423 | mData->externalUID = id; |
408 | } | 424 | } |
409 | 425 | ||
410 | QString Addressee::externalUID() const | 426 | QString Addressee::externalUID() const |
411 | { | 427 | { |
412 | return mData->externalUID; | 428 | return mData->externalUID; |
413 | } | 429 | } |
414 | void Addressee::setOriginalExternalUID( const QString &id ) | 430 | void Addressee::setOriginalExternalUID( const QString &id ) |
415 | { | 431 | { |
416 | if ( id == mData->originalExternalUID ) return; | 432 | if ( id == mData->originalExternalUID ) return; |
417 | detach(); | 433 | detach(); |
418 | mData->empty = false; | 434 | mData->empty = false; |
419 | //qDebug("*******Set orig uid %s ", id.latin1()); | 435 | //qDebug("*******Set orig uid %s ", id.latin1()); |
420 | mData->originalExternalUID = id; | 436 | mData->originalExternalUID = id; |
421 | } | 437 | } |
422 | 438 | ||
423 | QString Addressee::originalExternalUID() const | 439 | QString Addressee::originalExternalUID() const |
424 | { | 440 | { |
425 | return mData->originalExternalUID; | 441 | return mData->originalExternalUID; |
426 | } | 442 | } |
427 | 443 | ||
428 | void Addressee::setUid( const QString &id ) | 444 | void Addressee::setUid( const QString &id ) |
429 | { | 445 | { |
430 | if ( id == mData->uid ) return; | 446 | if ( id == mData->uid ) return; |
431 | detach(); | 447 | detach(); |
432 | //qDebug("****setuid %s ", id.latin1()); | 448 | //qDebug("****setuid %s ", id.latin1()); |
433 | mData->empty = false; | 449 | mData->empty = false; |
434 | mData->uid = id; | 450 | mData->uid = id; |
435 | } | 451 | } |
436 | 452 | ||
437 | QString Addressee::uid() const | 453 | QString Addressee::uid() const |
438 | { | 454 | { |
439 | if ( mData->uid.isEmpty() ) | 455 | if ( mData->uid.isEmpty() ) |
440 | mData->uid = KApplication::randomString( 10 ); | 456 | mData->uid = KApplication::randomString( 10 ); |
441 | 457 | ||
442 | return mData->uid; | 458 | return mData->uid; |
443 | } | 459 | } |
444 | 460 | ||
445 | QString Addressee::uidLabel() | 461 | QString Addressee::uidLabel() |
446 | { | 462 | { |
447 | return i18n("Unique Identifier"); | 463 | return i18n("Unique Identifier"); |
448 | } | 464 | } |
449 | 465 | ||
450 | void Addressee::setName( const QString &name ) | 466 | void Addressee::setName( const QString &name ) |
451 | { | 467 | { |
452 | if ( name == mData->name ) return; | 468 | if ( name == mData->name ) return; |
453 | detach(); | 469 | detach(); |
454 | mData->empty = false; | 470 | mData->empty = false; |
455 | mData->name = name; | 471 | mData->name = name; |
456 | } | 472 | } |
457 | 473 | ||
458 | QString Addressee::name() const | 474 | QString Addressee::name() const |
459 | { | 475 | { |
460 | return mData->name; | 476 | return mData->name; |
461 | } | 477 | } |
462 | 478 | ||
463 | QString Addressee::nameLabel() | 479 | QString Addressee::nameLabel() |
464 | { | 480 | { |
465 | return i18n("Name"); | 481 | return i18n("Name"); |
466 | } | 482 | } |
467 | 483 | ||
468 | 484 | ||
469 | void Addressee::setFormattedName( const QString &formattedName ) | 485 | void Addressee::setFormattedName( const QString &formattedName ) |
470 | { | 486 | { |
471 | if ( formattedName == mData->formattedName ) return; | 487 | if ( formattedName == mData->formattedName ) return; |
472 | detach(); | 488 | detach(); |
473 | mData->empty = false; | 489 | mData->empty = false; |
474 | mData->formattedName = formattedName; | 490 | mData->formattedName = formattedName; |
475 | } | 491 | } |
476 | 492 | ||
477 | QString Addressee::formattedName() const | 493 | QString Addressee::formattedName() const |
478 | { | 494 | { |
479 | return mData->formattedName; | 495 | return mData->formattedName; |
480 | } | 496 | } |
481 | 497 | ||
482 | QString Addressee::formattedNameLabel() | 498 | QString Addressee::formattedNameLabel() |
483 | { | 499 | { |
484 | return i18n("Formatted Name"); | 500 | return i18n("Formatted Name"); |
485 | } | 501 | } |
486 | 502 | ||
487 | 503 | ||
488 | void Addressee::setFamilyName( const QString &familyName ) | 504 | void Addressee::setFamilyName( const QString &familyName ) |
489 | { | 505 | { |
490 | if ( familyName == mData->familyName ) return; | 506 | if ( familyName == mData->familyName ) return; |
491 | detach(); | 507 | detach(); |
492 | mData->empty = false; | 508 | mData->empty = false; |
493 | mData->familyName = familyName; | 509 | mData->familyName = familyName; |
494 | } | 510 | } |
495 | 511 | ||
496 | QString Addressee::familyName() const | 512 | QString Addressee::familyName() const |
497 | { | 513 | { |
498 | return mData->familyName; | 514 | return mData->familyName; |
499 | } | 515 | } |
500 | 516 | ||
501 | QString Addressee::familyNameLabel() | 517 | QString Addressee::familyNameLabel() |
502 | { | 518 | { |
503 | return i18n("Family Name"); | 519 | return i18n("Family Name"); |
504 | } | 520 | } |
505 | 521 | ||
506 | 522 | ||
507 | void Addressee::setGivenName( const QString &givenName ) | 523 | void Addressee::setGivenName( const QString &givenName ) |
508 | { | 524 | { |
509 | if ( givenName == mData->givenName ) return; | 525 | if ( givenName == mData->givenName ) return; |
510 | detach(); | 526 | detach(); |
511 | mData->empty = false; | 527 | mData->empty = false; |
512 | mData->givenName = givenName; | 528 | mData->givenName = givenName; |
513 | } | 529 | } |
514 | 530 | ||
515 | QString Addressee::givenName() const | 531 | QString Addressee::givenName() const |
516 | { | 532 | { |
517 | return mData->givenName; | 533 | return mData->givenName; |
518 | } | 534 | } |
519 | 535 | ||
520 | QString Addressee::givenNameLabel() | 536 | QString Addressee::givenNameLabel() |
521 | { | 537 | { |
522 | return i18n("Given Name"); | 538 | return i18n("Given Name"); |
523 | } | 539 | } |
524 | 540 | ||
525 | 541 | ||
526 | void Addressee::setAdditionalName( const QString &additionalName ) | 542 | void Addressee::setAdditionalName( const QString &additionalName ) |
527 | { | 543 | { |
528 | if ( additionalName == mData->additionalName ) return; | 544 | if ( additionalName == mData->additionalName ) return; |
529 | detach(); | 545 | detach(); |
530 | mData->empty = false; | 546 | mData->empty = false; |
531 | mData->additionalName = additionalName; | 547 | mData->additionalName = additionalName; |
532 | } | 548 | } |
533 | 549 | ||
534 | QString Addressee::additionalName() const | 550 | QString Addressee::additionalName() const |
535 | { | 551 | { |
536 | return mData->additionalName; | 552 | return mData->additionalName; |
537 | } | 553 | } |
538 | 554 | ||
539 | QString Addressee::additionalNameLabel() | 555 | QString Addressee::additionalNameLabel() |
540 | { | 556 | { |
541 | return i18n("Additional Names"); | 557 | return i18n("Additional Names"); |
542 | } | 558 | } |
543 | 559 | ||
544 | 560 | ||
545 | void Addressee::setPrefix( const QString &prefix ) | 561 | void Addressee::setPrefix( const QString &prefix ) |
546 | { | 562 | { |
547 | if ( prefix == mData->prefix ) return; | 563 | if ( prefix == mData->prefix ) return; |
548 | detach(); | 564 | detach(); |
549 | mData->empty = false; | 565 | mData->empty = false; |
550 | mData->prefix = prefix; | 566 | mData->prefix = prefix; |
551 | } | 567 | } |
552 | 568 | ||
553 | QString Addressee::prefix() const | 569 | QString Addressee::prefix() const |
554 | { | 570 | { |
555 | return mData->prefix; | 571 | return mData->prefix; |
556 | } | 572 | } |
557 | 573 | ||
558 | QString Addressee::prefixLabel() | 574 | QString Addressee::prefixLabel() |
559 | { | 575 | { |
560 | return i18n("Honorific Prefixes"); | 576 | return i18n("Honorific Prefixes"); |
561 | } | 577 | } |
562 | 578 | ||
563 | 579 | ||
564 | void Addressee::setSuffix( const QString &suffix ) | 580 | void Addressee::setSuffix( const QString &suffix ) |
565 | { | 581 | { |
566 | if ( suffix == mData->suffix ) return; | 582 | if ( suffix == mData->suffix ) return; |
567 | detach(); | 583 | detach(); |
568 | mData->empty = false; | 584 | mData->empty = false; |
569 | mData->suffix = suffix; | 585 | mData->suffix = suffix; |
570 | } | 586 | } |
571 | 587 | ||
572 | QString Addressee::suffix() const | 588 | QString Addressee::suffix() const |
573 | { | 589 | { |
574 | return mData->suffix; | 590 | return mData->suffix; |
575 | } | 591 | } |
576 | 592 | ||
577 | QString Addressee::suffixLabel() | 593 | QString Addressee::suffixLabel() |
578 | { | 594 | { |
579 | return i18n("Honorific Suffixes"); | 595 | return i18n("Honorific Suffixes"); |
580 | } | 596 | } |
581 | 597 | ||
582 | 598 | ||
583 | void Addressee::setNickName( const QString &nickName ) | 599 | void Addressee::setNickName( const QString &nickName ) |
584 | { | 600 | { |
585 | if ( nickName == mData->nickName ) return; | 601 | if ( nickName == mData->nickName ) return; |
586 | detach(); | 602 | detach(); |
587 | mData->empty = false; | 603 | mData->empty = false; |
588 | mData->nickName = nickName; | 604 | mData->nickName = nickName; |
589 | } | 605 | } |
590 | 606 | ||
591 | QString Addressee::nickName() const | 607 | QString Addressee::nickName() const |
592 | { | 608 | { |
593 | return mData->nickName; | 609 | return mData->nickName; |
594 | } | 610 | } |
595 | 611 | ||
596 | QString Addressee::nickNameLabel() | 612 | QString Addressee::nickNameLabel() |
597 | { | 613 | { |
598 | return i18n("Nick Name"); | 614 | return i18n("Nick Name"); |
599 | } | 615 | } |
600 | 616 | ||
601 | 617 | ||
602 | void Addressee::setBirthday( const QDateTime &birthday ) | 618 | void Addressee::setBirthday( const QDateTime &birthday ) |
603 | { | 619 | { |
604 | if ( birthday == mData->birthday ) return; | 620 | if ( birthday == mData->birthday ) return; |
605 | detach(); | 621 | detach(); |
606 | mData->empty = false; | 622 | mData->empty = false; |
607 | mData->birthday = birthday; | 623 | mData->birthday = birthday; |
608 | } | 624 | } |
609 | 625 | ||
610 | QDateTime Addressee::birthday() const | 626 | QDateTime Addressee::birthday() const |
611 | { | 627 | { |
612 | return mData->birthday; | 628 | return mData->birthday; |
613 | } | 629 | } |
614 | 630 | ||
615 | QString Addressee::birthdayLabel() | 631 | QString Addressee::birthdayLabel() |
616 | { | 632 | { |
617 | return i18n("Birthday"); | 633 | return i18n("Birthday"); |
618 | } | 634 | } |
619 | 635 | ||
620 | 636 | ||
621 | QString Addressee::homeAddressStreetLabel() | 637 | QString Addressee::homeAddressStreetLabel() |
622 | { | 638 | { |
623 | return i18n("Home Address Street"); | 639 | return i18n("Home Address Street"); |
624 | } | 640 | } |
625 | 641 | ||
626 | 642 | ||
627 | QString Addressee::homeAddressLocalityLabel() | 643 | QString Addressee::homeAddressLocalityLabel() |
628 | { | 644 | { |
629 | return i18n("Home Address Locality"); | 645 | return i18n("Home Address Locality"); |
630 | } | 646 | } |
631 | 647 | ||
632 | 648 | ||
633 | QString Addressee::homeAddressRegionLabel() | 649 | QString Addressee::homeAddressRegionLabel() |
634 | { | 650 | { |
635 | return i18n("Home Address Region"); | 651 | return i18n("Home Address Region"); |
636 | } | 652 | } |
637 | 653 | ||
638 | 654 | ||
639 | QString Addressee::homeAddressPostalCodeLabel() | 655 | QString Addressee::homeAddressPostalCodeLabel() |
640 | { | 656 | { |
641 | return i18n("Home Address Postal Code"); | 657 | return i18n("Home Address Postal Code"); |
642 | } | 658 | } |
643 | 659 | ||
644 | 660 | ||
645 | QString Addressee::homeAddressCountryLabel() | 661 | QString Addressee::homeAddressCountryLabel() |
646 | { | 662 | { |
647 | return i18n("Home Address Country"); | 663 | return i18n("Home Address Country"); |
648 | } | 664 | } |
649 | 665 | ||
650 | 666 | ||
651 | QString Addressee::homeAddressLabelLabel() | 667 | QString Addressee::homeAddressLabelLabel() |
652 | { | 668 | { |
653 | return i18n("Home Address Label"); | 669 | return i18n("Home Address Label"); |
654 | } | 670 | } |
655 | 671 | ||
656 | 672 | ||
657 | QString Addressee::businessAddressStreetLabel() | 673 | QString Addressee::businessAddressStreetLabel() |
658 | { | 674 | { |
659 | return i18n("Business Address Street"); | 675 | return i18n("Business Address Street"); |
660 | } | 676 | } |
661 | 677 | ||
662 | 678 | ||
663 | QString Addressee::businessAddressLocalityLabel() | 679 | QString Addressee::businessAddressLocalityLabel() |
664 | { | 680 | { |
665 | return i18n("Business Address Locality"); | 681 | return i18n("Business Address Locality"); |
666 | } | 682 | } |
667 | 683 | ||
668 | 684 | ||
669 | QString Addressee::businessAddressRegionLabel() | 685 | QString Addressee::businessAddressRegionLabel() |
670 | { | 686 | { |
671 | return i18n("Business Address Region"); | 687 | return i18n("Business Address Region"); |
672 | } | 688 | } |
673 | 689 | ||
674 | 690 | ||
675 | QString Addressee::businessAddressPostalCodeLabel() | 691 | QString Addressee::businessAddressPostalCodeLabel() |
676 | { | 692 | { |
677 | return i18n("Business Address Postal Code"); | 693 | return i18n("Business Address Postal Code"); |
678 | } | 694 | } |
679 | 695 | ||
680 | 696 | ||
681 | QString Addressee::businessAddressCountryLabel() | 697 | QString Addressee::businessAddressCountryLabel() |
682 | { | 698 | { |
683 | return i18n("Business Address Country"); | 699 | return i18n("Business Address Country"); |
684 | } | 700 | } |
685 | 701 | ||
686 | 702 | ||
687 | QString Addressee::businessAddressLabelLabel() | 703 | QString Addressee::businessAddressLabelLabel() |
688 | { | 704 | { |
689 | return i18n("Business Address Label"); | 705 | return i18n("Business Address Label"); |
690 | } | 706 | } |
691 | 707 | ||
692 | 708 | ||
693 | QString Addressee::homePhoneLabel() | 709 | QString Addressee::homePhoneLabel() |
694 | { | 710 | { |
695 | return i18n("Home Phone"); | 711 | return i18n("Home Phone"); |
696 | } | 712 | } |
697 | 713 | ||
698 | 714 | ||
699 | QString Addressee::businessPhoneLabel() | 715 | QString Addressee::businessPhoneLabel() |
700 | { | 716 | { |
701 | return i18n("Business Phone"); | 717 | return i18n("Business Phone"); |
702 | } | 718 | } |
703 | 719 | ||
704 | 720 | ||
705 | QString Addressee::mobilePhoneLabel() | 721 | QString Addressee::mobilePhoneLabel() |
706 | { | 722 | { |
707 | return i18n("Mobile Phone"); | 723 | return i18n("Mobile Phone"); |
708 | } | 724 | } |
709 | 725 | ||
710 | 726 | ||
711 | QString Addressee::homeFaxLabel() | 727 | QString Addressee::homeFaxLabel() |
712 | { | 728 | { |
713 | return i18n("Home Fax"); | 729 | return i18n("Home Fax"); |
714 | } | 730 | } |
715 | 731 | ||
716 | 732 | ||
717 | QString Addressee::businessFaxLabel() | 733 | QString Addressee::businessFaxLabel() |
718 | { | 734 | { |
719 | return i18n("Business Fax"); | 735 | return i18n("Business Fax"); |
720 | } | 736 | } |
721 | 737 | ||
722 | 738 | ||
723 | QString Addressee::carPhoneLabel() | 739 | QString Addressee::carPhoneLabel() |
724 | { | 740 | { |
725 | return i18n("Car Phone"); | 741 | return i18n("Car Phone"); |
726 | } | 742 | } |
727 | 743 | ||
728 | 744 | ||
729 | QString Addressee::isdnLabel() | 745 | QString Addressee::isdnLabel() |
730 | { | 746 | { |
731 | return i18n("ISDN"); | 747 | return i18n("ISDN"); |
732 | } | 748 | } |
733 | 749 | ||
734 | 750 | ||
735 | QString Addressee::pagerLabel() | 751 | QString Addressee::pagerLabel() |
736 | { | 752 | { |
737 | return i18n("Pager"); | 753 | return i18n("Pager"); |
738 | } | 754 | } |
739 | 755 | ||
740 | QString Addressee::sipLabel() | 756 | QString Addressee::sipLabel() |
741 | { | 757 | { |
742 | return i18n("SIP"); | 758 | return i18n("SIP"); |
743 | } | 759 | } |
744 | 760 | ||
745 | QString Addressee::emailLabel() | 761 | QString Addressee::emailLabel() |
746 | { | 762 | { |
747 | return i18n("Email Address"); | 763 | return i18n("Email Address"); |
748 | } | 764 | } |
749 | 765 | ||
750 | 766 | ||
751 | void Addressee::setMailer( const QString &mailer ) | 767 | void Addressee::setMailer( const QString &mailer ) |
752 | { | 768 | { |
753 | if ( mailer == mData->mailer ) return; | 769 | if ( mailer == mData->mailer ) return; |
754 | detach(); | 770 | detach(); |
755 | mData->empty = false; | 771 | mData->empty = false; |
756 | mData->mailer = mailer; | 772 | mData->mailer = mailer; |
757 | } | 773 | } |
758 | 774 | ||
759 | QString Addressee::mailer() const | 775 | QString Addressee::mailer() const |
760 | { | 776 | { |
761 | return mData->mailer; | 777 | return mData->mailer; |
762 | } | 778 | } |
763 | 779 | ||
764 | QString Addressee::mailerLabel() | 780 | QString Addressee::mailerLabel() |
765 | { | 781 | { |
766 | return i18n("Mail Client"); | 782 | return i18n("Mail Client"); |
767 | } | 783 | } |
768 | 784 | ||
769 | 785 | ||
770 | void Addressee::setTimeZone( const TimeZone &timeZone ) | 786 | void Addressee::setTimeZone( const TimeZone &timeZone ) |
771 | { | 787 | { |
772 | if ( timeZone == mData->timeZone ) return; | 788 | if ( timeZone == mData->timeZone ) return; |
773 | detach(); | 789 | detach(); |
774 | mData->empty = false; | 790 | mData->empty = false; |
775 | mData->timeZone = timeZone; | 791 | mData->timeZone = timeZone; |
776 | } | 792 | } |
777 | 793 | ||
778 | TimeZone Addressee::timeZone() const | 794 | TimeZone Addressee::timeZone() const |
779 | { | 795 | { |
780 | return mData->timeZone; | 796 | return mData->timeZone; |
781 | } | 797 | } |
782 | 798 | ||
783 | QString Addressee::timeZoneLabel() | 799 | QString Addressee::timeZoneLabel() |
784 | { | 800 | { |
785 | return i18n("Time Zone"); | 801 | return i18n("Time Zone"); |
786 | } | 802 | } |
787 | 803 | ||
788 | 804 | ||
789 | void Addressee::setGeo( const Geo &geo ) | 805 | void Addressee::setGeo( const Geo &geo ) |
790 | { | 806 | { |
791 | if ( geo == mData->geo ) return; | 807 | if ( geo == mData->geo ) return; |
792 | detach(); | 808 | detach(); |
793 | mData->empty = false; | 809 | mData->empty = false; |
794 | mData->geo = geo; | 810 | mData->geo = geo; |
795 | } | 811 | } |
796 | 812 | ||
797 | Geo Addressee::geo() const | 813 | Geo Addressee::geo() const |
798 | { | 814 | { |
799 | return mData->geo; | 815 | return mData->geo; |
800 | } | 816 | } |
801 | 817 | ||
802 | QString Addressee::geoLabel() | 818 | QString Addressee::geoLabel() |
803 | { | 819 | { |
804 | return i18n("Geographic Position"); | 820 | return i18n("Geographic Position"); |
805 | } | 821 | } |
806 | 822 | ||
807 | 823 | ||
808 | void Addressee::setTitle( const QString &title ) | 824 | void Addressee::setTitle( const QString &title ) |
809 | { | 825 | { |
810 | if ( title == mData->title ) return; | 826 | if ( title == mData->title ) return; |
811 | detach(); | 827 | detach(); |
812 | mData->empty = false; | 828 | mData->empty = false; |
813 | mData->title = title; | 829 | mData->title = title; |
814 | } | 830 | } |
815 | 831 | ||
816 | QString Addressee::title() const | 832 | QString Addressee::title() const |
817 | { | 833 | { |
818 | return mData->title; | 834 | return mData->title; |
819 | } | 835 | } |
820 | 836 | ||
821 | QString Addressee::titleLabel() | 837 | QString Addressee::titleLabel() |
822 | { | 838 | { |
823 | return i18n("Title"); | 839 | return i18n("Title"); |
824 | } | 840 | } |
825 | 841 | ||
826 | 842 | ||
827 | void Addressee::setRole( const QString &role ) | 843 | void Addressee::setRole( const QString &role ) |
828 | { | 844 | { |
829 | if ( role == mData->role ) return; | 845 | if ( role == mData->role ) return; |
830 | detach(); | 846 | detach(); |
831 | mData->empty = false; | 847 | mData->empty = false; |
832 | mData->role = role; | 848 | mData->role = role; |
833 | } | 849 | } |
834 | 850 | ||
835 | QString Addressee::role() const | 851 | QString Addressee::role() const |
836 | { | 852 | { |
837 | return mData->role; | 853 | return mData->role; |
838 | } | 854 | } |
839 | 855 | ||
840 | QString Addressee::roleLabel() | 856 | QString Addressee::roleLabel() |
841 | { | 857 | { |
842 | return i18n("Role"); | 858 | return i18n("Role"); |
843 | } | 859 | } |
844 | 860 | ||
845 | 861 | ||
846 | void Addressee::setOrganization( const QString &organization ) | 862 | void Addressee::setOrganization( const QString &organization ) |
847 | { | 863 | { |
848 | if ( organization == mData->organization ) return; | 864 | if ( organization == mData->organization ) return; |
849 | detach(); | 865 | detach(); |
850 | mData->empty = false; | 866 | mData->empty = false; |
851 | mData->organization = organization; | 867 | mData->organization = organization; |
852 | } | 868 | } |
853 | 869 | ||
854 | QString Addressee::organization() const | 870 | QString Addressee::organization() const |
855 | { | 871 | { |
856 | return mData->organization; | 872 | return mData->organization; |
857 | } | 873 | } |
858 | 874 | ||
859 | QString Addressee::organizationLabel() | 875 | QString Addressee::organizationLabel() |
860 | { | 876 | { |
861 | return i18n("Organization"); | 877 | return i18n("Organization"); |
862 | } | 878 | } |
863 | 879 | ||
864 | 880 | ||
865 | void Addressee::setNote( const QString ¬e ) | 881 | void Addressee::setNote( const QString ¬e ) |
866 | { | 882 | { |
867 | if ( note == mData->note ) return; | 883 | if ( note == mData->note ) return; |
868 | detach(); | 884 | detach(); |
869 | mData->empty = false; | 885 | mData->empty = false; |
870 | mData->note = note; | 886 | mData->note = note; |
871 | } | 887 | } |
872 | 888 | ||
873 | QString Addressee::note() const | 889 | QString Addressee::note() const |
874 | { | 890 | { |
875 | return mData->note; | 891 | return mData->note; |
876 | } | 892 | } |
877 | 893 | ||
878 | QString Addressee::noteLabel() | 894 | QString Addressee::noteLabel() |
879 | { | 895 | { |
880 | return i18n("Note"); | 896 | return i18n("Note"); |
881 | } | 897 | } |
882 | 898 | ||
883 | 899 | ||
884 | void Addressee::setProductId( const QString &productId ) | 900 | void Addressee::setProductId( const QString &productId ) |
885 | { | 901 | { |
886 | if ( productId == mData->productId ) return; | 902 | if ( productId == mData->productId ) return; |
887 | detach(); | 903 | detach(); |
888 | mData->empty = false; | 904 | mData->empty = false; |
889 | mData->productId = productId; | 905 | mData->productId = productId; |
890 | } | 906 | } |
891 | 907 | ||
892 | QString Addressee::productId() const | 908 | QString Addressee::productId() const |
893 | { | 909 | { |
894 | return mData->productId; | 910 | return mData->productId; |
895 | } | 911 | } |
896 | 912 | ||
897 | QString Addressee::productIdLabel() | 913 | QString Addressee::productIdLabel() |
898 | { | 914 | { |
899 | return i18n("Product Identifier"); | 915 | return i18n("Product Identifier"); |
900 | } | 916 | } |
901 | 917 | ||
902 | 918 | ||
903 | void Addressee::setRevision( const QDateTime &revision ) | 919 | void Addressee::setRevision( const QDateTime &revision ) |
904 | { | 920 | { |
905 | if ( revision == mData->revision ) return; | 921 | if ( revision == mData->revision ) return; |
906 | detach(); | 922 | detach(); |
907 | mData->empty = false; | 923 | mData->empty = false; |
908 | mData->revision = revision; | 924 | mData->revision = revision; |
909 | } | 925 | } |
910 | 926 | ||
911 | QDateTime Addressee::revision() const | 927 | QDateTime Addressee::revision() const |
912 | { | 928 | { |
913 | return mData->revision; | 929 | return mData->revision; |
914 | } | 930 | } |
915 | 931 | ||
916 | QString Addressee::revisionLabel() | 932 | QString Addressee::revisionLabel() |
917 | { | 933 | { |
918 | return i18n("Revision Date"); | 934 | return i18n("Revision Date"); |
919 | } | 935 | } |
920 | 936 | ||
921 | 937 | ||
922 | void Addressee::setSortString( const QString &sortString ) | 938 | void Addressee::setSortString( const QString &sortString ) |
923 | { | 939 | { |
924 | if ( sortString == mData->sortString ) return; | 940 | if ( sortString == mData->sortString ) return; |
925 | detach(); | 941 | detach(); |
926 | mData->empty = false; | 942 | mData->empty = false; |
927 | mData->sortString = sortString; | 943 | mData->sortString = sortString; |
928 | } | 944 | } |
929 | 945 | ||
930 | QString Addressee::sortString() const | 946 | QString Addressee::sortString() const |
931 | { | 947 | { |
932 | return mData->sortString; | 948 | return mData->sortString; |
933 | } | 949 | } |
934 | 950 | ||
935 | QString Addressee::sortStringLabel() | 951 | QString Addressee::sortStringLabel() |
936 | { | 952 | { |
937 | return i18n("Sort String"); | 953 | return i18n("Sort String"); |
938 | } | 954 | } |
939 | 955 | ||
940 | 956 | ||
941 | void Addressee::setUrl( const KURL &url ) | 957 | void Addressee::setUrl( const KURL &url ) |
942 | { | 958 | { |
943 | if ( url == mData->url ) return; | 959 | if ( url == mData->url ) return; |
944 | detach(); | 960 | detach(); |
945 | mData->empty = false; | 961 | mData->empty = false; |
946 | mData->url = url; | 962 | mData->url = url; |
947 | } | 963 | } |
948 | 964 | ||
949 | KURL Addressee::url() const | 965 | KURL Addressee::url() const |
950 | { | 966 | { |
951 | return mData->url; | 967 | return mData->url; |
952 | } | 968 | } |
953 | 969 | ||
954 | QString Addressee::urlLabel() | 970 | QString Addressee::urlLabel() |
955 | { | 971 | { |
956 | return i18n("URL"); | 972 | return i18n("URL"); |
957 | } | 973 | } |
958 | 974 | ||
959 | 975 | ||
960 | void Addressee::setSecrecy( const Secrecy &secrecy ) | 976 | void Addressee::setSecrecy( const Secrecy &secrecy ) |
961 | { | 977 | { |
962 | if ( secrecy == mData->secrecy ) return; | 978 | if ( secrecy == mData->secrecy ) return; |
963 | detach(); | 979 | detach(); |
964 | mData->empty = false; | 980 | mData->empty = false; |
965 | mData->secrecy = secrecy; | 981 | mData->secrecy = secrecy; |
966 | } | 982 | } |
967 | 983 | ||
968 | Secrecy Addressee::secrecy() const | 984 | Secrecy Addressee::secrecy() const |
969 | { | 985 | { |
970 | return mData->secrecy; | 986 | return mData->secrecy; |
971 | } | 987 | } |
972 | 988 | ||
973 | QString Addressee::secrecyLabel() | 989 | QString Addressee::secrecyLabel() |
974 | { | 990 | { |
975 | return i18n("Security Class"); | 991 | return i18n("Security Class"); |
976 | } | 992 | } |
977 | 993 | ||
978 | 994 | ||
979 | void Addressee::setLogo( const Picture &logo ) | 995 | void Addressee::setLogo( const Picture &logo ) |
980 | { | 996 | { |
981 | if ( logo == mData->logo ) return; | 997 | if ( logo == mData->logo ) return; |
982 | detach(); | 998 | detach(); |
983 | mData->empty = false; | 999 | mData->empty = false; |
984 | mData->logo = logo; | 1000 | mData->logo = logo; |
985 | } | 1001 | } |
986 | 1002 | ||
987 | Picture Addressee::logo() const | 1003 | Picture Addressee::logo() const |
988 | { | 1004 | { |
989 | return mData->logo; | 1005 | return mData->logo; |
990 | } | 1006 | } |
991 | 1007 | ||
992 | QString Addressee::logoLabel() | 1008 | QString Addressee::logoLabel() |
993 | { | 1009 | { |
994 | return i18n("Logo"); | 1010 | return i18n("Logo"); |
995 | } | 1011 | } |
996 | 1012 | ||
997 | 1013 | ||
998 | void Addressee::setPhoto( const Picture &photo ) | 1014 | void Addressee::setPhoto( const Picture &photo ) |
999 | { | 1015 | { |
1000 | if ( photo == mData->photo ) return; | 1016 | if ( photo == mData->photo ) return; |
1001 | detach(); | 1017 | detach(); |
1002 | mData->empty = false; | 1018 | mData->empty = false; |
1003 | mData->photo = photo; | 1019 | mData->photo = photo; |
1004 | } | 1020 | } |
1005 | 1021 | ||
1006 | Picture Addressee::photo() const | 1022 | Picture Addressee::photo() const |
1007 | { | 1023 | { |
1008 | return mData->photo; | 1024 | return mData->photo; |
1009 | } | 1025 | } |
1010 | 1026 | ||
1011 | QString Addressee::photoLabel() | 1027 | QString Addressee::photoLabel() |
1012 | { | 1028 | { |
1013 | return i18n("Photo"); | 1029 | return i18n("Photo"); |
1014 | } | 1030 | } |
1015 | 1031 | ||
1016 | 1032 | ||
1017 | void Addressee::setSound( const Sound &sound ) | 1033 | void Addressee::setSound( const Sound &sound ) |
1018 | { | 1034 | { |
1019 | if ( sound == mData->sound ) return; | 1035 | if ( sound == mData->sound ) return; |
1020 | detach(); | 1036 | detach(); |
1021 | mData->empty = false; | 1037 | mData->empty = false; |
1022 | mData->sound = sound; | 1038 | mData->sound = sound; |
1023 | } | 1039 | } |
1024 | 1040 | ||
1025 | Sound Addressee::sound() const | 1041 | Sound Addressee::sound() const |
1026 | { | 1042 | { |
1027 | return mData->sound; | 1043 | return mData->sound; |
1028 | } | 1044 | } |
1029 | 1045 | ||
1030 | QString Addressee::soundLabel() | 1046 | QString Addressee::soundLabel() |
1031 | { | 1047 | { |
1032 | return i18n("Sound"); | 1048 | return i18n("Sound"); |
1033 | } | 1049 | } |
1034 | 1050 | ||
1035 | 1051 | ||
1036 | void Addressee::setAgent( const Agent &agent ) | 1052 | void Addressee::setAgent( const Agent &agent ) |
1037 | { | 1053 | { |
1038 | if ( agent == mData->agent ) return; | 1054 | if ( agent == mData->agent ) return; |
1039 | detach(); | 1055 | detach(); |
1040 | mData->empty = false; | 1056 | mData->empty = false; |
1041 | mData->agent = agent; | 1057 | mData->agent = agent; |
1042 | } | 1058 | } |
1043 | 1059 | ||
1044 | Agent Addressee::agent() const | 1060 | Agent Addressee::agent() const |
1045 | { | 1061 | { |
1046 | return mData->agent; | 1062 | return mData->agent; |
1047 | } | 1063 | } |
1048 | 1064 | ||
1049 | QString Addressee::agentLabel() | 1065 | QString Addressee::agentLabel() |
1050 | { | 1066 | { |
1051 | return i18n("Agent"); | 1067 | return i18n("Agent"); |
1052 | } | 1068 | } |
1053 | 1069 | ||
1054 | 1070 | ||
1055 | 1071 | ||
1056 | void Addressee::setNameFromString( const QString &str ) | 1072 | void Addressee::setNameFromString( const QString &str ) |
1057 | { | 1073 | { |
1058 | setFormattedName( str ); | 1074 | setFormattedName( str ); |
1059 | setName( str ); | 1075 | setName( str ); |
1060 | 1076 | ||
1061 | static bool first = true; | 1077 | static bool first = true; |
1062 | static QStringList titles; | 1078 | static QStringList titles; |
1063 | static QStringList suffixes; | 1079 | static QStringList suffixes; |
1064 | static QStringList prefixes; | 1080 | static QStringList prefixes; |
1065 | 1081 | ||
1066 | if ( first ) { | 1082 | if ( first ) { |
1067 | first = false; | 1083 | first = false; |
1068 | titles += i18n( "Dr." ); | 1084 | titles += i18n( "Dr." ); |
1069 | titles += i18n( "Miss" ); | 1085 | titles += i18n( "Miss" ); |
1070 | titles += i18n( "Mr." ); | 1086 | titles += i18n( "Mr." ); |
1071 | titles += i18n( "Mrs." ); | 1087 | titles += i18n( "Mrs." ); |
1072 | titles += i18n( "Ms." ); | 1088 | titles += i18n( "Ms." ); |
1073 | titles += i18n( "Prof." ); | 1089 | titles += i18n( "Prof." ); |
1074 | 1090 | ||
1075 | suffixes += i18n( "I" ); | 1091 | suffixes += i18n( "I" ); |
1076 | suffixes += i18n( "II" ); | 1092 | suffixes += i18n( "II" ); |
1077 | suffixes += i18n( "III" ); | 1093 | suffixes += i18n( "III" ); |
1078 | suffixes += i18n( "Jr." ); | 1094 | suffixes += i18n( "Jr." ); |
1079 | suffixes += i18n( "Sr." ); | 1095 | suffixes += i18n( "Sr." ); |
1080 | 1096 | ||
1081 | prefixes += "van"; | 1097 | prefixes += "van"; |
1082 | prefixes += "von"; | 1098 | prefixes += "von"; |
1083 | prefixes += "de"; | 1099 | prefixes += "de"; |
1084 | 1100 | ||
1085 | KConfig config( locateLocal( "config", "kabcrc") ); | 1101 | KConfig config( locateLocal( "config", "kabcrc") ); |
1086 | config.setGroup( "General" ); | 1102 | config.setGroup( "General" ); |
1087 | titles += config.readListEntry( "Prefixes" ); | 1103 | titles += config.readListEntry( "Prefixes" ); |
1088 | titles.remove( "" ); | 1104 | titles.remove( "" ); |
1089 | prefixes += config.readListEntry( "Inclusions" ); | 1105 | prefixes += config.readListEntry( "Inclusions" ); |
1090 | prefixes.remove( "" ); | 1106 | prefixes.remove( "" ); |
1091 | suffixes += config.readListEntry( "Suffixes" ); | 1107 | suffixes += config.readListEntry( "Suffixes" ); |
1092 | suffixes.remove( "" ); | 1108 | suffixes.remove( "" ); |
1093 | } | 1109 | } |
1094 | 1110 | ||
1095 | // clear all name parts | 1111 | // clear all name parts |
1096 | setPrefix( "" ); | 1112 | setPrefix( "" ); |
1097 | setGivenName( "" ); | 1113 | setGivenName( "" ); |
1098 | setAdditionalName( "" ); | 1114 | setAdditionalName( "" ); |
1099 | setFamilyName( "" ); | 1115 | setFamilyName( "" ); |
1100 | setSuffix( "" ); | 1116 | setSuffix( "" ); |
1101 | 1117 | ||
1102 | if ( str.isEmpty() ) | 1118 | if ( str.isEmpty() ) |
1103 | return; | 1119 | return; |
1104 | 1120 | ||
1105 | int i = str.find(','); | 1121 | int i = str.find(','); |
1106 | if( i < 0 ) { | 1122 | if( i < 0 ) { |
1107 | QStringList parts = QStringList::split( " ", str ); | 1123 | QStringList parts = QStringList::split( " ", str ); |
1108 | int leftOffset = 0; | 1124 | int leftOffset = 0; |
1109 | int rightOffset = parts.count() - 1; | 1125 | int rightOffset = parts.count() - 1; |
1110 | 1126 | ||
1111 | QString suffix; | 1127 | QString suffix; |
1112 | while ( rightOffset >= 0 ) { | 1128 | while ( rightOffset >= 0 ) { |
1113 | if ( suffixes.contains( parts[ rightOffset ] ) ) { | 1129 | if ( suffixes.contains( parts[ rightOffset ] ) ) { |
1114 | suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " ")); | 1130 | suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " ")); |
1115 | rightOffset--; | 1131 | rightOffset--; |
1116 | } else | 1132 | } else |
1117 | break; | 1133 | break; |
1118 | } | 1134 | } |
1119 | setSuffix( suffix ); | 1135 | setSuffix( suffix ); |
1120 | 1136 | ||
1121 | if ( rightOffset < 0 ) | 1137 | if ( rightOffset < 0 ) |
1122 | return; | 1138 | return; |
1123 | 1139 | ||
1124 | if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) { | 1140 | if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) { |
1125 | setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] ); | 1141 | setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] ); |
1126 | rightOffset--; | 1142 | rightOffset--; |
1127 | } else | 1143 | } else |
1128 | setFamilyName( parts[ rightOffset ] ); | 1144 | setFamilyName( parts[ rightOffset ] ); |
1129 | 1145 | ||
1130 | QString prefix; | 1146 | QString prefix; |
1131 | while ( leftOffset < rightOffset ) { | 1147 | while ( leftOffset < rightOffset ) { |
1132 | if ( titles.contains( parts[ leftOffset ] ) ) { | 1148 | if ( titles.contains( parts[ leftOffset ] ) ) { |
1133 | prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); | 1149 | prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); |
1134 | leftOffset++; | 1150 | leftOffset++; |
1135 | } else | 1151 | } else |
1136 | break; | 1152 | break; |
1137 | } | 1153 | } |
1138 | setPrefix( prefix ); | 1154 | setPrefix( prefix ); |
1139 | 1155 | ||
1140 | if ( leftOffset < rightOffset ) { | 1156 | if ( leftOffset < rightOffset ) { |
1141 | setGivenName( parts[ leftOffset ] ); | 1157 | setGivenName( parts[ leftOffset ] ); |
1142 | leftOffset++; | 1158 | leftOffset++; |
1143 | } | 1159 | } |
1144 | 1160 | ||
1145 | QString additionalName; | 1161 | QString additionalName; |
1146 | while ( leftOffset < rightOffset ) { | 1162 | while ( leftOffset < rightOffset ) { |
1147 | additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] ); | 1163 | additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] ); |
1148 | leftOffset++; | 1164 | leftOffset++; |
1149 | } | 1165 | } |
1150 | setAdditionalName( additionalName ); | 1166 | setAdditionalName( additionalName ); |
1151 | } else { | 1167 | } else { |
1152 | QString part1 = str.left( i ); | 1168 | QString part1 = str.left( i ); |
1153 | QString part2 = str.mid( i + 1 ); | 1169 | QString part2 = str.mid( i + 1 ); |
1154 | 1170 | ||
1155 | QStringList parts = QStringList::split( " ", part1 ); | 1171 | QStringList parts = QStringList::split( " ", part1 ); |
1156 | int leftOffset = 0; | 1172 | int leftOffset = 0; |
1157 | int rightOffset = parts.count() - 1; | 1173 | int rightOffset = parts.count() - 1; |
1158 | 1174 | ||
1159 | QString suffix; | 1175 | QString suffix; |
1160 | while ( rightOffset >= 0 ) { | 1176 | while ( rightOffset >= 0 ) { |
1161 | if ( suffixes.contains( parts[ rightOffset ] ) ) { | 1177 | if ( suffixes.contains( parts[ rightOffset ] ) ) { |
1162 | suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " ")); | 1178 | suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " ")); |
1163 | rightOffset--; | 1179 | rightOffset--; |
1164 | } else | 1180 | } else |
1165 | break; | 1181 | break; |
1166 | } | 1182 | } |
1167 | setSuffix( suffix ); | 1183 | setSuffix( suffix ); |
1168 | 1184 | ||
1169 | if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) { | 1185 | if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) { |
1170 | setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] ); | 1186 | setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] ); |
1171 | rightOffset--; | 1187 | rightOffset--; |
1172 | } else | 1188 | } else |
1173 | setFamilyName( parts[ rightOffset ] ); | 1189 | setFamilyName( parts[ rightOffset ] ); |
1174 | 1190 | ||
1175 | QString prefix; | 1191 | QString prefix; |
1176 | while ( leftOffset < rightOffset ) { | 1192 | while ( leftOffset < rightOffset ) { |
1177 | if ( titles.contains( parts[ leftOffset ] ) ) { | 1193 | if ( titles.contains( parts[ leftOffset ] ) ) { |
1178 | prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); | 1194 | prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); |
1179 | leftOffset++; | 1195 | leftOffset++; |
1180 | } else | 1196 | } else |
1181 | break; | 1197 | break; |
1182 | } | 1198 | } |
1183 | 1199 | ||
1184 | parts = QStringList::split( " ", part2 ); | 1200 | parts = QStringList::split( " ", part2 ); |
1185 | 1201 | ||
1186 | leftOffset = 0; | 1202 | leftOffset = 0; |
1187 | rightOffset = parts.count(); | 1203 | rightOffset = parts.count(); |
1188 | 1204 | ||
1189 | while ( leftOffset < rightOffset ) { | 1205 | while ( leftOffset < rightOffset ) { |
1190 | if ( titles.contains( parts[ leftOffset ] ) ) { | 1206 | if ( titles.contains( parts[ leftOffset ] ) ) { |
1191 | prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); | 1207 | prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); |
1192 | leftOffset++; | 1208 | leftOffset++; |
1193 | } else | 1209 | } else |
1194 | break; | 1210 | break; |
1195 | } | 1211 | } |
1196 | setPrefix( prefix ); | 1212 | setPrefix( prefix ); |
1197 | 1213 | ||
1198 | if ( leftOffset < rightOffset ) { | 1214 | if ( leftOffset < rightOffset ) { |
1199 | setGivenName( parts[ leftOffset ] ); | 1215 | setGivenName( parts[ leftOffset ] ); |
1200 | leftOffset++; | 1216 | leftOffset++; |
1201 | } | 1217 | } |
1202 | 1218 | ||
1203 | QString additionalName; | 1219 | QString additionalName; |
1204 | while ( leftOffset < rightOffset ) { | 1220 | while ( leftOffset < rightOffset ) { |
1205 | additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] ); | 1221 | additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] ); |
1206 | leftOffset++; | 1222 | leftOffset++; |
1207 | } | 1223 | } |
1208 | setAdditionalName( additionalName ); | 1224 | setAdditionalName( additionalName ); |
1209 | } | 1225 | } |
1210 | } | 1226 | } |
1211 | 1227 | ||
1212 | QString Addressee::realName() const | 1228 | QString Addressee::realName() const |
1213 | { | 1229 | { |
1214 | if ( !formattedName().isEmpty() ) | 1230 | if ( !formattedName().isEmpty() ) |
1215 | return formattedName(); | 1231 | return formattedName(); |
1216 | 1232 | ||
1217 | QString n = assembledName(); | 1233 | QString n = assembledName(); |
1218 | 1234 | ||
1219 | if ( n.isEmpty() ) | 1235 | if ( n.isEmpty() ) |
1220 | n = name(); | 1236 | n = name(); |
1221 | 1237 | ||
1222 | return n; | 1238 | return n; |
1223 | } | 1239 | } |
1224 | 1240 | ||
1225 | QString Addressee::assembledName() const | 1241 | QString Addressee::assembledName() const |
1226 | { | 1242 | { |
1227 | QString name = prefix() + " " + givenName() + " " + additionalName() + " " + | 1243 | QString name = prefix() + " " + givenName() + " " + additionalName() + " " + |
1228 | familyName() + " " + suffix(); | 1244 | familyName() + " " + suffix(); |
1229 | 1245 | ||
1230 | return name.simplifyWhiteSpace(); | 1246 | return name.simplifyWhiteSpace(); |
1231 | } | 1247 | } |
1232 | 1248 | ||
1233 | QString Addressee::fullEmail( const QString &email ) const | 1249 | QString Addressee::fullEmail( const QString &email ) const |
1234 | { | 1250 | { |
1235 | QString e; | 1251 | QString e; |
1236 | if ( email.isNull() ) { | 1252 | if ( email.isNull() ) { |
1237 | e = preferredEmail(); | 1253 | e = preferredEmail(); |
1238 | } else { | 1254 | } else { |
1239 | e = email; | 1255 | e = email; |
1240 | } | 1256 | } |
1241 | if ( e.isEmpty() ) return QString::null; | 1257 | if ( e.isEmpty() ) return QString::null; |
1242 | 1258 | ||
1243 | QString text; | 1259 | QString text; |
1244 | if ( realName().isEmpty() ) | 1260 | if ( realName().isEmpty() ) |
1245 | text = e; | 1261 | text = e; |
1246 | else | 1262 | else |
1247 | text = assembledName() + " <" + e + ">"; | 1263 | text = assembledName() + " <" + e + ">"; |
1248 | 1264 | ||
1249 | return text; | 1265 | return text; |
1250 | } | 1266 | } |
1251 | 1267 | ||
1252 | void Addressee::insertEmail( const QString &email, bool preferred ) | 1268 | void Addressee::insertEmail( const QString &email, bool preferred ) |
1253 | { | 1269 | { |
1254 | detach(); | 1270 | detach(); |
1255 | 1271 | ||
1256 | QStringList::Iterator it = mData->emails.find( email ); | 1272 | QStringList::Iterator it = mData->emails.find( email ); |
1257 | 1273 | ||
1258 | if ( it != mData->emails.end() ) { | 1274 | if ( it != mData->emails.end() ) { |
1259 | if ( !preferred || it == mData->emails.begin() ) return; | 1275 | if ( !preferred || it == mData->emails.begin() ) return; |
1260 | mData->emails.remove( it ); | 1276 | mData->emails.remove( it ); |
1261 | mData->emails.prepend( email ); | 1277 | mData->emails.prepend( email ); |
1262 | } else { | 1278 | } else { |
1263 | if ( preferred ) { | 1279 | if ( preferred ) { |
1264 | mData->emails.prepend( email ); | 1280 | mData->emails.prepend( email ); |
1265 | } else { | 1281 | } else { |
1266 | mData->emails.append( email ); | 1282 | mData->emails.append( email ); |
1267 | } | 1283 | } |
1268 | } | 1284 | } |
1269 | } | 1285 | } |
1270 | 1286 | ||
1271 | void Addressee::removeEmail( const QString &email ) | 1287 | void Addressee::removeEmail( const QString &email ) |
1272 | { | 1288 | { |
1273 | detach(); | 1289 | detach(); |
1274 | 1290 | ||
1275 | QStringList::Iterator it = mData->emails.find( email ); | 1291 | QStringList::Iterator it = mData->emails.find( email ); |
1276 | if ( it == mData->emails.end() ) return; | 1292 | if ( it == mData->emails.end() ) return; |
1277 | 1293 | ||
1278 | mData->emails.remove( it ); | 1294 | mData->emails.remove( it ); |
1279 | } | 1295 | } |
1280 | 1296 | ||
1281 | QString Addressee::preferredEmail() const | 1297 | QString Addressee::preferredEmail() const |
1282 | { | 1298 | { |
1283 | if ( mData->emails.count() == 0 ) return QString::null; | 1299 | if ( mData->emails.count() == 0 ) return QString::null; |
1284 | else return mData->emails.first(); | 1300 | else return mData->emails.first(); |
1285 | } | 1301 | } |
1286 | 1302 | ||
1287 | QStringList Addressee::emails() const | 1303 | QStringList Addressee::emails() const |
1288 | { | 1304 | { |
1289 | return mData->emails; | 1305 | return mData->emails; |
1290 | } | 1306 | } |
1291 | void Addressee::setEmails( const QStringList& emails ) { | 1307 | void Addressee::setEmails( const QStringList& emails ) { |
1292 | detach(); | 1308 | detach(); |
1293 | mData->emails = emails; | 1309 | mData->emails = emails; |
1294 | } | 1310 | } |
1295 | void Addressee::insertPhoneNumber( const PhoneNumber &phoneNumber ) | 1311 | void Addressee::insertPhoneNumber( const PhoneNumber &phoneNumber ) |
1296 | { | 1312 | { |
1297 | detach(); | 1313 | detach(); |
1298 | mData->empty = false; | 1314 | mData->empty = false; |
1299 | 1315 | ||
1300 | PhoneNumber::List::Iterator it; | 1316 | PhoneNumber::List::Iterator it; |
1301 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 1317 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
1302 | if ( (*it).id() == phoneNumber.id() ) { | 1318 | if ( (*it).id() == phoneNumber.id() ) { |
1303 | *it = phoneNumber; | 1319 | *it = phoneNumber; |
1304 | return; | 1320 | return; |
1305 | } | 1321 | } |
1306 | } | 1322 | } |
1307 | mData->phoneNumbers.append( phoneNumber ); | 1323 | mData->phoneNumbers.append( phoneNumber ); |
1308 | } | 1324 | } |
1309 | 1325 | ||
1310 | void Addressee::removePhoneNumber( const PhoneNumber &phoneNumber ) | 1326 | void Addressee::removePhoneNumber( const PhoneNumber &phoneNumber ) |
1311 | { | 1327 | { |
1312 | detach(); | 1328 | detach(); |
1313 | 1329 | ||
1314 | PhoneNumber::List::Iterator it; | 1330 | PhoneNumber::List::Iterator it; |
1315 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 1331 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
1316 | if ( (*it).id() == phoneNumber.id() ) { | 1332 | if ( (*it).id() == phoneNumber.id() ) { |
1317 | mData->phoneNumbers.remove( it ); | 1333 | mData->phoneNumbers.remove( it ); |
1318 | return; | 1334 | return; |
1319 | } | 1335 | } |
1320 | } | 1336 | } |
1321 | } | 1337 | } |
1322 | 1338 | ||
1323 | PhoneNumber Addressee::phoneNumber( int type ) const | 1339 | PhoneNumber Addressee::phoneNumber( int type ) const |
1324 | { | 1340 | { |
1325 | PhoneNumber phoneNumber( "", type ); | 1341 | PhoneNumber phoneNumber( "", type ); |
1326 | PhoneNumber::List::ConstIterator it; | 1342 | PhoneNumber::List::ConstIterator it; |
1327 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 1343 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
1328 | if ( matchBinaryPatternP( (*it).type(), type ) ) { | 1344 | if ( matchBinaryPatternP( (*it).type(), type ) ) { |
1329 | if ( (*it).type() & PhoneNumber::Pref ) | 1345 | if ( (*it).type() & PhoneNumber::Pref ) |
1330 | return (*it); | 1346 | return (*it); |
1331 | else if ( phoneNumber.number().isEmpty() ) | 1347 | else if ( phoneNumber.number().isEmpty() ) |
1332 | phoneNumber = (*it); | 1348 | phoneNumber = (*it); |
1333 | } | 1349 | } |
1334 | } | 1350 | } |
1335 | 1351 | ||
1336 | return phoneNumber; | 1352 | return phoneNumber; |
1337 | } | 1353 | } |
1338 | 1354 | ||
1339 | PhoneNumber::List Addressee::phoneNumbers() const | 1355 | PhoneNumber::List Addressee::phoneNumbers() const |
1340 | { | 1356 | { |
1341 | return mData->phoneNumbers; | 1357 | return mData->phoneNumbers; |
1342 | } | 1358 | } |
1343 | 1359 | ||
1344 | PhoneNumber::List Addressee::phoneNumbers( int type ) const | 1360 | PhoneNumber::List Addressee::phoneNumbers( int type ) const |
1345 | { | 1361 | { |
1346 | PhoneNumber::List list; | 1362 | PhoneNumber::List list; |
1347 | 1363 | ||
1348 | PhoneNumber::List::ConstIterator it; | 1364 | PhoneNumber::List::ConstIterator it; |
1349 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 1365 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
1350 | if ( matchBinaryPattern( (*it).type(), type ) ) { | 1366 | if ( matchBinaryPattern( (*it).type(), type ) ) { |
1351 | list.append( *it ); | 1367 | list.append( *it ); |
1352 | } | 1368 | } |
1353 | } | 1369 | } |
1354 | return list; | 1370 | return list; |
1355 | } | 1371 | } |
1356 | 1372 | ||
1357 | PhoneNumber Addressee::findPhoneNumber( const QString &id ) const | 1373 | PhoneNumber Addressee::findPhoneNumber( const QString &id ) const |
1358 | { | 1374 | { |
1359 | PhoneNumber::List::ConstIterator it; | 1375 | PhoneNumber::List::ConstIterator it; |
1360 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 1376 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
1361 | if ( (*it).id() == id ) { | 1377 | if ( (*it).id() == id ) { |
1362 | return *it; | 1378 | return *it; |
1363 | } | 1379 | } |
1364 | } | 1380 | } |
1365 | return PhoneNumber(); | 1381 | return PhoneNumber(); |
1366 | } | 1382 | } |
1367 | 1383 | ||
1368 | void Addressee::insertKey( const Key &key ) | 1384 | void Addressee::insertKey( const Key &key ) |
1369 | { | 1385 | { |
1370 | detach(); | 1386 | detach(); |
1371 | mData->empty = false; | 1387 | mData->empty = false; |
1372 | 1388 | ||
1373 | Key::List::Iterator it; | 1389 | Key::List::Iterator it; |
1374 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { | 1390 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { |
1375 | if ( (*it).id() == key.id() ) { | 1391 | if ( (*it).id() == key.id() ) { |
1376 | *it = key; | 1392 | *it = key; |
1377 | return; | 1393 | return; |
1378 | } | 1394 | } |
1379 | } | 1395 | } |
1380 | mData->keys.append( key ); | 1396 | mData->keys.append( key ); |
1381 | } | 1397 | } |
1382 | 1398 | ||
1383 | void Addressee::removeKey( const Key &key ) | 1399 | void Addressee::removeKey( const Key &key ) |
1384 | { | 1400 | { |
1385 | detach(); | 1401 | detach(); |
1386 | 1402 | ||
1387 | Key::List::Iterator it; | 1403 | Key::List::Iterator it; |
1388 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { | 1404 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { |
1389 | if ( (*it).id() == key.id() ) { | 1405 | if ( (*it).id() == key.id() ) { |
1390 | mData->keys.remove( key ); | 1406 | mData->keys.remove( key ); |
1391 | return; | 1407 | return; |
1392 | } | 1408 | } |
1393 | } | 1409 | } |
1394 | } | 1410 | } |
1395 | 1411 | ||
1396 | Key Addressee::key( int type, QString customTypeString ) const | 1412 | Key Addressee::key( int type, QString customTypeString ) const |
1397 | { | 1413 | { |
1398 | Key::List::ConstIterator it; | 1414 | Key::List::ConstIterator it; |
1399 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { | 1415 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { |
1400 | if ( (*it).type() == type ) { | 1416 | if ( (*it).type() == type ) { |
1401 | if ( type == Key::Custom ) { | 1417 | if ( type == Key::Custom ) { |
1402 | if ( customTypeString.isEmpty() ) { | 1418 | if ( customTypeString.isEmpty() ) { |
1403 | return *it; | 1419 | return *it; |
1404 | } else { | 1420 | } else { |
1405 | if ( (*it).customTypeString() == customTypeString ) | 1421 | if ( (*it).customTypeString() == customTypeString ) |
1406 | return (*it); | 1422 | return (*it); |
1407 | } | 1423 | } |
1408 | } else { | 1424 | } else { |
1409 | return *it; | 1425 | return *it; |
1410 | } | 1426 | } |
1411 | } | 1427 | } |
1412 | } | 1428 | } |
1413 | return Key( QString(), type ); | 1429 | return Key( QString(), type ); |
1414 | } | 1430 | } |
1415 | void Addressee::setKeys( const Key::List& list ) { | 1431 | void Addressee::setKeys( const Key::List& list ) { |
1416 | detach(); | 1432 | detach(); |
1417 | mData->keys = list; | 1433 | mData->keys = list; |
1418 | } | 1434 | } |
1419 | 1435 | ||
1420 | Key::List Addressee::keys() const | 1436 | Key::List Addressee::keys() const |
1421 | { | 1437 | { |
1422 | return mData->keys; | 1438 | return mData->keys; |
1423 | } | 1439 | } |
1424 | 1440 | ||
1425 | Key::List Addressee::keys( int type, QString customTypeString ) const | 1441 | Key::List Addressee::keys( int type, QString customTypeString ) const |
1426 | { | 1442 | { |
1427 | Key::List list; | 1443 | Key::List list; |
1428 | 1444 | ||
1429 | Key::List::ConstIterator it; | 1445 | Key::List::ConstIterator it; |
1430 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { | 1446 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { |
1431 | if ( (*it).type() == type ) { | 1447 | if ( (*it).type() == type ) { |
1432 | if ( type == Key::Custom ) { | 1448 | if ( type == Key::Custom ) { |
1433 | if ( customTypeString.isEmpty() ) { | 1449 | if ( customTypeString.isEmpty() ) { |
1434 | list.append(*it); | 1450 | list.append(*it); |
1435 | } else { | 1451 | } else { |
1436 | if ( (*it).customTypeString() == customTypeString ) | 1452 | if ( (*it).customTypeString() == customTypeString ) |
1437 | list.append(*it); | 1453 | list.append(*it); |
1438 | } | 1454 | } |
1439 | } else { | 1455 | } else { |
1440 | list.append(*it); | 1456 | list.append(*it); |
1441 | } | 1457 | } |
1442 | } | 1458 | } |
1443 | } | 1459 | } |
1444 | return list; | 1460 | return list; |
1445 | } | 1461 | } |
1446 | 1462 | ||
1447 | Key Addressee::findKey( const QString &id ) const | 1463 | Key Addressee::findKey( const QString &id ) const |
1448 | { | 1464 | { |
1449 | Key::List::ConstIterator it; | 1465 | Key::List::ConstIterator it; |
1450 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { | 1466 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { |
1451 | if ( (*it).id() == id ) { | 1467 | if ( (*it).id() == id ) { |
1452 | return *it; | 1468 | return *it; |
1453 | } | 1469 | } |
1454 | } | 1470 | } |
1455 | return Key(); | 1471 | return Key(); |
1456 | } | 1472 | } |
1457 | 1473 | ||
1458 | QString Addressee::asString() const | 1474 | QString Addressee::asString() const |
1459 | { | 1475 | { |
1460 | return "Smith, agent Smith..."; | 1476 | return "Smith, agent Smith..."; |
1461 | } | 1477 | } |
1462 | 1478 | ||
1463 | void Addressee::dump() const | 1479 | void Addressee::dump() const |
1464 | { | 1480 | { |
1465 | return; | 1481 | return; |
1466 | kdDebug(5700) << "Addressee {" << endl; | 1482 | kdDebug(5700) << "Addressee {" << endl; |
1467 | 1483 | ||
1468 | kdDebug(5700) << " Uid: '" << uid() << "'" << endl; | 1484 | kdDebug(5700) << " Uid: '" << uid() << "'" << endl; |
1469 | 1485 | ||
1470 | kdDebug(5700) << " Name: '" << name() << "'" << endl; | 1486 | kdDebug(5700) << " Name: '" << name() << "'" << endl; |
1471 | kdDebug(5700) << " FormattedName: '" << formattedName() << "'" << endl; | 1487 | kdDebug(5700) << " FormattedName: '" << formattedName() << "'" << endl; |
1472 | kdDebug(5700) << " FamilyName: '" << familyName() << "'" << endl; | 1488 | kdDebug(5700) << " FamilyName: '" << familyName() << "'" << endl; |
1473 | kdDebug(5700) << " GivenName: '" << givenName() << "'" << endl; | 1489 | kdDebug(5700) << " GivenName: '" << givenName() << "'" << endl; |
1474 | kdDebug(5700) << " AdditionalName: '" << additionalName() << "'" << endl; | 1490 | kdDebug(5700) << " AdditionalName: '" << additionalName() << "'" << endl; |
1475 | kdDebug(5700) << " Prefix: '" << prefix() << "'" << endl; | 1491 | kdDebug(5700) << " Prefix: '" << prefix() << "'" << endl; |
1476 | kdDebug(5700) << " Suffix: '" << suffix() << "'" << endl; | 1492 | kdDebug(5700) << " Suffix: '" << suffix() << "'" << endl; |
1477 | kdDebug(5700) << " NickName: '" << nickName() << "'" << endl; | 1493 | kdDebug(5700) << " NickName: '" << nickName() << "'" << endl; |
1478 | kdDebug(5700) << " Birthday: '" << birthday().toString() << "'" << endl; | 1494 | kdDebug(5700) << " Birthday: '" << birthday().toString() << "'" << endl; |
1479 | kdDebug(5700) << " Mailer: '" << mailer() << "'" << endl; | 1495 | kdDebug(5700) << " Mailer: '" << mailer() << "'" << endl; |
1480 | kdDebug(5700) << " TimeZone: '" << timeZone().asString() << "'" << endl; | 1496 | kdDebug(5700) << " TimeZone: '" << timeZone().asString() << "'" << endl; |
1481 | kdDebug(5700) << " Geo: '" << geo().asString() << "'" << endl; | 1497 | kdDebug(5700) << " Geo: '" << geo().asString() << "'" << endl; |
1482 | kdDebug(5700) << " Title: '" << title() << "'" << endl; | 1498 | kdDebug(5700) << " Title: '" << title() << "'" << endl; |
1483 | kdDebug(5700) << " Role: '" << role() << "'" << endl; | 1499 | kdDebug(5700) << " Role: '" << role() << "'" << endl; |
1484 | kdDebug(5700) << " Organization: '" << organization() << "'" << endl; | 1500 | kdDebug(5700) << " Organization: '" << organization() << "'" << endl; |
1485 | kdDebug(5700) << " Note: '" << note() << "'" << endl; | 1501 | kdDebug(5700) << " Note: '" << note() << "'" << endl; |
1486 | kdDebug(5700) << " ProductId: '" << productId() << "'" << endl; | 1502 | kdDebug(5700) << " ProductId: '" << productId() << "'" << endl; |
1487 | kdDebug(5700) << " Revision: '" << revision().toString() << "'" << endl; | 1503 | kdDebug(5700) << " Revision: '" << revision().toString() << "'" << endl; |
1488 | kdDebug(5700) << " SortString: '" << sortString() << "'" << endl; | 1504 | kdDebug(5700) << " SortString: '" << sortString() << "'" << endl; |
1489 | kdDebug(5700) << " Url: '" << url().url() << "'" << endl; | 1505 | kdDebug(5700) << " Url: '" << url().url() << "'" << endl; |
1490 | kdDebug(5700) << " Secrecy: '" << secrecy().asString() << "'" << endl; | 1506 | kdDebug(5700) << " Secrecy: '" << secrecy().asString() << "'" << endl; |
1491 | kdDebug(5700) << " Logo: '" << logo().asString() << "'" << endl; | 1507 | kdDebug(5700) << " Logo: '" << logo().asString() << "'" << endl; |
1492 | kdDebug(5700) << " Photo: '" << photo().asString() << "'" << endl; | 1508 | kdDebug(5700) << " Photo: '" << photo().asString() << "'" << endl; |
1493 | kdDebug(5700) << " Sound: '" << sound().asString() << "'" << endl; | 1509 | kdDebug(5700) << " Sound: '" << sound().asString() << "'" << endl; |
1494 | kdDebug(5700) << " Agent: '" << agent().asString() << "'" << endl; | 1510 | kdDebug(5700) << " Agent: '" << agent().asString() << "'" << endl; |
1495 | 1511 | ||
1496 | kdDebug(5700) << " Emails {" << endl; | 1512 | kdDebug(5700) << " Emails {" << endl; |
1497 | QStringList e = emails(); | 1513 | QStringList e = emails(); |
1498 | QStringList::ConstIterator it; | 1514 | QStringList::ConstIterator it; |
1499 | for( it = e.begin(); it != e.end(); ++it ) { | 1515 | for( it = e.begin(); it != e.end(); ++it ) { |
1500 | kdDebug(5700) << " " << (*it) << endl; | 1516 | kdDebug(5700) << " " << (*it) << endl; |
1501 | } | 1517 | } |
1502 | kdDebug(5700) << " }" << endl; | 1518 | kdDebug(5700) << " }" << endl; |
1503 | 1519 | ||
1504 | kdDebug(5700) << " PhoneNumbers {" << endl; | 1520 | kdDebug(5700) << " PhoneNumbers {" << endl; |
1505 | PhoneNumber::List p = phoneNumbers(); | 1521 | PhoneNumber::List p = phoneNumbers(); |
1506 | PhoneNumber::List::ConstIterator it2; | 1522 | PhoneNumber::List::ConstIterator it2; |
1507 | for( it2 = p.begin(); it2 != p.end(); ++it2 ) { | 1523 | for( it2 = p.begin(); it2 != p.end(); ++it2 ) { |
1508 | kdDebug(5700) << " Type: " << int((*it2).type()) << " Number: " << (*it2).number() << endl; | 1524 | kdDebug(5700) << " Type: " << int((*it2).type()) << " Number: " << (*it2).number() << endl; |
1509 | } | 1525 | } |
1510 | kdDebug(5700) << " }" << endl; | 1526 | kdDebug(5700) << " }" << endl; |
1511 | 1527 | ||
1512 | Address::List a = addresses(); | 1528 | Address::List a = addresses(); |
1513 | Address::List::ConstIterator it3; | 1529 | Address::List::ConstIterator it3; |
1514 | for( it3 = a.begin(); it3 != a.end(); ++it3 ) { | 1530 | for( it3 = a.begin(); it3 != a.end(); ++it3 ) { |
1515 | (*it3).dump(); | 1531 | (*it3).dump(); |
1516 | } | 1532 | } |
1517 | 1533 | ||
1518 | kdDebug(5700) << " Keys {" << endl; | 1534 | kdDebug(5700) << " Keys {" << endl; |
1519 | Key::List k = keys(); | 1535 | Key::List k = keys(); |
1520 | Key::List::ConstIterator it4; | 1536 | Key::List::ConstIterator it4; |
1521 | for( it4 = k.begin(); it4 != k.end(); ++it4 ) { | 1537 | for( it4 = k.begin(); it4 != k.end(); ++it4 ) { |
1522 | kdDebug(5700) << " Type: " << int((*it4).type()) << | 1538 | kdDebug(5700) << " Type: " << int((*it4).type()) << |
1523 | " Key: " << (*it4).textData() << | 1539 | " Key: " << (*it4).textData() << |
1524 | " CustomString: " << (*it4).customTypeString() << endl; | 1540 | " CustomString: " << (*it4).customTypeString() << endl; |
1525 | } | 1541 | } |
1526 | kdDebug(5700) << " }" << endl; | 1542 | kdDebug(5700) << " }" << endl; |
1527 | 1543 | ||
1528 | kdDebug(5700) << "}" << endl; | 1544 | kdDebug(5700) << "}" << endl; |
1529 | } | 1545 | } |
1530 | 1546 | ||
1531 | 1547 | ||
1532 | void Addressee::insertAddress( const Address &address ) | 1548 | void Addressee::insertAddress( const Address &address ) |
1533 | { | 1549 | { |
1534 | detach(); | 1550 | detach(); |
1535 | mData->empty = false; | 1551 | mData->empty = false; |
1536 | 1552 | ||
1537 | Address::List::Iterator it; | 1553 | Address::List::Iterator it; |
1538 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { | 1554 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { |
1539 | if ( (*it).id() == address.id() ) { | 1555 | if ( (*it).id() == address.id() ) { |
1540 | *it = address; | 1556 | *it = address; |
1541 | return; | 1557 | return; |
1542 | } | 1558 | } |
1543 | } | 1559 | } |
1544 | mData->addresses.append( address ); | 1560 | mData->addresses.append( address ); |
1545 | } | 1561 | } |
1546 | 1562 | ||
1547 | void Addressee::removeAddress( const Address &address ) | 1563 | void Addressee::removeAddress( const Address &address ) |
1548 | { | 1564 | { |
1549 | detach(); | 1565 | detach(); |
1550 | 1566 | ||
1551 | Address::List::Iterator it; | 1567 | Address::List::Iterator it; |
1552 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { | 1568 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { |
1553 | if ( (*it).id() == address.id() ) { | 1569 | if ( (*it).id() == address.id() ) { |
1554 | mData->addresses.remove( it ); | 1570 | mData->addresses.remove( it ); |
1555 | return; | 1571 | return; |
1556 | } | 1572 | } |
1557 | } | 1573 | } |
1558 | } | 1574 | } |
1559 | 1575 | ||
1560 | Address Addressee::address( int type ) const | 1576 | Address Addressee::address( int type ) const |
1561 | { | 1577 | { |
1562 | Address address( type ); | 1578 | Address address( type ); |
1563 | Address::List::ConstIterator it; | 1579 | Address::List::ConstIterator it; |
1564 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { | 1580 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { |
1565 | if ( matchBinaryPatternA( (*it).type(), type ) ) { | 1581 | if ( matchBinaryPatternA( (*it).type(), type ) ) { |
1566 | if ( (*it).type() & Address::Pref ) | 1582 | if ( (*it).type() & Address::Pref ) |
1567 | return (*it); | 1583 | return (*it); |
1568 | else if ( address.isEmpty() ) | 1584 | else if ( address.isEmpty() ) |
1569 | address = (*it); | 1585 | address = (*it); |
1570 | } | 1586 | } |
1571 | } | 1587 | } |
1572 | 1588 | ||
1573 | return address; | 1589 | return address; |
1574 | } | 1590 | } |
1575 | 1591 | ||
1576 | Address::List Addressee::addresses() const | 1592 | Address::List Addressee::addresses() const |
1577 | { | 1593 | { |
1578 | return mData->addresses; | 1594 | return mData->addresses; |
1579 | } | 1595 | } |
1580 | 1596 | ||
1581 | Address::List Addressee::addresses( int type ) const | 1597 | Address::List Addressee::addresses( int type ) const |
1582 | { | 1598 | { |
1583 | Address::List list; | 1599 | Address::List list; |
1584 | 1600 | ||
1585 | Address::List::ConstIterator it; | 1601 | Address::List::ConstIterator it; |
1586 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { | 1602 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { |
1587 | if ( matchBinaryPattern( (*it).type(), type ) ) { | 1603 | if ( matchBinaryPattern( (*it).type(), type ) ) { |
1588 | list.append( *it ); | 1604 | list.append( *it ); |
1589 | } | 1605 | } |
1590 | } | 1606 | } |
1591 | 1607 | ||
1592 | return list; | 1608 | return list; |
1593 | } | 1609 | } |
1594 | 1610 | ||
1595 | Address Addressee::findAddress( const QString &id ) const | 1611 | Address Addressee::findAddress( const QString &id ) const |
1596 | { | 1612 | { |
1597 | Address::List::ConstIterator it; | 1613 | Address::List::ConstIterator it; |
1598 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { | 1614 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { |
1599 | if ( (*it).id() == id ) { | 1615 | if ( (*it).id() == id ) { |
1600 | return *it; | 1616 | return *it; |
1601 | } | 1617 | } |
1602 | } | 1618 | } |
1603 | return Address(); | 1619 | return Address(); |
1604 | } | 1620 | } |
1605 | 1621 | ||
1606 | void Addressee::insertCategory( const QString &c ) | 1622 | void Addressee::insertCategory( const QString &c ) |
1607 | { | 1623 | { |
1608 | detach(); | 1624 | detach(); |
1609 | mData->empty = false; | 1625 | mData->empty = false; |
1610 | 1626 | ||
1611 | if ( mData->categories.contains( c ) ) return; | 1627 | if ( mData->categories.contains( c ) ) return; |
1612 | 1628 | ||
1613 | mData->categories.append( c ); | 1629 | mData->categories.append( c ); |
1614 | } | 1630 | } |
1615 | 1631 | ||
1616 | void Addressee::removeCategory( const QString &c ) | 1632 | void Addressee::removeCategory( const QString &c ) |
1617 | { | 1633 | { |
1618 | detach(); | 1634 | detach(); |
1619 | 1635 | ||
1620 | QStringList::Iterator it = mData->categories.find( c ); | 1636 | QStringList::Iterator it = mData->categories.find( c ); |
1621 | if ( it == mData->categories.end() ) return; | 1637 | if ( it == mData->categories.end() ) return; |
1622 | 1638 | ||
1623 | mData->categories.remove( it ); | 1639 | mData->categories.remove( it ); |
1624 | } | 1640 | } |
1625 | 1641 | ||
1626 | bool Addressee::hasCategory( const QString &c ) const | 1642 | bool Addressee::hasCategory( const QString &c ) const |
1627 | { | 1643 | { |
1628 | return ( mData->categories.contains( c ) ); | 1644 | return ( mData->categories.contains( c ) ); |
1629 | } | 1645 | } |
1630 | 1646 | ||
1631 | void Addressee::setCategories( const QStringList &c ) | 1647 | void Addressee::setCategories( const QStringList &c ) |
1632 | { | 1648 | { |
1633 | detach(); | 1649 | detach(); |
1634 | mData->empty = false; | 1650 | mData->empty = false; |
1635 | 1651 | ||
1636 | mData->categories = c; | 1652 | mData->categories = c; |
1637 | } | 1653 | } |
1638 | 1654 | ||
1639 | QStringList Addressee::categories() const | 1655 | QStringList Addressee::categories() const |
1640 | { | 1656 | { |
1641 | return mData->categories; | 1657 | return mData->categories; |
1642 | } | 1658 | } |
1643 | 1659 | ||
1644 | void Addressee::insertCustom( const QString &app, const QString &name, | 1660 | void Addressee::insertCustom( const QString &app, const QString &name, |
1645 | const QString &value ) | 1661 | const QString &value ) |
1646 | { | 1662 | { |
1647 | if ( value.isNull() || name.isEmpty() || app.isEmpty() ) return; | 1663 | if ( value.isNull() || name.isEmpty() || app.isEmpty() ) return; |
1648 | 1664 | ||
1649 | detach(); | 1665 | detach(); |
1650 | mData->empty = false; | 1666 | mData->empty = false; |
1651 | 1667 | ||
1652 | QString qualifiedName = app + "-" + name + ":"; | 1668 | QString qualifiedName = app + "-" + name + ":"; |
1653 | 1669 | ||
1654 | QStringList::Iterator it; | 1670 | QStringList::Iterator it; |
1655 | for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { | 1671 | for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { |
1656 | if ( (*it).startsWith( qualifiedName ) ) { | 1672 | if ( (*it).startsWith( qualifiedName ) ) { |
1657 | (*it) = qualifiedName + value; | 1673 | (*it) = qualifiedName + value; |
1658 | return; | 1674 | return; |
1659 | } | 1675 | } |
1660 | } | 1676 | } |
1661 | mData->custom.append( qualifiedName + value ); | 1677 | mData->custom.append( qualifiedName + value ); |
1662 | } | 1678 | } |
1663 | 1679 | ||
1664 | void Addressee::removeCustom( const QString &app, const QString &name) | 1680 | void Addressee::removeCustom( const QString &app, const QString &name) |
1665 | { | 1681 | { |
1666 | detach(); | 1682 | detach(); |
1667 | 1683 | ||
1668 | QString qualifiedName = app + "-" + name + ":"; | 1684 | QString qualifiedName = app + "-" + name + ":"; |
1669 | 1685 | ||
1670 | QStringList::Iterator it; | 1686 | QStringList::Iterator it; |
1671 | for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { | 1687 | for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { |
1672 | if ( (*it).startsWith( qualifiedName ) ) { | 1688 | if ( (*it).startsWith( qualifiedName ) ) { |
1673 | mData->custom.remove( it ); | 1689 | mData->custom.remove( it ); |
1674 | return; | 1690 | return; |
1675 | } | 1691 | } |
1676 | } | 1692 | } |
1677 | } | 1693 | } |
1678 | 1694 | ||
1679 | QString Addressee::custom( const QString &app, const QString &name ) const | 1695 | QString Addressee::custom( const QString &app, const QString &name ) const |
1680 | { | 1696 | { |
1681 | QString qualifiedName = app + "-" + name + ":"; | 1697 | QString qualifiedName = app + "-" + name + ":"; |
1682 | QString value; | 1698 | QString value; |
1683 | 1699 | ||
1684 | QStringList::ConstIterator it; | 1700 | QStringList::ConstIterator it; |
1685 | for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { | 1701 | for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { |
1686 | if ( (*it).startsWith( qualifiedName ) ) { | 1702 | if ( (*it).startsWith( qualifiedName ) ) { |
1687 | value = (*it).mid( (*it).find( ":" ) + 1 ); | 1703 | value = (*it).mid( (*it).find( ":" ) + 1 ); |
1688 | break; | 1704 | break; |
1689 | } | 1705 | } |
1690 | } | 1706 | } |
1691 | 1707 | ||
1692 | return value; | 1708 | return value; |
1693 | } | 1709 | } |
1694 | 1710 | ||
1695 | void Addressee::setCustoms( const QStringList &l ) | 1711 | void Addressee::setCustoms( const QStringList &l ) |
1696 | { | 1712 | { |
1697 | detach(); | 1713 | detach(); |
1698 | mData->empty = false; | 1714 | mData->empty = false; |
1699 | 1715 | ||
1700 | mData->custom = l; | 1716 | mData->custom = l; |
1701 | } | 1717 | } |
1702 | 1718 | ||
1703 | QStringList Addressee::customs() const | 1719 | QStringList Addressee::customs() const |
1704 | { | 1720 | { |
1705 | return mData->custom; | 1721 | return mData->custom; |
1706 | } | 1722 | } |
1707 | 1723 | ||
1708 | void Addressee::parseEmailAddress( const QString &rawEmail, QString &fullName, | 1724 | void Addressee::parseEmailAddress( const QString &rawEmail, QString &fullName, |
1709 | QString &email) | 1725 | QString &email) |
1710 | { | 1726 | { |
1711 | int startPos, endPos, len; | 1727 | int startPos, endPos, len; |
1712 | QString partA, partB, result; | 1728 | QString partA, partB, result; |
1713 | char endCh = '>'; | 1729 | char endCh = '>'; |
1714 | 1730 | ||
1715 | startPos = rawEmail.find('<'); | 1731 | startPos = rawEmail.find('<'); |
1716 | if (startPos < 0) | 1732 | if (startPos < 0) |
1717 | { | 1733 | { |
1718 | startPos = rawEmail.find('('); | 1734 | startPos = rawEmail.find('('); |
1719 | endCh = ')'; | 1735 | endCh = ')'; |
1720 | } | 1736 | } |
1721 | if (startPos < 0) | 1737 | if (startPos < 0) |
1722 | { | 1738 | { |
1723 | // We couldn't find any separators, so we assume the whole string | 1739 | // We couldn't find any separators, so we assume the whole string |
1724 | // is the email address | 1740 | // is the email address |
1725 | email = rawEmail; | 1741 | email = rawEmail; |
1726 | fullName = ""; | 1742 | fullName = ""; |
1727 | } | 1743 | } |
1728 | else | 1744 | else |
1729 | { | 1745 | { |
1730 | // We have a start position, try to find an end | 1746 | // We have a start position, try to find an end |
1731 | endPos = rawEmail.find(endCh, startPos+1); | 1747 | endPos = rawEmail.find(endCh, startPos+1); |
1732 | 1748 | ||
1733 | if (endPos < 0) | 1749 | if (endPos < 0) |
1734 | { | 1750 | { |
1735 | // We couldn't find the end of the email address. We can only | 1751 | // We couldn't find the end of the email address. We can only |
1736 | // assume the entire string is the email address. | 1752 | // assume the entire string is the email address. |
1737 | email = rawEmail; | 1753 | email = rawEmail; |
1738 | fullName = ""; | 1754 | fullName = ""; |
1739 | } | 1755 | } |
1740 | else | 1756 | else |
1741 | { | 1757 | { |
1742 | // We have a start and end to the email address | 1758 | // We have a start and end to the email address |
1743 | 1759 | ||
1744 | // Grab the name part | 1760 | // Grab the name part |
1745 | fullName = rawEmail.left(startPos).stripWhiteSpace(); | 1761 | fullName = rawEmail.left(startPos).stripWhiteSpace(); |
1746 | 1762 | ||
1747 | // grab the email part | 1763 | // grab the email part |
1748 | email = rawEmail.mid(startPos+1, endPos-startPos-1).stripWhiteSpace(); | 1764 | email = rawEmail.mid(startPos+1, endPos-startPos-1).stripWhiteSpace(); |
1749 | 1765 | ||
1750 | // Check that we do not have any extra characters on the end of the | 1766 | // Check that we do not have any extra characters on the end of the |
1751 | // strings | 1767 | // strings |
1752 | len = fullName.length(); | 1768 | len = fullName.length(); |
1753 | if (fullName[0]=='"' && fullName[len-1]=='"') | 1769 | if (fullName[0]=='"' && fullName[len-1]=='"') |
1754 | fullName = fullName.mid(1, len-2); | 1770 | fullName = fullName.mid(1, len-2); |
1755 | else if (fullName[0]=='<' && fullName[len-1]=='>') | 1771 | else if (fullName[0]=='<' && fullName[len-1]=='>') |
1756 | fullName = fullName.mid(1, len-2); | 1772 | fullName = fullName.mid(1, len-2); |
1757 | else if (fullName[0]=='(' && fullName[len-1]==')') | 1773 | else if (fullName[0]=='(' && fullName[len-1]==')') |
1758 | fullName = fullName.mid(1, len-2); | 1774 | fullName = fullName.mid(1, len-2); |
1759 | } | 1775 | } |
1760 | } | 1776 | } |
1761 | } | 1777 | } |
1762 | 1778 | ||
1763 | void Addressee::setResource( Resource *resource ) | 1779 | void Addressee::setResource( Resource *resource ) |
1764 | { | 1780 | { |
1765 | detach(); | 1781 | detach(); |
1766 | mData->resource = resource; | 1782 | mData->resource = resource; |
1767 | } | 1783 | } |
1768 | 1784 | ||
1769 | Resource *Addressee::resource() const | 1785 | Resource *Addressee::resource() const |
1770 | { | 1786 | { |
1771 | return mData->resource; | 1787 | return mData->resource; |
1772 | } | 1788 | } |
1773 | 1789 | ||
1774 | //US | 1790 | //US |
1775 | QString Addressee::resourceLabel() | 1791 | QString Addressee::resourceLabel() |
1776 | { | 1792 | { |
1777 | return i18n("Resource"); | 1793 | return i18n("Resource"); |
1778 | } | 1794 | } |
1779 | 1795 | ||
1780 | void Addressee::setChanged( bool value ) | 1796 | void Addressee::setChanged( bool value ) |
1781 | { | 1797 | { |
1782 | detach(); | 1798 | detach(); |
1783 | mData->changed = value; | 1799 | mData->changed = value; |
1784 | } | 1800 | } |
1785 | 1801 | ||
1786 | bool Addressee::changed() const | 1802 | bool Addressee::changed() const |
1787 | { | 1803 | { |
1788 | return mData->changed; | 1804 | return mData->changed; |
1789 | } | 1805 | } |
1790 | 1806 | ||
1791 | QDataStream &KABC::operator<<( QDataStream &s, const Addressee &a ) | 1807 | QDataStream &KABC::operator<<( QDataStream &s, const Addressee &a ) |
1792 | { | 1808 | { |
1793 | if (!a.mData) return s; | 1809 | if (!a.mData) return s; |
1794 | 1810 | ||
1795 | s << a.uid(); | 1811 | s << a.uid(); |
1796 | 1812 | ||
1797 | s << a.mData->name; | 1813 | s << a.mData->name; |
1798 | s << a.mData->formattedName; | 1814 | s << a.mData->formattedName; |
1799 | s << a.mData->familyName; | 1815 | s << a.mData->familyName; |
1800 | s << a.mData->givenName; | 1816 | s << a.mData->givenName; |
1801 | s << a.mData->additionalName; | 1817 | s << a.mData->additionalName; |
1802 | s << a.mData->prefix; | 1818 | s << a.mData->prefix; |
1803 | s << a.mData->suffix; | 1819 | s << a.mData->suffix; |
1804 | s << a.mData->nickName; | 1820 | s << a.mData->nickName; |
1805 | s << a.mData->birthday; | 1821 | s << a.mData->birthday; |
1806 | s << a.mData->mailer; | 1822 | s << a.mData->mailer; |
1807 | s << a.mData->timeZone; | 1823 | s << a.mData->timeZone; |
1808 | s << a.mData->geo; | 1824 | s << a.mData->geo; |
1809 | s << a.mData->title; | 1825 | s << a.mData->title; |
1810 | s << a.mData->role; | 1826 | s << a.mData->role; |
1811 | s << a.mData->organization; | 1827 | s << a.mData->organization; |
1812 | s << a.mData->note; | 1828 | s << a.mData->note; |
1813 | s << a.mData->productId; | 1829 | s << a.mData->productId; |
1814 | s << a.mData->revision; | 1830 | s << a.mData->revision; |
1815 | s << a.mData->sortString; | 1831 | s << a.mData->sortString; |
1816 | s << a.mData->url; | 1832 | s << a.mData->url; |
1817 | s << a.mData->secrecy; | 1833 | s << a.mData->secrecy; |
1818 | s << a.mData->logo; | 1834 | s << a.mData->logo; |
1819 | s << a.mData->photo; | 1835 | s << a.mData->photo; |
1820 | s << a.mData->sound; | 1836 | s << a.mData->sound; |
1821 | s << a.mData->agent; | 1837 | s << a.mData->agent; |
1822 | s << a.mData->phoneNumbers; | 1838 | s << a.mData->phoneNumbers; |
1823 | s << a.mData->addresses; | 1839 | s << a.mData->addresses; |
1824 | s << a.mData->emails; | 1840 | s << a.mData->emails; |
1825 | s << a.mData->categories; | 1841 | s << a.mData->categories; |
1826 | s << a.mData->custom; | 1842 | s << a.mData->custom; |
1827 | s << a.mData->keys; | 1843 | s << a.mData->keys; |
1828 | return s; | 1844 | return s; |
1829 | } | 1845 | } |
1830 | 1846 | ||
1831 | QDataStream &KABC::operator>>( QDataStream &s, Addressee &a ) | 1847 | QDataStream &KABC::operator>>( QDataStream &s, Addressee &a ) |
1832 | { | 1848 | { |
1833 | if (!a.mData) return s; | 1849 | if (!a.mData) return s; |
1834 | 1850 | ||
1835 | s >> a.mData->uid; | 1851 | s >> a.mData->uid; |
1836 | 1852 | ||
1837 | s >> a.mData->name; | 1853 | s >> a.mData->name; |
1838 | s >> a.mData->formattedName; | 1854 | s >> a.mData->formattedName; |
1839 | s >> a.mData->familyName; | 1855 | s >> a.mData->familyName; |
1840 | s >> a.mData->givenName; | 1856 | s >> a.mData->givenName; |
1841 | s >> a.mData->additionalName; | 1857 | s >> a.mData->additionalName; |
1842 | s >> a.mData->prefix; | 1858 | s >> a.mData->prefix; |
1843 | s >> a.mData->suffix; | 1859 | s >> a.mData->suffix; |
1844 | s >> a.mData->nickName; | 1860 | s >> a.mData->nickName; |
1845 | s >> a.mData->birthday; | 1861 | s >> a.mData->birthday; |
1846 | s >> a.mData->mailer; | 1862 | s >> a.mData->mailer; |
1847 | s >> a.mData->timeZone; | 1863 | s >> a.mData->timeZone; |
1848 | s >> a.mData->geo; | 1864 | s >> a.mData->geo; |
1849 | s >> a.mData->title; | 1865 | s >> a.mData->title; |
1850 | s >> a.mData->role; | 1866 | s >> a.mData->role; |
1851 | s >> a.mData->organization; | 1867 | s >> a.mData->organization; |
1852 | s >> a.mData->note; | 1868 | s >> a.mData->note; |
1853 | s >> a.mData->productId; | 1869 | s >> a.mData->productId; |
1854 | s >> a.mData->revision; | 1870 | s >> a.mData->revision; |
1855 | s >> a.mData->sortString; | 1871 | s >> a.mData->sortString; |
1856 | s >> a.mData->url; | 1872 | s >> a.mData->url; |
1857 | s >> a.mData->secrecy; | 1873 | s >> a.mData->secrecy; |
1858 | s >> a.mData->logo; | 1874 | s >> a.mData->logo; |
1859 | s >> a.mData->photo; | 1875 | s >> a.mData->photo; |
1860 | s >> a.mData->sound; | 1876 | s >> a.mData->sound; |
1861 | s >> a.mData->agent; | 1877 | s >> a.mData->agent; |
1862 | s >> a.mData->phoneNumbers; | 1878 | s >> a.mData->phoneNumbers; |
1863 | s >> a.mData->addresses; | 1879 | s >> a.mData->addresses; |
1864 | s >> a.mData->emails; | 1880 | s >> a.mData->emails; |
1865 | s >> a.mData->categories; | 1881 | s >> a.mData->categories; |
1866 | s >> a.mData->custom; | 1882 | s >> a.mData->custom; |
1867 | s >> a.mData->keys; | 1883 | s >> a.mData->keys; |
1868 | 1884 | ||
1869 | a.mData->empty = false; | 1885 | a.mData->empty = false; |
1870 | 1886 | ||
1871 | return s; | 1887 | return s; |
1872 | } | 1888 | } |
1873 | bool matchBinaryPattern( int value, int pattern ) | 1889 | bool matchBinaryPattern( int value, int pattern ) |
1874 | { | 1890 | { |
1875 | /** | 1891 | /** |
1876 | We want to match all telephonnumbers/addresses which have the bits in the | 1892 | We want to match all telephonnumbers/addresses which have the bits in the |
1877 | pattern set. More are allowed. | 1893 | pattern set. More are allowed. |
1878 | if pattern == 0 we have a special handling, then we want only those with | 1894 | if pattern == 0 we have a special handling, then we want only those with |
1879 | exactly no bit set. | 1895 | exactly no bit set. |
1880 | */ | 1896 | */ |
1881 | if ( pattern == 0 ) | 1897 | if ( pattern == 0 ) |
1882 | return ( value == 0 ); | 1898 | return ( value == 0 ); |
1883 | else | 1899 | else |
1884 | return ( pattern == ( pattern & value ) ); | 1900 | return ( pattern == ( pattern & value ) ); |
1885 | } | 1901 | } |
1886 | 1902 | ||
1887 | bool matchBinaryPatternP( int value, int pattern ) | 1903 | bool matchBinaryPatternP( int value, int pattern ) |
1888 | { | 1904 | { |
1889 | 1905 | ||
1890 | if ( pattern == 0 ) | 1906 | if ( pattern == 0 ) |
1891 | return ( value == 0 ); | 1907 | return ( value == 0 ); |
1892 | else | 1908 | else |
1893 | return ( (pattern |PhoneNumber::Pref ) == ( value |PhoneNumber::Pref ) ); | 1909 | return ( (pattern |PhoneNumber::Pref ) == ( value |PhoneNumber::Pref ) ); |
1894 | } | 1910 | } |
1895 | bool matchBinaryPatternA( int value, int pattern ) | 1911 | bool matchBinaryPatternA( int value, int pattern ) |
1896 | { | 1912 | { |
1897 | 1913 | ||
1898 | if ( pattern == 0 ) | 1914 | if ( pattern == 0 ) |
1899 | return ( value == 0 ); | 1915 | return ( value == 0 ); |
1900 | else | 1916 | else |
1901 | return ( (pattern | Address::Pref) == ( value | Address::Pref ) ); | 1917 | return ( (pattern | Address::Pref) == ( value | Address::Pref ) ); |
1902 | } | 1918 | } |
diff --git a/kabc/addressee.h b/kabc/addressee.h index 4cafa86..44f0629 100644 --- a/kabc/addressee.h +++ b/kabc/addressee.h | |||
@@ -1,847 +1,848 @@ | |||
1 | /*** Warning! This file has been generated by the script makeaddressee ***/ | 1 | /*** Warning! This file has been generated by the script makeaddressee ***/ |
2 | /* | 2 | /* |
3 | This file is part of libkabc. | 3 | This file is part of libkabc. |
4 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 4 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
5 | 5 | ||
6 | This library is free software; you can redistribute it and/or | 6 | This library is free software; you can redistribute it and/or |
7 | modify it under the terms of the GNU Library General Public | 7 | modify it under the terms of the GNU Library General Public |
8 | License as published by the Free Software Foundation; either | 8 | License as published by the Free Software Foundation; either |
9 | version 2 of the License, or (at your option) any later version. | 9 | version 2 of the License, or (at your option) any later version. |
10 | 10 | ||
11 | This library is distributed in the hope that it will be useful, | 11 | This library is distributed in the hope that it will be useful, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
14 | Library General Public License for more details. | 14 | Library General Public License for more details. |
15 | 15 | ||
16 | You should have received a copy of the GNU Library General Public License | 16 | You should have received a copy of the GNU Library General Public License |
17 | along with this library; see the file COPYING.LIB. If not, write to | 17 | along with this library; see the file COPYING.LIB. If not, write to |
18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
19 | Boston, MA 02111-1307, USA. | 19 | Boston, MA 02111-1307, USA. |
20 | */ | 20 | */ |
21 | 21 | ||
22 | /* | 22 | /* |
23 | Enhanced Version of the file for platform independent KDE tools. | 23 | Enhanced Version of the file for platform independent KDE tools. |
24 | Copyright (c) 2004 Ulf Schenk | 24 | Copyright (c) 2004 Ulf Schenk |
25 | 25 | ||
26 | $Id$ | 26 | $Id$ |
27 | */ | 27 | */ |
28 | 28 | ||
29 | #ifndef KABC_ADDRESSEE_H | 29 | #ifndef KABC_ADDRESSEE_H |
30 | #define KABC_ADDRESSEE_H | 30 | #define KABC_ADDRESSEE_H |
31 | 31 | ||
32 | #include <qdatetime.h> | 32 | #include <qdatetime.h> |
33 | #include <qstring.h> | 33 | #include <qstring.h> |
34 | #include <qstringlist.h> | 34 | #include <qstringlist.h> |
35 | #include <qvaluelist.h> | 35 | #include <qvaluelist.h> |
36 | 36 | ||
37 | #include <ksharedptr.h> | 37 | #include <ksharedptr.h> |
38 | #include <kurl.h> | 38 | #include <kurl.h> |
39 | 39 | ||
40 | #include "address.h" | 40 | #include "address.h" |
41 | #include "agent.h" | 41 | #include "agent.h" |
42 | #include "geo.h" | 42 | #include "geo.h" |
43 | #include "key.h" | 43 | #include "key.h" |
44 | #include "phonenumber.h" | 44 | #include "phonenumber.h" |
45 | #include "picture.h" | 45 | #include "picture.h" |
46 | #include "secrecy.h" | 46 | #include "secrecy.h" |
47 | #include "sound.h" | 47 | #include "sound.h" |
48 | #include "timezone.h" | 48 | #include "timezone.h" |
49 | 49 | ||
50 | namespace KABC { | 50 | namespace KABC { |
51 | 51 | ||
52 | class Resource; | 52 | class Resource; |
53 | 53 | ||
54 | /** | 54 | /** |
55 | @short address book entry | 55 | @short address book entry |
56 | 56 | ||
57 | This class represents an entry in the address book. | 57 | This class represents an entry in the address book. |
58 | 58 | ||
59 | The data of this class is implicitly shared. You can pass this class by value. | 59 | The data of this class is implicitly shared. You can pass this class by value. |
60 | 60 | ||
61 | If you need the name of a field for presenting it to the user you should use | 61 | If you need the name of a field for presenting it to the user you should use |
62 | the functions ending in Label(). They return a translated string which can be | 62 | the functions ending in Label(). They return a translated string which can be |
63 | used as label for the corresponding field. | 63 | used as label for the corresponding field. |
64 | 64 | ||
65 | About the name fields: | 65 | About the name fields: |
66 | 66 | ||
67 | givenName() is the first name and familyName() the last name. In some | 67 | givenName() is the first name and familyName() the last name. In some |
68 | countries the family name comes first, that's the reason for the | 68 | countries the family name comes first, that's the reason for the |
69 | naming. formattedName() is the full name with the correct formatting. | 69 | naming. formattedName() is the full name with the correct formatting. |
70 | It is used as an override, when the correct formatting can't be generated | 70 | It is used as an override, when the correct formatting can't be generated |
71 | from the other name fields automatically. | 71 | from the other name fields automatically. |
72 | 72 | ||
73 | realName() returns a fully formatted name(). It uses formattedName, if set, | 73 | realName() returns a fully formatted name(). It uses formattedName, if set, |
74 | otherwise it constucts the name from the name fields. As fallback, if | 74 | otherwise it constucts the name from the name fields. As fallback, if |
75 | nothing else is set it uses name(). | 75 | nothing else is set it uses name(). |
76 | 76 | ||
77 | name() is the NAME type of RFC2426. It can be used as internal name for the | 77 | name() is the NAME type of RFC2426. It can be used as internal name for the |
78 | data enty, but shouldn't be used for displaying the data to the user. | 78 | data enty, but shouldn't be used for displaying the data to the user. |
79 | */ | 79 | */ |
80 | class Addressee | 80 | class Addressee |
81 | { | 81 | { |
82 | friend QDataStream &operator<<( QDataStream &, const Addressee & ); | 82 | friend QDataStream &operator<<( QDataStream &, const Addressee & ); |
83 | friend QDataStream &operator>>( QDataStream &, Addressee & ); | 83 | friend QDataStream &operator>>( QDataStream &, Addressee & ); |
84 | 84 | ||
85 | public: | 85 | public: |
86 | typedef QValueList<Addressee> List; | 86 | typedef QValueList<Addressee> List; |
87 | 87 | ||
88 | /** | 88 | /** |
89 | Construct an empty address book entry. | 89 | Construct an empty address book entry. |
90 | */ | 90 | */ |
91 | Addressee(); | 91 | Addressee(); |
92 | ~Addressee(); | 92 | ~Addressee(); |
93 | 93 | ||
94 | Addressee( const Addressee & ); | 94 | Addressee( const Addressee & ); |
95 | Addressee &operator=( const Addressee & ); | 95 | Addressee &operator=( const Addressee & ); |
96 | 96 | ||
97 | bool operator==( const Addressee & ) const; | 97 | bool operator==( const Addressee & ) const; |
98 | bool operator!=( const Addressee & ) const; | 98 | bool operator!=( const Addressee & ) const; |
99 | // sync stuff | 99 | // sync stuff |
100 | void setTempSyncStat(int id); | 100 | void setTempSyncStat(int id); |
101 | int tempSyncStat() const; | 101 | int tempSyncStat() const; |
102 | void setIDStr( const QString & ); | 102 | void setIDStr( const QString & ); |
103 | QString IDStr() const; | 103 | QString IDStr() const; |
104 | void setID( const QString &, const QString & ); | 104 | void setID( const QString &, const QString & ); |
105 | QString getID( const QString & ); | 105 | QString getID( const QString & ); |
106 | void setCsum( const QString &, const QString & ); | 106 | void setCsum( const QString &, const QString & ); |
107 | QString getCsum( const QString & ); | 107 | QString getCsum( const QString & ); |
108 | void removeID(const QString &); | 108 | void removeID(const QString &); |
109 | void computeCsum(const QString &dev); | 109 | void computeCsum(const QString &dev); |
110 | ulong getCsum4List( const QStringList & attList); | 110 | ulong getCsum4List( const QStringList & attList); |
111 | /** | 111 | /** |
112 | Return, if the address book entry is empty. | 112 | Return, if the address book entry is empty. |
113 | */ | 113 | */ |
114 | bool isEmpty() const; | 114 | bool isEmpty() const; |
115 | void setExternalUID( const QString &id ); | 115 | void setExternalUID( const QString &id ); |
116 | QString externalUID() const; | 116 | QString externalUID() const; |
117 | void setOriginalExternalUID( const QString &id ); | 117 | void setOriginalExternalUID( const QString &id ); |
118 | QString originalExternalUID() const; | 118 | QString originalExternalUID() const; |
119 | void mergeContact( const Addressee& ad ); | 119 | void mergeContact( const Addressee& ad ); |
120 | void simplifyEmails(); | 120 | void simplifyEmails(); |
121 | void simplifyAddresses(); | ||
121 | void simplifyPhoneNumbers(); | 122 | void simplifyPhoneNumbers(); |
122 | void simplifyPhoneNumberTypes(); | 123 | void simplifyPhoneNumberTypes(); |
123 | 124 | ||
124 | /** | 125 | /** |
125 | Set unique identifier. | 126 | Set unique identifier. |
126 | */ | 127 | */ |
127 | void setUid( const QString &uid ); | 128 | void setUid( const QString &uid ); |
128 | /** | 129 | /** |
129 | Return unique identifier. | 130 | Return unique identifier. |
130 | */ | 131 | */ |
131 | QString uid() const; | 132 | QString uid() const; |
132 | /** | 133 | /** |
133 | Return translated label for uid field. | 134 | Return translated label for uid field. |
134 | */ | 135 | */ |
135 | static QString uidLabel(); | 136 | static QString uidLabel(); |
136 | 137 | ||
137 | /** | 138 | /** |
138 | Set name. | 139 | Set name. |
139 | */ | 140 | */ |
140 | void setName( const QString &name ); | 141 | void setName( const QString &name ); |
141 | /** | 142 | /** |
142 | Return name. | 143 | Return name. |
143 | */ | 144 | */ |
144 | QString name() const; | 145 | QString name() const; |
145 | /** | 146 | /** |
146 | Return translated label for name field. | 147 | Return translated label for name field. |
147 | */ | 148 | */ |
148 | static QString nameLabel(); | 149 | static QString nameLabel(); |
149 | 150 | ||
150 | /** | 151 | /** |
151 | Set formatted name. | 152 | Set formatted name. |
152 | */ | 153 | */ |
153 | void setFormattedName( const QString &formattedName ); | 154 | void setFormattedName( const QString &formattedName ); |
154 | /** | 155 | /** |
155 | Return formatted name. | 156 | Return formatted name. |
156 | */ | 157 | */ |
157 | QString formattedName() const; | 158 | QString formattedName() const; |
158 | /** | 159 | /** |
159 | Return translated label for formattedName field. | 160 | Return translated label for formattedName field. |
160 | */ | 161 | */ |
161 | static QString formattedNameLabel(); | 162 | static QString formattedNameLabel(); |
162 | 163 | ||
163 | /** | 164 | /** |
164 | Set family name. | 165 | Set family name. |
165 | */ | 166 | */ |
166 | void setFamilyName( const QString &familyName ); | 167 | void setFamilyName( const QString &familyName ); |
167 | /** | 168 | /** |
168 | Return family name. | 169 | Return family name. |
169 | */ | 170 | */ |
170 | QString familyName() const; | 171 | QString familyName() const; |
171 | /** | 172 | /** |
172 | Return translated label for familyName field. | 173 | Return translated label for familyName field. |
173 | */ | 174 | */ |
174 | static QString familyNameLabel(); | 175 | static QString familyNameLabel(); |
175 | 176 | ||
176 | /** | 177 | /** |
177 | Set given name. | 178 | Set given name. |
178 | */ | 179 | */ |
179 | void setGivenName( const QString &givenName ); | 180 | void setGivenName( const QString &givenName ); |
180 | /** | 181 | /** |
181 | Return given name. | 182 | Return given name. |
182 | */ | 183 | */ |
183 | QString givenName() const; | 184 | QString givenName() const; |
184 | /** | 185 | /** |
185 | Return translated label for givenName field. | 186 | Return translated label for givenName field. |
186 | */ | 187 | */ |
187 | static QString givenNameLabel(); | 188 | static QString givenNameLabel(); |
188 | 189 | ||
189 | /** | 190 | /** |
190 | Set additional names. | 191 | Set additional names. |
191 | */ | 192 | */ |
192 | void setAdditionalName( const QString &additionalName ); | 193 | void setAdditionalName( const QString &additionalName ); |
193 | /** | 194 | /** |
194 | Return additional names. | 195 | Return additional names. |
195 | */ | 196 | */ |
196 | QString additionalName() const; | 197 | QString additionalName() const; |
197 | /** | 198 | /** |
198 | Return translated label for additionalName field. | 199 | Return translated label for additionalName field. |
199 | */ | 200 | */ |
200 | static QString additionalNameLabel(); | 201 | static QString additionalNameLabel(); |
201 | 202 | ||
202 | /** | 203 | /** |
203 | Set honorific prefixes. | 204 | Set honorific prefixes. |
204 | */ | 205 | */ |
205 | void setPrefix( const QString &prefix ); | 206 | void setPrefix( const QString &prefix ); |
206 | /** | 207 | /** |
207 | Return honorific prefixes. | 208 | Return honorific prefixes. |
208 | */ | 209 | */ |
209 | QString prefix() const; | 210 | QString prefix() const; |
210 | /** | 211 | /** |
211 | Return translated label for prefix field. | 212 | Return translated label for prefix field. |
212 | */ | 213 | */ |
213 | static QString prefixLabel(); | 214 | static QString prefixLabel(); |
214 | 215 | ||
215 | /** | 216 | /** |
216 | Set honorific suffixes. | 217 | Set honorific suffixes. |
217 | */ | 218 | */ |
218 | void setSuffix( const QString &suffix ); | 219 | void setSuffix( const QString &suffix ); |
219 | /** | 220 | /** |
220 | Return honorific suffixes. | 221 | Return honorific suffixes. |
221 | */ | 222 | */ |
222 | QString suffix() const; | 223 | QString suffix() const; |
223 | /** | 224 | /** |
224 | Return translated label for suffix field. | 225 | Return translated label for suffix field. |
225 | */ | 226 | */ |
226 | static QString suffixLabel(); | 227 | static QString suffixLabel(); |
227 | 228 | ||
228 | /** | 229 | /** |
229 | Set nick name. | 230 | Set nick name. |
230 | */ | 231 | */ |
231 | void setNickName( const QString &nickName ); | 232 | void setNickName( const QString &nickName ); |
232 | /** | 233 | /** |
233 | Return nick name. | 234 | Return nick name. |
234 | */ | 235 | */ |
235 | QString nickName() const; | 236 | QString nickName() const; |
236 | /** | 237 | /** |
237 | Return translated label for nickName field. | 238 | Return translated label for nickName field. |
238 | */ | 239 | */ |
239 | static QString nickNameLabel(); | 240 | static QString nickNameLabel(); |
240 | 241 | ||
241 | /** | 242 | /** |
242 | Set birthday. | 243 | Set birthday. |
243 | */ | 244 | */ |
244 | void setBirthday( const QDateTime &birthday ); | 245 | void setBirthday( const QDateTime &birthday ); |
245 | /** | 246 | /** |
246 | Return birthday. | 247 | Return birthday. |
247 | */ | 248 | */ |
248 | QDateTime birthday() const; | 249 | QDateTime birthday() const; |
249 | /** | 250 | /** |
250 | Return translated label for birthday field. | 251 | Return translated label for birthday field. |
251 | */ | 252 | */ |
252 | static QString birthdayLabel(); | 253 | static QString birthdayLabel(); |
253 | 254 | ||
254 | /** | 255 | /** |
255 | Return translated label for homeAddressStreet field. | 256 | Return translated label for homeAddressStreet field. |
256 | */ | 257 | */ |
257 | static QString homeAddressStreetLabel(); | 258 | static QString homeAddressStreetLabel(); |
258 | 259 | ||
259 | /** | 260 | /** |
260 | Return translated label for homeAddressLocality field. | 261 | Return translated label for homeAddressLocality field. |
261 | */ | 262 | */ |
262 | static QString homeAddressLocalityLabel(); | 263 | static QString homeAddressLocalityLabel(); |
263 | 264 | ||
264 | /** | 265 | /** |
265 | Return translated label for homeAddressRegion field. | 266 | Return translated label for homeAddressRegion field. |
266 | */ | 267 | */ |
267 | static QString homeAddressRegionLabel(); | 268 | static QString homeAddressRegionLabel(); |
268 | 269 | ||
269 | /** | 270 | /** |
270 | Return translated label for homeAddressPostalCode field. | 271 | Return translated label for homeAddressPostalCode field. |
271 | */ | 272 | */ |
272 | static QString homeAddressPostalCodeLabel(); | 273 | static QString homeAddressPostalCodeLabel(); |
273 | 274 | ||
274 | /** | 275 | /** |
275 | Return translated label for homeAddressCountry field. | 276 | Return translated label for homeAddressCountry field. |
276 | */ | 277 | */ |
277 | static QString homeAddressCountryLabel(); | 278 | static QString homeAddressCountryLabel(); |
278 | 279 | ||
279 | /** | 280 | /** |
280 | Return translated label for homeAddressLabel field. | 281 | Return translated label for homeAddressLabel field. |
281 | */ | 282 | */ |
282 | static QString homeAddressLabelLabel(); | 283 | static QString homeAddressLabelLabel(); |
283 | 284 | ||
284 | /** | 285 | /** |
285 | Return translated label for businessAddressStreet field. | 286 | Return translated label for businessAddressStreet field. |
286 | */ | 287 | */ |
287 | static QString businessAddressStreetLabel(); | 288 | static QString businessAddressStreetLabel(); |
288 | 289 | ||
289 | /** | 290 | /** |
290 | Return translated label for businessAddressLocality field. | 291 | Return translated label for businessAddressLocality field. |
291 | */ | 292 | */ |
292 | static QString businessAddressLocalityLabel(); | 293 | static QString businessAddressLocalityLabel(); |
293 | 294 | ||
294 | /** | 295 | /** |
295 | Return translated label for businessAddressRegion field. | 296 | Return translated label for businessAddressRegion field. |
296 | */ | 297 | */ |
297 | static QString businessAddressRegionLabel(); | 298 | static QString businessAddressRegionLabel(); |
298 | 299 | ||
299 | /** | 300 | /** |
300 | Return translated label for businessAddressPostalCode field. | 301 | Return translated label for businessAddressPostalCode field. |
301 | */ | 302 | */ |
302 | static QString businessAddressPostalCodeLabel(); | 303 | static QString businessAddressPostalCodeLabel(); |
303 | 304 | ||
304 | /** | 305 | /** |
305 | Return translated label for businessAddressCountry field. | 306 | Return translated label for businessAddressCountry field. |
306 | */ | 307 | */ |
307 | static QString businessAddressCountryLabel(); | 308 | static QString businessAddressCountryLabel(); |
308 | 309 | ||
309 | /** | 310 | /** |
310 | Return translated label for businessAddressLabel field. | 311 | Return translated label for businessAddressLabel field. |
311 | */ | 312 | */ |
312 | static QString businessAddressLabelLabel(); | 313 | static QString businessAddressLabelLabel(); |
313 | 314 | ||
314 | /** | 315 | /** |
315 | Return translated label for homePhone field. | 316 | Return translated label for homePhone field. |
316 | */ | 317 | */ |
317 | static QString homePhoneLabel(); | 318 | static QString homePhoneLabel(); |
318 | 319 | ||
319 | /** | 320 | /** |
320 | Return translated label for businessPhone field. | 321 | Return translated label for businessPhone field. |
321 | */ | 322 | */ |
322 | static QString businessPhoneLabel(); | 323 | static QString businessPhoneLabel(); |
323 | 324 | ||
324 | /** | 325 | /** |
325 | Return translated label for mobilePhone field. | 326 | Return translated label for mobilePhone field. |
326 | */ | 327 | */ |
327 | static QString mobilePhoneLabel(); | 328 | static QString mobilePhoneLabel(); |
328 | 329 | ||
329 | /** | 330 | /** |
330 | Return translated label for homeFax field. | 331 | Return translated label for homeFax field. |
331 | */ | 332 | */ |
332 | static QString homeFaxLabel(); | 333 | static QString homeFaxLabel(); |
333 | 334 | ||
334 | /** | 335 | /** |
335 | Return translated label for businessFax field. | 336 | Return translated label for businessFax field. |
336 | */ | 337 | */ |
337 | static QString businessFaxLabel(); | 338 | static QString businessFaxLabel(); |
338 | 339 | ||
339 | /** | 340 | /** |
340 | Return translated label for carPhone field. | 341 | Return translated label for carPhone field. |
341 | */ | 342 | */ |
342 | static QString carPhoneLabel(); | 343 | static QString carPhoneLabel(); |
343 | 344 | ||
344 | /** | 345 | /** |
345 | Return translated label for isdn field. | 346 | Return translated label for isdn field. |
346 | */ | 347 | */ |
347 | static QString isdnLabel(); | 348 | static QString isdnLabel(); |
348 | 349 | ||
349 | /** | 350 | /** |
350 | Return translated label for pager field. | 351 | Return translated label for pager field. |
351 | */ | 352 | */ |
352 | static QString pagerLabel(); | 353 | static QString pagerLabel(); |
353 | 354 | ||
354 | /** | 355 | /** |
355 | Return translated label for sip field. | 356 | Return translated label for sip field. |
356 | */ | 357 | */ |
357 | static QString sipLabel(); | 358 | static QString sipLabel(); |
358 | 359 | ||
359 | /** | 360 | /** |
360 | Return translated label for email field. | 361 | Return translated label for email field. |
361 | */ | 362 | */ |
362 | static QString emailLabel(); | 363 | static QString emailLabel(); |
363 | 364 | ||
364 | /** | 365 | /** |
365 | Set mail client. | 366 | Set mail client. |
366 | */ | 367 | */ |
367 | void setMailer( const QString &mailer ); | 368 | void setMailer( const QString &mailer ); |
368 | /** | 369 | /** |
369 | Return mail client. | 370 | Return mail client. |
370 | */ | 371 | */ |
371 | QString mailer() const; | 372 | QString mailer() const; |
372 | /** | 373 | /** |
373 | Return translated label for mailer field. | 374 | Return translated label for mailer field. |
374 | */ | 375 | */ |
375 | static QString mailerLabel(); | 376 | static QString mailerLabel(); |
376 | 377 | ||
377 | /** | 378 | /** |
378 | Set time zone. | 379 | Set time zone. |
379 | */ | 380 | */ |
380 | void setTimeZone( const TimeZone &timeZone ); | 381 | void setTimeZone( const TimeZone &timeZone ); |
381 | /** | 382 | /** |
382 | Return time zone. | 383 | Return time zone. |
383 | */ | 384 | */ |
384 | TimeZone timeZone() const; | 385 | TimeZone timeZone() const; |
385 | /** | 386 | /** |
386 | Return translated label for timeZone field. | 387 | Return translated label for timeZone field. |
387 | */ | 388 | */ |
388 | static QString timeZoneLabel(); | 389 | static QString timeZoneLabel(); |
389 | 390 | ||
390 | /** | 391 | /** |
391 | Set geographic position. | 392 | Set geographic position. |
392 | */ | 393 | */ |
393 | void setGeo( const Geo &geo ); | 394 | void setGeo( const Geo &geo ); |
394 | /** | 395 | /** |
395 | Return geographic position. | 396 | Return geographic position. |
396 | */ | 397 | */ |
397 | Geo geo() const; | 398 | Geo geo() const; |
398 | /** | 399 | /** |
399 | Return translated label for geo field. | 400 | Return translated label for geo field. |
400 | */ | 401 | */ |
401 | static QString geoLabel(); | 402 | static QString geoLabel(); |
402 | 403 | ||
403 | /** | 404 | /** |
404 | Set title. | 405 | Set title. |
405 | */ | 406 | */ |
406 | void setTitle( const QString &title ); | 407 | void setTitle( const QString &title ); |
407 | /** | 408 | /** |
408 | Return title. | 409 | Return title. |
409 | */ | 410 | */ |
410 | QString title() const; | 411 | QString title() const; |
411 | /** | 412 | /** |
412 | Return translated label for title field. | 413 | Return translated label for title field. |
413 | */ | 414 | */ |
414 | static QString titleLabel(); | 415 | static QString titleLabel(); |
415 | 416 | ||
416 | /** | 417 | /** |
417 | Set role. | 418 | Set role. |
418 | */ | 419 | */ |
419 | void setRole( const QString &role ); | 420 | void setRole( const QString &role ); |
420 | /** | 421 | /** |
421 | Return role. | 422 | Return role. |
422 | */ | 423 | */ |
423 | QString role() const; | 424 | QString role() const; |
424 | /** | 425 | /** |
425 | Return translated label for role field. | 426 | Return translated label for role field. |
426 | */ | 427 | */ |
427 | static QString roleLabel(); | 428 | static QString roleLabel(); |
428 | 429 | ||
429 | /** | 430 | /** |
430 | Set organization. | 431 | Set organization. |
431 | */ | 432 | */ |
432 | void setOrganization( const QString &organization ); | 433 | void setOrganization( const QString &organization ); |
433 | /** | 434 | /** |
434 | Return organization. | 435 | Return organization. |
435 | */ | 436 | */ |
436 | QString organization() const; | 437 | QString organization() const; |
437 | /** | 438 | /** |
438 | Return translated label for organization field. | 439 | Return translated label for organization field. |
439 | */ | 440 | */ |
440 | static QString organizationLabel(); | 441 | static QString organizationLabel(); |
441 | 442 | ||
442 | /** | 443 | /** |
443 | Set note. | 444 | Set note. |
444 | */ | 445 | */ |
445 | void setNote( const QString ¬e ); | 446 | void setNote( const QString ¬e ); |
446 | /** | 447 | /** |
447 | Return note. | 448 | Return note. |
448 | */ | 449 | */ |
449 | QString note() const; | 450 | QString note() const; |
450 | /** | 451 | /** |
451 | Return translated label for note field. | 452 | Return translated label for note field. |
452 | */ | 453 | */ |
453 | static QString noteLabel(); | 454 | static QString noteLabel(); |
454 | 455 | ||
455 | /** | 456 | /** |
456 | Set product identifier. | 457 | Set product identifier. |
457 | */ | 458 | */ |
458 | void setProductId( const QString &productId ); | 459 | void setProductId( const QString &productId ); |
459 | /** | 460 | /** |
460 | Return product identifier. | 461 | Return product identifier. |
461 | */ | 462 | */ |
462 | QString productId() const; | 463 | QString productId() const; |
463 | /** | 464 | /** |
464 | Return translated label for productId field. | 465 | Return translated label for productId field. |
465 | */ | 466 | */ |
466 | static QString productIdLabel(); | 467 | static QString productIdLabel(); |
467 | 468 | ||
468 | /** | 469 | /** |
469 | Set revision date. | 470 | Set revision date. |
470 | */ | 471 | */ |
471 | void setRevision( const QDateTime &revision ); | 472 | void setRevision( const QDateTime &revision ); |
472 | /** | 473 | /** |
473 | Return revision date. | 474 | Return revision date. |
474 | */ | 475 | */ |
475 | QDateTime revision() const; | 476 | QDateTime revision() const; |
476 | /** | 477 | /** |
477 | Return translated label for revision field. | 478 | Return translated label for revision field. |
478 | */ | 479 | */ |
479 | static QString revisionLabel(); | 480 | static QString revisionLabel(); |
480 | 481 | ||
481 | /** | 482 | /** |
482 | Set sort string. | 483 | Set sort string. |
483 | */ | 484 | */ |
484 | void setSortString( const QString &sortString ); | 485 | void setSortString( const QString &sortString ); |
485 | /** | 486 | /** |
486 | Return sort string. | 487 | Return sort string. |
487 | */ | 488 | */ |
488 | QString sortString() const; | 489 | QString sortString() const; |
489 | /** | 490 | /** |
490 | Return translated label for sortString field. | 491 | Return translated label for sortString field. |
491 | */ | 492 | */ |
492 | static QString sortStringLabel(); | 493 | static QString sortStringLabel(); |
493 | 494 | ||
494 | /** | 495 | /** |
495 | Set URL. | 496 | Set URL. |
496 | */ | 497 | */ |
497 | void setUrl( const KURL &url ); | 498 | void setUrl( const KURL &url ); |
498 | /** | 499 | /** |
499 | Return URL. | 500 | Return URL. |
500 | */ | 501 | */ |
501 | KURL url() const; | 502 | KURL url() const; |
502 | /** | 503 | /** |
503 | Return translated label for url field. | 504 | Return translated label for url field. |
504 | */ | 505 | */ |
505 | static QString urlLabel(); | 506 | static QString urlLabel(); |
506 | 507 | ||
507 | /** | 508 | /** |
508 | Set security class. | 509 | Set security class. |
509 | */ | 510 | */ |
510 | void setSecrecy( const Secrecy &secrecy ); | 511 | void setSecrecy( const Secrecy &secrecy ); |
511 | /** | 512 | /** |
512 | Return security class. | 513 | Return security class. |
513 | */ | 514 | */ |
514 | Secrecy secrecy() const; | 515 | Secrecy secrecy() const; |
515 | /** | 516 | /** |
516 | Return translated label for secrecy field. | 517 | Return translated label for secrecy field. |
517 | */ | 518 | */ |
518 | static QString secrecyLabel(); | 519 | static QString secrecyLabel(); |
519 | 520 | ||
520 | /** | 521 | /** |
521 | Set logo. | 522 | Set logo. |
522 | */ | 523 | */ |
523 | void setLogo( const Picture &logo ); | 524 | void setLogo( const Picture &logo ); |
524 | /** | 525 | /** |
525 | Return logo. | 526 | Return logo. |
526 | */ | 527 | */ |
527 | Picture logo() const; | 528 | Picture logo() const; |
528 | /** | 529 | /** |
529 | Return translated label for logo field. | 530 | Return translated label for logo field. |
530 | */ | 531 | */ |
531 | static QString logoLabel(); | 532 | static QString logoLabel(); |
532 | 533 | ||
533 | /** | 534 | /** |
534 | Set photo. | 535 | Set photo. |
535 | */ | 536 | */ |
536 | void setPhoto( const Picture &photo ); | 537 | void setPhoto( const Picture &photo ); |
537 | /** | 538 | /** |
538 | Return photo. | 539 | Return photo. |
539 | */ | 540 | */ |
540 | Picture photo() const; | 541 | Picture photo() const; |
541 | /** | 542 | /** |
542 | Return translated label for photo field. | 543 | Return translated label for photo field. |
543 | */ | 544 | */ |
544 | static QString photoLabel(); | 545 | static QString photoLabel(); |
545 | 546 | ||
546 | /** | 547 | /** |
547 | Set sound. | 548 | Set sound. |
548 | */ | 549 | */ |
549 | void setSound( const Sound &sound ); | 550 | void setSound( const Sound &sound ); |
550 | /** | 551 | /** |
551 | Return sound. | 552 | Return sound. |
552 | */ | 553 | */ |
553 | Sound sound() const; | 554 | Sound sound() const; |
554 | /** | 555 | /** |
555 | Return translated label for sound field. | 556 | Return translated label for sound field. |
556 | */ | 557 | */ |
557 | static QString soundLabel(); | 558 | static QString soundLabel(); |
558 | 559 | ||
559 | /** | 560 | /** |
560 | Set agent. | 561 | Set agent. |
561 | */ | 562 | */ |
562 | void setAgent( const Agent &agent ); | 563 | void setAgent( const Agent &agent ); |
563 | /** | 564 | /** |
564 | Return agent. | 565 | Return agent. |
565 | */ | 566 | */ |
566 | Agent agent() const; | 567 | Agent agent() const; |
567 | /** | 568 | /** |
568 | Return translated label for agent field. | 569 | Return translated label for agent field. |
569 | */ | 570 | */ |
570 | static QString agentLabel(); | 571 | static QString agentLabel(); |
571 | 572 | ||
572 | /** | 573 | /** |
573 | Set name fields by parsing the given string and trying to associate the | 574 | Set name fields by parsing the given string and trying to associate the |
574 | parts of the string with according fields. This function should probably | 575 | parts of the string with according fields. This function should probably |
575 | be a bit more clever. | 576 | be a bit more clever. |
576 | */ | 577 | */ |
577 | void setNameFromString( const QString & ); | 578 | void setNameFromString( const QString & ); |
578 | 579 | ||
579 | /** | 580 | /** |
580 | Return the name of the addressee. This is calculated from all the name | 581 | Return the name of the addressee. This is calculated from all the name |
581 | fields. | 582 | fields. |
582 | */ | 583 | */ |
583 | QString realName() const; | 584 | QString realName() const; |
584 | 585 | ||
585 | /** | 586 | /** |
586 | Return the name that consists of all name parts. | 587 | Return the name that consists of all name parts. |
587 | */ | 588 | */ |
588 | QString assembledName() const; | 589 | QString assembledName() const; |
589 | 590 | ||
590 | /** | 591 | /** |
591 | Return email address including real name. | 592 | Return email address including real name. |
592 | 593 | ||
593 | @param email Email address to be used to construct the full email string. | 594 | @param email Email address to be used to construct the full email string. |
594 | If this is QString::null the preferred email address is used. | 595 | If this is QString::null the preferred email address is used. |
595 | */ | 596 | */ |
596 | QString fullEmail( const QString &email=QString::null ) const; | 597 | QString fullEmail( const QString &email=QString::null ) const; |
597 | 598 | ||
598 | /** | 599 | /** |
599 | Insert an email address. If the email address already exists in this | 600 | Insert an email address. If the email address already exists in this |
600 | addressee it is not duplicated. | 601 | addressee it is not duplicated. |
601 | 602 | ||
602 | @param email Email address | 603 | @param email Email address |
603 | @param preferred Set to true, if this is the preferred email address of | 604 | @param preferred Set to true, if this is the preferred email address of |
604 | the addressee. | 605 | the addressee. |
605 | */ | 606 | */ |
606 | void insertEmail( const QString &email, bool preferred=false ); | 607 | void insertEmail( const QString &email, bool preferred=false ); |
607 | 608 | ||
608 | /** | 609 | /** |
609 | Remove email address. If the email address doesn't exist, nothing happens. | 610 | Remove email address. If the email address doesn't exist, nothing happens. |
610 | */ | 611 | */ |
611 | void removeEmail( const QString &email ); | 612 | void removeEmail( const QString &email ); |
612 | 613 | ||
613 | /** | 614 | /** |
614 | Return preferred email address. This is the first email address or the | 615 | Return preferred email address. This is the first email address or the |
615 | last one added with @ref insertEmail() with a set preferred parameter. | 616 | last one added with @ref insertEmail() with a set preferred parameter. |
616 | */ | 617 | */ |
617 | QString preferredEmail() const; | 618 | QString preferredEmail() const; |
618 | 619 | ||
619 | /** | 620 | /** |
620 | Return list of all email addresses. | 621 | Return list of all email addresses. |
621 | */ | 622 | */ |
622 | QStringList emails() const; | 623 | QStringList emails() const; |
623 | 624 | ||
624 | /** | 625 | /** |
625 | Set the emails to @param. | 626 | Set the emails to @param. |
626 | The first email address gets the preferred one! | 627 | The first email address gets the preferred one! |
627 | @param list The list of email addresses. | 628 | @param list The list of email addresses. |
628 | */ | 629 | */ |
629 | void setEmails( const QStringList& list); | 630 | void setEmails( const QStringList& list); |
630 | 631 | ||
631 | /** | 632 | /** |
632 | Insert a phone number. If a phone number with the same id already exists | 633 | Insert a phone number. If a phone number with the same id already exists |
633 | in this addressee it is not duplicated. | 634 | in this addressee it is not duplicated. |
634 | */ | 635 | */ |
635 | void insertPhoneNumber( const PhoneNumber &phoneNumber ); | 636 | void insertPhoneNumber( const PhoneNumber &phoneNumber ); |
636 | 637 | ||
637 | /** | 638 | /** |
638 | Remove phone number. If no phone number with the given id exists for this | 639 | Remove phone number. If no phone number with the given id exists for this |
639 | addresse nothing happens. | 640 | addresse nothing happens. |
640 | */ | 641 | */ |
641 | void removePhoneNumber( const PhoneNumber &phoneNumber ); | 642 | void removePhoneNumber( const PhoneNumber &phoneNumber ); |
642 | 643 | ||
643 | /** | 644 | /** |
644 | Return phone number, which matches the given type. | 645 | Return phone number, which matches the given type. |
645 | */ | 646 | */ |
646 | PhoneNumber phoneNumber( int type ) const; | 647 | PhoneNumber phoneNumber( int type ) const; |
647 | 648 | ||
648 | /** | 649 | /** |
649 | Return list of all phone numbers. | 650 | Return list of all phone numbers. |
650 | */ | 651 | */ |
651 | PhoneNumber::List phoneNumbers() const; | 652 | PhoneNumber::List phoneNumbers() const; |
652 | 653 | ||
653 | /** | 654 | /** |
654 | Return list of phone numbers with a special type. | 655 | Return list of phone numbers with a special type. |
655 | */ | 656 | */ |
656 | PhoneNumber::List phoneNumbers( int type ) const; | 657 | PhoneNumber::List phoneNumbers( int type ) const; |
657 | 658 | ||
658 | /** | 659 | /** |
659 | Return phone number with the given id. | 660 | Return phone number with the given id. |
660 | */ | 661 | */ |
661 | PhoneNumber findPhoneNumber( const QString &id ) const; | 662 | PhoneNumber findPhoneNumber( const QString &id ) const; |
662 | 663 | ||
663 | /** | 664 | /** |
664 | Insert a key. If a key with the same id already exists | 665 | Insert a key. If a key with the same id already exists |
665 | in this addressee it is not duplicated. | 666 | in this addressee it is not duplicated. |
666 | */ | 667 | */ |
667 | void insertKey( const Key &key ); | 668 | void insertKey( const Key &key ); |
668 | 669 | ||
669 | /** | 670 | /** |
670 | Remove a key. If no key with the given id exists for this | 671 | Remove a key. If no key with the given id exists for this |
671 | addresse nothing happens. | 672 | addresse nothing happens. |
672 | */ | 673 | */ |
673 | void removeKey( const Key &key ); | 674 | void removeKey( const Key &key ); |
674 | 675 | ||
675 | /** | 676 | /** |
676 | Return key, which matches the given type. | 677 | Return key, which matches the given type. |
677 | If @p type == Key::Custom you can specify a string | 678 | If @p type == Key::Custom you can specify a string |
678 | that should match. If you leave the string empty, the first | 679 | that should match. If you leave the string empty, the first |
679 | key with a custom value is returned. | 680 | key with a custom value is returned. |
680 | */ | 681 | */ |
681 | Key key( int type, QString customTypeString = QString::null ) const; | 682 | Key key( int type, QString customTypeString = QString::null ) const; |
682 | 683 | ||
683 | /** | 684 | /** |
684 | Return list of all keys. | 685 | Return list of all keys. |
685 | */ | 686 | */ |
686 | Key::List keys() const; | 687 | Key::List keys() const; |
687 | 688 | ||
688 | /** | 689 | /** |
689 | Set the list of keys | 690 | Set the list of keys |
690 | @param keys The keys to be set. | 691 | @param keys The keys to be set. |
691 | */ | 692 | */ |
692 | void setKeys( const Key::List& keys); | 693 | void setKeys( const Key::List& keys); |
693 | 694 | ||
694 | /** | 695 | /** |
695 | Return list of keys with a special type. | 696 | Return list of keys with a special type. |
696 | If @p type == Key::Custom you can specify a string | 697 | If @p type == Key::Custom you can specify a string |
697 | that should match. If you leave the string empty, all custom | 698 | that should match. If you leave the string empty, all custom |
698 | keys will be returned. | 699 | keys will be returned. |
699 | */ | 700 | */ |
700 | Key::List keys( int type, QString customTypeString = QString::null ) const; | 701 | Key::List keys( int type, QString customTypeString = QString::null ) const; |
701 | 702 | ||
702 | /** | 703 | /** |
703 | Return key with the given id. | 704 | Return key with the given id. |
704 | */ | 705 | */ |
705 | Key findKey( const QString &id ) const; | 706 | Key findKey( const QString &id ) const; |
706 | 707 | ||
707 | /** | 708 | /** |
708 | Insert an address. If an address with the same id already exists | 709 | Insert an address. If an address with the same id already exists |
709 | in this addressee it is not duplicated. | 710 | in this addressee it is not duplicated. |
710 | */ | 711 | */ |
711 | void insertAddress( const Address &address ); | 712 | void insertAddress( const Address &address ); |
712 | 713 | ||
713 | /** | 714 | /** |
714 | Remove address. If no address with the given id exists for this | 715 | Remove address. If no address with the given id exists for this |
715 | addresse nothing happens. | 716 | addresse nothing happens. |
716 | */ | 717 | */ |
717 | void removeAddress( const Address &address ); | 718 | void removeAddress( const Address &address ); |
718 | 719 | ||
719 | /** | 720 | /** |
720 | Return address, which matches the given type. | 721 | Return address, which matches the given type. |
721 | */ | 722 | */ |
722 | Address address( int type ) const; | 723 | Address address( int type ) const; |
723 | 724 | ||
724 | /** | 725 | /** |
725 | Return list of all addresses. | 726 | Return list of all addresses. |
726 | */ | 727 | */ |
727 | Address::List addresses() const; | 728 | Address::List addresses() const; |
728 | 729 | ||
729 | /** | 730 | /** |
730 | Return list of addresses with a special type. | 731 | Return list of addresses with a special type. |
731 | */ | 732 | */ |
732 | Address::List addresses( int type ) const; | 733 | Address::List addresses( int type ) const; |
733 | 734 | ||
734 | /** | 735 | /** |
735 | Return address with the given id. | 736 | Return address with the given id. |
736 | */ | 737 | */ |
737 | Address findAddress( const QString &id ) const; | 738 | Address findAddress( const QString &id ) const; |
738 | 739 | ||
739 | /** | 740 | /** |
740 | Insert category. If the category already exists it is not duplicated. | 741 | Insert category. If the category already exists it is not duplicated. |
741 | */ | 742 | */ |
742 | void insertCategory( const QString & ); | 743 | void insertCategory( const QString & ); |
743 | 744 | ||
744 | /** | 745 | /** |
745 | Remove category. | 746 | Remove category. |
746 | */ | 747 | */ |
747 | void removeCategory( const QString & ); | 748 | void removeCategory( const QString & ); |
748 | 749 | ||
749 | /** | 750 | /** |
750 | Return, if addressee has the given category. | 751 | Return, if addressee has the given category. |
751 | */ | 752 | */ |
752 | bool hasCategory( const QString & ) const; | 753 | bool hasCategory( const QString & ) const; |
753 | 754 | ||
754 | /** | 755 | /** |
755 | Set categories to given value. | 756 | Set categories to given value. |
756 | */ | 757 | */ |
757 | void setCategories( const QStringList & ); | 758 | void setCategories( const QStringList & ); |
758 | 759 | ||
759 | /** | 760 | /** |
760 | Return list of all set categories. | 761 | Return list of all set categories. |
761 | */ | 762 | */ |
762 | QStringList categories() const; | 763 | QStringList categories() const; |
763 | 764 | ||
764 | /** | 765 | /** |
765 | Insert custom entry. The entry is identified by the name of the inserting | 766 | Insert custom entry. The entry is identified by the name of the inserting |
766 | application and a unique name. If an entry with the given app and name | 767 | application and a unique name. If an entry with the given app and name |
767 | already exists its value is replaced with the new given value. | 768 | already exists its value is replaced with the new given value. |
768 | */ | 769 | */ |
769 | void insertCustom( const QString &app, const QString &name, | 770 | void insertCustom( const QString &app, const QString &name, |
770 | const QString &value ); | 771 | const QString &value ); |
771 | 772 | ||
772 | /** | 773 | /** |
773 | Remove custom entry. | 774 | Remove custom entry. |
774 | */ | 775 | */ |
775 | void removeCustom( const QString &app, const QString &name ); | 776 | void removeCustom( const QString &app, const QString &name ); |
776 | 777 | ||
777 | /** | 778 | /** |
778 | Return value of custom entry, identified by app and entry name. | 779 | Return value of custom entry, identified by app and entry name. |
779 | */ | 780 | */ |
780 | QString custom( const QString &app, const QString &name ) const; | 781 | QString custom( const QString &app, const QString &name ) const; |
781 | 782 | ||
782 | /** | 783 | /** |
783 | Set all custom entries. | 784 | Set all custom entries. |
784 | */ | 785 | */ |
785 | void setCustoms( const QStringList & ); | 786 | void setCustoms( const QStringList & ); |
786 | 787 | ||
787 | /** | 788 | /** |
788 | Return list of all custom entries. | 789 | Return list of all custom entries. |
789 | */ | 790 | */ |
790 | QStringList customs() const; | 791 | QStringList customs() const; |
791 | 792 | ||
792 | /** | 793 | /** |
793 | Parse full email address. The result is given back in fullName and email. | 794 | Parse full email address. The result is given back in fullName and email. |
794 | */ | 795 | */ |
795 | static void parseEmailAddress( const QString &rawEmail, QString &fullName, | 796 | static void parseEmailAddress( const QString &rawEmail, QString &fullName, |
796 | QString &email ); | 797 | QString &email ); |
797 | 798 | ||
798 | /** | 799 | /** |
799 | Debug output. | 800 | Debug output. |
800 | */ | 801 | */ |
801 | void dump() const; | 802 | void dump() const; |
802 | 803 | ||
803 | /** | 804 | /** |
804 | Returns string representation of the addressee. | 805 | Returns string representation of the addressee. |
805 | */ | 806 | */ |
806 | QString asString() const; | 807 | QString asString() const; |
807 | 808 | ||
808 | /** | 809 | /** |
809 | Set resource where the addressee is from. | 810 | Set resource where the addressee is from. |
810 | */ | 811 | */ |
811 | void setResource( Resource *resource ); | 812 | void setResource( Resource *resource ); |
812 | 813 | ||
813 | /** | 814 | /** |
814 | Return pointer to resource. | 815 | Return pointer to resource. |
815 | */ | 816 | */ |
816 | Resource *resource() const; | 817 | Resource *resource() const; |
817 | 818 | ||
818 | /** | 819 | /** |
819 | Return resourcelabel. | 820 | Return resourcelabel. |
820 | */ | 821 | */ |
821 | //US | 822 | //US |
822 | static QString resourceLabel(); | 823 | static QString resourceLabel(); |
823 | 824 | ||
824 | /** | 825 | /** |
825 | Mark addressee as changed. | 826 | Mark addressee as changed. |
826 | */ | 827 | */ |
827 | void setChanged( bool value ); | 828 | void setChanged( bool value ); |
828 | 829 | ||
829 | /** | 830 | /** |
830 | Return whether the addressee is changed. | 831 | Return whether the addressee is changed. |
831 | */ | 832 | */ |
832 | bool changed() const; | 833 | bool changed() const; |
833 | 834 | ||
834 | private: | 835 | private: |
835 | Addressee copy(); | 836 | Addressee copy(); |
836 | void detach(); | 837 | void detach(); |
837 | 838 | ||
838 | struct AddresseeData; | 839 | struct AddresseeData; |
839 | mutable KSharedPtr<AddresseeData> mData; | 840 | mutable KSharedPtr<AddresseeData> mData; |
840 | }; | 841 | }; |
841 | 842 | ||
842 | QDataStream &operator<<( QDataStream &, const Addressee & ); | 843 | QDataStream &operator<<( QDataStream &, const Addressee & ); |
843 | QDataStream &operator>>( QDataStream &, Addressee & ); | 844 | QDataStream &operator>>( QDataStream &, Addressee & ); |
844 | 845 | ||
845 | } | 846 | } |
846 | 847 | ||
847 | #endif | 848 | #endif |