summaryrefslogtreecommitdiffabout
path: root/kabc
Unidiff
Diffstat (limited to 'kabc') (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/addressee.cpp75
-rw-r--r--kabc/phonenumber.cpp32
-rw-r--r--kabc/phonenumber.h1
3 files changed, 62 insertions, 46 deletions
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp
index cb10160..2aca559 100644
--- a/kabc/addressee.cpp
+++ b/kabc/addressee.cpp
@@ -182,349 +182,342 @@ ulong Addressee::getCsum4List( const QStringList & attList)
182{ 182{
183 int max = attList.count(); 183 int max = attList.count();
184 ulong cSum = 0; 184 ulong cSum = 0;
185 int j,k,i; 185 int j,k,i;
186 int add; 186 int add;
187 for ( i = 0; i < max ; ++i ) { 187 for ( i = 0; i < max ; ++i ) {
188 QString s = attList[i]; 188 QString s = attList[i];
189 if ( ! s.isEmpty() ){ 189 if ( ! s.isEmpty() ){
190 j = s.length(); 190 j = s.length();
191 for ( k = 0; k < j; ++k ) { 191 for ( k = 0; k < j; ++k ) {
192 int mul = k +1; 192 int mul = k +1;
193 add = s[k].unicode (); 193 add = s[k].unicode ();
194 if ( k < 16 ) 194 if ( k < 16 )
195 mul = mul * mul; 195 mul = mul * mul;
196 int ii = i+1; 196 int ii = i+1;
197 add = add * mul *ii*ii*ii; 197 add = add * mul *ii*ii*ii;
198 cSum += add; 198 cSum += add;
199 } 199 }
200 } 200 }
201 201
202 } 202 }
203 //QString dump = attList.join(","); 203 //QString dump = attList.join(",");
204 //qDebug("csum: %d %s", cSum,dump.latin1()); 204 //qDebug("csum: %d %s", cSum,dump.latin1());
205 205
206 return cSum; 206 return cSum;
207 207
208} 208}
209void Addressee::computeCsum(const QString &dev) 209void Addressee::computeCsum(const QString &dev)
210{ 210{
211 QStringList l; 211 QStringList l;
212 if ( !mData->name.isEmpty() ) l.append(mData->name); 212 if ( !mData->name.isEmpty() ) l.append(mData->name);
213 if ( !mData->formattedName.isEmpty() ) l.append(mData->formattedName ); 213 if ( !mData->formattedName.isEmpty() ) l.append(mData->formattedName );
214 if ( !mData->familyName.isEmpty() ) l.append( mData->familyName ); 214 if ( !mData->familyName.isEmpty() ) l.append( mData->familyName );
215 if ( !mData->givenName.isEmpty() ) l.append(mData->givenName ); 215 if ( !mData->givenName.isEmpty() ) l.append(mData->givenName );
216 if ( !mData->additionalName ) l.append( mData->additionalName ); 216 if ( !mData->additionalName ) l.append( mData->additionalName );
217 if ( !mData->prefix.isEmpty() ) l.append( mData->prefix ); 217 if ( !mData->prefix.isEmpty() ) l.append( mData->prefix );
218 if ( !mData->suffix.isEmpty() ) l.append( mData->suffix ); 218 if ( !mData->suffix.isEmpty() ) l.append( mData->suffix );
219 if ( !mData->nickName.isEmpty() ) l.append( mData->nickName ); 219 if ( !mData->nickName.isEmpty() ) l.append( mData->nickName );
220 if ( mData->birthday.isValid() ) l.append( mData->birthday.toString() ); 220 if ( mData->birthday.isValid() ) l.append( mData->birthday.toString() );
221 if ( !mData->mailer.isEmpty() ) l.append( mData->mailer ); 221 if ( !mData->mailer.isEmpty() ) l.append( mData->mailer );
222 if ( mData->timeZone.isValid() ) l.append( mData->timeZone.asString() ); 222 if ( mData->timeZone.isValid() ) l.append( mData->timeZone.asString() );
223 if ( mData->geo.isValid() ) l.append( mData->geo.asString() ); 223 if ( mData->geo.isValid() ) l.append( mData->geo.asString() );
224 if ( !mData->title .isEmpty() ) l.append( mData->title ); 224 if ( !mData->title .isEmpty() ) l.append( mData->title );
225 if ( !mData->role.isEmpty() ) l.append( mData->role ); 225 if ( !mData->role.isEmpty() ) l.append( mData->role );
226 if ( !mData->organization.isEmpty() ) l.append( mData->organization ); 226 if ( !mData->organization.isEmpty() ) l.append( mData->organization );
227 if ( !mData->note.isEmpty() ) l.append( mData->note ); 227 if ( !mData->note.isEmpty() ) l.append( mData->note );
228 if ( !mData->productId.isEmpty() ) l.append(mData->productId ); 228 if ( !mData->productId.isEmpty() ) l.append(mData->productId );
229 if ( !mData->sortString.isEmpty() ) l.append( mData->sortString ); 229 if ( !mData->sortString.isEmpty() ) l.append( mData->sortString );
230 if ( mData->secrecy.isValid() ) l.append( mData->secrecy.asString()); 230 if ( mData->secrecy.isValid() ) l.append( mData->secrecy.asString());
231 // if ( !mData->logo.isEmpty() ) l.append( ); 231 // if ( !mData->logo.isEmpty() ) l.append( );
232 //if ( !mData->photo.isEmpty() ) l.append( ); 232 //if ( !mData->photo.isEmpty() ) l.append( );
233 //if ( !mData->sound.isEmpty() ) l.append( ); 233 //if ( !mData->sound.isEmpty() ) l.append( );
234 //if ( !mData->agent.isEmpty() ) l.append( ); 234 //if ( !mData->agent.isEmpty() ) l.append( );
235 if ( mData->url.isValid() ) 235 if ( mData->url.isValid() )
236 if ( ! mData->url.path().isEmpty()) l.append( mData->url.path() ); 236 if ( ! mData->url.path().isEmpty()) l.append( mData->url.path() );
237 KABC::PhoneNumber::List phoneNumbers; 237 KABC::PhoneNumber::List phoneNumbers;
238 KABC::PhoneNumber::List::Iterator phoneIter; 238 KABC::PhoneNumber::List::Iterator phoneIter;
239 239
240 QStringList t; 240 QStringList t;
241 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); 241 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end();
242 ++phoneIter ) 242 ++phoneIter )
243 t.append( ( *phoneIter ).number()+QString::number( ( *phoneIter ).type() ) ); 243 t.append( ( *phoneIter ).number()+QString::number( ( *phoneIter ).type() ) );
244 t.sort(); 244 t.sort();
245 uint iii; 245 uint iii;
246 for ( iii = 0; iii < t.count(); ++iii) 246 for ( iii = 0; iii < t.count(); ++iii)
247 l.append( t[iii] ); 247 l.append( t[iii] );
248 t = mData->emails; 248 t = mData->emails;
249 t.sort(); 249 t.sort();
250 for ( iii = 0; iii < t.count(); ++iii) 250 for ( iii = 0; iii < t.count(); ++iii)
251 l.append( t[iii] ); 251 l.append( t[iii] );
252 t = mData->categories; 252 t = mData->categories;
253 t.sort(); 253 t.sort();
254 for ( iii = 0; iii < t.count(); ++iii) 254 for ( iii = 0; iii < t.count(); ++iii)
255 l.append( t[iii] ); 255 l.append( t[iii] );
256 t = mData->custom; 256 t = mData->custom;
257 t.sort(); 257 t.sort();
258 for ( iii = 0; iii < t.count(); ++iii) 258 for ( iii = 0; iii < t.count(); ++iii)
259 l.append( t[iii] ); 259 l.append( t[iii] );
260 KABC::Address::List::Iterator addressIter; 260 KABC::Address::List::Iterator addressIter;
261 for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); 261 for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end();
262 ++addressIter ) { 262 ++addressIter ) {
263 t = (*addressIter).asList(); 263 t = (*addressIter).asList();
264 t.sort(); 264 t.sort();
265 for ( iii = 0; iii < t.count(); ++iii) 265 for ( iii = 0; iii < t.count(); ++iii)
266 l.append( t[iii] ); 266 l.append( t[iii] );
267 } 267 }
268 uint cs = getCsum4List(l); 268 uint cs = getCsum4List(l);
269 // qDebug("CSUM computed %d %s %s", cs,QString::number (cs ).latin1(), uid().latin1() ); 269 // qDebug("CSUM computed %d %s %s", cs,QString::number (cs ).latin1(), uid().latin1() );
270 setCsum( dev, QString::number (cs )); 270 setCsum( dev, QString::number (cs ));
271} 271}
272 272
273void Addressee::mergeContact( const Addressee& ad , bool isSubSet) // = false) 273void Addressee::mergeContact( const Addressee& ad , bool isSubSet) // = false)
274{ 274{
275 275
276 detach(); 276 detach();
277 if ( mData->name.isEmpty() ) mData->name = ad.mData->name; 277 if ( mData->name.isEmpty() ) mData->name = ad.mData->name;
278 if ( mData->formattedName.isEmpty() ) mData->formattedName = ad.mData->formattedName; 278 if ( mData->formattedName.isEmpty() ) mData->formattedName = ad.mData->formattedName;
279 if ( mData->familyName.isEmpty() ) mData->familyName = ad.mData->familyName; 279 if ( mData->familyName.isEmpty() ) mData->familyName = ad.mData->familyName;
280 if ( mData->givenName.isEmpty() ) mData->givenName = ad.mData->givenName ; 280 if ( mData->givenName.isEmpty() ) mData->givenName = ad.mData->givenName ;
281 if ( mData->additionalName ) mData->additionalName = ad.mData->additionalName; 281 if ( mData->additionalName ) mData->additionalName = ad.mData->additionalName;
282 if ( mData->prefix.isEmpty() ) mData->prefix = ad.mData->prefix; 282 if ( mData->prefix.isEmpty() ) mData->prefix = ad.mData->prefix;
283 if ( mData->suffix.isEmpty() ) mData->suffix = ad.mData->suffix; 283 if ( mData->suffix.isEmpty() ) mData->suffix = ad.mData->suffix;
284 if ( mData->nickName.isEmpty() ) mData->nickName = ad.mData->nickName; 284 if ( mData->nickName.isEmpty() ) mData->nickName = ad.mData->nickName;
285 if ( !mData->birthday.isValid() ) 285 if ( !mData->birthday.isValid() )
286 if ( ad.mData->birthday.isValid()) 286 if ( ad.mData->birthday.isValid())
287 mData->birthday = ad.mData->birthday; 287 mData->birthday = ad.mData->birthday;
288 if ( mData->mailer.isEmpty() ) mData->mailer = ad.mData->mailer; 288 if ( mData->mailer.isEmpty() ) mData->mailer = ad.mData->mailer;
289 if ( !mData->timeZone.isValid() ) mData->timeZone = ad.mData->timeZone; 289 if ( !mData->timeZone.isValid() ) mData->timeZone = ad.mData->timeZone;
290 if ( !mData->geo.isValid() ) mData->geo = ad.mData->geo; 290 if ( !mData->geo.isValid() ) mData->geo = ad.mData->geo;
291 if ( mData->title .isEmpty() ) mData->title = ad.mData->title ; 291 if ( mData->title .isEmpty() ) mData->title = ad.mData->title ;
292 if ( mData->role.isEmpty() ) mData->role = ad.mData->role ; 292 if ( mData->role.isEmpty() ) mData->role = ad.mData->role ;
293 if ( mData->organization.isEmpty() ) mData->organization = ad.mData->organization ; 293 if ( mData->organization.isEmpty() ) mData->organization = ad.mData->organization ;
294 if ( mData->note.isEmpty() ) mData->note = ad.mData->note ; 294 if ( mData->note.isEmpty() ) mData->note = ad.mData->note ;
295 if ( mData->productId.isEmpty() ) mData->productId = ad.mData->productId; 295 if ( mData->productId.isEmpty() ) mData->productId = ad.mData->productId;
296 if ( mData->sortString.isEmpty() ) mData->sortString = ad.mData->sortString; 296 if ( mData->sortString.isEmpty() ) mData->sortString = ad.mData->sortString;
297 if ( !mData->secrecy.isValid() ) mData->secrecy = ad.mData->secrecy; 297 if ( !mData->secrecy.isValid() ) mData->secrecy = ad.mData->secrecy;
298 if ( ( !mData->url.isValid() && ad.mData->url.isValid() ) ) mData->url = ad.mData->url ; 298 if ( ( !mData->url.isValid() && ad.mData->url.isValid() ) ) mData->url = ad.mData->url ;
299 QStringList t; 299 QStringList t;
300 QStringList tAD; 300 QStringList tAD;
301 uint iii; 301 uint iii;
302 if ( isSubSet ) { 302 if ( isSubSet ) {
303 // ********** phone numbers 303 // ********** phone numbers
304 PhoneNumber::List phoneAD = ad.phoneNumbers(); 304 PhoneNumber::List phoneAD = ad.phoneNumbers();
305 PhoneNumber::List::Iterator phoneItAD; 305 PhoneNumber::List::Iterator phoneItAD;
306 for ( phoneItAD = phoneAD.begin(); phoneItAD != phoneAD.end(); ++phoneItAD ) { 306 for ( phoneItAD = phoneAD.begin(); phoneItAD != phoneAD.end(); ++phoneItAD ) {
307 bool found = false; 307 bool found = false;
308 PhoneNumber::List::Iterator it; 308 PhoneNumber::List::Iterator it;
309 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { 309 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) {
310 if ( (*it) == ( *phoneItAD ) ) { 310 if ( ( *phoneItAD ).contains( (*it) ) ) {
311 found = true; 311 found = true;
312 (*it).setType( ( *phoneItAD ).type() );
312 break; 313 break;
313 } 314 }
314 } 315 }
315 if ( ! found ) 316 if ( ! found )
316 mData->phoneNumbers.append( *phoneItAD ); 317 mData->phoneNumbers.append( *phoneItAD );
317 } 318 }
318 // ************* emails; 319 // ************* emails;
319 t = mData->emails; 320 t = mData->emails;
320 tAD = ad.mData->emails; 321 tAD = ad.mData->emails;
321 for ( iii = 0; iii < tAD.count(); ++iii) 322 for ( iii = 0; iii < tAD.count(); ++iii)
322 if ( !t.contains(tAD[iii] ) ) 323 if ( !t.contains(tAD[iii] ) )
323 mData->emails.append( tAD[iii] ); 324 mData->emails.append( tAD[iii] );
324 // ************* categories; 325 // ************* categories;
325 t = mData->categories; 326 t = mData->categories;
326 tAD = ad.mData->categories; 327 tAD = ad.mData->categories;
327 for ( iii = 0; iii < tAD.count(); ++iii) 328 for ( iii = 0; iii < tAD.count(); ++iii)
328 if ( !t.contains(tAD[iii] ) ) 329 if ( !t.contains(tAD[iii] ) )
329 mData->categories.append( tAD[iii] ); 330 mData->categories.append( tAD[iii] );
330 331
331 332
332 } 333 }
333 334
334 QStringList::ConstIterator it; 335 QStringList::ConstIterator it;
335 for( it = ad.mData->custom.begin(); it != ad.mData->custom.end(); ++it ) { 336 for( it = ad.mData->custom.begin(); it != ad.mData->custom.end(); ++it ) {
336 QString qualifiedName = (*it).left( (*it).find( ":" )); 337 QString qualifiedName = (*it).left( (*it).find( ":" ));
337 bool found = false; 338 bool found = false;
338 QStringList::ConstIterator itL; 339 QStringList::ConstIterator itL;
339 for( itL = mData->custom.begin(); itL != mData->custom.end(); ++itL ) { 340 for( itL = mData->custom.begin(); itL != mData->custom.end(); ++itL ) {
340 if ( (*itL).startsWith( qualifiedName ) ) { 341 if ( (*itL).startsWith( qualifiedName ) ) {
341 found = true; 342 found = true;
342 break; 343 break;
343 } 344 }
344 } 345 }
345 if ( ! found ) { 346 if ( ! found ) {
346 mData->custom.append( *it ); 347 mData->custom.append( *it );
347 } 348 }
348 } 349 }
349 if ( mData->logo.undefined() && !ad.mData->logo.undefined() ) mData->logo = ad.mData->logo; 350 if ( mData->logo.undefined() && !ad.mData->logo.undefined() ) mData->logo = ad.mData->logo;
350 if ( mData->photo.undefined() && !ad.mData->photo.undefined() ) mData->photo = ad.mData->photo; 351 if ( mData->photo.undefined() && !ad.mData->photo.undefined() ) mData->photo = ad.mData->photo;
351 if ( !mData->sound.isIntern() ) { 352 if ( !mData->sound.isIntern() ) {
352 if ( mData->sound.url().isEmpty() ) { 353 if ( mData->sound.url().isEmpty() ) {
353 mData->sound = ad.mData->sound; 354 mData->sound = ad.mData->sound;
354 } 355 }
355 } 356 }
356 if ( !mData->agent.isIntern() ) { 357 if ( !mData->agent.isIntern() ) {
357 if ( mData->agent.url().isEmpty() ) { 358 if ( mData->agent.url().isEmpty() ) {
358 mData->agent = ad.mData->agent; 359 mData->agent = ad.mData->agent;
359 } 360 }
360 } 361 }
361 362 {
362#if 0 363 Key::List::Iterator itA;
363 364 for( itA = ad.mData->keys.begin(); itA != ad.mData->keys.end(); ++itA ) {
364 if ( mData->url.isValid() ) 365 bool found = false;
365 if ( ! mData->url.path().isEmpty()) l.append( mData->url.path() ); 366 Key::List::Iterator it;
366 KABC::PhoneNumber::List phoneNumbers; 367 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) {
367 KABC::PhoneNumber::List::Iterator phoneIter; 368 if ( (*it) == (*itA)) {
368 369 found = true;
369 QStringList t; 370 break;
370 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); 371
371 ++phoneIter ) 372 }
372 t.append( ( *phoneIter ).number()+QString::number( ( *phoneIter ).type() ) ); 373 }
373 t.sort(); 374 if ( ! found ) {
374 uint iii; 375 mData->keys.append( *itA );
375 for ( iii = 0; iii < t.count(); ++iii) 376 }
376 l.append( t[iii] ); 377 }
377 t = mData->emails;
378 t.sort();
379 for ( iii = 0; iii < t.count(); ++iii)
380 l.append( t[iii] );
381 t = mData->categories;
382 t.sort();
383 for ( iii = 0; iii < t.count(); ++iii)
384 l.append( t[iii] );
385 t = mData->custom;
386 t.sort();
387 for ( iii = 0; iii < t.count(); ++iii)
388 l.append( t[iii] );
389 KABC::Address::List::Iterator addressIter;
390 for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end();
391 ++addressIter ) {
392 t = (*addressIter).asList();
393 t.sort();
394 for ( iii = 0; iii < t.count(); ++iii)
395 l.append( t[iii] );
396 } 378 }
379 KABC::Address::List::Iterator addressIterA;
380 for ( addressIterA = ad.mData->addresses.begin(); addressIterA != ad.mData->addresses.end(); ++addressIterA ) {
381 bool found = false;
382 KABC::Address::List::Iterator addressIter;
383 for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end();
384 ++addressIter ) {
385 if ( (*addressIter) == (*addressIterA)) {
386 found = true;
387 (*addressIter).setType( (*addressIterA).type() );
388 break;
389 }
397 390
398#endif 391 }
399 392 if ( ! found ) {
400 // pending: 393 mData->addresses.append( *addressIterA );
401 // merging addresses 394 }
402 // merging keys 395 }
403 //qDebug("merge contact %s ", ad.uid().latin1()); 396 //qDebug("merge contact %s ", ad.uid().latin1());
404 setUid( ad.uid() ); 397 setUid( ad.uid() );
405 setRevision( ad.revision() ); 398 setRevision( ad.revision() );
406} 399}
407 400
408bool Addressee::removeVoice() 401bool Addressee::removeVoice()
409{ 402{
410 PhoneNumber::List phoneN = phoneNumbers(); 403 PhoneNumber::List phoneN = phoneNumbers();
411 PhoneNumber::List::Iterator phoneIt; 404 PhoneNumber::List::Iterator phoneIt;
412 bool found = false; 405 bool found = false;
413 for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) { 406 for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) {
414 if ( (*phoneIt).type() & PhoneNumber::Voice) { // voice found 407 if ( (*phoneIt).type() & PhoneNumber::Voice) { // voice found
415 if ((*phoneIt).type() - PhoneNumber::Voice ) { 408 if ((*phoneIt).type() - PhoneNumber::Voice ) {
416 (*phoneIt).setType((*phoneIt).type() - PhoneNumber::Voice ); 409 (*phoneIt).setType((*phoneIt).type() - PhoneNumber::Voice );
417 insertPhoneNumber( (*phoneIt) ); 410 insertPhoneNumber( (*phoneIt) );
418 found = true; 411 found = true;
419 } 412 }
420 } 413 }
421 414
422 } 415 }
423 return found; 416 return found;
424} 417}
425 418
426bool Addressee::containsAdr(const Addressee& ad ) 419bool Addressee::containsAdr(const Addressee& ad )
427{ 420{
428 if ( ! ad.mData->familyName.isEmpty() ) if ( mData->familyName != ad.mData->familyName) return false; 421 if ( ! ad.mData->familyName.isEmpty() ) if ( mData->familyName != ad.mData->familyName) return false;
429 if ( ! ad.mData->givenName.isEmpty() )if ( mData->givenName != ad.mData->givenName ) return false; 422 if ( ! ad.mData->givenName.isEmpty() )if ( mData->givenName != ad.mData->givenName ) return false;
430 if ( ad.mData->url.isValid() ) if (mData->url != ad.mData->url) return false ; 423 if ( ad.mData->url.isValid() ) if (mData->url != ad.mData->url) return false ;
431 if ( ! ad.mData->role.isEmpty() ) if (mData->role != ad.mData->role) return false ; 424 if ( ! ad.mData->role.isEmpty() ) if (mData->role != ad.mData->role) return false ;
432 if ( ! ad.mData->organization.isEmpty() ) if (mData->organization != ad.mData->organization) return false ; 425 if ( ! ad.mData->organization.isEmpty() ) if (mData->organization != ad.mData->organization) return false ;
433 if ( ! ad.mData->note.isEmpty() ) if (mData->note != ad.mData->note) return false ; 426 if ( ! ad.mData->note.isEmpty() ) if (mData->note != ad.mData->note) return false ;
434 if ( ! ad.mData->title .isEmpty() ) if (mData->title != ad.mData->title ) return false ; 427 if ( ! ad.mData->title .isEmpty() ) if (mData->title != ad.mData->title ) return false ;
435 428
436 // compare phone numbers 429 // compare phone numbers
437 PhoneNumber::List phoneN = ad.phoneNumbers(); 430 PhoneNumber::List phoneN = ad.phoneNumbers();
438 PhoneNumber::List::Iterator phoneIt; 431 PhoneNumber::List::Iterator phoneIt;
439 bool found = false; 432 bool found = false;
440 for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) { 433 for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) {
441 bool found = false; 434 bool found = false;
442 PhoneNumber::List phoneL = ad.phoneNumbers(); 435 PhoneNumber::List phoneL = ad.phoneNumbers();
443 PhoneNumber::List::Iterator phoneItL; 436 PhoneNumber::List::Iterator phoneItL;
444 for ( phoneItL = phoneL.begin(); phoneItL != phoneL.end(); ++phoneItL ) { 437 for ( phoneItL = phoneL.begin(); phoneItL != phoneL.end(); ++phoneItL ) {
445 if ( ( *phoneItL ).number() == ( *phoneIt ).number() ) { 438 if ( ( *phoneItL ).number() == ( *phoneIt ).number() ) {
446 found = true; 439 found = true;
447 break; 440 break;
448 } 441 }
449 } 442 }
450 if ( ! found ) 443 if ( ! found )
451 return false; 444 return false;
452 } 445 }
453 return true; 446 return true;
454 447
455} 448}
456void Addressee::simplifyAddresses() 449void Addressee::simplifyAddresses()
457{ 450{
458 int max = 2; 451 int max = 2;
459 if ( mData->url.isValid() ) 452 if ( mData->url.isValid() )
460 max = 1; 453 max = 1;
461 if ( mData->addresses.count() <= max ) return ; 454 if ( mData->addresses.count() <= max ) return ;
462 int count = 0; 455 int count = 0;
463 Address::List list; 456 Address::List list;
464 Address::List::Iterator it; 457 Address::List::Iterator it;
465 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { 458 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) {
466 if ( count >= max ) 459 if ( count >= max )
467 list.append( *it ); 460 list.append( *it );
468 ++count; 461 ++count;
469 } 462 }
470 for( it = list.begin(); it != list.end(); ++it ) { 463 for( it = list.begin(); it != list.end(); ++it ) {
471 removeAddress( (*it) ); 464 removeAddress( (*it) );
472 } 465 }
473} 466}
474 467
475// removes all emails but the first 468// removes all emails but the first
476// needed by phone sync 469// needed by phone sync
477void Addressee::simplifyEmails() 470void Addressee::simplifyEmails()
478{ 471{
479 if ( mData->emails.count() == 0 ) return ; 472 if ( mData->emails.count() == 0 ) return ;
480 QString email = mData->emails.first(); 473 QString email = mData->emails.first();
481 detach(); 474 detach();
482 mData->emails.clear(); 475 mData->emails.clear();
483 mData->emails.append( email ); 476 mData->emails.append( email );
484} 477}
485 478
486void Addressee::simplifyPhoneNumbers() 479void Addressee::simplifyPhoneNumbers()
487{ 480{
488 KABC::PhoneNumber::List removeNumbers; 481 KABC::PhoneNumber::List removeNumbers;
489 KABC::PhoneNumber::List::Iterator phoneIter; 482 KABC::PhoneNumber::List::Iterator phoneIter;
490 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); 483 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end();
491 ++phoneIter ) { 484 ++phoneIter ) {
492 if ( ! ( *phoneIter ).simplifyNumber() ) 485 if ( ! ( *phoneIter ).simplifyNumber() )
493 removeNumbers.append( ( *phoneIter ) ); 486 removeNumbers.append( ( *phoneIter ) );
494 } 487 }
495 for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end(); 488 for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end();
496 ++phoneIter ) { 489 ++phoneIter ) {
497 removePhoneNumber(( *phoneIter )); 490 removePhoneNumber(( *phoneIter ));
498 } 491 }
499} 492}
500void Addressee::simplifyPhoneNumberTypes() 493void Addressee::simplifyPhoneNumberTypes()
501{ 494{
502 KABC::PhoneNumber::List::Iterator phoneIter; 495 KABC::PhoneNumber::List::Iterator phoneIter;
503 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); 496 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end();
504 ++phoneIter ) 497 ++phoneIter )
505 ( *phoneIter ).simplifyType(); 498 ( *phoneIter ).simplifyType();
506} 499}
507void Addressee::removeID(const QString &prof) 500void Addressee::removeID(const QString &prof)
508{ 501{
509 detach(); 502 detach();
510 mData->mExternalId = KIdManager::removeId ( mData->mExternalId, prof); 503 mData->mExternalId = KIdManager::removeId ( mData->mExternalId, prof);
511 504
512} 505}
513void Addressee::setID( const QString & prof , const QString & id ) 506void Addressee::setID( const QString & prof , const QString & id )
514{ 507{
515 detach(); 508 detach();
516 mData->mExternalId = KIdManager::setId ( mData->mExternalId, prof, id ); 509 mData->mExternalId = KIdManager::setId ( mData->mExternalId, prof, id );
517 //qDebug("setID2 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); 510 //qDebug("setID2 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() );
518} 511}
519void Addressee::setTempSyncStat( int id ) 512void Addressee::setTempSyncStat( int id )
520{ 513{
521 if ( mData->mTempSyncStat == id ) return; 514 if ( mData->mTempSyncStat == id ) return;
522 detach(); 515 detach();
523 mData->mTempSyncStat = id; 516 mData->mTempSyncStat = id;
524} 517}
525int Addressee::tempSyncStat() const 518int Addressee::tempSyncStat() const
526{ 519{
527 return mData->mTempSyncStat; 520 return mData->mTempSyncStat;
528} 521}
529 522
530QString Addressee::getID( const QString & prof) 523QString Addressee::getID( const QString & prof)
diff --git a/kabc/phonenumber.cpp b/kabc/phonenumber.cpp
index d7e3925..3d82553 100644
--- a/kabc/phonenumber.cpp
+++ b/kabc/phonenumber.cpp
@@ -1,217 +1,239 @@
1/* 1/*
2 This file is part of libkabc. 2 This file is part of libkabc.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20 20
21/* 21/*
22Enhanced Version of the file for platform independent KDE tools. 22Enhanced Version of the file for platform independent KDE tools.
23Copyright (c) 2004 Ulf Schenk 23Copyright (c) 2004 Ulf Schenk
24 24
25$Id$ 25$Id$
26*/ 26*/
27 27
28#include <kapplication.h> 28#include <kapplication.h>
29#include <klocale.h> 29#include <klocale.h>
30 30
31#include "phonenumber.h" 31#include "phonenumber.h"
32 32
33using namespace KABC; 33using namespace KABC;
34 34
35PhoneNumber::PhoneNumber() : 35PhoneNumber::PhoneNumber() :
36 mType( Home ) 36 mType( Home )
37{ 37{
38 init(); 38 init();
39} 39}
40 40
41PhoneNumber::PhoneNumber( const QString &number, int type ) : 41PhoneNumber::PhoneNumber( const QString &number, int type ) :
42 mType( type ), mNumber( number ) 42 mType( type ), mNumber( number )
43{ 43{
44 init(); 44 init();
45} 45}
46 46
47PhoneNumber::~PhoneNumber() 47PhoneNumber::~PhoneNumber()
48{ 48{
49} 49}
50 50
51void PhoneNumber::init() 51void PhoneNumber::init()
52{ 52{
53 mId = KApplication::randomString( 8 ); 53 mId = KApplication::randomString( 8 );
54} 54}
55 55
56bool PhoneNumber::operator==( const PhoneNumber &p ) const 56bool PhoneNumber::operator==( const PhoneNumber &p ) const
57{ 57{
58 if ( mNumber != p.mNumber ) return false; 58 if ( mNumber != p.mNumber ) return false;
59 if ( mType != p.mType ) return false; 59 if ( mType != p.mType ) return false;
60 60
61 return true; 61 return true;
62} 62}
63 63
64bool PhoneNumber::operator!=( const PhoneNumber &p ) const 64bool PhoneNumber::operator!=( const PhoneNumber &p ) const
65{ 65{
66 return !( p == *this ); 66 return !( p == *this );
67} 67}
68 68
69bool PhoneNumber::simplifyNumber() 69bool PhoneNumber::simplifyNumber()
70{ 70{
71 QString Number; 71 QString Number;
72 int i; 72 int i;
73 Number = mNumber.stripWhiteSpace (); 73 Number = mNumber.stripWhiteSpace ();
74 mNumber = ""; 74 mNumber = "";
75 for ( i = 0; i < Number.length(); ++i) { 75 for ( i = 0; i < Number.length(); ++i) {
76 if ( Number.at(i).isDigit() || Number.at(i) == '+'|| Number.at(i) == '*'|| Number.at(i) == '#' ) 76 if ( Number.at(i).isDigit() || Number.at(i) == '+'|| Number.at(i) == '*'|| Number.at(i) == '#' )
77 mNumber += Number.at(i); 77 mNumber += Number.at(i);
78 } 78 }
79 return ( mNumber.length() > 0 ); 79 return ( mNumber.length() > 0 );
80} 80}
81// make cellphone compatible 81// make cellphone compatible
82void PhoneNumber::simplifyType() 82void PhoneNumber::simplifyType()
83{ 83{
84 if ( mType & Fax ) mType = Fax; 84 if ( mType & Fax ) mType = Fax;
85 else if ( mType & Cell ) mType = Cell; 85 else if ( mType & Cell ) mType = Cell;
86 else if ( mType & Work ) mType = Work ; 86 else if ( mType & Work ) mType = Work ;
87 else if ( mType & Home ) mType = Home; 87 else if ( mType & Home ) mType = Home;
88 else mType = Pref; 88 else mType = Pref;
89} 89}
90bool PhoneNumber::contains( const PhoneNumber &p )
91{
92 QString Number;
93 QString Num;
94 uint i;
95 Number = mNumber.stripWhiteSpace ();
96 Num = "";
97 for ( i = 0; i < Number.length(); ++i) {
98 if ( Number.at(i).isDigit() || Number.at(i) == '+'|| Number.at(i) == '*'|| Number.at(i) == '#' )
99 Num += Number.at(i);
100 }
101 QString NumberR;
102 QString NumR;
103 NumberR = p.mNumber.stripWhiteSpace ();
104 NumR = "";
105 for ( i = 0; i < NumberR.length(); ++i) {
106 if ( NumberR.at(i).isDigit() || NumberR.at(i) == '+'|| NumberR.at(i) == '*'|| NumberR.at(i) == '#' )
107 NumR += NumberR.at(i);
108 }
109 return (Num == NumR);
110}
111
90void PhoneNumber::setId( const QString &id ) 112void PhoneNumber::setId( const QString &id )
91{ 113{
92 mId = id; 114 mId = id;
93} 115}
94 116
95QString PhoneNumber::id() const 117QString PhoneNumber::id() const
96{ 118{
97 return mId; 119 return mId;
98} 120}
99 121
100void PhoneNumber::setNumber( const QString &number ) 122void PhoneNumber::setNumber( const QString &number )
101{ 123{
102 mNumber = number; 124 mNumber = number;
103} 125}
104 126
105QString PhoneNumber::number() const 127QString PhoneNumber::number() const
106{ 128{
107 return mNumber; 129 return mNumber;
108} 130}
109 131
110void PhoneNumber::setType( int type ) 132void PhoneNumber::setType( int type )
111{ 133{
112 mType = type; 134 mType = type;
113} 135}
114 136
115int PhoneNumber::type() const 137int PhoneNumber::type() const
116{ 138{
117 return mType; 139 return mType;
118} 140}
119 141
120QString PhoneNumber::typeLabel() const 142QString PhoneNumber::typeLabel() const
121{ 143{
122 QString label; 144 QString label;
123 bool first = true; 145 bool first = true;
124 146
125 TypeList list = typeList(); 147 TypeList list = typeList();
126 148
127 TypeList::Iterator it; 149 TypeList::Iterator it;
128 for ( it = list.begin(); it != list.end(); ++it ) { 150 for ( it = list.begin(); it != list.end(); ++it ) {
129 if ( ( type() & (*it) ) && ( (*it) != Pref ) ) { 151 if ( ( type() & (*it) ) && ( (*it) != Pref ) ) {
130 label.append( ( first ? "" : "/" ) + typeLabel( *it ) ); 152 label.append( ( first ? "" : "/" ) + typeLabel( *it ) );
131 if ( first ) 153 if ( first )
132 first = false; 154 first = false;
133 } 155 }
134 } 156 }
135 157
136 return label; 158 return label;
137} 159}
138 160
139QString PhoneNumber::label() const 161QString PhoneNumber::label() const
140{ 162{
141 return typeLabel( type() ); 163 return typeLabel( type() );
142} 164}
143 165
144PhoneNumber::TypeList PhoneNumber::typeList() 166PhoneNumber::TypeList PhoneNumber::typeList()
145{ 167{
146 TypeList list; 168 TypeList list;
147 169
148 list << Home << Work << Msg << Pref << Voice << Fax << Cell << Video 170 list << Home << Work << Msg << Pref << Voice << Fax << Cell << Video
149 << Bbs << Modem << Car << Isdn << Pcs << Pager << Sip; 171 << Bbs << Modem << Car << Isdn << Pcs << Pager << Sip;
150 172
151 return list; 173 return list;
152} 174}
153 175
154QString PhoneNumber::label( int type ) 176QString PhoneNumber::label( int type )
155{ 177{
156 return typeLabel( type ); 178 return typeLabel( type );
157} 179}
158 180
159QString PhoneNumber::typeLabel( int type ) 181QString PhoneNumber::typeLabel( int type )
160{ 182{
161 QString typeString; 183 QString typeString;
162 184
163 if ((type & Home) == Home) 185 if ((type & Home) == Home)
164 typeString += i18n("Home"); 186 typeString += i18n("Home");
165 else if ((type & Work) == Work) 187 else if ((type & Work) == Work)
166 typeString += i18n("Work"); 188 typeString += i18n("Work");
167 189
168 if (!typeString.isEmpty()) 190 if (!typeString.isEmpty())
169 typeString += " "; 191 typeString += " ";
170 192
171 if ((type & Cell) == Cell) 193 if ((type & Cell) == Cell)
172 typeString += i18n("Mobile"); 194 typeString += i18n("Mobile");
173 else if ((type & Fax) == Fax) 195 else if ((type & Fax) == Fax)
174 typeString += i18n("Fax"); 196 typeString += i18n("Fax");
175 else if ((type & Msg) == Msg) 197 else if ((type & Msg) == Msg)
176 typeString += i18n("Messenger"); 198 typeString += i18n("Messenger");
177 else if ((type & Voice) == Voice) { 199 else if ((type & Voice) == Voice) {
178// add nothing in case of the Voice flag 200// add nothing in case of the Voice flag
179// typeString += i18n("Voice"); 201// typeString += i18n("Voice");
180 } 202 }
181 else if ((type & Video) == Video) 203 else if ((type & Video) == Video)
182 typeString += i18n("Video"); 204 typeString += i18n("Video");
183 else if ((type & Bbs) == Bbs) 205 else if ((type & Bbs) == Bbs)
184 typeString += i18n("Mailbox"); 206 typeString += i18n("Mailbox");
185 else if ((type & Modem) == Modem) 207 else if ((type & Modem) == Modem)
186 typeString += i18n("Modem"); 208 typeString += i18n("Modem");
187 else if ((type & Car) == Car) 209 else if ((type & Car) == Car)
188 typeString += i18n("Car"); 210 typeString += i18n("Car");
189 else if ((type & Isdn) == Isdn) 211 else if ((type & Isdn) == Isdn)
190 typeString += i18n("ISDN"); 212 typeString += i18n("ISDN");
191 else if ((type & Pcs) == Pcs) 213 else if ((type & Pcs) == Pcs)
192 typeString += i18n("PCS"); 214 typeString += i18n("PCS");
193 else if ((type & Pager) == Pager) 215 else if ((type & Pager) == Pager)
194 typeString += i18n("Pager"); 216 typeString += i18n("Pager");
195 else if ((type & Sip) == Sip) 217 else if ((type & Sip) == Sip)
196 typeString += i18n("SIP"); 218 typeString += i18n("SIP");
197 219
198 // add the prefered flag 220 // add the prefered flag
199 if (!typeString.isEmpty()) 221 if (!typeString.isEmpty())
200 typeString += " "; 222 typeString += " ";
201 /* 223 /*
202 if ((type & Pref) == Pref) 224 if ((type & Pref) == Pref)
203 typeString += i18n("(p)"); 225 typeString += i18n("(p)");
204 */ 226 */
205 //if we still have no match, return "other" 227 //if we still have no match, return "other"
206 if (typeString.isEmpty()) 228 if (typeString.isEmpty())
207 return i18n("Other"); 229 return i18n("Other");
208 230
209 231
210 return typeString; 232 return typeString;
211} 233}
212 234
213QDataStream &KABC::operator<<( QDataStream &s, const PhoneNumber &phone ) 235QDataStream &KABC::operator<<( QDataStream &s, const PhoneNumber &phone )
214{ 236{
215 return s << phone.mId << phone.mType << phone.mNumber; 237 return s << phone.mId << phone.mType << phone.mNumber;
216} 238}
217 239
diff --git a/kabc/phonenumber.h b/kabc/phonenumber.h
index 410a52f..2d4d3e0 100644
--- a/kabc/phonenumber.h
+++ b/kabc/phonenumber.h
@@ -1,168 +1,169 @@
1/* 1/*
2 This file is part of libkabc. 2 This file is part of libkabc.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20 20
21/* 21/*
22Enhanced Version of the file for platform independent KDE tools. 22Enhanced Version of the file for platform independent KDE tools.
23Copyright (c) 2004 Ulf Schenk 23Copyright (c) 2004 Ulf Schenk
24 24
25$Id$ 25$Id$
26*/ 26*/
27 27
28#ifndef KABC_PHONENUMBER_H 28#ifndef KABC_PHONENUMBER_H
29#define KABC_PHONENUMBER_H 29#define KABC_PHONENUMBER_H
30 30
31#include <qvaluelist.h> 31#include <qvaluelist.h>
32#include <qstring.h> 32#include <qstring.h>
33 33
34namespace KABC { 34namespace KABC {
35 35
36/** 36/**
37 @short Phonenumber information. 37 @short Phonenumber information.
38 38
39 This class provides phone number information. A phone number is classified by 39 This class provides phone number information. A phone number is classified by
40 a type. The following types are available, it's possible to use multiple types 40 a type. The following types are available, it's possible to use multiple types
41 @ref Types for a number by combining them through a logical or. 41 @ref Types for a number by combining them through a logical or.
42*/ 42*/
43class PhoneNumber 43class PhoneNumber
44{ 44{
45 friend QDataStream &operator<<( QDataStream &, const PhoneNumber & ); 45 friend QDataStream &operator<<( QDataStream &, const PhoneNumber & );
46 friend QDataStream &operator>>( QDataStream &, PhoneNumber & ); 46 friend QDataStream &operator>>( QDataStream &, PhoneNumber & );
47 47
48 public: 48 public:
49 typedef QValueList<PhoneNumber> List; 49 typedef QValueList<PhoneNumber> List;
50 typedef QValueList<int> TypeList; 50 typedef QValueList<int> TypeList;
51 51
52 /** 52 /**
53 @li @p Home - Home number 53 @li @p Home - Home number
54 @li @p Work - Office number 54 @li @p Work - Office number
55 @li @p Msg - Messaging 55 @li @p Msg - Messaging
56 @li @p Pref - Preferred number 56 @li @p Pref - Preferred number
57 @li @p Voice - Voice 57 @li @p Voice - Voice
58 @li @p Fax - Fax machine 58 @li @p Fax - Fax machine
59 @li @p Cell - Cell phone 59 @li @p Cell - Cell phone
60 @li @p Video - Video phone 60 @li @p Video - Video phone
61 @li @p Bbs - Mailbox 61 @li @p Bbs - Mailbox
62 @li @p Modem - Modem 62 @li @p Modem - Modem
63 @li @p Car - Car phone 63 @li @p Car - Car phone
64 @li @p Isdn - ISDN connection 64 @li @p Isdn - ISDN connection
65 @li @p Pcs - Personal Communication Service 65 @li @p Pcs - Personal Communication Service
66 @li @p Pager - Pager 66 @li @p Pager - Pager
67 @li @p SIP - VoIP 67 @li @p SIP - VoIP
68 */ 68 */
69 enum Types { Home = 1, Work = 2, Msg = 4, Pref = 8, Voice = 16, Fax = 32, 69 enum Types { Home = 1, Work = 2, Msg = 4, Pref = 8, Voice = 16, Fax = 32,
70 Cell = 64, Video = 128, Bbs = 256, Modem = 512, Car = 1024, 70 Cell = 64, Video = 128, Bbs = 256, Modem = 512, Car = 1024,
71 Isdn = 2048, Pcs = 4096, Pager = 8192, Sip = 16384 }; 71 Isdn = 2048, Pcs = 4096, Pager = 8192, Sip = 16384 };
72 72
73 /** 73 /**
74 Create an empty phone number object. 74 Create an empty phone number object.
75 */ 75 */
76 PhoneNumber(); 76 PhoneNumber();
77 77
78 /** 78 /**
79 Create a phonenumber object. 79 Create a phonenumber object.
80 80
81 @param number Number 81 @param number Number
82 @param type Type as defined in enum. Multiple types can be 82 @param type Type as defined in enum. Multiple types can be
83 specified by combining them by a logical or. 83 specified by combining them by a logical or.
84 */ 84 */
85 PhoneNumber( const QString &number, int type = Home ); 85 PhoneNumber( const QString &number, int type = Home );
86 86
87 /** 87 /**
88 Destructor. 88 Destructor.
89 */ 89 */
90 ~PhoneNumber(); 90 ~PhoneNumber();
91 91
92 bool operator==( const PhoneNumber & ) const; 92 bool operator==( const PhoneNumber & ) const;
93 bool operator!=( const PhoneNumber & ) const; 93 bool operator!=( const PhoneNumber & ) const;
94 94
95 bool contains( const PhoneNumber &p );
95 /** 96 /**
96 Sets the unique identifier. 97 Sets the unique identifier.
97 */ 98 */
98 void setId( const QString &id ); 99 void setId( const QString &id );
99 100
100 /** 101 /**
101 Returns the unique identifier. 102 Returns the unique identifier.
102 */ 103 */
103 QString id() const; 104 QString id() const;
104 105
105 /** 106 /**
106 Sets the number. 107 Sets the number.
107 */ 108 */
108 void setNumber( const QString & ); 109 void setNumber( const QString & );
109 110
110 /** 111 /**
111 Returns the number. 112 Returns the number.
112 */ 113 */
113 QString number() const; 114 QString number() const;
114 115
115 /** 116 /**
116 Sets the type. Multiple types can be specified by combining them by 117 Sets the type. Multiple types can be specified by combining them by
117 a logical or. 118 a logical or.
118 */ 119 */
119 void setType( int ); 120 void setType( int );
120 121
121 /** 122 /**
122 Returns the type. Can be a multiple types combined by a logical or. 123 Returns the type. Can be a multiple types combined by a logical or.
123 */ 124 */
124 int type() const; 125 int type() const;
125 126
126 /** 127 /**
127 Returns a translated string of all types the address has. 128 Returns a translated string of all types the address has.
128 */ 129 */
129 QString typeLabel() const; 130 QString typeLabel() const;
130 131
131 /** 132 /**
132 Returns the translated label for phone number depending on its type. 133 Returns the translated label for phone number depending on its type.
133 */ 134 */
134 QString label() const; 135 QString label() const;
135 136
136 /** 137 /**
137 Returns a list of all available types 138 Returns a list of all available types
138 */ 139 */
139 static TypeList typeList(); 140 static TypeList typeList();
140 141
141 /** 142 /**
142 Returns the translated label for phone number type. 143 Returns the translated label for phone number type.
143 */ 144 */
144 static QString typeLabel( int type ); 145 static QString typeLabel( int type );
145 146
146 /** 147 /**
147 Returns the translated label for phone number type. 148 Returns the translated label for phone number type.
148 @obsolete 149 @obsolete
149 */ 150 */
150 static QString label( int type ); 151 static QString label( int type );
151 bool simplifyNumber(); 152 bool simplifyNumber();
152 void simplifyType(); 153 void simplifyType();
153 154
154 private: 155 private:
155 void init(); 156 void init();
156 157
157 QString mId; 158 QString mId;
158 159
159 int mType; 160 int mType;
160 QString mNumber; 161 QString mNumber;
161}; 162};
162 163
163QDataStream &operator<<( QDataStream &, const PhoneNumber & ); 164QDataStream &operator<<( QDataStream &, const PhoneNumber & );
164QDataStream &operator>>( QDataStream &, PhoneNumber & ); 165QDataStream &operator>>( QDataStream &, PhoneNumber & );
165 166
166} 167}
167 168
168#endif 169#endif