summaryrefslogtreecommitdiffabout
path: root/kabc/addressbook.cpp
Unidiff
Diffstat (limited to 'kabc/addressbook.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/addressbook.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/kabc/addressbook.cpp b/kabc/addressbook.cpp
index 3ec0795..d03dea3 100644
--- a/kabc/addressbook.cpp
+++ b/kabc/addressbook.cpp
@@ -367,194 +367,199 @@ bool AddressBook::saveAB()
367 367
368 KRES::Manager<Resource>::ActiveIterator it; 368 KRES::Manager<Resource>::ActiveIterator it;
369 KRES::Manager<Resource> *manager = d->mManager; 369 KRES::Manager<Resource> *manager = d->mManager;
370 for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) { 370 for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) {
371 if ( !(*it)->readOnly() && (*it)->isOpen() ) { 371 if ( !(*it)->readOnly() && (*it)->isOpen() ) {
372 Ticket *ticket = requestSaveTicket( *it ); 372 Ticket *ticket = requestSaveTicket( *it );
373// qDebug("StdAddressBook::save '%s'", (*it)->resourceName().latin1() ); 373// qDebug("StdAddressBook::save '%s'", (*it)->resourceName().latin1() );
374 if ( !ticket ) { 374 if ( !ticket ) {
375 error( i18n( "Unable to save to resource '%1'. It is locked." ) 375 error( i18n( "Unable to save to resource '%1'. It is locked." )
376 .arg( (*it)->resourceName() ) ); 376 .arg( (*it)->resourceName() ) );
377 return false; 377 return false;
378 } 378 }
379 379
380 //if ( !save( ticket ) ) 380 //if ( !save( ticket ) )
381 if ( ticket->resource() ) { 381 if ( ticket->resource() ) {
382 if ( ! ticket->resource()->save( ticket ) ) 382 if ( ! ticket->resource()->save( ticket ) )
383 ok = false; 383 ok = false;
384 } else 384 } else
385 ok = false; 385 ok = false;
386 386
387 } 387 }
388 } 388 }
389 return ok; 389 return ok;
390} 390}
391 391
392AddressBook::Iterator AddressBook::begin() 392AddressBook::Iterator AddressBook::begin()
393{ 393{
394 Iterator it = Iterator(); 394 Iterator it = Iterator();
395 it.d->mIt = d->mAddressees.begin(); 395 it.d->mIt = d->mAddressees.begin();
396 return it; 396 return it;
397} 397}
398 398
399AddressBook::ConstIterator AddressBook::begin() const 399AddressBook::ConstIterator AddressBook::begin() const
400{ 400{
401 ConstIterator it = ConstIterator(); 401 ConstIterator it = ConstIterator();
402 it.d->mIt = d->mAddressees.begin(); 402 it.d->mIt = d->mAddressees.begin();
403 return it; 403 return it;
404} 404}
405 405
406AddressBook::Iterator AddressBook::end() 406AddressBook::Iterator AddressBook::end()
407{ 407{
408 Iterator it = Iterator(); 408 Iterator it = Iterator();
409 it.d->mIt = d->mAddressees.end(); 409 it.d->mIt = d->mAddressees.end();
410 return it; 410 return it;
411} 411}
412 412
413AddressBook::ConstIterator AddressBook::end() const 413AddressBook::ConstIterator AddressBook::end() const
414{ 414{
415 ConstIterator it = ConstIterator(); 415 ConstIterator it = ConstIterator();
416 it.d->mIt = d->mAddressees.end(); 416 it.d->mIt = d->mAddressees.end();
417 return it; 417 return it;
418} 418}
419 419
420void AddressBook::clear() 420void AddressBook::clear()
421{ 421{
422 d->mAddressees.clear(); 422 d->mAddressees.clear();
423} 423}
424 424
425Ticket *AddressBook::requestSaveTicket( Resource *resource ) 425Ticket *AddressBook::requestSaveTicket( Resource *resource )
426{ 426{
427 kdDebug(5700) << "AddressBook::requestSaveTicket()" << endl; 427 kdDebug(5700) << "AddressBook::requestSaveTicket()" << endl;
428 428
429 if ( !resource ) 429 if ( !resource )
430 { 430 {
431 qDebug("AddressBook::requestSaveTicket no resource" ); 431 qDebug("AddressBook::requestSaveTicket no resource" );
432 resource = standardResource(); 432 resource = standardResource();
433 } 433 }
434 434
435 KRES::Manager<Resource>::ActiveIterator it; 435 KRES::Manager<Resource>::ActiveIterator it;
436 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) { 436 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) {
437 if ( (*it) == resource ) { 437 if ( (*it) == resource ) {
438 if ( (*it)->readOnly() || !(*it)->isOpen() ) 438 if ( (*it)->readOnly() || !(*it)->isOpen() )
439 return 0; 439 return 0;
440 else 440 else
441 return (*it)->requestSaveTicket(); 441 return (*it)->requestSaveTicket();
442 } 442 }
443 } 443 }
444 444
445 return 0; 445 return 0;
446} 446}
447 447
448void AddressBook::insertAddressee( const Addressee &a, bool setRev ) 448void AddressBook::insertAddressee( const Addressee &a, bool setRev )
449{ 449{
450 Addressee::List::Iterator it; 450 Addressee::List::Iterator it;
451 for ( it = d->mAddressees.begin(); it != d->mAddressees.end(); ++it ) { 451 for ( it = d->mAddressees.begin(); it != d->mAddressees.end(); ++it ) {
452 if ( a.uid() == (*it).uid() ) { 452 if ( a.uid() == (*it).uid() ) {
453 bool changed = false; 453 bool changed = false;
454 Addressee addr = a; 454 Addressee addr = a;
455 if ( addr != (*it) ) 455 if ( addr != (*it) )
456 changed = true; 456 changed = true;
457 457
458 (*it) = a; 458 (*it) = a;
459 if ( (*it).resource() == 0 ) 459 if ( (*it).resource() == 0 )
460 (*it).setResource( standardResource() ); 460 (*it).setResource( standardResource() );
461 461
462 if ( changed ) { 462 if ( changed ) {
463 if ( setRev ) 463 if ( setRev ) {
464 (*it).setRevision( QDateTime::currentDateTime() ); 464 // get rid of micro seconds
465 QDateTime dt = QDateTime::currentDateTime();
466 QTime t = dt.time();
467 dt.setTime( QTime (t.hour (), t.minute (), t.second () ) );
468 (*it).setRevision( dt );
469 }
465 (*it).setChanged( true ); 470 (*it).setChanged( true );
466 } 471 }
467 472
468 return; 473 return;
469 } 474 }
470 } 475 }
471 d->mAddressees.append( a ); 476 d->mAddressees.append( a );
472 Addressee& addr = d->mAddressees.last(); 477 Addressee& addr = d->mAddressees.last();
473 if ( addr.resource() == 0 ) 478 if ( addr.resource() == 0 )
474 addr.setResource( standardResource() ); 479 addr.setResource( standardResource() );
475 480
476 addr.setChanged( true ); 481 addr.setChanged( true );
477} 482}
478 483
479void AddressBook::removeAddressee( const Addressee &a ) 484void AddressBook::removeAddressee( const Addressee &a )
480{ 485{
481 Iterator it; 486 Iterator it;
482 for ( it = begin(); it != end(); ++it ) { 487 for ( it = begin(); it != end(); ++it ) {
483 if ( a.uid() == (*it).uid() ) { 488 if ( a.uid() == (*it).uid() ) {
484 removeAddressee( it ); 489 removeAddressee( it );
485 return; 490 return;
486 } 491 }
487 } 492 }
488} 493}
489 494
490void AddressBook::removeAddressee( const Iterator &it ) 495void AddressBook::removeAddressee( const Iterator &it )
491{ 496{
492 d->mRemovedAddressees.append( (*it) ); 497 d->mRemovedAddressees.append( (*it) );
493 d->mAddressees.remove( it.d->mIt ); 498 d->mAddressees.remove( it.d->mIt );
494} 499}
495 500
496AddressBook::Iterator AddressBook::find( const Addressee &a ) 501AddressBook::Iterator AddressBook::find( const Addressee &a )
497{ 502{
498 Iterator it; 503 Iterator it;
499 for ( it = begin(); it != end(); ++it ) { 504 for ( it = begin(); it != end(); ++it ) {
500 if ( a.uid() == (*it).uid() ) { 505 if ( a.uid() == (*it).uid() ) {
501 return it; 506 return it;
502 } 507 }
503 } 508 }
504 return end(); 509 return end();
505} 510}
506 511
507Addressee AddressBook::findByUid( const QString &uid ) 512Addressee AddressBook::findByUid( const QString &uid )
508{ 513{
509 Iterator it; 514 Iterator it;
510 for ( it = begin(); it != end(); ++it ) { 515 for ( it = begin(); it != end(); ++it ) {
511 if ( uid == (*it).uid() ) { 516 if ( uid == (*it).uid() ) {
512 return *it; 517 return *it;
513 } 518 }
514 } 519 }
515 return Addressee(); 520 return Addressee();
516} 521}
517Addressee::List AddressBook::getExternLastSyncAddressees() 522Addressee::List AddressBook::getExternLastSyncAddressees()
518{ 523{
519 Addressee::List results; 524 Addressee::List results;
520 525
521 Iterator it; 526 Iterator it;
522 for ( it = begin(); it != end(); ++it ) { 527 for ( it = begin(); it != end(); ++it ) {
523 if ( (*it).uid().left( 20 ) == "last-syncAddressee-" ) { 528 if ( (*it).uid().left( 20 ) == "last-syncAddressee-" ) {
524 if ( (*it).familyName().left(3) == "E: " ) 529 if ( (*it).familyName().left(3) == "E: " )
525 results.append( *it ); 530 results.append( *it );
526 } 531 }
527 } 532 }
528 533
529 return results; 534 return results;
530} 535}
531void AddressBook::resetTempSyncStat() 536void AddressBook::resetTempSyncStat()
532{ 537{
533 Iterator it; 538 Iterator it;
534 for ( it = begin(); it != end(); ++it ) { 539 for ( it = begin(); it != end(); ++it ) {
535 (*it).setTempSyncStat ( SYNC_TEMPSTATE_INITIAL ); 540 (*it).setTempSyncStat ( SYNC_TEMPSTATE_INITIAL );
536 } 541 }
537 542
538} 543}
539 544
540QStringList AddressBook:: uidList() 545QStringList AddressBook:: uidList()
541{ 546{
542 QStringList results; 547 QStringList results;
543 Iterator it; 548 Iterator it;
544 for ( it = begin(); it != end(); ++it ) { 549 for ( it = begin(); it != end(); ++it ) {
545 results.append( (*it).uid() ); 550 results.append( (*it).uid() );
546 } 551 }
547 return results; 552 return results;
548} 553}
549 554
550 555
551Addressee::List AddressBook::allAddressees() 556Addressee::List AddressBook::allAddressees()
552{ 557{
553 return d->mAddressees; 558 return d->mAddressees;
554} 559}
555 560
556Addressee::List AddressBook::findByName( const QString &name ) 561Addressee::List AddressBook::findByName( const QString &name )
557{ 562{
558 Addressee::List results; 563 Addressee::List results;
559 564
560 Iterator it; 565 Iterator it;