-rw-r--r-- | kabc/addressee.cpp | 54 |
1 files changed, 53 insertions, 1 deletions
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp index 4cdd5e5..fb32f6e 100644 --- a/kabc/addressee.cpp +++ b/kabc/addressee.cpp | |||
@@ -1,1630 +1,1682 @@ | |||
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 | //US | 36 | //US |
36 | #include <kstandarddirs.h> | 37 | #include <kstandarddirs.h> |
38 | #include <libkcal/syncdefines.h> | ||
37 | 39 | ||
38 | //US #include "resource.h" | 40 | //US #include "resource.h" |
39 | #include "addressee.h" | 41 | #include "addressee.h" |
40 | 42 | ||
41 | using namespace KABC; | 43 | using namespace KABC; |
42 | 44 | ||
43 | static bool matchBinaryPattern( int value, int pattern ); | 45 | static bool matchBinaryPattern( int value, int pattern ); |
44 | 46 | ||
45 | struct Addressee::AddresseeData : public KShared | 47 | struct Addressee::AddresseeData : public KShared |
46 | { | 48 | { |
47 | QString uid; | 49 | QString uid; |
48 | QString name; | 50 | QString name; |
49 | QString formattedName; | 51 | QString formattedName; |
50 | QString familyName; | 52 | QString familyName; |
51 | QString givenName; | 53 | QString givenName; |
52 | QString additionalName; | 54 | QString additionalName; |
53 | QString prefix; | 55 | QString prefix; |
54 | QString suffix; | 56 | QString suffix; |
55 | QString nickName; | 57 | QString nickName; |
56 | QDateTime birthday; | 58 | QDateTime birthday; |
57 | QString mailer; | 59 | QString mailer; |
58 | TimeZone timeZone; | 60 | TimeZone timeZone; |
59 | Geo geo; | 61 | Geo geo; |
60 | QString title; | 62 | QString title; |
61 | QString role; | 63 | QString role; |
62 | QString organization; | 64 | QString organization; |
63 | QString note; | 65 | QString note; |
64 | QString productId; | 66 | QString productId; |
65 | QDateTime revision; | 67 | QDateTime revision; |
66 | QString sortString; | 68 | QString sortString; |
67 | KURL url; | 69 | KURL url; |
68 | Secrecy secrecy; | 70 | Secrecy secrecy; |
69 | Picture logo; | 71 | Picture logo; |
70 | Picture photo; | 72 | Picture photo; |
71 | Sound sound; | 73 | Sound sound; |
72 | Agent agent; | 74 | Agent agent; |
73 | 75 | QString mExternalId; | |
74 | PhoneNumber::List phoneNumbers; | 76 | PhoneNumber::List phoneNumbers; |
75 | Address::List addresses; | 77 | Address::List addresses; |
76 | Key::List keys; | 78 | Key::List keys; |
77 | QStringList emails; | 79 | QStringList emails; |
78 | QStringList categories; | 80 | QStringList categories; |
79 | QStringList custom; | 81 | QStringList custom; |
80 | 82 | ||
81 | Resource *resource; | 83 | Resource *resource; |
82 | 84 | ||
83 | bool empty :1; | 85 | bool empty :1; |
84 | bool changed :1; | 86 | bool changed :1; |
85 | }; | 87 | }; |
86 | 88 | ||
87 | Addressee::Addressee() | 89 | Addressee::Addressee() |
88 | { | 90 | { |
89 | mData = new AddresseeData; | 91 | mData = new AddresseeData; |
90 | mData->empty = true; | 92 | mData->empty = true; |
91 | mData->changed = false; | 93 | mData->changed = false; |
92 | mData->resource = 0; | 94 | mData->resource = 0; |
95 | mData->mExternalId = ":"; | ||
96 | mTempSyncStat = SYNC_TEMPSTATE_INITIAL; | ||
93 | } | 97 | } |
94 | 98 | ||
95 | Addressee::~Addressee() | 99 | Addressee::~Addressee() |
96 | { | 100 | { |
97 | } | 101 | } |
98 | 102 | ||
99 | Addressee::Addressee( const Addressee &a ) | 103 | Addressee::Addressee( const Addressee &a ) |
100 | { | 104 | { |
101 | mData = a.mData; | 105 | mData = a.mData; |
106 | mTempSyncStat = SYNC_TEMPSTATE_INITIAL; | ||
102 | } | 107 | } |
103 | 108 | ||
104 | Addressee &Addressee::operator=( const Addressee &a ) | 109 | Addressee &Addressee::operator=( const Addressee &a ) |
105 | { | 110 | { |
106 | mData = a.mData; | 111 | mData = a.mData; |
107 | return (*this); | 112 | return (*this); |
108 | } | 113 | } |
109 | 114 | ||
110 | Addressee Addressee::copy() | 115 | Addressee Addressee::copy() |
111 | { | 116 | { |
112 | Addressee a; | 117 | Addressee a; |
113 | *(a.mData) = *mData; | 118 | *(a.mData) = *mData; |
114 | return a; | 119 | return a; |
115 | } | 120 | } |
116 | 121 | ||
117 | void Addressee::detach() | 122 | void Addressee::detach() |
118 | { | 123 | { |
119 | if ( mData.count() == 1 ) return; | 124 | if ( mData.count() == 1 ) return; |
120 | *this = copy(); | 125 | *this = copy(); |
121 | } | 126 | } |
122 | 127 | ||
123 | bool Addressee::operator==( const Addressee &a ) const | 128 | bool Addressee::operator==( const Addressee &a ) const |
124 | { | 129 | { |
125 | if ( uid() != a.uid() ) return false; | 130 | if ( uid() != a.uid() ) return false; |
126 | if ( mData->name != a.mData->name ) return false; | 131 | if ( mData->name != a.mData->name ) return false; |
127 | if ( mData->formattedName != a.mData->formattedName ) return false; | 132 | if ( mData->formattedName != a.mData->formattedName ) return false; |
128 | if ( mData->familyName != a.mData->familyName ) return false; | 133 | if ( mData->familyName != a.mData->familyName ) return false; |
129 | if ( mData->givenName != a.mData->givenName ) return false; | 134 | if ( mData->givenName != a.mData->givenName ) return false; |
130 | if ( mData->additionalName != a.mData->additionalName ) return false; | 135 | if ( mData->additionalName != a.mData->additionalName ) return false; |
131 | if ( mData->prefix != a.mData->prefix ) return false; | 136 | if ( mData->prefix != a.mData->prefix ) return false; |
132 | if ( mData->suffix != a.mData->suffix ) return false; | 137 | if ( mData->suffix != a.mData->suffix ) return false; |
133 | if ( mData->nickName != a.mData->nickName ) return false; | 138 | if ( mData->nickName != a.mData->nickName ) return false; |
134 | if ( mData->birthday != a.mData->birthday ) return false; | 139 | if ( mData->birthday != a.mData->birthday ) return false; |
135 | if ( mData->mailer != a.mData->mailer ) return false; | 140 | if ( mData->mailer != a.mData->mailer ) return false; |
136 | if ( mData->timeZone != a.mData->timeZone ) return false; | 141 | if ( mData->timeZone != a.mData->timeZone ) return false; |
137 | if ( mData->geo != a.mData->geo ) return false; | 142 | if ( mData->geo != a.mData->geo ) return false; |
138 | if ( mData->title != a.mData->title ) return false; | 143 | if ( mData->title != a.mData->title ) return false; |
139 | if ( mData->role != a.mData->role ) return false; | 144 | if ( mData->role != a.mData->role ) return false; |
140 | if ( mData->organization != a.mData->organization ) return false; | 145 | if ( mData->organization != a.mData->organization ) return false; |
141 | if ( mData->note != a.mData->note ) return false; | 146 | if ( mData->note != a.mData->note ) return false; |
142 | if ( mData->productId != a.mData->productId ) return false; | 147 | if ( mData->productId != a.mData->productId ) return false; |
143 | if ( mData->revision != a.mData->revision ) return false; | 148 | if ( mData->revision != a.mData->revision ) return false; |
144 | if ( mData->sortString != a.mData->sortString ) return false; | 149 | if ( mData->sortString != a.mData->sortString ) return false; |
145 | if ( mData->secrecy != a.mData->secrecy ) return false; | 150 | if ( mData->secrecy != a.mData->secrecy ) return false; |
146 | if ( mData->logo != a.mData->logo ) return false; | 151 | if ( mData->logo != a.mData->logo ) return false; |
147 | if ( mData->photo != a.mData->photo ) return false; | 152 | if ( mData->photo != a.mData->photo ) return false; |
148 | if ( mData->sound != a.mData->sound ) return false; | 153 | if ( mData->sound != a.mData->sound ) return false; |
149 | if ( mData->agent != a.mData->agent ) return false; | 154 | if ( mData->agent != a.mData->agent ) return false; |
150 | if ( ( mData->url.isValid() || a.mData->url.isValid() ) && | 155 | if ( ( mData->url.isValid() || a.mData->url.isValid() ) && |
151 | ( mData->url != a.mData->url ) ) return false; | 156 | ( mData->url != a.mData->url ) ) return false; |
152 | if ( mData->phoneNumbers != a.mData->phoneNumbers ) return false; | 157 | if ( mData->phoneNumbers != a.mData->phoneNumbers ) return false; |
153 | if ( mData->addresses != a.mData->addresses ) return false; | 158 | if ( mData->addresses != a.mData->addresses ) return false; |
154 | if ( mData->keys != a.mData->keys ) return false; | 159 | if ( mData->keys != a.mData->keys ) return false; |
155 | if ( mData->emails != a.mData->emails ) return false; | 160 | if ( mData->emails != a.mData->emails ) return false; |
156 | if ( mData->categories != a.mData->categories ) return false; | 161 | if ( mData->categories != a.mData->categories ) return false; |
157 | if ( mData->custom != a.mData->custom ) return false; | 162 | if ( mData->custom != a.mData->custom ) return false; |
158 | 163 | ||
159 | return true; | 164 | return true; |
160 | } | 165 | } |
161 | 166 | ||
162 | bool Addressee::operator!=( const Addressee &a ) const | 167 | bool Addressee::operator!=( const Addressee &a ) const |
163 | { | 168 | { |
164 | return !( a == *this ); | 169 | return !( a == *this ); |
165 | } | 170 | } |
166 | 171 | ||
167 | bool Addressee::isEmpty() const | 172 | bool Addressee::isEmpty() const |
168 | { | 173 | { |
169 | return mData->empty; | 174 | return mData->empty; |
170 | } | 175 | } |
176 | void Addressee::removeID(const QString &prof) | ||
177 | { | ||
178 | detach(); | ||
179 | mData->mExternalId = KIdManager::removeId ( mData->mExternalId, prof); | ||
180 | |||
181 | } | ||
182 | void Addressee::setID( const QString & prof , const QString & id ) | ||
183 | { | ||
184 | detach(); | ||
185 | mData->mExternalId = KIdManager::setId ( mData->mExternalId, prof, id ); | ||
186 | } | ||
187 | void Addressee::setTempSyncStat( int id ) | ||
188 | { | ||
189 | mTempSyncStat = id; | ||
190 | } | ||
191 | int Addressee::tempSyncStat() const | ||
192 | { | ||
193 | return mTempSyncStat; | ||
194 | } | ||
195 | |||
196 | QString Addressee::getID( const QString & prof) | ||
197 | { | ||
198 | return KIdManager::getId ( mData->mExternalId, prof ); | ||
199 | } | ||
200 | |||
201 | void Addressee::setCsum( const QString & prof , const QString & id ) | ||
202 | { | ||
203 | detach(); | ||
204 | mData->mExternalId = KIdManager::setCsum ( mData->mExternalId, prof, id ); | ||
205 | } | ||
206 | |||
207 | QString Addressee::getCsum( const QString & prof) | ||
208 | { | ||
209 | return KIdManager::getCsum ( mData->mExternalId, prof ); | ||
210 | } | ||
211 | |||
212 | void Addressee::setIDStr( const QString & s ) | ||
213 | { | ||
214 | detach(); | ||
215 | mData->mExternalId = s; | ||
216 | } | ||
217 | |||
218 | QString Addressee::IDStr() const | ||
219 | { | ||
220 | return mData->mExternalId; | ||
221 | } | ||
222 | |||
171 | 223 | ||
172 | void Addressee::setUid( const QString &id ) | 224 | void Addressee::setUid( const QString &id ) |
173 | { | 225 | { |
174 | if ( id == mData->uid ) return; | 226 | if ( id == mData->uid ) return; |
175 | detach(); | 227 | detach(); |
176 | mData->empty = false; | 228 | mData->empty = false; |
177 | mData->uid = id; | 229 | mData->uid = id; |
178 | } | 230 | } |
179 | 231 | ||
180 | QString Addressee::uid() const | 232 | QString Addressee::uid() const |
181 | { | 233 | { |
182 | if ( mData->uid.isEmpty() ) | 234 | if ( mData->uid.isEmpty() ) |
183 | mData->uid = KApplication::randomString( 10 ); | 235 | mData->uid = KApplication::randomString( 10 ); |
184 | 236 | ||
185 | return mData->uid; | 237 | return mData->uid; |
186 | } | 238 | } |
187 | 239 | ||
188 | QString Addressee::uidLabel() | 240 | QString Addressee::uidLabel() |
189 | { | 241 | { |
190 | return i18n("Unique Identifier"); | 242 | return i18n("Unique Identifier"); |
191 | } | 243 | } |
192 | 244 | ||
193 | void Addressee::setName( const QString &name ) | 245 | void Addressee::setName( const QString &name ) |
194 | { | 246 | { |
195 | if ( name == mData->name ) return; | 247 | if ( name == mData->name ) return; |
196 | detach(); | 248 | detach(); |
197 | mData->empty = false; | 249 | mData->empty = false; |
198 | mData->name = name; | 250 | mData->name = name; |
199 | } | 251 | } |
200 | 252 | ||
201 | QString Addressee::name() const | 253 | QString Addressee::name() const |
202 | { | 254 | { |
203 | return mData->name; | 255 | return mData->name; |
204 | } | 256 | } |
205 | 257 | ||
206 | QString Addressee::nameLabel() | 258 | QString Addressee::nameLabel() |
207 | { | 259 | { |
208 | return i18n("Name"); | 260 | return i18n("Name"); |
209 | } | 261 | } |
210 | 262 | ||
211 | 263 | ||
212 | void Addressee::setFormattedName( const QString &formattedName ) | 264 | void Addressee::setFormattedName( const QString &formattedName ) |
213 | { | 265 | { |
214 | if ( formattedName == mData->formattedName ) return; | 266 | if ( formattedName == mData->formattedName ) return; |
215 | detach(); | 267 | detach(); |
216 | mData->empty = false; | 268 | mData->empty = false; |
217 | mData->formattedName = formattedName; | 269 | mData->formattedName = formattedName; |
218 | } | 270 | } |
219 | 271 | ||
220 | QString Addressee::formattedName() const | 272 | QString Addressee::formattedName() const |
221 | { | 273 | { |
222 | return mData->formattedName; | 274 | return mData->formattedName; |
223 | } | 275 | } |
224 | 276 | ||
225 | QString Addressee::formattedNameLabel() | 277 | QString Addressee::formattedNameLabel() |
226 | { | 278 | { |
227 | return i18n("Formatted Name"); | 279 | return i18n("Formatted Name"); |
228 | } | 280 | } |
229 | 281 | ||
230 | 282 | ||
231 | void Addressee::setFamilyName( const QString &familyName ) | 283 | void Addressee::setFamilyName( const QString &familyName ) |
232 | { | 284 | { |
233 | if ( familyName == mData->familyName ) return; | 285 | if ( familyName == mData->familyName ) return; |
234 | detach(); | 286 | detach(); |
235 | mData->empty = false; | 287 | mData->empty = false; |
236 | mData->familyName = familyName; | 288 | mData->familyName = familyName; |
237 | } | 289 | } |
238 | 290 | ||
239 | QString Addressee::familyName() const | 291 | QString Addressee::familyName() const |
240 | { | 292 | { |
241 | return mData->familyName; | 293 | return mData->familyName; |
242 | } | 294 | } |
243 | 295 | ||
244 | QString Addressee::familyNameLabel() | 296 | QString Addressee::familyNameLabel() |
245 | { | 297 | { |
246 | return i18n("Family Name"); | 298 | return i18n("Family Name"); |
247 | } | 299 | } |
248 | 300 | ||
249 | 301 | ||
250 | void Addressee::setGivenName( const QString &givenName ) | 302 | void Addressee::setGivenName( const QString &givenName ) |
251 | { | 303 | { |
252 | if ( givenName == mData->givenName ) return; | 304 | if ( givenName == mData->givenName ) return; |
253 | detach(); | 305 | detach(); |
254 | mData->empty = false; | 306 | mData->empty = false; |
255 | mData->givenName = givenName; | 307 | mData->givenName = givenName; |
256 | } | 308 | } |
257 | 309 | ||
258 | QString Addressee::givenName() const | 310 | QString Addressee::givenName() const |
259 | { | 311 | { |
260 | return mData->givenName; | 312 | return mData->givenName; |
261 | } | 313 | } |
262 | 314 | ||
263 | QString Addressee::givenNameLabel() | 315 | QString Addressee::givenNameLabel() |
264 | { | 316 | { |
265 | return i18n("Given Name"); | 317 | return i18n("Given Name"); |
266 | } | 318 | } |
267 | 319 | ||
268 | 320 | ||
269 | void Addressee::setAdditionalName( const QString &additionalName ) | 321 | void Addressee::setAdditionalName( const QString &additionalName ) |
270 | { | 322 | { |
271 | if ( additionalName == mData->additionalName ) return; | 323 | if ( additionalName == mData->additionalName ) return; |
272 | detach(); | 324 | detach(); |
273 | mData->empty = false; | 325 | mData->empty = false; |
274 | mData->additionalName = additionalName; | 326 | mData->additionalName = additionalName; |
275 | } | 327 | } |
276 | 328 | ||
277 | QString Addressee::additionalName() const | 329 | QString Addressee::additionalName() const |
278 | { | 330 | { |
279 | return mData->additionalName; | 331 | return mData->additionalName; |
280 | } | 332 | } |
281 | 333 | ||
282 | QString Addressee::additionalNameLabel() | 334 | QString Addressee::additionalNameLabel() |
283 | { | 335 | { |
284 | return i18n("Additional Names"); | 336 | return i18n("Additional Names"); |
285 | } | 337 | } |
286 | 338 | ||
287 | 339 | ||
288 | void Addressee::setPrefix( const QString &prefix ) | 340 | void Addressee::setPrefix( const QString &prefix ) |
289 | { | 341 | { |
290 | if ( prefix == mData->prefix ) return; | 342 | if ( prefix == mData->prefix ) return; |
291 | detach(); | 343 | detach(); |
292 | mData->empty = false; | 344 | mData->empty = false; |
293 | mData->prefix = prefix; | 345 | mData->prefix = prefix; |
294 | } | 346 | } |
295 | 347 | ||
296 | QString Addressee::prefix() const | 348 | QString Addressee::prefix() const |
297 | { | 349 | { |
298 | return mData->prefix; | 350 | return mData->prefix; |
299 | } | 351 | } |
300 | 352 | ||
301 | QString Addressee::prefixLabel() | 353 | QString Addressee::prefixLabel() |
302 | { | 354 | { |
303 | return i18n("Honorific Prefixes"); | 355 | return i18n("Honorific Prefixes"); |
304 | } | 356 | } |
305 | 357 | ||
306 | 358 | ||
307 | void Addressee::setSuffix( const QString &suffix ) | 359 | void Addressee::setSuffix( const QString &suffix ) |
308 | { | 360 | { |
309 | if ( suffix == mData->suffix ) return; | 361 | if ( suffix == mData->suffix ) return; |
310 | detach(); | 362 | detach(); |
311 | mData->empty = false; | 363 | mData->empty = false; |
312 | mData->suffix = suffix; | 364 | mData->suffix = suffix; |
313 | } | 365 | } |
314 | 366 | ||
315 | QString Addressee::suffix() const | 367 | QString Addressee::suffix() const |
316 | { | 368 | { |
317 | return mData->suffix; | 369 | return mData->suffix; |
318 | } | 370 | } |
319 | 371 | ||
320 | QString Addressee::suffixLabel() | 372 | QString Addressee::suffixLabel() |
321 | { | 373 | { |
322 | return i18n("Honorific Suffixes"); | 374 | return i18n("Honorific Suffixes"); |
323 | } | 375 | } |
324 | 376 | ||
325 | 377 | ||
326 | void Addressee::setNickName( const QString &nickName ) | 378 | void Addressee::setNickName( const QString &nickName ) |
327 | { | 379 | { |
328 | if ( nickName == mData->nickName ) return; | 380 | if ( nickName == mData->nickName ) return; |
329 | detach(); | 381 | detach(); |
330 | mData->empty = false; | 382 | mData->empty = false; |
331 | mData->nickName = nickName; | 383 | mData->nickName = nickName; |
332 | } | 384 | } |
333 | 385 | ||
334 | QString Addressee::nickName() const | 386 | QString Addressee::nickName() const |
335 | { | 387 | { |
336 | return mData->nickName; | 388 | return mData->nickName; |
337 | } | 389 | } |
338 | 390 | ||
339 | QString Addressee::nickNameLabel() | 391 | QString Addressee::nickNameLabel() |
340 | { | 392 | { |
341 | return i18n("Nick Name"); | 393 | return i18n("Nick Name"); |
342 | } | 394 | } |
343 | 395 | ||
344 | 396 | ||
345 | void Addressee::setBirthday( const QDateTime &birthday ) | 397 | void Addressee::setBirthday( const QDateTime &birthday ) |
346 | { | 398 | { |
347 | if ( birthday == mData->birthday ) return; | 399 | if ( birthday == mData->birthday ) return; |
348 | detach(); | 400 | detach(); |
349 | mData->empty = false; | 401 | mData->empty = false; |
350 | mData->birthday = birthday; | 402 | mData->birthday = birthday; |
351 | } | 403 | } |
352 | 404 | ||
353 | QDateTime Addressee::birthday() const | 405 | QDateTime Addressee::birthday() const |
354 | { | 406 | { |
355 | return mData->birthday; | 407 | return mData->birthday; |
356 | } | 408 | } |
357 | 409 | ||
358 | QString Addressee::birthdayLabel() | 410 | QString Addressee::birthdayLabel() |
359 | { | 411 | { |
360 | return i18n("Birthday"); | 412 | return i18n("Birthday"); |
361 | } | 413 | } |
362 | 414 | ||
363 | 415 | ||
364 | QString Addressee::homeAddressStreetLabel() | 416 | QString Addressee::homeAddressStreetLabel() |
365 | { | 417 | { |
366 | return i18n("Home Address Street"); | 418 | return i18n("Home Address Street"); |
367 | } | 419 | } |
368 | 420 | ||
369 | 421 | ||
370 | QString Addressee::homeAddressLocalityLabel() | 422 | QString Addressee::homeAddressLocalityLabel() |
371 | { | 423 | { |
372 | return i18n("Home Address Locality"); | 424 | return i18n("Home Address Locality"); |
373 | } | 425 | } |
374 | 426 | ||
375 | 427 | ||
376 | QString Addressee::homeAddressRegionLabel() | 428 | QString Addressee::homeAddressRegionLabel() |
377 | { | 429 | { |
378 | return i18n("Home Address Region"); | 430 | return i18n("Home Address Region"); |
379 | } | 431 | } |
380 | 432 | ||
381 | 433 | ||
382 | QString Addressee::homeAddressPostalCodeLabel() | 434 | QString Addressee::homeAddressPostalCodeLabel() |
383 | { | 435 | { |
384 | return i18n("Home Address Postal Code"); | 436 | return i18n("Home Address Postal Code"); |
385 | } | 437 | } |
386 | 438 | ||
387 | 439 | ||
388 | QString Addressee::homeAddressCountryLabel() | 440 | QString Addressee::homeAddressCountryLabel() |
389 | { | 441 | { |
390 | return i18n("Home Address Country"); | 442 | return i18n("Home Address Country"); |
391 | } | 443 | } |
392 | 444 | ||
393 | 445 | ||
394 | QString Addressee::homeAddressLabelLabel() | 446 | QString Addressee::homeAddressLabelLabel() |
395 | { | 447 | { |
396 | return i18n("Home Address Label"); | 448 | return i18n("Home Address Label"); |
397 | } | 449 | } |
398 | 450 | ||
399 | 451 | ||
400 | QString Addressee::businessAddressStreetLabel() | 452 | QString Addressee::businessAddressStreetLabel() |
401 | { | 453 | { |
402 | return i18n("Business Address Street"); | 454 | return i18n("Business Address Street"); |
403 | } | 455 | } |
404 | 456 | ||
405 | 457 | ||
406 | QString Addressee::businessAddressLocalityLabel() | 458 | QString Addressee::businessAddressLocalityLabel() |
407 | { | 459 | { |
408 | return i18n("Business Address Locality"); | 460 | return i18n("Business Address Locality"); |
409 | } | 461 | } |
410 | 462 | ||
411 | 463 | ||
412 | QString Addressee::businessAddressRegionLabel() | 464 | QString Addressee::businessAddressRegionLabel() |
413 | { | 465 | { |
414 | return i18n("Business Address Region"); | 466 | return i18n("Business Address Region"); |
415 | } | 467 | } |
416 | 468 | ||
417 | 469 | ||
418 | QString Addressee::businessAddressPostalCodeLabel() | 470 | QString Addressee::businessAddressPostalCodeLabel() |
419 | { | 471 | { |
420 | return i18n("Business Address Postal Code"); | 472 | return i18n("Business Address Postal Code"); |
421 | } | 473 | } |
422 | 474 | ||
423 | 475 | ||
424 | QString Addressee::businessAddressCountryLabel() | 476 | QString Addressee::businessAddressCountryLabel() |
425 | { | 477 | { |
426 | return i18n("Business Address Country"); | 478 | return i18n("Business Address Country"); |
427 | } | 479 | } |
428 | 480 | ||
429 | 481 | ||
430 | QString Addressee::businessAddressLabelLabel() | 482 | QString Addressee::businessAddressLabelLabel() |
431 | { | 483 | { |
432 | return i18n("Business Address Label"); | 484 | return i18n("Business Address Label"); |
433 | } | 485 | } |
434 | 486 | ||
435 | 487 | ||
436 | QString Addressee::homePhoneLabel() | 488 | QString Addressee::homePhoneLabel() |
437 | { | 489 | { |
438 | return i18n("Home Phone"); | 490 | return i18n("Home Phone"); |
439 | } | 491 | } |
440 | 492 | ||
441 | 493 | ||
442 | QString Addressee::businessPhoneLabel() | 494 | QString Addressee::businessPhoneLabel() |
443 | { | 495 | { |
444 | return i18n("Business Phone"); | 496 | return i18n("Business Phone"); |
445 | } | 497 | } |
446 | 498 | ||
447 | 499 | ||
448 | QString Addressee::mobilePhoneLabel() | 500 | QString Addressee::mobilePhoneLabel() |
449 | { | 501 | { |
450 | return i18n("Mobile Phone"); | 502 | return i18n("Mobile Phone"); |
451 | } | 503 | } |
452 | 504 | ||
453 | 505 | ||
454 | QString Addressee::homeFaxLabel() | 506 | QString Addressee::homeFaxLabel() |
455 | { | 507 | { |
456 | return i18n("Home Fax"); | 508 | return i18n("Home Fax"); |
457 | } | 509 | } |
458 | 510 | ||
459 | 511 | ||
460 | QString Addressee::businessFaxLabel() | 512 | QString Addressee::businessFaxLabel() |
461 | { | 513 | { |
462 | return i18n("Business Fax"); | 514 | return i18n("Business Fax"); |
463 | } | 515 | } |
464 | 516 | ||
465 | 517 | ||
466 | QString Addressee::carPhoneLabel() | 518 | QString Addressee::carPhoneLabel() |
467 | { | 519 | { |
468 | return i18n("Car Phone"); | 520 | return i18n("Car Phone"); |
469 | } | 521 | } |
470 | 522 | ||
471 | 523 | ||
472 | QString Addressee::isdnLabel() | 524 | QString Addressee::isdnLabel() |
473 | { | 525 | { |
474 | return i18n("ISDN"); | 526 | return i18n("ISDN"); |
475 | } | 527 | } |
476 | 528 | ||
477 | 529 | ||
478 | QString Addressee::pagerLabel() | 530 | QString Addressee::pagerLabel() |
479 | { | 531 | { |
480 | return i18n("Pager"); | 532 | return i18n("Pager"); |
481 | } | 533 | } |
482 | 534 | ||
483 | QString Addressee::sipLabel() | 535 | QString Addressee::sipLabel() |
484 | { | 536 | { |
485 | return i18n("SIP"); | 537 | return i18n("SIP"); |
486 | } | 538 | } |
487 | 539 | ||
488 | QString Addressee::emailLabel() | 540 | QString Addressee::emailLabel() |
489 | { | 541 | { |
490 | return i18n("Email Address"); | 542 | return i18n("Email Address"); |
491 | } | 543 | } |
492 | 544 | ||
493 | 545 | ||
494 | void Addressee::setMailer( const QString &mailer ) | 546 | void Addressee::setMailer( const QString &mailer ) |
495 | { | 547 | { |
496 | if ( mailer == mData->mailer ) return; | 548 | if ( mailer == mData->mailer ) return; |
497 | detach(); | 549 | detach(); |
498 | mData->empty = false; | 550 | mData->empty = false; |
499 | mData->mailer = mailer; | 551 | mData->mailer = mailer; |
500 | } | 552 | } |
501 | 553 | ||
502 | QString Addressee::mailer() const | 554 | QString Addressee::mailer() const |
503 | { | 555 | { |
504 | return mData->mailer; | 556 | return mData->mailer; |
505 | } | 557 | } |
506 | 558 | ||
507 | QString Addressee::mailerLabel() | 559 | QString Addressee::mailerLabel() |
508 | { | 560 | { |
509 | return i18n("Mail Client"); | 561 | return i18n("Mail Client"); |
510 | } | 562 | } |
511 | 563 | ||
512 | 564 | ||
513 | void Addressee::setTimeZone( const TimeZone &timeZone ) | 565 | void Addressee::setTimeZone( const TimeZone &timeZone ) |
514 | { | 566 | { |
515 | if ( timeZone == mData->timeZone ) return; | 567 | if ( timeZone == mData->timeZone ) return; |
516 | detach(); | 568 | detach(); |
517 | mData->empty = false; | 569 | mData->empty = false; |
518 | mData->timeZone = timeZone; | 570 | mData->timeZone = timeZone; |
519 | } | 571 | } |
520 | 572 | ||
521 | TimeZone Addressee::timeZone() const | 573 | TimeZone Addressee::timeZone() const |
522 | { | 574 | { |
523 | return mData->timeZone; | 575 | return mData->timeZone; |
524 | } | 576 | } |
525 | 577 | ||
526 | QString Addressee::timeZoneLabel() | 578 | QString Addressee::timeZoneLabel() |
527 | { | 579 | { |
528 | return i18n("Time Zone"); | 580 | return i18n("Time Zone"); |
529 | } | 581 | } |
530 | 582 | ||
531 | 583 | ||
532 | void Addressee::setGeo( const Geo &geo ) | 584 | void Addressee::setGeo( const Geo &geo ) |
533 | { | 585 | { |
534 | if ( geo == mData->geo ) return; | 586 | if ( geo == mData->geo ) return; |
535 | detach(); | 587 | detach(); |
536 | mData->empty = false; | 588 | mData->empty = false; |
537 | mData->geo = geo; | 589 | mData->geo = geo; |
538 | } | 590 | } |
539 | 591 | ||
540 | Geo Addressee::geo() const | 592 | Geo Addressee::geo() const |
541 | { | 593 | { |
542 | return mData->geo; | 594 | return mData->geo; |
543 | } | 595 | } |
544 | 596 | ||
545 | QString Addressee::geoLabel() | 597 | QString Addressee::geoLabel() |
546 | { | 598 | { |
547 | return i18n("Geographic Position"); | 599 | return i18n("Geographic Position"); |
548 | } | 600 | } |
549 | 601 | ||
550 | 602 | ||
551 | void Addressee::setTitle( const QString &title ) | 603 | void Addressee::setTitle( const QString &title ) |
552 | { | 604 | { |
553 | if ( title == mData->title ) return; | 605 | if ( title == mData->title ) return; |
554 | detach(); | 606 | detach(); |
555 | mData->empty = false; | 607 | mData->empty = false; |
556 | mData->title = title; | 608 | mData->title = title; |
557 | } | 609 | } |
558 | 610 | ||
559 | QString Addressee::title() const | 611 | QString Addressee::title() const |
560 | { | 612 | { |
561 | return mData->title; | 613 | return mData->title; |
562 | } | 614 | } |
563 | 615 | ||
564 | QString Addressee::titleLabel() | 616 | QString Addressee::titleLabel() |
565 | { | 617 | { |
566 | return i18n("Title"); | 618 | return i18n("Title"); |
567 | } | 619 | } |
568 | 620 | ||
569 | 621 | ||
570 | void Addressee::setRole( const QString &role ) | 622 | void Addressee::setRole( const QString &role ) |
571 | { | 623 | { |
572 | if ( role == mData->role ) return; | 624 | if ( role == mData->role ) return; |
573 | detach(); | 625 | detach(); |
574 | mData->empty = false; | 626 | mData->empty = false; |
575 | mData->role = role; | 627 | mData->role = role; |
576 | } | 628 | } |
577 | 629 | ||
578 | QString Addressee::role() const | 630 | QString Addressee::role() const |
579 | { | 631 | { |
580 | return mData->role; | 632 | return mData->role; |
581 | } | 633 | } |
582 | 634 | ||
583 | QString Addressee::roleLabel() | 635 | QString Addressee::roleLabel() |
584 | { | 636 | { |
585 | return i18n("Role"); | 637 | return i18n("Role"); |
586 | } | 638 | } |
587 | 639 | ||
588 | 640 | ||
589 | void Addressee::setOrganization( const QString &organization ) | 641 | void Addressee::setOrganization( const QString &organization ) |
590 | { | 642 | { |
591 | if ( organization == mData->organization ) return; | 643 | if ( organization == mData->organization ) return; |
592 | detach(); | 644 | detach(); |
593 | mData->empty = false; | 645 | mData->empty = false; |
594 | mData->organization = organization; | 646 | mData->organization = organization; |
595 | } | 647 | } |
596 | 648 | ||
597 | QString Addressee::organization() const | 649 | QString Addressee::organization() const |
598 | { | 650 | { |
599 | return mData->organization; | 651 | return mData->organization; |
600 | } | 652 | } |
601 | 653 | ||
602 | QString Addressee::organizationLabel() | 654 | QString Addressee::organizationLabel() |
603 | { | 655 | { |
604 | return i18n("Organization"); | 656 | return i18n("Organization"); |
605 | } | 657 | } |
606 | 658 | ||
607 | 659 | ||
608 | void Addressee::setNote( const QString ¬e ) | 660 | void Addressee::setNote( const QString ¬e ) |
609 | { | 661 | { |
610 | if ( note == mData->note ) return; | 662 | if ( note == mData->note ) return; |
611 | detach(); | 663 | detach(); |
612 | mData->empty = false; | 664 | mData->empty = false; |
613 | mData->note = note; | 665 | mData->note = note; |
614 | } | 666 | } |
615 | 667 | ||
616 | QString Addressee::note() const | 668 | QString Addressee::note() const |
617 | { | 669 | { |
618 | return mData->note; | 670 | return mData->note; |
619 | } | 671 | } |
620 | 672 | ||
621 | QString Addressee::noteLabel() | 673 | QString Addressee::noteLabel() |
622 | { | 674 | { |
623 | return i18n("Note"); | 675 | return i18n("Note"); |
624 | } | 676 | } |
625 | 677 | ||
626 | 678 | ||
627 | void Addressee::setProductId( const QString &productId ) | 679 | void Addressee::setProductId( const QString &productId ) |
628 | { | 680 | { |
629 | if ( productId == mData->productId ) return; | 681 | if ( productId == mData->productId ) return; |
630 | detach(); | 682 | detach(); |
631 | mData->empty = false; | 683 | mData->empty = false; |
632 | mData->productId = productId; | 684 | mData->productId = productId; |
633 | } | 685 | } |
634 | 686 | ||
635 | QString Addressee::productId() const | 687 | QString Addressee::productId() const |
636 | { | 688 | { |
637 | return mData->productId; | 689 | return mData->productId; |
638 | } | 690 | } |
639 | 691 | ||
640 | QString Addressee::productIdLabel() | 692 | QString Addressee::productIdLabel() |
641 | { | 693 | { |
642 | return i18n("Product Identifier"); | 694 | return i18n("Product Identifier"); |
643 | } | 695 | } |
644 | 696 | ||
645 | 697 | ||
646 | void Addressee::setRevision( const QDateTime &revision ) | 698 | void Addressee::setRevision( const QDateTime &revision ) |
647 | { | 699 | { |
648 | if ( revision == mData->revision ) return; | 700 | if ( revision == mData->revision ) return; |
649 | detach(); | 701 | detach(); |
650 | mData->empty = false; | 702 | mData->empty = false; |
651 | mData->revision = revision; | 703 | mData->revision = revision; |
652 | } | 704 | } |
653 | 705 | ||
654 | QDateTime Addressee::revision() const | 706 | QDateTime Addressee::revision() const |
655 | { | 707 | { |
656 | return mData->revision; | 708 | return mData->revision; |
657 | } | 709 | } |
658 | 710 | ||
659 | QString Addressee::revisionLabel() | 711 | QString Addressee::revisionLabel() |
660 | { | 712 | { |
661 | return i18n("Revision Date"); | 713 | return i18n("Revision Date"); |
662 | } | 714 | } |
663 | 715 | ||
664 | 716 | ||
665 | void Addressee::setSortString( const QString &sortString ) | 717 | void Addressee::setSortString( const QString &sortString ) |
666 | { | 718 | { |
667 | if ( sortString == mData->sortString ) return; | 719 | if ( sortString == mData->sortString ) return; |
668 | detach(); | 720 | detach(); |
669 | mData->empty = false; | 721 | mData->empty = false; |
670 | mData->sortString = sortString; | 722 | mData->sortString = sortString; |
671 | } | 723 | } |
672 | 724 | ||
673 | QString Addressee::sortString() const | 725 | QString Addressee::sortString() const |
674 | { | 726 | { |
675 | return mData->sortString; | 727 | return mData->sortString; |
676 | } | 728 | } |
677 | 729 | ||
678 | QString Addressee::sortStringLabel() | 730 | QString Addressee::sortStringLabel() |
679 | { | 731 | { |
680 | return i18n("Sort String"); | 732 | return i18n("Sort String"); |
681 | } | 733 | } |
682 | 734 | ||
683 | 735 | ||
684 | void Addressee::setUrl( const KURL &url ) | 736 | void Addressee::setUrl( const KURL &url ) |
685 | { | 737 | { |
686 | if ( url == mData->url ) return; | 738 | if ( url == mData->url ) return; |
687 | detach(); | 739 | detach(); |
688 | mData->empty = false; | 740 | mData->empty = false; |
689 | mData->url = url; | 741 | mData->url = url; |
690 | } | 742 | } |
691 | 743 | ||
692 | KURL Addressee::url() const | 744 | KURL Addressee::url() const |
693 | { | 745 | { |
694 | return mData->url; | 746 | return mData->url; |
695 | } | 747 | } |
696 | 748 | ||
697 | QString Addressee::urlLabel() | 749 | QString Addressee::urlLabel() |
698 | { | 750 | { |
699 | return i18n("URL"); | 751 | return i18n("URL"); |
700 | } | 752 | } |
701 | 753 | ||
702 | 754 | ||
703 | void Addressee::setSecrecy( const Secrecy &secrecy ) | 755 | void Addressee::setSecrecy( const Secrecy &secrecy ) |
704 | { | 756 | { |
705 | if ( secrecy == mData->secrecy ) return; | 757 | if ( secrecy == mData->secrecy ) return; |
706 | detach(); | 758 | detach(); |
707 | mData->empty = false; | 759 | mData->empty = false; |
708 | mData->secrecy = secrecy; | 760 | mData->secrecy = secrecy; |
709 | } | 761 | } |
710 | 762 | ||
711 | Secrecy Addressee::secrecy() const | 763 | Secrecy Addressee::secrecy() const |
712 | { | 764 | { |
713 | return mData->secrecy; | 765 | return mData->secrecy; |
714 | } | 766 | } |
715 | 767 | ||
716 | QString Addressee::secrecyLabel() | 768 | QString Addressee::secrecyLabel() |
717 | { | 769 | { |
718 | return i18n("Security Class"); | 770 | return i18n("Security Class"); |
719 | } | 771 | } |
720 | 772 | ||
721 | 773 | ||
722 | void Addressee::setLogo( const Picture &logo ) | 774 | void Addressee::setLogo( const Picture &logo ) |
723 | { | 775 | { |
724 | if ( logo == mData->logo ) return; | 776 | if ( logo == mData->logo ) return; |
725 | detach(); | 777 | detach(); |
726 | mData->empty = false; | 778 | mData->empty = false; |
727 | mData->logo = logo; | 779 | mData->logo = logo; |
728 | } | 780 | } |
729 | 781 | ||
730 | Picture Addressee::logo() const | 782 | Picture Addressee::logo() const |
731 | { | 783 | { |
732 | return mData->logo; | 784 | return mData->logo; |
733 | } | 785 | } |
734 | 786 | ||
735 | QString Addressee::logoLabel() | 787 | QString Addressee::logoLabel() |
736 | { | 788 | { |
737 | return i18n("Logo"); | 789 | return i18n("Logo"); |
738 | } | 790 | } |
739 | 791 | ||
740 | 792 | ||
741 | void Addressee::setPhoto( const Picture &photo ) | 793 | void Addressee::setPhoto( const Picture &photo ) |
742 | { | 794 | { |
743 | if ( photo == mData->photo ) return; | 795 | if ( photo == mData->photo ) return; |
744 | detach(); | 796 | detach(); |
745 | mData->empty = false; | 797 | mData->empty = false; |
746 | mData->photo = photo; | 798 | mData->photo = photo; |
747 | } | 799 | } |
748 | 800 | ||
749 | Picture Addressee::photo() const | 801 | Picture Addressee::photo() const |
750 | { | 802 | { |
751 | return mData->photo; | 803 | return mData->photo; |
752 | } | 804 | } |
753 | 805 | ||
754 | QString Addressee::photoLabel() | 806 | QString Addressee::photoLabel() |
755 | { | 807 | { |
756 | return i18n("Photo"); | 808 | return i18n("Photo"); |
757 | } | 809 | } |
758 | 810 | ||
759 | 811 | ||
760 | void Addressee::setSound( const Sound &sound ) | 812 | void Addressee::setSound( const Sound &sound ) |
761 | { | 813 | { |
762 | if ( sound == mData->sound ) return; | 814 | if ( sound == mData->sound ) return; |
763 | detach(); | 815 | detach(); |
764 | mData->empty = false; | 816 | mData->empty = false; |
765 | mData->sound = sound; | 817 | mData->sound = sound; |
766 | } | 818 | } |
767 | 819 | ||
768 | Sound Addressee::sound() const | 820 | Sound Addressee::sound() const |
769 | { | 821 | { |
770 | return mData->sound; | 822 | return mData->sound; |
771 | } | 823 | } |
772 | 824 | ||
773 | QString Addressee::soundLabel() | 825 | QString Addressee::soundLabel() |
774 | { | 826 | { |
775 | return i18n("Sound"); | 827 | return i18n("Sound"); |
776 | } | 828 | } |
777 | 829 | ||
778 | 830 | ||
779 | void Addressee::setAgent( const Agent &agent ) | 831 | void Addressee::setAgent( const Agent &agent ) |
780 | { | 832 | { |
781 | if ( agent == mData->agent ) return; | 833 | if ( agent == mData->agent ) return; |
782 | detach(); | 834 | detach(); |
783 | mData->empty = false; | 835 | mData->empty = false; |
784 | mData->agent = agent; | 836 | mData->agent = agent; |
785 | } | 837 | } |
786 | 838 | ||
787 | Agent Addressee::agent() const | 839 | Agent Addressee::agent() const |
788 | { | 840 | { |
789 | return mData->agent; | 841 | return mData->agent; |
790 | } | 842 | } |
791 | 843 | ||
792 | QString Addressee::agentLabel() | 844 | QString Addressee::agentLabel() |
793 | { | 845 | { |
794 | return i18n("Agent"); | 846 | return i18n("Agent"); |
795 | } | 847 | } |
796 | 848 | ||
797 | 849 | ||
798 | 850 | ||
799 | void Addressee::setNameFromString( const QString &str ) | 851 | void Addressee::setNameFromString( const QString &str ) |
800 | { | 852 | { |
801 | setFormattedName( str ); | 853 | setFormattedName( str ); |
802 | setName( str ); | 854 | setName( str ); |
803 | 855 | ||
804 | static bool first = true; | 856 | static bool first = true; |
805 | static QStringList titles; | 857 | static QStringList titles; |
806 | static QStringList suffixes; | 858 | static QStringList suffixes; |
807 | static QStringList prefixes; | 859 | static QStringList prefixes; |
808 | 860 | ||
809 | if ( first ) { | 861 | if ( first ) { |
810 | first = false; | 862 | first = false; |
811 | titles += i18n( "Dr." ); | 863 | titles += i18n( "Dr." ); |
812 | titles += i18n( "Miss" ); | 864 | titles += i18n( "Miss" ); |
813 | titles += i18n( "Mr." ); | 865 | titles += i18n( "Mr." ); |
814 | titles += i18n( "Mrs." ); | 866 | titles += i18n( "Mrs." ); |
815 | titles += i18n( "Ms." ); | 867 | titles += i18n( "Ms." ); |
816 | titles += i18n( "Prof." ); | 868 | titles += i18n( "Prof." ); |
817 | 869 | ||
818 | suffixes += i18n( "I" ); | 870 | suffixes += i18n( "I" ); |
819 | suffixes += i18n( "II" ); | 871 | suffixes += i18n( "II" ); |
820 | suffixes += i18n( "III" ); | 872 | suffixes += i18n( "III" ); |
821 | suffixes += i18n( "Jr." ); | 873 | suffixes += i18n( "Jr." ); |
822 | suffixes += i18n( "Sr." ); | 874 | suffixes += i18n( "Sr." ); |
823 | 875 | ||
824 | prefixes += "van"; | 876 | prefixes += "van"; |
825 | prefixes += "von"; | 877 | prefixes += "von"; |
826 | prefixes += "de"; | 878 | prefixes += "de"; |
827 | 879 | ||
828 | KConfig config( locateLocal( "config", "kabcrc") ); | 880 | KConfig config( locateLocal( "config", "kabcrc") ); |
829 | config.setGroup( "General" ); | 881 | config.setGroup( "General" ); |
830 | titles += config.readListEntry( "Prefixes" ); | 882 | titles += config.readListEntry( "Prefixes" ); |
831 | titles.remove( "" ); | 883 | titles.remove( "" ); |
832 | prefixes += config.readListEntry( "Inclusions" ); | 884 | prefixes += config.readListEntry( "Inclusions" ); |
833 | prefixes.remove( "" ); | 885 | prefixes.remove( "" ); |
834 | suffixes += config.readListEntry( "Suffixes" ); | 886 | suffixes += config.readListEntry( "Suffixes" ); |
835 | suffixes.remove( "" ); | 887 | suffixes.remove( "" ); |
836 | } | 888 | } |
837 | 889 | ||
838 | // clear all name parts | 890 | // clear all name parts |
839 | setPrefix( "" ); | 891 | setPrefix( "" ); |
840 | setGivenName( "" ); | 892 | setGivenName( "" ); |
841 | setAdditionalName( "" ); | 893 | setAdditionalName( "" ); |
842 | setFamilyName( "" ); | 894 | setFamilyName( "" ); |
843 | setSuffix( "" ); | 895 | setSuffix( "" ); |
844 | 896 | ||
845 | if ( str.isEmpty() ) | 897 | if ( str.isEmpty() ) |
846 | return; | 898 | return; |
847 | 899 | ||
848 | int i = str.find(','); | 900 | int i = str.find(','); |
849 | if( i < 0 ) { | 901 | if( i < 0 ) { |
850 | QStringList parts = QStringList::split( " ", str ); | 902 | QStringList parts = QStringList::split( " ", str ); |
851 | int leftOffset = 0; | 903 | int leftOffset = 0; |
852 | int rightOffset = parts.count() - 1; | 904 | int rightOffset = parts.count() - 1; |
853 | 905 | ||
854 | QString suffix; | 906 | QString suffix; |
855 | while ( rightOffset >= 0 ) { | 907 | while ( rightOffset >= 0 ) { |
856 | if ( suffixes.contains( parts[ rightOffset ] ) ) { | 908 | if ( suffixes.contains( parts[ rightOffset ] ) ) { |
857 | suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " ")); | 909 | suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " ")); |
858 | rightOffset--; | 910 | rightOffset--; |
859 | } else | 911 | } else |
860 | break; | 912 | break; |
861 | } | 913 | } |
862 | setSuffix( suffix ); | 914 | setSuffix( suffix ); |
863 | 915 | ||
864 | if ( rightOffset < 0 ) | 916 | if ( rightOffset < 0 ) |
865 | return; | 917 | return; |
866 | 918 | ||
867 | if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) { | 919 | if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) { |
868 | setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] ); | 920 | setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] ); |
869 | rightOffset--; | 921 | rightOffset--; |
870 | } else | 922 | } else |
871 | setFamilyName( parts[ rightOffset ] ); | 923 | setFamilyName( parts[ rightOffset ] ); |
872 | 924 | ||
873 | QString prefix; | 925 | QString prefix; |
874 | while ( leftOffset < rightOffset ) { | 926 | while ( leftOffset < rightOffset ) { |
875 | if ( titles.contains( parts[ leftOffset ] ) ) { | 927 | if ( titles.contains( parts[ leftOffset ] ) ) { |
876 | prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); | 928 | prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); |
877 | leftOffset++; | 929 | leftOffset++; |
878 | } else | 930 | } else |
879 | break; | 931 | break; |
880 | } | 932 | } |
881 | setPrefix( prefix ); | 933 | setPrefix( prefix ); |
882 | 934 | ||
883 | if ( leftOffset < rightOffset ) { | 935 | if ( leftOffset < rightOffset ) { |
884 | setGivenName( parts[ leftOffset ] ); | 936 | setGivenName( parts[ leftOffset ] ); |
885 | leftOffset++; | 937 | leftOffset++; |
886 | } | 938 | } |
887 | 939 | ||
888 | QString additionalName; | 940 | QString additionalName; |
889 | while ( leftOffset < rightOffset ) { | 941 | while ( leftOffset < rightOffset ) { |
890 | additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] ); | 942 | additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] ); |
891 | leftOffset++; | 943 | leftOffset++; |
892 | } | 944 | } |
893 | setAdditionalName( additionalName ); | 945 | setAdditionalName( additionalName ); |
894 | } else { | 946 | } else { |
895 | QString part1 = str.left( i ); | 947 | QString part1 = str.left( i ); |
896 | QString part2 = str.mid( i + 1 ); | 948 | QString part2 = str.mid( i + 1 ); |
897 | 949 | ||
898 | QStringList parts = QStringList::split( " ", part1 ); | 950 | QStringList parts = QStringList::split( " ", part1 ); |
899 | int leftOffset = 0; | 951 | int leftOffset = 0; |
900 | int rightOffset = parts.count() - 1; | 952 | int rightOffset = parts.count() - 1; |
901 | 953 | ||
902 | QString suffix; | 954 | QString suffix; |
903 | while ( rightOffset >= 0 ) { | 955 | while ( rightOffset >= 0 ) { |
904 | if ( suffixes.contains( parts[ rightOffset ] ) ) { | 956 | if ( suffixes.contains( parts[ rightOffset ] ) ) { |
905 | suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " ")); | 957 | suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " ")); |
906 | rightOffset--; | 958 | rightOffset--; |
907 | } else | 959 | } else |
908 | break; | 960 | break; |
909 | } | 961 | } |
910 | setSuffix( suffix ); | 962 | setSuffix( suffix ); |
911 | 963 | ||
912 | if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) { | 964 | if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) { |
913 | setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] ); | 965 | setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] ); |
914 | rightOffset--; | 966 | rightOffset--; |
915 | } else | 967 | } else |
916 | setFamilyName( parts[ rightOffset ] ); | 968 | setFamilyName( parts[ rightOffset ] ); |
917 | 969 | ||
918 | QString prefix; | 970 | QString prefix; |
919 | while ( leftOffset < rightOffset ) { | 971 | while ( leftOffset < rightOffset ) { |
920 | if ( titles.contains( parts[ leftOffset ] ) ) { | 972 | if ( titles.contains( parts[ leftOffset ] ) ) { |
921 | prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); | 973 | prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); |
922 | leftOffset++; | 974 | leftOffset++; |
923 | } else | 975 | } else |
924 | break; | 976 | break; |
925 | } | 977 | } |
926 | 978 | ||
927 | parts = QStringList::split( " ", part2 ); | 979 | parts = QStringList::split( " ", part2 ); |
928 | 980 | ||
929 | leftOffset = 0; | 981 | leftOffset = 0; |
930 | rightOffset = parts.count(); | 982 | rightOffset = parts.count(); |
931 | 983 | ||
932 | while ( leftOffset < rightOffset ) { | 984 | while ( leftOffset < rightOffset ) { |
933 | if ( titles.contains( parts[ leftOffset ] ) ) { | 985 | if ( titles.contains( parts[ leftOffset ] ) ) { |
934 | prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); | 986 | prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); |
935 | leftOffset++; | 987 | leftOffset++; |
936 | } else | 988 | } else |
937 | break; | 989 | break; |
938 | } | 990 | } |
939 | setPrefix( prefix ); | 991 | setPrefix( prefix ); |
940 | 992 | ||
941 | if ( leftOffset < rightOffset ) { | 993 | if ( leftOffset < rightOffset ) { |
942 | setGivenName( parts[ leftOffset ] ); | 994 | setGivenName( parts[ leftOffset ] ); |
943 | leftOffset++; | 995 | leftOffset++; |
944 | } | 996 | } |
945 | 997 | ||
946 | QString additionalName; | 998 | QString additionalName; |
947 | while ( leftOffset < rightOffset ) { | 999 | while ( leftOffset < rightOffset ) { |
948 | additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] ); | 1000 | additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] ); |
949 | leftOffset++; | 1001 | leftOffset++; |
950 | } | 1002 | } |
951 | setAdditionalName( additionalName ); | 1003 | setAdditionalName( additionalName ); |
952 | } | 1004 | } |
953 | } | 1005 | } |
954 | 1006 | ||
955 | QString Addressee::realName() const | 1007 | QString Addressee::realName() const |
956 | { | 1008 | { |
957 | if ( !formattedName().isEmpty() ) | 1009 | if ( !formattedName().isEmpty() ) |
958 | return formattedName(); | 1010 | return formattedName(); |
959 | 1011 | ||
960 | QString n = assembledName(); | 1012 | QString n = assembledName(); |
961 | 1013 | ||
962 | if ( n.isEmpty() ) | 1014 | if ( n.isEmpty() ) |
963 | n = name(); | 1015 | n = name(); |
964 | 1016 | ||
965 | return n; | 1017 | return n; |
966 | } | 1018 | } |
967 | 1019 | ||
968 | QString Addressee::assembledName() const | 1020 | QString Addressee::assembledName() const |
969 | { | 1021 | { |
970 | QString name = prefix() + " " + givenName() + " " + additionalName() + " " + | 1022 | QString name = prefix() + " " + givenName() + " " + additionalName() + " " + |
971 | familyName() + " " + suffix(); | 1023 | familyName() + " " + suffix(); |
972 | 1024 | ||
973 | return name.simplifyWhiteSpace(); | 1025 | return name.simplifyWhiteSpace(); |
974 | } | 1026 | } |
975 | 1027 | ||
976 | QString Addressee::fullEmail( const QString &email ) const | 1028 | QString Addressee::fullEmail( const QString &email ) const |
977 | { | 1029 | { |
978 | QString e; | 1030 | QString e; |
979 | if ( email.isNull() ) { | 1031 | if ( email.isNull() ) { |
980 | e = preferredEmail(); | 1032 | e = preferredEmail(); |
981 | } else { | 1033 | } else { |
982 | e = email; | 1034 | e = email; |
983 | } | 1035 | } |
984 | if ( e.isEmpty() ) return QString::null; | 1036 | if ( e.isEmpty() ) return QString::null; |
985 | 1037 | ||
986 | QString text; | 1038 | QString text; |
987 | if ( realName().isEmpty() ) | 1039 | if ( realName().isEmpty() ) |
988 | text = e; | 1040 | text = e; |
989 | else | 1041 | else |
990 | text = assembledName() + " <" + e + ">"; | 1042 | text = assembledName() + " <" + e + ">"; |
991 | 1043 | ||
992 | return text; | 1044 | return text; |
993 | } | 1045 | } |
994 | 1046 | ||
995 | void Addressee::insertEmail( const QString &email, bool preferred ) | 1047 | void Addressee::insertEmail( const QString &email, bool preferred ) |
996 | { | 1048 | { |
997 | detach(); | 1049 | detach(); |
998 | 1050 | ||
999 | QStringList::Iterator it = mData->emails.find( email ); | 1051 | QStringList::Iterator it = mData->emails.find( email ); |
1000 | 1052 | ||
1001 | if ( it != mData->emails.end() ) { | 1053 | if ( it != mData->emails.end() ) { |
1002 | if ( !preferred || it == mData->emails.begin() ) return; | 1054 | if ( !preferred || it == mData->emails.begin() ) return; |
1003 | mData->emails.remove( it ); | 1055 | mData->emails.remove( it ); |
1004 | mData->emails.prepend( email ); | 1056 | mData->emails.prepend( email ); |
1005 | } else { | 1057 | } else { |
1006 | if ( preferred ) { | 1058 | if ( preferred ) { |
1007 | mData->emails.prepend( email ); | 1059 | mData->emails.prepend( email ); |
1008 | } else { | 1060 | } else { |
1009 | mData->emails.append( email ); | 1061 | mData->emails.append( email ); |
1010 | } | 1062 | } |
1011 | } | 1063 | } |
1012 | } | 1064 | } |
1013 | 1065 | ||
1014 | void Addressee::removeEmail( const QString &email ) | 1066 | void Addressee::removeEmail( const QString &email ) |
1015 | { | 1067 | { |
1016 | detach(); | 1068 | detach(); |
1017 | 1069 | ||
1018 | QStringList::Iterator it = mData->emails.find( email ); | 1070 | QStringList::Iterator it = mData->emails.find( email ); |
1019 | if ( it == mData->emails.end() ) return; | 1071 | if ( it == mData->emails.end() ) return; |
1020 | 1072 | ||
1021 | mData->emails.remove( it ); | 1073 | mData->emails.remove( it ); |
1022 | } | 1074 | } |
1023 | 1075 | ||
1024 | QString Addressee::preferredEmail() const | 1076 | QString Addressee::preferredEmail() const |
1025 | { | 1077 | { |
1026 | if ( mData->emails.count() == 0 ) return QString::null; | 1078 | if ( mData->emails.count() == 0 ) return QString::null; |
1027 | else return mData->emails.first(); | 1079 | else return mData->emails.first(); |
1028 | } | 1080 | } |
1029 | 1081 | ||
1030 | QStringList Addressee::emails() const | 1082 | QStringList Addressee::emails() const |
1031 | { | 1083 | { |
1032 | return mData->emails; | 1084 | return mData->emails; |
1033 | } | 1085 | } |
1034 | void Addressee::setEmails( const QStringList& emails ) { | 1086 | void Addressee::setEmails( const QStringList& emails ) { |
1035 | detach(); | 1087 | detach(); |
1036 | mData->emails = emails; | 1088 | mData->emails = emails; |
1037 | } | 1089 | } |
1038 | void Addressee::insertPhoneNumber( const PhoneNumber &phoneNumber ) | 1090 | void Addressee::insertPhoneNumber( const PhoneNumber &phoneNumber ) |
1039 | { | 1091 | { |
1040 | detach(); | 1092 | detach(); |
1041 | mData->empty = false; | 1093 | mData->empty = false; |
1042 | 1094 | ||
1043 | PhoneNumber::List::Iterator it; | 1095 | PhoneNumber::List::Iterator it; |
1044 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 1096 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
1045 | if ( (*it).id() == phoneNumber.id() ) { | 1097 | if ( (*it).id() == phoneNumber.id() ) { |
1046 | *it = phoneNumber; | 1098 | *it = phoneNumber; |
1047 | return; | 1099 | return; |
1048 | } | 1100 | } |
1049 | } | 1101 | } |
1050 | mData->phoneNumbers.append( phoneNumber ); | 1102 | mData->phoneNumbers.append( phoneNumber ); |
1051 | } | 1103 | } |
1052 | 1104 | ||
1053 | void Addressee::removePhoneNumber( const PhoneNumber &phoneNumber ) | 1105 | void Addressee::removePhoneNumber( const PhoneNumber &phoneNumber ) |
1054 | { | 1106 | { |
1055 | detach(); | 1107 | detach(); |
1056 | 1108 | ||
1057 | PhoneNumber::List::Iterator it; | 1109 | PhoneNumber::List::Iterator it; |
1058 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 1110 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
1059 | if ( (*it).id() == phoneNumber.id() ) { | 1111 | if ( (*it).id() == phoneNumber.id() ) { |
1060 | mData->phoneNumbers.remove( it ); | 1112 | mData->phoneNumbers.remove( it ); |
1061 | return; | 1113 | return; |
1062 | } | 1114 | } |
1063 | } | 1115 | } |
1064 | } | 1116 | } |
1065 | 1117 | ||
1066 | PhoneNumber Addressee::phoneNumber( int type ) const | 1118 | PhoneNumber Addressee::phoneNumber( int type ) const |
1067 | { | 1119 | { |
1068 | PhoneNumber phoneNumber( "", type ); | 1120 | PhoneNumber phoneNumber( "", type ); |
1069 | PhoneNumber::List::ConstIterator it; | 1121 | PhoneNumber::List::ConstIterator it; |
1070 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 1122 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
1071 | if ( matchBinaryPattern( (*it).type(), type ) ) { | 1123 | if ( matchBinaryPattern( (*it).type(), type ) ) { |
1072 | if ( (*it).type() & PhoneNumber::Pref ) | 1124 | if ( (*it).type() & PhoneNumber::Pref ) |
1073 | return (*it); | 1125 | return (*it); |
1074 | else if ( phoneNumber.number().isEmpty() ) | 1126 | else if ( phoneNumber.number().isEmpty() ) |
1075 | phoneNumber = (*it); | 1127 | phoneNumber = (*it); |
1076 | } | 1128 | } |
1077 | } | 1129 | } |
1078 | 1130 | ||
1079 | return phoneNumber; | 1131 | return phoneNumber; |
1080 | } | 1132 | } |
1081 | 1133 | ||
1082 | PhoneNumber::List Addressee::phoneNumbers() const | 1134 | PhoneNumber::List Addressee::phoneNumbers() const |
1083 | { | 1135 | { |
1084 | return mData->phoneNumbers; | 1136 | return mData->phoneNumbers; |
1085 | } | 1137 | } |
1086 | 1138 | ||
1087 | PhoneNumber::List Addressee::phoneNumbers( int type ) const | 1139 | PhoneNumber::List Addressee::phoneNumbers( int type ) const |
1088 | { | 1140 | { |
1089 | PhoneNumber::List list; | 1141 | PhoneNumber::List list; |
1090 | 1142 | ||
1091 | PhoneNumber::List::ConstIterator it; | 1143 | PhoneNumber::List::ConstIterator it; |
1092 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 1144 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
1093 | if ( matchBinaryPattern( (*it).type(), type ) ) { | 1145 | if ( matchBinaryPattern( (*it).type(), type ) ) { |
1094 | list.append( *it ); | 1146 | list.append( *it ); |
1095 | } | 1147 | } |
1096 | } | 1148 | } |
1097 | return list; | 1149 | return list; |
1098 | } | 1150 | } |
1099 | 1151 | ||
1100 | PhoneNumber Addressee::findPhoneNumber( const QString &id ) const | 1152 | PhoneNumber Addressee::findPhoneNumber( const QString &id ) const |
1101 | { | 1153 | { |
1102 | PhoneNumber::List::ConstIterator it; | 1154 | PhoneNumber::List::ConstIterator it; |
1103 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 1155 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
1104 | if ( (*it).id() == id ) { | 1156 | if ( (*it).id() == id ) { |
1105 | return *it; | 1157 | return *it; |
1106 | } | 1158 | } |
1107 | } | 1159 | } |
1108 | return PhoneNumber(); | 1160 | return PhoneNumber(); |
1109 | } | 1161 | } |
1110 | 1162 | ||
1111 | void Addressee::insertKey( const Key &key ) | 1163 | void Addressee::insertKey( const Key &key ) |
1112 | { | 1164 | { |
1113 | detach(); | 1165 | detach(); |
1114 | mData->empty = false; | 1166 | mData->empty = false; |
1115 | 1167 | ||
1116 | Key::List::Iterator it; | 1168 | Key::List::Iterator it; |
1117 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { | 1169 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { |
1118 | if ( (*it).id() == key.id() ) { | 1170 | if ( (*it).id() == key.id() ) { |
1119 | *it = key; | 1171 | *it = key; |
1120 | return; | 1172 | return; |
1121 | } | 1173 | } |
1122 | } | 1174 | } |
1123 | mData->keys.append( key ); | 1175 | mData->keys.append( key ); |
1124 | } | 1176 | } |
1125 | 1177 | ||
1126 | void Addressee::removeKey( const Key &key ) | 1178 | void Addressee::removeKey( const Key &key ) |
1127 | { | 1179 | { |
1128 | detach(); | 1180 | detach(); |
1129 | 1181 | ||
1130 | Key::List::Iterator it; | 1182 | Key::List::Iterator it; |
1131 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { | 1183 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { |
1132 | if ( (*it).id() == key.id() ) { | 1184 | if ( (*it).id() == key.id() ) { |
1133 | mData->keys.remove( key ); | 1185 | mData->keys.remove( key ); |
1134 | return; | 1186 | return; |
1135 | } | 1187 | } |
1136 | } | 1188 | } |
1137 | } | 1189 | } |
1138 | 1190 | ||
1139 | Key Addressee::key( int type, QString customTypeString ) const | 1191 | Key Addressee::key( int type, QString customTypeString ) const |
1140 | { | 1192 | { |
1141 | Key::List::ConstIterator it; | 1193 | Key::List::ConstIterator it; |
1142 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { | 1194 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { |
1143 | if ( (*it).type() == type ) { | 1195 | if ( (*it).type() == type ) { |
1144 | if ( type == Key::Custom ) { | 1196 | if ( type == Key::Custom ) { |
1145 | if ( customTypeString.isEmpty() ) { | 1197 | if ( customTypeString.isEmpty() ) { |
1146 | return *it; | 1198 | return *it; |
1147 | } else { | 1199 | } else { |
1148 | if ( (*it).customTypeString() == customTypeString ) | 1200 | if ( (*it).customTypeString() == customTypeString ) |
1149 | return (*it); | 1201 | return (*it); |
1150 | } | 1202 | } |
1151 | } else { | 1203 | } else { |
1152 | return *it; | 1204 | return *it; |
1153 | } | 1205 | } |
1154 | } | 1206 | } |
1155 | } | 1207 | } |
1156 | return Key( QString(), type ); | 1208 | return Key( QString(), type ); |
1157 | } | 1209 | } |
1158 | void Addressee::setKeys( const Key::List& list ) { | 1210 | void Addressee::setKeys( const Key::List& list ) { |
1159 | detach(); | 1211 | detach(); |
1160 | mData->keys = list; | 1212 | mData->keys = list; |
1161 | } | 1213 | } |
1162 | 1214 | ||
1163 | Key::List Addressee::keys() const | 1215 | Key::List Addressee::keys() const |
1164 | { | 1216 | { |
1165 | return mData->keys; | 1217 | return mData->keys; |
1166 | } | 1218 | } |
1167 | 1219 | ||
1168 | Key::List Addressee::keys( int type, QString customTypeString ) const | 1220 | Key::List Addressee::keys( int type, QString customTypeString ) const |
1169 | { | 1221 | { |
1170 | Key::List list; | 1222 | Key::List list; |
1171 | 1223 | ||
1172 | Key::List::ConstIterator it; | 1224 | Key::List::ConstIterator it; |
1173 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { | 1225 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { |
1174 | if ( (*it).type() == type ) { | 1226 | if ( (*it).type() == type ) { |
1175 | if ( type == Key::Custom ) { | 1227 | if ( type == Key::Custom ) { |
1176 | if ( customTypeString.isEmpty() ) { | 1228 | if ( customTypeString.isEmpty() ) { |
1177 | list.append(*it); | 1229 | list.append(*it); |
1178 | } else { | 1230 | } else { |
1179 | if ( (*it).customTypeString() == customTypeString ) | 1231 | if ( (*it).customTypeString() == customTypeString ) |
1180 | list.append(*it); | 1232 | list.append(*it); |
1181 | } | 1233 | } |
1182 | } else { | 1234 | } else { |
1183 | list.append(*it); | 1235 | list.append(*it); |
1184 | } | 1236 | } |
1185 | } | 1237 | } |
1186 | } | 1238 | } |
1187 | return list; | 1239 | return list; |
1188 | } | 1240 | } |
1189 | 1241 | ||
1190 | Key Addressee::findKey( const QString &id ) const | 1242 | Key Addressee::findKey( const QString &id ) const |
1191 | { | 1243 | { |
1192 | Key::List::ConstIterator it; | 1244 | Key::List::ConstIterator it; |
1193 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { | 1245 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { |
1194 | if ( (*it).id() == id ) { | 1246 | if ( (*it).id() == id ) { |
1195 | return *it; | 1247 | return *it; |
1196 | } | 1248 | } |
1197 | } | 1249 | } |
1198 | return Key(); | 1250 | return Key(); |
1199 | } | 1251 | } |
1200 | 1252 | ||
1201 | QString Addressee::asString() const | 1253 | QString Addressee::asString() const |
1202 | { | 1254 | { |
1203 | return "Smith, agent Smith..."; | 1255 | return "Smith, agent Smith..."; |
1204 | } | 1256 | } |
1205 | 1257 | ||
1206 | void Addressee::dump() const | 1258 | void Addressee::dump() const |
1207 | { | 1259 | { |
1208 | return; | 1260 | return; |
1209 | kdDebug(5700) << "Addressee {" << endl; | 1261 | kdDebug(5700) << "Addressee {" << endl; |
1210 | 1262 | ||
1211 | kdDebug(5700) << " Uid: '" << uid() << "'" << endl; | 1263 | kdDebug(5700) << " Uid: '" << uid() << "'" << endl; |
1212 | 1264 | ||
1213 | kdDebug(5700) << " Name: '" << name() << "'" << endl; | 1265 | kdDebug(5700) << " Name: '" << name() << "'" << endl; |
1214 | kdDebug(5700) << " FormattedName: '" << formattedName() << "'" << endl; | 1266 | kdDebug(5700) << " FormattedName: '" << formattedName() << "'" << endl; |
1215 | kdDebug(5700) << " FamilyName: '" << familyName() << "'" << endl; | 1267 | kdDebug(5700) << " FamilyName: '" << familyName() << "'" << endl; |
1216 | kdDebug(5700) << " GivenName: '" << givenName() << "'" << endl; | 1268 | kdDebug(5700) << " GivenName: '" << givenName() << "'" << endl; |
1217 | kdDebug(5700) << " AdditionalName: '" << additionalName() << "'" << endl; | 1269 | kdDebug(5700) << " AdditionalName: '" << additionalName() << "'" << endl; |
1218 | kdDebug(5700) << " Prefix: '" << prefix() << "'" << endl; | 1270 | kdDebug(5700) << " Prefix: '" << prefix() << "'" << endl; |
1219 | kdDebug(5700) << " Suffix: '" << suffix() << "'" << endl; | 1271 | kdDebug(5700) << " Suffix: '" << suffix() << "'" << endl; |
1220 | kdDebug(5700) << " NickName: '" << nickName() << "'" << endl; | 1272 | kdDebug(5700) << " NickName: '" << nickName() << "'" << endl; |
1221 | kdDebug(5700) << " Birthday: '" << birthday().toString() << "'" << endl; | 1273 | kdDebug(5700) << " Birthday: '" << birthday().toString() << "'" << endl; |
1222 | kdDebug(5700) << " Mailer: '" << mailer() << "'" << endl; | 1274 | kdDebug(5700) << " Mailer: '" << mailer() << "'" << endl; |
1223 | kdDebug(5700) << " TimeZone: '" << timeZone().asString() << "'" << endl; | 1275 | kdDebug(5700) << " TimeZone: '" << timeZone().asString() << "'" << endl; |
1224 | kdDebug(5700) << " Geo: '" << geo().asString() << "'" << endl; | 1276 | kdDebug(5700) << " Geo: '" << geo().asString() << "'" << endl; |
1225 | kdDebug(5700) << " Title: '" << title() << "'" << endl; | 1277 | kdDebug(5700) << " Title: '" << title() << "'" << endl; |
1226 | kdDebug(5700) << " Role: '" << role() << "'" << endl; | 1278 | kdDebug(5700) << " Role: '" << role() << "'" << endl; |
1227 | kdDebug(5700) << " Organization: '" << organization() << "'" << endl; | 1279 | kdDebug(5700) << " Organization: '" << organization() << "'" << endl; |
1228 | kdDebug(5700) << " Note: '" << note() << "'" << endl; | 1280 | kdDebug(5700) << " Note: '" << note() << "'" << endl; |
1229 | kdDebug(5700) << " ProductId: '" << productId() << "'" << endl; | 1281 | kdDebug(5700) << " ProductId: '" << productId() << "'" << endl; |
1230 | kdDebug(5700) << " Revision: '" << revision().toString() << "'" << endl; | 1282 | kdDebug(5700) << " Revision: '" << revision().toString() << "'" << endl; |
1231 | kdDebug(5700) << " SortString: '" << sortString() << "'" << endl; | 1283 | kdDebug(5700) << " SortString: '" << sortString() << "'" << endl; |
1232 | kdDebug(5700) << " Url: '" << url().url() << "'" << endl; | 1284 | kdDebug(5700) << " Url: '" << url().url() << "'" << endl; |
1233 | kdDebug(5700) << " Secrecy: '" << secrecy().asString() << "'" << endl; | 1285 | kdDebug(5700) << " Secrecy: '" << secrecy().asString() << "'" << endl; |
1234 | kdDebug(5700) << " Logo: '" << logo().asString() << "'" << endl; | 1286 | kdDebug(5700) << " Logo: '" << logo().asString() << "'" << endl; |
1235 | kdDebug(5700) << " Photo: '" << photo().asString() << "'" << endl; | 1287 | kdDebug(5700) << " Photo: '" << photo().asString() << "'" << endl; |
1236 | kdDebug(5700) << " Sound: '" << sound().asString() << "'" << endl; | 1288 | kdDebug(5700) << " Sound: '" << sound().asString() << "'" << endl; |
1237 | kdDebug(5700) << " Agent: '" << agent().asString() << "'" << endl; | 1289 | kdDebug(5700) << " Agent: '" << agent().asString() << "'" << endl; |
1238 | 1290 | ||
1239 | kdDebug(5700) << " Emails {" << endl; | 1291 | kdDebug(5700) << " Emails {" << endl; |
1240 | QStringList e = emails(); | 1292 | QStringList e = emails(); |
1241 | QStringList::ConstIterator it; | 1293 | QStringList::ConstIterator it; |
1242 | for( it = e.begin(); it != e.end(); ++it ) { | 1294 | for( it = e.begin(); it != e.end(); ++it ) { |
1243 | kdDebug(5700) << " " << (*it) << endl; | 1295 | kdDebug(5700) << " " << (*it) << endl; |
1244 | } | 1296 | } |
1245 | kdDebug(5700) << " }" << endl; | 1297 | kdDebug(5700) << " }" << endl; |
1246 | 1298 | ||
1247 | kdDebug(5700) << " PhoneNumbers {" << endl; | 1299 | kdDebug(5700) << " PhoneNumbers {" << endl; |
1248 | PhoneNumber::List p = phoneNumbers(); | 1300 | PhoneNumber::List p = phoneNumbers(); |
1249 | PhoneNumber::List::ConstIterator it2; | 1301 | PhoneNumber::List::ConstIterator it2; |
1250 | for( it2 = p.begin(); it2 != p.end(); ++it2 ) { | 1302 | for( it2 = p.begin(); it2 != p.end(); ++it2 ) { |
1251 | kdDebug(5700) << " Type: " << int((*it2).type()) << " Number: " << (*it2).number() << endl; | 1303 | kdDebug(5700) << " Type: " << int((*it2).type()) << " Number: " << (*it2).number() << endl; |
1252 | } | 1304 | } |
1253 | kdDebug(5700) << " }" << endl; | 1305 | kdDebug(5700) << " }" << endl; |
1254 | 1306 | ||
1255 | Address::List a = addresses(); | 1307 | Address::List a = addresses(); |
1256 | Address::List::ConstIterator it3; | 1308 | Address::List::ConstIterator it3; |
1257 | for( it3 = a.begin(); it3 != a.end(); ++it3 ) { | 1309 | for( it3 = a.begin(); it3 != a.end(); ++it3 ) { |
1258 | (*it3).dump(); | 1310 | (*it3).dump(); |
1259 | } | 1311 | } |
1260 | 1312 | ||
1261 | kdDebug(5700) << " Keys {" << endl; | 1313 | kdDebug(5700) << " Keys {" << endl; |
1262 | Key::List k = keys(); | 1314 | Key::List k = keys(); |
1263 | Key::List::ConstIterator it4; | 1315 | Key::List::ConstIterator it4; |
1264 | for( it4 = k.begin(); it4 != k.end(); ++it4 ) { | 1316 | for( it4 = k.begin(); it4 != k.end(); ++it4 ) { |
1265 | kdDebug(5700) << " Type: " << int((*it4).type()) << | 1317 | kdDebug(5700) << " Type: " << int((*it4).type()) << |
1266 | " Key: " << (*it4).textData() << | 1318 | " Key: " << (*it4).textData() << |
1267 | " CustomString: " << (*it4).customTypeString() << endl; | 1319 | " CustomString: " << (*it4).customTypeString() << endl; |
1268 | } | 1320 | } |
1269 | kdDebug(5700) << " }" << endl; | 1321 | kdDebug(5700) << " }" << endl; |
1270 | 1322 | ||
1271 | kdDebug(5700) << "}" << endl; | 1323 | kdDebug(5700) << "}" << endl; |
1272 | } | 1324 | } |
1273 | 1325 | ||
1274 | 1326 | ||
1275 | void Addressee::insertAddress( const Address &address ) | 1327 | void Addressee::insertAddress( const Address &address ) |
1276 | { | 1328 | { |
1277 | detach(); | 1329 | detach(); |
1278 | mData->empty = false; | 1330 | mData->empty = false; |
1279 | 1331 | ||
1280 | Address::List::Iterator it; | 1332 | Address::List::Iterator it; |
1281 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { | 1333 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { |
1282 | if ( (*it).id() == address.id() ) { | 1334 | if ( (*it).id() == address.id() ) { |
1283 | *it = address; | 1335 | *it = address; |
1284 | return; | 1336 | return; |
1285 | } | 1337 | } |
1286 | } | 1338 | } |
1287 | mData->addresses.append( address ); | 1339 | mData->addresses.append( address ); |
1288 | } | 1340 | } |
1289 | 1341 | ||
1290 | void Addressee::removeAddress( const Address &address ) | 1342 | void Addressee::removeAddress( const Address &address ) |
1291 | { | 1343 | { |
1292 | detach(); | 1344 | detach(); |
1293 | 1345 | ||
1294 | Address::List::Iterator it; | 1346 | Address::List::Iterator it; |
1295 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { | 1347 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { |
1296 | if ( (*it).id() == address.id() ) { | 1348 | if ( (*it).id() == address.id() ) { |
1297 | mData->addresses.remove( it ); | 1349 | mData->addresses.remove( it ); |
1298 | return; | 1350 | return; |
1299 | } | 1351 | } |
1300 | } | 1352 | } |
1301 | } | 1353 | } |
1302 | 1354 | ||
1303 | Address Addressee::address( int type ) const | 1355 | Address Addressee::address( int type ) const |
1304 | { | 1356 | { |
1305 | Address address( type ); | 1357 | Address address( type ); |
1306 | Address::List::ConstIterator it; | 1358 | Address::List::ConstIterator it; |
1307 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { | 1359 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { |
1308 | if ( matchBinaryPattern( (*it).type(), type ) ) { | 1360 | if ( matchBinaryPattern( (*it).type(), type ) ) { |
1309 | if ( (*it).type() & Address::Pref ) | 1361 | if ( (*it).type() & Address::Pref ) |
1310 | return (*it); | 1362 | return (*it); |
1311 | else if ( address.isEmpty() ) | 1363 | else if ( address.isEmpty() ) |
1312 | address = (*it); | 1364 | address = (*it); |
1313 | } | 1365 | } |
1314 | } | 1366 | } |
1315 | 1367 | ||
1316 | return address; | 1368 | return address; |
1317 | } | 1369 | } |
1318 | 1370 | ||
1319 | Address::List Addressee::addresses() const | 1371 | Address::List Addressee::addresses() const |
1320 | { | 1372 | { |
1321 | return mData->addresses; | 1373 | return mData->addresses; |
1322 | } | 1374 | } |
1323 | 1375 | ||
1324 | Address::List Addressee::addresses( int type ) const | 1376 | Address::List Addressee::addresses( int type ) const |
1325 | { | 1377 | { |
1326 | Address::List list; | 1378 | Address::List list; |
1327 | 1379 | ||
1328 | Address::List::ConstIterator it; | 1380 | Address::List::ConstIterator it; |
1329 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { | 1381 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { |
1330 | if ( matchBinaryPattern( (*it).type(), type ) ) { | 1382 | if ( matchBinaryPattern( (*it).type(), type ) ) { |
1331 | list.append( *it ); | 1383 | list.append( *it ); |
1332 | } | 1384 | } |
1333 | } | 1385 | } |
1334 | 1386 | ||
1335 | return list; | 1387 | return list; |
1336 | } | 1388 | } |
1337 | 1389 | ||
1338 | Address Addressee::findAddress( const QString &id ) const | 1390 | Address Addressee::findAddress( const QString &id ) const |
1339 | { | 1391 | { |
1340 | Address::List::ConstIterator it; | 1392 | Address::List::ConstIterator it; |
1341 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { | 1393 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { |
1342 | if ( (*it).id() == id ) { | 1394 | if ( (*it).id() == id ) { |
1343 | return *it; | 1395 | return *it; |
1344 | } | 1396 | } |
1345 | } | 1397 | } |
1346 | return Address(); | 1398 | return Address(); |
1347 | } | 1399 | } |
1348 | 1400 | ||
1349 | void Addressee::insertCategory( const QString &c ) | 1401 | void Addressee::insertCategory( const QString &c ) |
1350 | { | 1402 | { |
1351 | detach(); | 1403 | detach(); |
1352 | mData->empty = false; | 1404 | mData->empty = false; |
1353 | 1405 | ||
1354 | if ( mData->categories.contains( c ) ) return; | 1406 | if ( mData->categories.contains( c ) ) return; |
1355 | 1407 | ||
1356 | mData->categories.append( c ); | 1408 | mData->categories.append( c ); |
1357 | } | 1409 | } |
1358 | 1410 | ||
1359 | void Addressee::removeCategory( const QString &c ) | 1411 | void Addressee::removeCategory( const QString &c ) |
1360 | { | 1412 | { |
1361 | detach(); | 1413 | detach(); |
1362 | 1414 | ||
1363 | QStringList::Iterator it = mData->categories.find( c ); | 1415 | QStringList::Iterator it = mData->categories.find( c ); |
1364 | if ( it == mData->categories.end() ) return; | 1416 | if ( it == mData->categories.end() ) return; |
1365 | 1417 | ||
1366 | mData->categories.remove( it ); | 1418 | mData->categories.remove( it ); |
1367 | } | 1419 | } |
1368 | 1420 | ||
1369 | bool Addressee::hasCategory( const QString &c ) const | 1421 | bool Addressee::hasCategory( const QString &c ) const |
1370 | { | 1422 | { |
1371 | return ( mData->categories.contains( c ) ); | 1423 | return ( mData->categories.contains( c ) ); |
1372 | } | 1424 | } |
1373 | 1425 | ||
1374 | void Addressee::setCategories( const QStringList &c ) | 1426 | void Addressee::setCategories( const QStringList &c ) |
1375 | { | 1427 | { |
1376 | detach(); | 1428 | detach(); |
1377 | mData->empty = false; | 1429 | mData->empty = false; |
1378 | 1430 | ||
1379 | mData->categories = c; | 1431 | mData->categories = c; |
1380 | } | 1432 | } |
1381 | 1433 | ||
1382 | QStringList Addressee::categories() const | 1434 | QStringList Addressee::categories() const |
1383 | { | 1435 | { |
1384 | return mData->categories; | 1436 | return mData->categories; |
1385 | } | 1437 | } |
1386 | 1438 | ||
1387 | void Addressee::insertCustom( const QString &app, const QString &name, | 1439 | void Addressee::insertCustom( const QString &app, const QString &name, |
1388 | const QString &value ) | 1440 | const QString &value ) |
1389 | { | 1441 | { |
1390 | if ( value.isNull() || name.isEmpty() || app.isEmpty() ) return; | 1442 | if ( value.isNull() || name.isEmpty() || app.isEmpty() ) return; |
1391 | 1443 | ||
1392 | detach(); | 1444 | detach(); |
1393 | mData->empty = false; | 1445 | mData->empty = false; |
1394 | 1446 | ||
1395 | QString qualifiedName = app + "-" + name + ":"; | 1447 | QString qualifiedName = app + "-" + name + ":"; |
1396 | 1448 | ||
1397 | QStringList::Iterator it; | 1449 | QStringList::Iterator it; |
1398 | for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { | 1450 | for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { |
1399 | if ( (*it).startsWith( qualifiedName ) ) { | 1451 | if ( (*it).startsWith( qualifiedName ) ) { |
1400 | (*it) = qualifiedName + value; | 1452 | (*it) = qualifiedName + value; |
1401 | return; | 1453 | return; |
1402 | } | 1454 | } |
1403 | } | 1455 | } |
1404 | 1456 | ||
1405 | mData->custom.append( qualifiedName + value ); | 1457 | mData->custom.append( qualifiedName + value ); |
1406 | } | 1458 | } |
1407 | 1459 | ||
1408 | void Addressee::removeCustom( const QString &app, const QString &name) | 1460 | void Addressee::removeCustom( const QString &app, const QString &name) |
1409 | { | 1461 | { |
1410 | detach(); | 1462 | detach(); |
1411 | 1463 | ||
1412 | QString qualifiedName = app + "-" + name + ":"; | 1464 | QString qualifiedName = app + "-" + name + ":"; |
1413 | 1465 | ||
1414 | QStringList::Iterator it; | 1466 | QStringList::Iterator it; |
1415 | for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { | 1467 | for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { |
1416 | if ( (*it).startsWith( qualifiedName ) ) { | 1468 | if ( (*it).startsWith( qualifiedName ) ) { |
1417 | mData->custom.remove( it ); | 1469 | mData->custom.remove( it ); |
1418 | return; | 1470 | return; |
1419 | } | 1471 | } |
1420 | } | 1472 | } |
1421 | } | 1473 | } |
1422 | 1474 | ||
1423 | QString Addressee::custom( const QString &app, const QString &name ) const | 1475 | QString Addressee::custom( const QString &app, const QString &name ) const |
1424 | { | 1476 | { |
1425 | QString qualifiedName = app + "-" + name + ":"; | 1477 | QString qualifiedName = app + "-" + name + ":"; |
1426 | QString value; | 1478 | QString value; |
1427 | 1479 | ||
1428 | QStringList::ConstIterator it; | 1480 | QStringList::ConstIterator it; |
1429 | for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { | 1481 | for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { |
1430 | if ( (*it).startsWith( qualifiedName ) ) { | 1482 | if ( (*it).startsWith( qualifiedName ) ) { |
1431 | value = (*it).mid( (*it).find( ":" ) + 1 ); | 1483 | value = (*it).mid( (*it).find( ":" ) + 1 ); |
1432 | break; | 1484 | break; |
1433 | } | 1485 | } |
1434 | } | 1486 | } |
1435 | 1487 | ||
1436 | return value; | 1488 | return value; |
1437 | } | 1489 | } |
1438 | 1490 | ||
1439 | void Addressee::setCustoms( const QStringList &l ) | 1491 | void Addressee::setCustoms( const QStringList &l ) |
1440 | { | 1492 | { |
1441 | detach(); | 1493 | detach(); |
1442 | mData->empty = false; | 1494 | mData->empty = false; |
1443 | 1495 | ||
1444 | mData->custom = l; | 1496 | mData->custom = l; |
1445 | } | 1497 | } |
1446 | 1498 | ||
1447 | QStringList Addressee::customs() const | 1499 | QStringList Addressee::customs() const |
1448 | { | 1500 | { |
1449 | return mData->custom; | 1501 | return mData->custom; |
1450 | } | 1502 | } |
1451 | 1503 | ||
1452 | void Addressee::parseEmailAddress( const QString &rawEmail, QString &fullName, | 1504 | void Addressee::parseEmailAddress( const QString &rawEmail, QString &fullName, |
1453 | QString &email) | 1505 | QString &email) |
1454 | { | 1506 | { |
1455 | int startPos, endPos, len; | 1507 | int startPos, endPos, len; |
1456 | QString partA, partB, result; | 1508 | QString partA, partB, result; |
1457 | char endCh = '>'; | 1509 | char endCh = '>'; |
1458 | 1510 | ||
1459 | startPos = rawEmail.find('<'); | 1511 | startPos = rawEmail.find('<'); |
1460 | if (startPos < 0) | 1512 | if (startPos < 0) |
1461 | { | 1513 | { |
1462 | startPos = rawEmail.find('('); | 1514 | startPos = rawEmail.find('('); |
1463 | endCh = ')'; | 1515 | endCh = ')'; |
1464 | } | 1516 | } |
1465 | if (startPos < 0) | 1517 | if (startPos < 0) |
1466 | { | 1518 | { |
1467 | // We couldn't find any separators, so we assume the whole string | 1519 | // We couldn't find any separators, so we assume the whole string |
1468 | // is the email address | 1520 | // is the email address |
1469 | email = rawEmail; | 1521 | email = rawEmail; |
1470 | fullName = ""; | 1522 | fullName = ""; |
1471 | } | 1523 | } |
1472 | else | 1524 | else |
1473 | { | 1525 | { |
1474 | // We have a start position, try to find an end | 1526 | // We have a start position, try to find an end |
1475 | endPos = rawEmail.find(endCh, startPos+1); | 1527 | endPos = rawEmail.find(endCh, startPos+1); |
1476 | 1528 | ||
1477 | if (endPos < 0) | 1529 | if (endPos < 0) |
1478 | { | 1530 | { |
1479 | // We couldn't find the end of the email address. We can only | 1531 | // We couldn't find the end of the email address. We can only |
1480 | // assume the entire string is the email address. | 1532 | // assume the entire string is the email address. |
1481 | email = rawEmail; | 1533 | email = rawEmail; |
1482 | fullName = ""; | 1534 | fullName = ""; |
1483 | } | 1535 | } |
1484 | else | 1536 | else |
1485 | { | 1537 | { |
1486 | // We have a start and end to the email address | 1538 | // We have a start and end to the email address |
1487 | 1539 | ||
1488 | // Grab the name part | 1540 | // Grab the name part |
1489 | fullName = rawEmail.left(startPos).stripWhiteSpace(); | 1541 | fullName = rawEmail.left(startPos).stripWhiteSpace(); |
1490 | 1542 | ||
1491 | // grab the email part | 1543 | // grab the email part |
1492 | email = rawEmail.mid(startPos+1, endPos-startPos-1).stripWhiteSpace(); | 1544 | email = rawEmail.mid(startPos+1, endPos-startPos-1).stripWhiteSpace(); |
1493 | 1545 | ||
1494 | // Check that we do not have any extra characters on the end of the | 1546 | // Check that we do not have any extra characters on the end of the |
1495 | // strings | 1547 | // strings |
1496 | len = fullName.length(); | 1548 | len = fullName.length(); |
1497 | if (fullName[0]=='"' && fullName[len-1]=='"') | 1549 | if (fullName[0]=='"' && fullName[len-1]=='"') |
1498 | fullName = fullName.mid(1, len-2); | 1550 | fullName = fullName.mid(1, len-2); |
1499 | else if (fullName[0]=='<' && fullName[len-1]=='>') | 1551 | else if (fullName[0]=='<' && fullName[len-1]=='>') |
1500 | fullName = fullName.mid(1, len-2); | 1552 | fullName = fullName.mid(1, len-2); |
1501 | else if (fullName[0]=='(' && fullName[len-1]==')') | 1553 | else if (fullName[0]=='(' && fullName[len-1]==')') |
1502 | fullName = fullName.mid(1, len-2); | 1554 | fullName = fullName.mid(1, len-2); |
1503 | } | 1555 | } |
1504 | } | 1556 | } |
1505 | } | 1557 | } |
1506 | 1558 | ||
1507 | void Addressee::setResource( Resource *resource ) | 1559 | void Addressee::setResource( Resource *resource ) |
1508 | { | 1560 | { |
1509 | detach(); | 1561 | detach(); |
1510 | mData->resource = resource; | 1562 | mData->resource = resource; |
1511 | } | 1563 | } |
1512 | 1564 | ||
1513 | Resource *Addressee::resource() const | 1565 | Resource *Addressee::resource() const |
1514 | { | 1566 | { |
1515 | return mData->resource; | 1567 | return mData->resource; |
1516 | } | 1568 | } |
1517 | 1569 | ||
1518 | //US | 1570 | //US |
1519 | QString Addressee::resourceLabel() | 1571 | QString Addressee::resourceLabel() |
1520 | { | 1572 | { |
1521 | return i18n("Resource"); | 1573 | return i18n("Resource"); |
1522 | } | 1574 | } |
1523 | 1575 | ||
1524 | void Addressee::setChanged( bool value ) | 1576 | void Addressee::setChanged( bool value ) |
1525 | { | 1577 | { |
1526 | detach(); | 1578 | detach(); |
1527 | mData->changed = value; | 1579 | mData->changed = value; |
1528 | } | 1580 | } |
1529 | 1581 | ||
1530 | bool Addressee::changed() const | 1582 | bool Addressee::changed() const |
1531 | { | 1583 | { |
1532 | return mData->changed; | 1584 | return mData->changed; |
1533 | } | 1585 | } |
1534 | 1586 | ||
1535 | QDataStream &KABC::operator<<( QDataStream &s, const Addressee &a ) | 1587 | QDataStream &KABC::operator<<( QDataStream &s, const Addressee &a ) |
1536 | { | 1588 | { |
1537 | if (!a.mData) return s; | 1589 | if (!a.mData) return s; |
1538 | 1590 | ||
1539 | s << a.uid(); | 1591 | s << a.uid(); |
1540 | 1592 | ||
1541 | s << a.mData->name; | 1593 | s << a.mData->name; |
1542 | s << a.mData->formattedName; | 1594 | s << a.mData->formattedName; |
1543 | s << a.mData->familyName; | 1595 | s << a.mData->familyName; |
1544 | s << a.mData->givenName; | 1596 | s << a.mData->givenName; |
1545 | s << a.mData->additionalName; | 1597 | s << a.mData->additionalName; |
1546 | s << a.mData->prefix; | 1598 | s << a.mData->prefix; |
1547 | s << a.mData->suffix; | 1599 | s << a.mData->suffix; |
1548 | s << a.mData->nickName; | 1600 | s << a.mData->nickName; |
1549 | s << a.mData->birthday; | 1601 | s << a.mData->birthday; |
1550 | s << a.mData->mailer; | 1602 | s << a.mData->mailer; |
1551 | s << a.mData->timeZone; | 1603 | s << a.mData->timeZone; |
1552 | s << a.mData->geo; | 1604 | s << a.mData->geo; |
1553 | s << a.mData->title; | 1605 | s << a.mData->title; |
1554 | s << a.mData->role; | 1606 | s << a.mData->role; |
1555 | s << a.mData->organization; | 1607 | s << a.mData->organization; |
1556 | s << a.mData->note; | 1608 | s << a.mData->note; |
1557 | s << a.mData->productId; | 1609 | s << a.mData->productId; |
1558 | s << a.mData->revision; | 1610 | s << a.mData->revision; |
1559 | s << a.mData->sortString; | 1611 | s << a.mData->sortString; |
1560 | s << a.mData->url; | 1612 | s << a.mData->url; |
1561 | s << a.mData->secrecy; | 1613 | s << a.mData->secrecy; |
1562 | s << a.mData->logo; | 1614 | s << a.mData->logo; |
1563 | s << a.mData->photo; | 1615 | s << a.mData->photo; |
1564 | s << a.mData->sound; | 1616 | s << a.mData->sound; |
1565 | s << a.mData->agent; | 1617 | s << a.mData->agent; |
1566 | s << a.mData->phoneNumbers; | 1618 | s << a.mData->phoneNumbers; |
1567 | s << a.mData->addresses; | 1619 | s << a.mData->addresses; |
1568 | s << a.mData->emails; | 1620 | s << a.mData->emails; |
1569 | s << a.mData->categories; | 1621 | s << a.mData->categories; |
1570 | s << a.mData->custom; | 1622 | s << a.mData->custom; |
1571 | s << a.mData->keys; | 1623 | s << a.mData->keys; |
1572 | return s; | 1624 | return s; |
1573 | } | 1625 | } |
1574 | 1626 | ||
1575 | QDataStream &KABC::operator>>( QDataStream &s, Addressee &a ) | 1627 | QDataStream &KABC::operator>>( QDataStream &s, Addressee &a ) |
1576 | { | 1628 | { |
1577 | if (!a.mData) return s; | 1629 | if (!a.mData) return s; |
1578 | 1630 | ||
1579 | s >> a.mData->uid; | 1631 | s >> a.mData->uid; |
1580 | 1632 | ||
1581 | s >> a.mData->name; | 1633 | s >> a.mData->name; |
1582 | s >> a.mData->formattedName; | 1634 | s >> a.mData->formattedName; |
1583 | s >> a.mData->familyName; | 1635 | s >> a.mData->familyName; |
1584 | s >> a.mData->givenName; | 1636 | s >> a.mData->givenName; |
1585 | s >> a.mData->additionalName; | 1637 | s >> a.mData->additionalName; |
1586 | s >> a.mData->prefix; | 1638 | s >> a.mData->prefix; |
1587 | s >> a.mData->suffix; | 1639 | s >> a.mData->suffix; |
1588 | s >> a.mData->nickName; | 1640 | s >> a.mData->nickName; |
1589 | s >> a.mData->birthday; | 1641 | s >> a.mData->birthday; |
1590 | s >> a.mData->mailer; | 1642 | s >> a.mData->mailer; |
1591 | s >> a.mData->timeZone; | 1643 | s >> a.mData->timeZone; |
1592 | s >> a.mData->geo; | 1644 | s >> a.mData->geo; |
1593 | s >> a.mData->title; | 1645 | s >> a.mData->title; |
1594 | s >> a.mData->role; | 1646 | s >> a.mData->role; |
1595 | s >> a.mData->organization; | 1647 | s >> a.mData->organization; |
1596 | s >> a.mData->note; | 1648 | s >> a.mData->note; |
1597 | s >> a.mData->productId; | 1649 | s >> a.mData->productId; |
1598 | s >> a.mData->revision; | 1650 | s >> a.mData->revision; |
1599 | s >> a.mData->sortString; | 1651 | s >> a.mData->sortString; |
1600 | s >> a.mData->url; | 1652 | s >> a.mData->url; |
1601 | s >> a.mData->secrecy; | 1653 | s >> a.mData->secrecy; |
1602 | s >> a.mData->logo; | 1654 | s >> a.mData->logo; |
1603 | s >> a.mData->photo; | 1655 | s >> a.mData->photo; |
1604 | s >> a.mData->sound; | 1656 | s >> a.mData->sound; |
1605 | s >> a.mData->agent; | 1657 | s >> a.mData->agent; |
1606 | s >> a.mData->phoneNumbers; | 1658 | s >> a.mData->phoneNumbers; |
1607 | s >> a.mData->addresses; | 1659 | s >> a.mData->addresses; |
1608 | s >> a.mData->emails; | 1660 | s >> a.mData->emails; |
1609 | s >> a.mData->categories; | 1661 | s >> a.mData->categories; |
1610 | s >> a.mData->custom; | 1662 | s >> a.mData->custom; |
1611 | s >> a.mData->keys; | 1663 | s >> a.mData->keys; |
1612 | 1664 | ||
1613 | a.mData->empty = false; | 1665 | a.mData->empty = false; |
1614 | 1666 | ||
1615 | return s; | 1667 | return s; |
1616 | } | 1668 | } |
1617 | 1669 | ||
1618 | bool matchBinaryPattern( int value, int pattern ) | 1670 | bool matchBinaryPattern( int value, int pattern ) |
1619 | { | 1671 | { |
1620 | /** | 1672 | /** |
1621 | We want to match all telephonnumbers/addresses which have the bits in the | 1673 | We want to match all telephonnumbers/addresses which have the bits in the |
1622 | pattern set. More are allowed. | 1674 | pattern set. More are allowed. |
1623 | if pattern == 0 we have a special handling, then we want only those with | 1675 | if pattern == 0 we have a special handling, then we want only those with |
1624 | exactly no bit set. | 1676 | exactly no bit set. |
1625 | */ | 1677 | */ |
1626 | if ( pattern == 0 ) | 1678 | if ( pattern == 0 ) |
1627 | return ( value == 0 ); | 1679 | return ( value == 0 ); |
1628 | else | 1680 | else |
1629 | return ( pattern == ( pattern & value ) ); | 1681 | return ( pattern == ( pattern & value ) ); |
1630 | } | 1682 | } |