summaryrefslogtreecommitdiffabout
path: root/kabc/addressbook.cpp
Unidiff
Diffstat (limited to 'kabc/addressbook.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/addressbook.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/kabc/addressbook.cpp b/kabc/addressbook.cpp
index c61b387..47d298a 100644
--- a/kabc/addressbook.cpp
+++ b/kabc/addressbook.cpp
@@ -302,257 +302,257 @@ AddressBook::ConstIterator AddressBook::begin() const
302{ 302{
303 ConstIterator it = ConstIterator(); 303 ConstIterator it = ConstIterator();
304 it.d->mIt = d->mAddressees.begin(); 304 it.d->mIt = d->mAddressees.begin();
305 return it; 305 return it;
306} 306}
307 307
308AddressBook::Iterator AddressBook::end() 308AddressBook::Iterator AddressBook::end()
309{ 309{
310 Iterator it = Iterator(); 310 Iterator it = Iterator();
311 it.d->mIt = d->mAddressees.end(); 311 it.d->mIt = d->mAddressees.end();
312 return it; 312 return it;
313} 313}
314 314
315AddressBook::ConstIterator AddressBook::end() const 315AddressBook::ConstIterator AddressBook::end() const
316{ 316{
317 ConstIterator it = ConstIterator(); 317 ConstIterator it = ConstIterator();
318 it.d->mIt = d->mAddressees.end(); 318 it.d->mIt = d->mAddressees.end();
319 return it; 319 return it;
320} 320}
321 321
322void AddressBook::clear() 322void AddressBook::clear()
323{ 323{
324 d->mAddressees.clear(); 324 d->mAddressees.clear();
325} 325}
326 326
327Ticket *AddressBook::requestSaveTicket( Resource *resource ) 327Ticket *AddressBook::requestSaveTicket( Resource *resource )
328{ 328{
329 kdDebug(5700) << "AddressBook::requestSaveTicket()" << endl; 329 kdDebug(5700) << "AddressBook::requestSaveTicket()" << endl;
330 330
331 if ( !resource ) 331 if ( !resource )
332 { 332 {
333 qDebug("AddressBook::requestSaveTicket no resource" ); 333 qDebug("AddressBook::requestSaveTicket no resource" );
334 resource = standardResource(); 334 resource = standardResource();
335 } 335 }
336 336
337 KRES::Manager<Resource>::ActiveIterator it; 337 KRES::Manager<Resource>::ActiveIterator it;
338 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) { 338 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) {
339 if ( (*it) == resource ) { 339 if ( (*it) == resource ) {
340 if ( (*it)->readOnly() || !(*it)->isOpen() ) 340 if ( (*it)->readOnly() || !(*it)->isOpen() )
341 return 0; 341 return 0;
342 else 342 else
343 return (*it)->requestSaveTicket(); 343 return (*it)->requestSaveTicket();
344 } 344 }
345 } 345 }
346 346
347 return 0; 347 return 0;
348} 348}
349 349
350void AddressBook::insertAddressee( const Addressee &a ) 350void AddressBook::insertAddressee( const Addressee &a )
351{ 351{
352 Addressee::List::Iterator it; 352 Addressee::List::Iterator it;
353 for ( it = d->mAddressees.begin(); it != d->mAddressees.end(); ++it ) { 353 for ( it = d->mAddressees.begin(); it != d->mAddressees.end(); ++it ) {
354 if ( a.uid() == (*it).uid() ) { 354 if ( a.uid() == (*it).uid() ) {
355 bool changed = false; 355 bool changed = false;
356 Addressee addr = a; 356 Addressee addr = a;
357 if ( addr != (*it) ) 357 if ( addr != (*it) )
358 changed = true; 358 changed = true;
359 359
360 (*it) = a; 360 (*it) = a;
361 if ( (*it).resource() == 0 ) 361 if ( (*it).resource() == 0 )
362 (*it).setResource( standardResource() ); 362 (*it).setResource( standardResource() );
363 363
364 if ( changed ) { 364 if ( changed ) {
365 (*it).setRevision( QDateTime::currentDateTime() ); 365 (*it).setRevision( QDateTime::currentDateTime() );
366 (*it).setChanged( true ); 366 (*it).setChanged( true );
367 } 367 }
368 368
369 return; 369 return;
370 } 370 }
371 } 371 }
372 d->mAddressees.append( a ); 372 d->mAddressees.append( a );
373 Addressee& addr = d->mAddressees.last(); 373 Addressee& addr = d->mAddressees.last();
374 if ( addr.resource() == 0 ) 374 if ( addr.resource() == 0 )
375 addr.setResource( standardResource() ); 375 addr.setResource( standardResource() );
376 376
377 addr.setChanged( true ); 377 addr.setChanged( true );
378} 378}
379 379
380void AddressBook::removeAddressee( const Addressee &a ) 380void AddressBook::removeAddressee( const Addressee &a )
381{ 381{
382 Iterator it; 382 Iterator it;
383 for ( it = begin(); it != end(); ++it ) { 383 for ( it = begin(); it != end(); ++it ) {
384 if ( a.uid() == (*it).uid() ) { 384 if ( a.uid() == (*it).uid() ) {
385 removeAddressee( it ); 385 removeAddressee( it );
386 return; 386 return;
387 } 387 }
388 } 388 }
389} 389}
390 390
391void AddressBook::removeAddressee( const Iterator &it ) 391void AddressBook::removeAddressee( const Iterator &it )
392{ 392{
393 d->mRemovedAddressees.append( (*it) ); 393 d->mRemovedAddressees.append( (*it) );
394 d->mAddressees.remove( it.d->mIt ); 394 d->mAddressees.remove( it.d->mIt );
395} 395}
396 396
397AddressBook::Iterator AddressBook::find( const Addressee &a ) 397AddressBook::Iterator AddressBook::find( const Addressee &a )
398{ 398{
399 Iterator it; 399 Iterator it;
400 for ( it = begin(); it != end(); ++it ) { 400 for ( it = begin(); it != end(); ++it ) {
401 if ( a.uid() == (*it).uid() ) { 401 if ( a.uid() == (*it).uid() ) {
402 return it; 402 return it;
403 } 403 }
404 } 404 }
405 return end(); 405 return end();
406} 406}
407 407
408Addressee AddressBook::findByUid( const QString &uid ) 408Addressee AddressBook::findByUid( const QString &uid )
409{ 409{
410 Iterator it; 410 Iterator it;
411 for ( it = begin(); it != end(); ++it ) { 411 for ( it = begin(); it != end(); ++it ) {
412 if ( uid == (*it).uid() ) { 412 if ( uid == (*it).uid() ) {
413 return *it; 413 return *it;
414 } 414 }
415 } 415 }
416 return Addressee(); 416 return Addressee();
417} 417}
418 418
419Addressee::List AddressBook::allAddressees() 419Addressee::List AddressBook::allAddressees()
420{ 420{
421 return d->mAddressees; 421 return d->mAddressees;
422} 422}
423 423
424Addressee::List AddressBook::findByName( const QString &name ) 424Addressee::List AddressBook::findByName( const QString &name )
425{ 425{
426 Addressee::List results; 426 Addressee::List results;
427 427
428 Iterator it; 428 Iterator it;
429 for ( it = begin(); it != end(); ++it ) { 429 for ( it = begin(); it != end(); ++it ) {
430 if ( name == (*it).name() ) { 430 if ( name == (*it).realName() ) {
431 results.append( *it ); 431 results.append( *it );
432 } 432 }
433 } 433 }
434 434
435 return results; 435 return results;
436} 436}
437 437
438Addressee::List AddressBook::findByEmail( const QString &email ) 438Addressee::List AddressBook::findByEmail( const QString &email )
439{ 439{
440 Addressee::List results; 440 Addressee::List results;
441 QStringList mailList; 441 QStringList mailList;
442 442
443 Iterator it; 443 Iterator it;
444 for ( it = begin(); it != end(); ++it ) { 444 for ( it = begin(); it != end(); ++it ) {
445 mailList = (*it).emails(); 445 mailList = (*it).emails();
446 for ( QStringList::Iterator ite = mailList.begin(); ite != mailList.end(); ++ite ) { 446 for ( QStringList::Iterator ite = mailList.begin(); ite != mailList.end(); ++ite ) {
447 if ( email == (*ite) ) { 447 if ( email == (*ite) ) {
448 results.append( *it ); 448 results.append( *it );
449 } 449 }
450 } 450 }
451 } 451 }
452 452
453 return results; 453 return results;
454} 454}
455 455
456Addressee::List AddressBook::findByCategory( const QString &category ) 456Addressee::List AddressBook::findByCategory( const QString &category )
457{ 457{
458 Addressee::List results; 458 Addressee::List results;
459 459
460 Iterator it; 460 Iterator it;
461 for ( it = begin(); it != end(); ++it ) { 461 for ( it = begin(); it != end(); ++it ) {
462 if ( (*it).hasCategory( category) ) { 462 if ( (*it).hasCategory( category) ) {
463 results.append( *it ); 463 results.append( *it );
464 } 464 }
465 } 465 }
466 466
467 return results; 467 return results;
468} 468}
469 469
470void AddressBook::dump() const 470void AddressBook::dump() const
471{ 471{
472 kdDebug(5700) << "AddressBook::dump() --- begin ---" << endl; 472 kdDebug(5700) << "AddressBook::dump() --- begin ---" << endl;
473 473
474 ConstIterator it; 474 ConstIterator it;
475 for( it = begin(); it != end(); ++it ) { 475 for( it = begin(); it != end(); ++it ) {
476 (*it).dump(); 476 (*it).dump();
477 } 477 }
478 478
479 kdDebug(5700) << "AddressBook::dump() --- end ---" << endl; 479 kdDebug(5700) << "AddressBook::dump() --- end ---" << endl;
480} 480}
481 481
482QString AddressBook::identifier() 482QString AddressBook::identifier()
483{ 483{
484 QStringList identifier; 484 QStringList identifier;
485 485
486 486
487 KRES::Manager<Resource>::ActiveIterator it; 487 KRES::Manager<Resource>::ActiveIterator it;
488 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) { 488 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) {
489 if ( !(*it)->identifier().isEmpty() ) 489 if ( !(*it)->identifier().isEmpty() )
490 identifier.append( (*it)->identifier() ); 490 identifier.append( (*it)->identifier() );
491 } 491 }
492 492
493 return identifier.join( ":" ); 493 return identifier.join( ":" );
494} 494}
495 495
496Field::List AddressBook::fields( int category ) 496Field::List AddressBook::fields( int category )
497{ 497{
498 if ( d->mAllFields.isEmpty() ) { 498 if ( d->mAllFields.isEmpty() ) {
499 d->mAllFields = Field::allFields(); 499 d->mAllFields = Field::allFields();
500 } 500 }
501 501
502 if ( category == Field::All ) return d->mAllFields; 502 if ( category == Field::All ) return d->mAllFields;
503 503
504 Field::List result; 504 Field::List result;
505 Field::List::ConstIterator it; 505 Field::List::ConstIterator it;
506 for( it = d->mAllFields.begin(); it != d->mAllFields.end(); ++it ) { 506 for( it = d->mAllFields.begin(); it != d->mAllFields.end(); ++it ) {
507 if ( (*it)->category() & category ) result.append( *it ); 507 if ( (*it)->category() & category ) result.append( *it );
508 } 508 }
509 509
510 return result; 510 return result;
511} 511}
512 512
513bool AddressBook::addCustomField( const QString &label, int category, 513bool AddressBook::addCustomField( const QString &label, int category,
514 const QString &key, const QString &app ) 514 const QString &key, const QString &app )
515{ 515{
516 if ( d->mAllFields.isEmpty() ) { 516 if ( d->mAllFields.isEmpty() ) {
517 d->mAllFields = Field::allFields(); 517 d->mAllFields = Field::allFields();
518 } 518 }
519//US QString a = app.isNull() ? KGlobal::instance()->instanceName() : app; 519//US QString a = app.isNull() ? KGlobal::instance()->instanceName() : app;
520 QString a = app.isNull() ? KGlobal::getAppName() : app; 520 QString a = app.isNull() ? KGlobal::getAppName() : app;
521 521
522 QString k = key.isNull() ? label : key; 522 QString k = key.isNull() ? label : key;
523 523
524 Field *field = Field::createCustomField( label, category, k, a ); 524 Field *field = Field::createCustomField( label, category, k, a );
525 525
526 if ( !field ) return false; 526 if ( !field ) return false;
527 527
528 d->mAllFields.append( field ); 528 d->mAllFields.append( field );
529 529
530 return true; 530 return true;
531} 531}
532 532
533QDataStream &KABC::operator<<( QDataStream &s, const AddressBook &ab ) 533QDataStream &KABC::operator<<( QDataStream &s, const AddressBook &ab )
534{ 534{
535 if (!ab.d) return s; 535 if (!ab.d) return s;
536 536
537 return s << ab.d->mAddressees; 537 return s << ab.d->mAddressees;
538} 538}
539 539
540QDataStream &KABC::operator>>( QDataStream &s, AddressBook &ab ) 540QDataStream &KABC::operator>>( QDataStream &s, AddressBook &ab )
541{ 541{
542 if (!ab.d) return s; 542 if (!ab.d) return s;
543 543
544 s >> ab.d->mAddressees; 544 s >> ab.d->mAddressees;
545 545
546 return s; 546 return s;
547} 547}
548 548
549bool AddressBook::addResource( Resource *resource ) 549bool AddressBook::addResource( Resource *resource )
550{ 550{
551 if ( !resource->open() ) { 551 if ( !resource->open() ) {
552 kdDebug(5700) << "AddressBook::addResource(): can't add resource" << endl; 552 kdDebug(5700) << "AddressBook::addResource(): can't add resource" << endl;
553 return false; 553 return false;
554 } 554 }
555 555
556 resource->setAddressBook( this ); 556 resource->setAddressBook( this );
557 557
558 d->mManager->add( resource ); 558 d->mManager->add( resource );