summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2004-11-08 21:38:38 (UTC)
committer zautrix <zautrix>2004-11-08 21:38:38 (UTC)
commit91edd790af2bb6c19954638da1e22158382203a0 (patch) (unidiff)
treef75e027f1d4e4bcfc0257593d0f2ee2c0405bbd8
parent7b899c8a9c38cf96fca6c46b20ae406a716dd213 (diff)
downloadkdepimpi-91edd790af2bb6c19954638da1e22158382203a0.zip
kdepimpi-91edd790af2bb6c19954638da1e22158382203a0.tar.gz
kdepimpi-91edd790af2bb6c19954638da1e22158382203a0.tar.bz2
menu rearranged
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/kabcore.cpp13
1 files changed, 9 insertions, 4 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index 755da11..d99a9cd 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -473,2629 +473,2634 @@ void KABCore::restoreSettings()
473 splitterSize.append( width() / 2 ); 473 splitterSize.append( width() / 2 );
474 splitterSize.append( width() / 2 ); 474 splitterSize.append( width() / 2 );
475 } 475 }
476 mExtensionBarSplitter->setSizes( splitterSize ); 476 mExtensionBarSplitter->setSizes( splitterSize );
477 477
478 } 478 }
479*/ 479*/
480 mViewManager->restoreSettings(); 480 mViewManager->restoreSettings();
481 mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField ); 481 mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField );
482 mExtensionManager->restoreSettings(); 482 mExtensionManager->restoreSettings();
483#ifdef DESKTOP_VERSION 483#ifdef DESKTOP_VERSION
484 int wid = width(); 484 int wid = width();
485 if ( wid < 10 ) 485 if ( wid < 10 )
486 wid = 400; 486 wid = 400;
487#else 487#else
488 int wid = QApplication::desktop()->width(); 488 int wid = QApplication::desktop()->width();
489 if ( wid < 640 ) 489 if ( wid < 640 )
490 wid = QApplication::desktop()->height(); 490 wid = QApplication::desktop()->height();
491#endif 491#endif
492 QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter; 492 QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter;
493 if ( true /*splitterSize.count() == 0*/ ) { 493 if ( true /*splitterSize.count() == 0*/ ) {
494 splitterSize.append( wid / 2 ); 494 splitterSize.append( wid / 2 );
495 splitterSize.append( wid / 2 ); 495 splitterSize.append( wid / 2 );
496 } 496 }
497 mMiniSplitter->setSizes( splitterSize ); 497 mMiniSplitter->setSizes( splitterSize );
498 if ( mExtensionBarSplitter ) { 498 if ( mExtensionBarSplitter ) {
499 //splitterSize = KABPrefs::instance()->mExtensionsSplitter; 499 //splitterSize = KABPrefs::instance()->mExtensionsSplitter;
500 if ( true /*splitterSize.count() == 0*/ ) { 500 if ( true /*splitterSize.count() == 0*/ ) {
501 splitterSize.append( wid / 2 ); 501 splitterSize.append( wid / 2 );
502 splitterSize.append( wid / 2 ); 502 splitterSize.append( wid / 2 );
503 } 503 }
504 mExtensionBarSplitter->setSizes( splitterSize ); 504 mExtensionBarSplitter->setSizes( splitterSize );
505 505
506 } 506 }
507 507
508 508
509} 509}
510 510
511void KABCore::saveSettings() 511void KABCore::saveSettings()
512{ 512{
513 KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked(); 513 KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked();
514 if ( mExtensionBarSplitter ) 514 if ( mExtensionBarSplitter )
515 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); 515 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes();
516 KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked(); 516 KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked();
517 KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes(); 517 KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes();
518#ifndef KAB_EMBEDDED 518#ifndef KAB_EMBEDDED
519 519
520 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); 520 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes();
521 KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes(); 521 KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes();
522#endif //KAB_EMBEDDED 522#endif //KAB_EMBEDDED
523 mExtensionManager->saveSettings(); 523 mExtensionManager->saveSettings();
524 mViewManager->saveSettings(); 524 mViewManager->saveSettings();
525 525
526 KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem(); 526 KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem();
527} 527}
528 528
529KABC::AddressBook *KABCore::addressBook() const 529KABC::AddressBook *KABCore::addressBook() const
530{ 530{
531 return mAddressBook; 531 return mAddressBook;
532} 532}
533 533
534KConfig *KABCore::config() 534KConfig *KABCore::config()
535{ 535{
536#ifndef KAB_EMBEDDED 536#ifndef KAB_EMBEDDED
537 return KABPrefs::instance()->config(); 537 return KABPrefs::instance()->config();
538#else //KAB_EMBEDDED 538#else //KAB_EMBEDDED
539 return KABPrefs::instance()->getConfig(); 539 return KABPrefs::instance()->getConfig();
540#endif //KAB_EMBEDDED 540#endif //KAB_EMBEDDED
541} 541}
542 542
543KActionCollection *KABCore::actionCollection() const 543KActionCollection *KABCore::actionCollection() const
544{ 544{
545 return mGUIClient->actionCollection(); 545 return mGUIClient->actionCollection();
546} 546}
547 547
548KABC::Field *KABCore::currentSearchField() const 548KABC::Field *KABCore::currentSearchField() const
549{ 549{
550 if (mIncSearchWidget) 550 if (mIncSearchWidget)
551 return mIncSearchWidget->currentField(); 551 return mIncSearchWidget->currentField();
552 else 552 else
553 return 0; 553 return 0;
554} 554}
555 555
556QStringList KABCore::selectedUIDs() const 556QStringList KABCore::selectedUIDs() const
557{ 557{
558 return mViewManager->selectedUids(); 558 return mViewManager->selectedUids();
559} 559}
560 560
561KABC::Resource *KABCore::requestResource( QWidget *parent ) 561KABC::Resource *KABCore::requestResource( QWidget *parent )
562{ 562{
563 QPtrList<KABC::Resource> kabcResources = addressBook()->resources(); 563 QPtrList<KABC::Resource> kabcResources = addressBook()->resources();
564 564
565 QPtrList<KRES::Resource> kresResources; 565 QPtrList<KRES::Resource> kresResources;
566 QPtrListIterator<KABC::Resource> resIt( kabcResources ); 566 QPtrListIterator<KABC::Resource> resIt( kabcResources );
567 KABC::Resource *resource; 567 KABC::Resource *resource;
568 while ( ( resource = resIt.current() ) != 0 ) { 568 while ( ( resource = resIt.current() ) != 0 ) {
569 ++resIt; 569 ++resIt;
570 if ( !resource->readOnly() ) { 570 if ( !resource->readOnly() ) {
571 KRES::Resource *res = static_cast<KRES::Resource*>( resource ); 571 KRES::Resource *res = static_cast<KRES::Resource*>( resource );
572 if ( res ) 572 if ( res )
573 kresResources.append( res ); 573 kresResources.append( res );
574 } 574 }
575 } 575 }
576 576
577 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent ); 577 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent );
578 return static_cast<KABC::Resource*>( res ); 578 return static_cast<KABC::Resource*>( res );
579} 579}
580 580
581#ifndef KAB_EMBEDDED 581#ifndef KAB_EMBEDDED
582KAboutData *KABCore::createAboutData() 582KAboutData *KABCore::createAboutData()
583#else //KAB_EMBEDDED 583#else //KAB_EMBEDDED
584void KABCore::createAboutData() 584void KABCore::createAboutData()
585#endif //KAB_EMBEDDED 585#endif //KAB_EMBEDDED
586{ 586{
587#ifndef KAB_EMBEDDED 587#ifndef KAB_EMBEDDED
588 KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ), 588 KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ),
589 "3.1", I18N_NOOP( "The KDE Address Book" ), 589 "3.1", I18N_NOOP( "The KDE Address Book" ),
590 KAboutData::License_GPL_V2, 590 KAboutData::License_GPL_V2,
591 I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) ); 591 I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) );
592 about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" ); 592 about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" );
593 about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) ); 593 about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) );
594 about->addAuthor( "Cornelius Schumacher", 594 about->addAuthor( "Cornelius Schumacher",
595 I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ), 595 I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ),
596 "schumacher@kde.org" ); 596 "schumacher@kde.org" );
597 about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ), 597 about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ),
598 "mpilone@slac.com" ); 598 "mpilone@slac.com" );
599 about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) ); 599 about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) );
600 about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) ); 600 about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) );
601 about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ), 601 about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ),
602 "michel@klaralvdalens-datakonsult.se" ); 602 "michel@klaralvdalens-datakonsult.se" );
603 about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ), 603 about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ),
604 "hansen@kde.org" ); 604 "hansen@kde.org" );
605 605
606 return about; 606 return about;
607#endif //KAB_EMBEDDED 607#endif //KAB_EMBEDDED
608 608
609 QString version; 609 QString version;
610#include <../version> 610#include <../version>
611 QMessageBox::about( this, "About KAddressbook/Pi", 611 QMessageBox::about( this, "About KAddressbook/Pi",
612 "KAddressbook/Platform-independent\n" 612 "KAddressbook/Platform-independent\n"
613 "(KA/Pi) " +version + " - " + 613 "(KA/Pi) " +version + " - " +
614#ifdef DESKTOP_VERSION 614#ifdef DESKTOP_VERSION
615 "Desktop Edition\n" 615 "Desktop Edition\n"
616#else 616#else
617 "PDA-Edition\n" 617 "PDA-Edition\n"
618 "for: Zaurus 5500 / 7x0 / 8x0\n" 618 "for: Zaurus 5500 / 7x0 / 8x0\n"
619#endif 619#endif
620 620
621 "(c) 2004 Ulf Schenk\n" 621 "(c) 2004 Ulf Schenk\n"
622 "(c) 2004 Lutz Rogowski\n" 622 "(c) 2004 Lutz Rogowski\n"
623 "(c) 1997-2003, The KDE PIM Team\n" 623 "(c) 1997-2003, The KDE PIM Team\n"
624 "Tobias Koenig Current maintainer\ntokoe@kde.org\n" 624 "Tobias Koenig Current maintainer\ntokoe@kde.org\n"
625 "Don Sanders Original author\n" 625 "Don Sanders Original author\n"
626 "Cornelius Schumacher Co-maintainer\nschumacher@kde.org\n" 626 "Cornelius Schumacher Co-maintainer\nschumacher@kde.org\n"
627 "Mike Pilone GUI and framework redesign\nmpilone@slac.com\n" 627 "Mike Pilone GUI and framework redesign\nmpilone@slac.com\n"
628 "Greg Stern DCOP interface\n" 628 "Greg Stern DCOP interface\n"
629 "Mark Westcot Contact pinning\n" 629 "Mark Westcot Contact pinning\n"
630 "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n" 630 "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n"
631 "Steffen Hansen LDAP Lookup\nhansen@kde.org\n" 631 "Steffen Hansen LDAP Lookup\nhansen@kde.org\n"
632#ifdef _WIN32_ 632#ifdef _WIN32_
633 "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n" 633 "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n"
634#endif 634#endif
635 ); 635 );
636} 636}
637 637
638void KABCore::setContactSelected( const QString &uid ) 638void KABCore::setContactSelected( const QString &uid )
639{ 639{
640 KABC::Addressee addr = mAddressBook->findByUid( uid ); 640 KABC::Addressee addr = mAddressBook->findByUid( uid );
641 if ( !mDetails->isHidden() ) 641 if ( !mDetails->isHidden() )
642 mDetails->setAddressee( addr ); 642 mDetails->setAddressee( addr );
643 643
644 if ( !addr.isEmpty() ) { 644 if ( !addr.isEmpty() ) {
645 emit contactSelected( addr.formattedName() ); 645 emit contactSelected( addr.formattedName() );
646 KABC::Picture pic = addr.photo(); 646 KABC::Picture pic = addr.photo();
647 if ( pic.isIntern() ) { 647 if ( pic.isIntern() ) {
648//US emit contactSelected( pic.data() ); 648//US emit contactSelected( pic.data() );
649//US instead use: 649//US instead use:
650 QPixmap px; 650 QPixmap px;
651 if (pic.data().isNull() != true) 651 if (pic.data().isNull() != true)
652 { 652 {
653 px.convertFromImage(pic.data()); 653 px.convertFromImage(pic.data());
654 } 654 }
655 655
656 emit contactSelected( px ); 656 emit contactSelected( px );
657 } 657 }
658 } 658 }
659 659
660 660
661 mExtensionManager->setSelectionChanged(); 661 mExtensionManager->setSelectionChanged();
662 662
663 // update the actions 663 // update the actions
664 bool selected = !uid.isEmpty(); 664 bool selected = !uid.isEmpty();
665 665
666 if ( mReadWrite ) { 666 if ( mReadWrite ) {
667 mActionCut->setEnabled( selected ); 667 mActionCut->setEnabled( selected );
668 mActionPaste->setEnabled( selected ); 668 mActionPaste->setEnabled( selected );
669 } 669 }
670 670
671 mActionCopy->setEnabled( selected ); 671 mActionCopy->setEnabled( selected );
672 mActionDelete->setEnabled( selected ); 672 mActionDelete->setEnabled( selected );
673 mActionEditAddressee->setEnabled( selected ); 673 mActionEditAddressee->setEnabled( selected );
674 mActionMail->setEnabled( selected ); 674 mActionMail->setEnabled( selected );
675 mActionMailVCard->setEnabled( selected ); 675 mActionMailVCard->setEnabled( selected );
676 //if (mActionBeam) 676 //if (mActionBeam)
677 //mActionBeam->setEnabled( selected ); 677 //mActionBeam->setEnabled( selected );
678 678
679 if (mActionBeamVCard) 679 if (mActionBeamVCard)
680 mActionBeamVCard->setEnabled( selected ); 680 mActionBeamVCard->setEnabled( selected );
681 681
682 mActionWhoAmI->setEnabled( selected ); 682 mActionWhoAmI->setEnabled( selected );
683 mActionCategories->setEnabled( selected ); 683 mActionCategories->setEnabled( selected );
684} 684}
685 685
686void KABCore::sendMail() 686void KABCore::sendMail()
687{ 687{
688 sendMail( mViewManager->selectedEmails().join( ", " ) ); 688 sendMail( mViewManager->selectedEmails().join( ", " ) );
689} 689}
690 690
691void KABCore::sendMail( const QString& emaillist ) 691void KABCore::sendMail( const QString& emaillist )
692{ 692{
693 // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... " 693 // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... "
694 if (emaillist.contains(",") > 0) 694 if (emaillist.contains(",") > 0)
695 ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null ); 695 ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null );
696 else 696 else
697 ExternalAppHandler::instance()->mailToOneContact( emaillist ); 697 ExternalAppHandler::instance()->mailToOneContact( emaillist );
698} 698}
699 699
700 700
701 701
702void KABCore::mailVCard() 702void KABCore::mailVCard()
703{ 703{
704 QStringList uids = mViewManager->selectedUids(); 704 QStringList uids = mViewManager->selectedUids();
705 if ( !uids.isEmpty() ) 705 if ( !uids.isEmpty() )
706 mailVCard( uids ); 706 mailVCard( uids );
707} 707}
708 708
709void KABCore::mailVCard( const QStringList& uids ) 709void KABCore::mailVCard( const QStringList& uids )
710{ 710{
711 QStringList urls; 711 QStringList urls;
712 712
713// QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); 713// QString tmpdir = locateLocal("tmp", KGlobal::getAppName());
714 714
715 QString dirName = "/tmp/" + KApplication::randomString( 8 ); 715 QString dirName = "/tmp/" + KApplication::randomString( 8 );
716 716
717 717
718 718
719 QDir().mkdir( dirName, true ); 719 QDir().mkdir( dirName, true );
720 720
721 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { 721 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) {
722 KABC::Addressee a = mAddressBook->findByUid( *it ); 722 KABC::Addressee a = mAddressBook->findByUid( *it );
723 723
724 if ( a.isEmpty() ) 724 if ( a.isEmpty() )
725 continue; 725 continue;
726 726
727 QString name = a.givenName() + "_" + a.familyName() + ".vcf"; 727 QString name = a.givenName() + "_" + a.familyName() + ".vcf";
728 728
729 QString fileName = dirName + "/" + name; 729 QString fileName = dirName + "/" + name;
730 730
731 QFile outFile(fileName); 731 QFile outFile(fileName);
732 732
733 if ( outFile.open(IO_WriteOnly) ) { // file opened successfully 733 if ( outFile.open(IO_WriteOnly) ) { // file opened successfully
734 KABC::VCardConverter converter; 734 KABC::VCardConverter converter;
735 QString vcard; 735 QString vcard;
736 736
737 converter.addresseeToVCard( a, vcard ); 737 converter.addresseeToVCard( a, vcard );
738 738
739 QTextStream t( &outFile ); // use a text stream 739 QTextStream t( &outFile ); // use a text stream
740 t.setEncoding( QTextStream::UnicodeUTF8 ); 740 t.setEncoding( QTextStream::UnicodeUTF8 );
741 t << vcard; 741 t << vcard;
742 742
743 outFile.close(); 743 outFile.close();
744 744
745 urls.append( fileName ); 745 urls.append( fileName );
746 } 746 }
747 } 747 }
748 748
749 bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") ); 749 bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") );
750 750
751 751
752/*US 752/*US
753 kapp->invokeMailer( QString::null, QString::null, QString::null, 753 kapp->invokeMailer( QString::null, QString::null, QString::null,
754 QString::null, // subject 754 QString::null, // subject
755 QString::null, // body 755 QString::null, // body
756 QString::null, 756 QString::null,
757 urls ); // attachments 757 urls ); // attachments
758*/ 758*/
759 759
760} 760}
761 761
762/** 762/**
763 Beams the "WhoAmI contact. 763 Beams the "WhoAmI contact.
764*/ 764*/
765void KABCore::beamMySelf() 765void KABCore::beamMySelf()
766{ 766{
767 KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI(); 767 KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI();
768 if (!a.isEmpty()) 768 if (!a.isEmpty())
769 { 769 {
770 QStringList uids; 770 QStringList uids;
771 uids << a.uid(); 771 uids << a.uid();
772 772
773 beamVCard(uids); 773 beamVCard(uids);
774 } else { 774 } else {
775 KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) ); 775 KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) );
776 776
777 777
778 } 778 }
779} 779}
780 780
781void KABCore::export2phone() 781void KABCore::export2phone()
782{ 782{
783 QStringList uids; 783 QStringList uids;
784 XXPortSelectDialog dlg( this, false, this ); 784 XXPortSelectDialog dlg( this, false, this );
785 if ( dlg.exec() ) 785 if ( dlg.exec() )
786 uids = dlg.uids(); 786 uids = dlg.uids();
787 else 787 else
788 return; 788 return;
789 if ( uids.isEmpty() ) 789 if ( uids.isEmpty() )
790 return; 790 return;
791 // qDebug("count %d ", uids.count()); 791 // qDebug("count %d ", uids.count());
792 792
793 KAex2phonePrefs ex2phone; 793 KAex2phonePrefs ex2phone;
794 ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); 794 ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection );
795 ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); 795 ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice );
796 ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); 796 ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel );
797 797
798 if ( !ex2phone.exec() ) { 798 if ( !ex2phone.exec() ) {
799 return; 799 return;
800 } 800 }
801 KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); 801 KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text();
802 KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); 802 KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text();
803 KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); 803 KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text();
804 804
805 805
806 PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, 806 PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice,
807 KPimGlobalPrefs::instance()->mEx2PhoneConnection, 807 KPimGlobalPrefs::instance()->mEx2PhoneConnection,
808 KPimGlobalPrefs::instance()->mEx2PhoneModel ); 808 KPimGlobalPrefs::instance()->mEx2PhoneModel );
809 809
810 QString fileName = getPhoneFile(); 810 QString fileName = getPhoneFile();
811 if ( ! mAddressBook->export2PhoneFormat( uids ,fileName ) ) 811 if ( ! mAddressBook->export2PhoneFormat( uids ,fileName ) )
812 return; 812 return;
813 813
814 message(i18n("Exporting to phone...")); 814 message(i18n("Exporting to phone..."));
815 QTimer::singleShot( 1, this , SLOT ( writeToPhone())); 815 QTimer::singleShot( 1, this , SLOT ( writeToPhone()));
816 816
817} 817}
818QString KABCore::getPhoneFile() 818QString KABCore::getPhoneFile()
819{ 819{
820#ifdef DESKTOP_VERSION 820#ifdef DESKTOP_VERSION
821 return locateLocal("tmp", "phonefile.vcf"); 821 return locateLocal("tmp", "phonefile.vcf");
822#else 822#else
823 return "/tmp/phonefile.vcf"; 823 return "/tmp/phonefile.vcf";
824#endif 824#endif
825 825
826} 826}
827void KABCore::writeToPhone( ) 827void KABCore::writeToPhone( )
828{ 828{
829 if ( PhoneAccess::writeToPhone( getPhoneFile() ) ) 829 if ( PhoneAccess::writeToPhone( getPhoneFile() ) )
830 message(i18n("Export to phone finished!")); 830 message(i18n("Export to phone finished!"));
831 else 831 else
832 qDebug(i18n("Error exporting to phone")); 832 qDebug(i18n("Error exporting to phone"));
833} 833}
834void KABCore::beamVCard() 834void KABCore::beamVCard()
835{ 835{
836 QStringList uids = mViewManager->selectedUids(); 836 QStringList uids = mViewManager->selectedUids();
837 if ( !uids.isEmpty() ) 837 if ( !uids.isEmpty() )
838 beamVCard( uids ); 838 beamVCard( uids );
839} 839}
840 840
841 841
842void KABCore::beamVCard(const QStringList& uids) 842void KABCore::beamVCard(const QStringList& uids)
843{ 843{
844 844
845 // LR: we should use the /tmp dir on the Zaurus, 845 // LR: we should use the /tmp dir on the Zaurus,
846 // because: /tmp = RAM, (HOME)/kdepim = flash memory 846 // because: /tmp = RAM, (HOME)/kdepim = flash memory
847 847
848#ifdef DESKTOP_VERSION 848#ifdef DESKTOP_VERSION
849 QString fileName = locateLocal("tmp", "kapibeamfile.vcf"); 849 QString fileName = locateLocal("tmp", "kapibeamfile.vcf");
850#else 850#else
851 QString fileName = "/tmp/kapibeamfile.vcf"; 851 QString fileName = "/tmp/kapibeamfile.vcf";
852#endif 852#endif
853 853
854 KABC::VCardConverter converter; 854 KABC::VCardConverter converter;
855 QString description; 855 QString description;
856 QString datastream; 856 QString datastream;
857 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { 857 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) {
858 KABC::Addressee a = mAddressBook->findByUid( *it ); 858 KABC::Addressee a = mAddressBook->findByUid( *it );
859 859
860 if ( a.isEmpty() ) 860 if ( a.isEmpty() )
861 continue; 861 continue;
862 862
863 if (description.isEmpty()) 863 if (description.isEmpty())
864 description = a.formattedName(); 864 description = a.formattedName();
865 865
866 QString vcard; 866 QString vcard;
867 converter.addresseeToVCard( a, vcard ); 867 converter.addresseeToVCard( a, vcard );
868 int start = 0; 868 int start = 0;
869 int next; 869 int next;
870 while ( (next = vcard.find("TYPE=", start) )>= 0 ) { 870 while ( (next = vcard.find("TYPE=", start) )>= 0 ) {
871 int semi = vcard.find(";", next); 871 int semi = vcard.find(";", next);
872 int dopp = vcard.find(":", next); 872 int dopp = vcard.find(":", next);
873 int sep; 873 int sep;
874 if ( semi < dopp && semi >= 0 ) 874 if ( semi < dopp && semi >= 0 )
875 sep = semi ; 875 sep = semi ;
876 else 876 else
877 sep = dopp; 877 sep = dopp;
878 datastream +=vcard.mid( start, next - start); 878 datastream +=vcard.mid( start, next - start);
879 datastream +=vcard.mid( next+5,sep -next -5 ).upper(); 879 datastream +=vcard.mid( next+5,sep -next -5 ).upper();
880 start = sep; 880 start = sep;
881 } 881 }
882 datastream += vcard.mid( start,vcard.length() ); 882 datastream += vcard.mid( start,vcard.length() );
883 } 883 }
884#ifndef DESKTOP_VERSION 884#ifndef DESKTOP_VERSION
885 QFile outFile(fileName); 885 QFile outFile(fileName);
886 if ( outFile.open(IO_WriteOnly) ) { 886 if ( outFile.open(IO_WriteOnly) ) {
887 datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); 887 datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" );
888 QTextStream t( &outFile ); // use a text stream 888 QTextStream t( &outFile ); // use a text stream
889 //t.setEncoding( QTextStream::UnicodeUTF8 ); 889 //t.setEncoding( QTextStream::UnicodeUTF8 );
890 t.setEncoding( QTextStream::Latin1 ); 890 t.setEncoding( QTextStream::Latin1 );
891 t <<datastream.latin1(); 891 t <<datastream.latin1();
892 outFile.close(); 892 outFile.close();
893 Ir *ir = new Ir( this ); 893 Ir *ir = new Ir( this );
894 connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); 894 connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) );
895 ir->send( fileName, description, "text/x-vCard" ); 895 ir->send( fileName, description, "text/x-vCard" );
896 } else { 896 } else {
897 qDebug("Error open temp beam file "); 897 qDebug("Error open temp beam file ");
898 return; 898 return;
899 } 899 }
900#endif 900#endif
901 901
902} 902}
903 903
904void KABCore::beamDone( Ir *ir ) 904void KABCore::beamDone( Ir *ir )
905{ 905{
906#ifndef DESKTOP_VERSION 906#ifndef DESKTOP_VERSION
907 delete ir; 907 delete ir;
908#endif 908#endif
909 topLevelWidget()->raise(); 909 topLevelWidget()->raise();
910 message( i18n("Beaming finished!") ); 910 message( i18n("Beaming finished!") );
911} 911}
912 912
913 913
914void KABCore::browse( const QString& url ) 914void KABCore::browse( const QString& url )
915{ 915{
916#ifndef KAB_EMBEDDED 916#ifndef KAB_EMBEDDED
917 kapp->invokeBrowser( url ); 917 kapp->invokeBrowser( url );
918#else //KAB_EMBEDDED 918#else //KAB_EMBEDDED
919 qDebug("KABCore::browse must be fixed"); 919 qDebug("KABCore::browse must be fixed");
920#endif //KAB_EMBEDDED 920#endif //KAB_EMBEDDED
921} 921}
922 922
923void KABCore::selectAllContacts() 923void KABCore::selectAllContacts()
924{ 924{
925 mViewManager->setSelected( QString::null, true ); 925 mViewManager->setSelected( QString::null, true );
926} 926}
927 927
928void KABCore::deleteContacts() 928void KABCore::deleteContacts()
929{ 929{
930 QStringList uidList = mViewManager->selectedUids(); 930 QStringList uidList = mViewManager->selectedUids();
931 deleteContacts( uidList ); 931 deleteContacts( uidList );
932} 932}
933 933
934void KABCore::deleteContacts( const QStringList &uids ) 934void KABCore::deleteContacts( const QStringList &uids )
935{ 935{
936 if ( uids.count() > 0 ) { 936 if ( uids.count() > 0 ) {
937 PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids ); 937 PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids );
938 UndoStack::instance()->push( command ); 938 UndoStack::instance()->push( command );
939 RedoStack::instance()->clear(); 939 RedoStack::instance()->clear();
940 940
941 // now if we deleted anything, refresh 941 // now if we deleted anything, refresh
942 setContactSelected( QString::null ); 942 setContactSelected( QString::null );
943 setModified( true ); 943 setModified( true );
944 } 944 }
945} 945}
946 946
947void KABCore::copyContacts() 947void KABCore::copyContacts()
948{ 948{
949 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 949 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
950 950
951 QString clipText = AddresseeUtil::addresseesToClipboard( addrList ); 951 QString clipText = AddresseeUtil::addresseesToClipboard( addrList );
952 952
953 kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl; 953 kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl;
954 954
955 QClipboard *cb = QApplication::clipboard(); 955 QClipboard *cb = QApplication::clipboard();
956 cb->setText( clipText ); 956 cb->setText( clipText );
957} 957}
958 958
959void KABCore::cutContacts() 959void KABCore::cutContacts()
960{ 960{
961 QStringList uidList = mViewManager->selectedUids(); 961 QStringList uidList = mViewManager->selectedUids();
962 962
963//US if ( uidList.size() > 0 ) { 963//US if ( uidList.size() > 0 ) {
964 if ( uidList.count() > 0 ) { 964 if ( uidList.count() > 0 ) {
965 PwCutCommand *command = new PwCutCommand( mAddressBook, uidList ); 965 PwCutCommand *command = new PwCutCommand( mAddressBook, uidList );
966 UndoStack::instance()->push( command ); 966 UndoStack::instance()->push( command );
967 RedoStack::instance()->clear(); 967 RedoStack::instance()->clear();
968 968
969 setModified( true ); 969 setModified( true );
970 } 970 }
971} 971}
972 972
973void KABCore::pasteContacts() 973void KABCore::pasteContacts()
974{ 974{
975 QClipboard *cb = QApplication::clipboard(); 975 QClipboard *cb = QApplication::clipboard();
976 976
977 KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() ); 977 KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() );
978 978
979 pasteContacts( list ); 979 pasteContacts( list );
980} 980}
981 981
982void KABCore::pasteContacts( KABC::Addressee::List &list ) 982void KABCore::pasteContacts( KABC::Addressee::List &list )
983{ 983{
984 KABC::Resource *resource = requestResource( this ); 984 KABC::Resource *resource = requestResource( this );
985 KABC::Addressee::List::Iterator it; 985 KABC::Addressee::List::Iterator it;
986 for ( it = list.begin(); it != list.end(); ++it ) 986 for ( it = list.begin(); it != list.end(); ++it )
987 (*it).setResource( resource ); 987 (*it).setResource( resource );
988 988
989 PwPasteCommand *command = new PwPasteCommand( this, list ); 989 PwPasteCommand *command = new PwPasteCommand( this, list );
990 UndoStack::instance()->push( command ); 990 UndoStack::instance()->push( command );
991 RedoStack::instance()->clear(); 991 RedoStack::instance()->clear();
992 992
993 setModified( true ); 993 setModified( true );
994} 994}
995 995
996void KABCore::setWhoAmI() 996void KABCore::setWhoAmI()
997{ 997{
998 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 998 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
999 999
1000 if ( addrList.count() > 1 ) { 1000 if ( addrList.count() > 1 ) {
1001 KMessageBox::sorry( this, i18n( "Please select only one contact." ) ); 1001 KMessageBox::sorry( this, i18n( "Please select only one contact." ) );
1002 return; 1002 return;
1003 } 1003 }
1004 1004
1005 QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) ); 1005 QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) );
1006 if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes ) 1006 if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes )
1007 static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] ); 1007 static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] );
1008} 1008}
1009void KABCore::editCategories() 1009void KABCore::editCategories()
1010{ 1010{
1011 KPIM::CategoryEditDialog dlg ( KABPrefs::instance(), this, "", true ); 1011 KPIM::CategoryEditDialog dlg ( KABPrefs::instance(), this, "", true );
1012 dlg.exec(); 1012 dlg.exec();
1013} 1013}
1014void KABCore::setCategories() 1014void KABCore::setCategories()
1015{ 1015{
1016 KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true ); 1016 KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true );
1017 if ( !dlg.exec() ) { 1017 if ( !dlg.exec() ) {
1018 message( i18n("Setting categories cancelled") ); 1018 message( i18n("Setting categories cancelled") );
1019 return; 1019 return;
1020 } 1020 }
1021 bool merge = false; 1021 bool merge = false;
1022 QString msg = i18n( "Merge with existing categories?" ); 1022 QString msg = i18n( "Merge with existing categories?" );
1023 if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes ) 1023 if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes )
1024 merge = true; 1024 merge = true;
1025 1025
1026 message( i18n("Setting categories ... please wait!") ); 1026 message( i18n("Setting categories ... please wait!") );
1027 QStringList categories = dlg.selectedCategories(); 1027 QStringList categories = dlg.selectedCategories();
1028 1028
1029 QStringList uids = mViewManager->selectedUids(); 1029 QStringList uids = mViewManager->selectedUids();
1030 QStringList::Iterator it; 1030 QStringList::Iterator it;
1031 for ( it = uids.begin(); it != uids.end(); ++it ) { 1031 for ( it = uids.begin(); it != uids.end(); ++it ) {
1032 KABC::Addressee addr = mAddressBook->findByUid( *it ); 1032 KABC::Addressee addr = mAddressBook->findByUid( *it );
1033 if ( !addr.isEmpty() ) { 1033 if ( !addr.isEmpty() ) {
1034 if ( !merge ) 1034 if ( !merge )
1035 addr.setCategories( categories ); 1035 addr.setCategories( categories );
1036 else { 1036 else {
1037 QStringList addrCategories = addr.categories(); 1037 QStringList addrCategories = addr.categories();
1038 QStringList::Iterator catIt; 1038 QStringList::Iterator catIt;
1039 for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) { 1039 for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) {
1040 if ( !addrCategories.contains( *catIt ) ) 1040 if ( !addrCategories.contains( *catIt ) )
1041 addrCategories.append( *catIt ); 1041 addrCategories.append( *catIt );
1042 } 1042 }
1043 addr.setCategories( addrCategories ); 1043 addr.setCategories( addrCategories );
1044 } 1044 }
1045 mAddressBook->insertAddressee( addr ); 1045 mAddressBook->insertAddressee( addr );
1046 } 1046 }
1047 } 1047 }
1048 1048
1049 if ( uids.count() > 0 ) 1049 if ( uids.count() > 0 )
1050 setModified( true ); 1050 setModified( true );
1051 message( i18n("Setting categories completed!") ); 1051 message( i18n("Setting categories completed!") );
1052} 1052}
1053 1053
1054void KABCore::setSearchFields( const KABC::Field::List &fields ) 1054void KABCore::setSearchFields( const KABC::Field::List &fields )
1055{ 1055{
1056 mIncSearchWidget->setFields( fields ); 1056 mIncSearchWidget->setFields( fields );
1057} 1057}
1058 1058
1059void KABCore::incrementalSearch( const QString& text ) 1059void KABCore::incrementalSearch( const QString& text )
1060{ 1060{
1061 mViewManager->doSearch( text, mIncSearchWidget->currentField() ); 1061 mViewManager->doSearch( text, mIncSearchWidget->currentField() );
1062} 1062}
1063 1063
1064void KABCore::setModified() 1064void KABCore::setModified()
1065{ 1065{
1066 setModified( true ); 1066 setModified( true );
1067} 1067}
1068 1068
1069void KABCore::setModifiedWOrefresh() 1069void KABCore::setModifiedWOrefresh()
1070{ 1070{
1071 // qDebug("KABCore::setModifiedWOrefresh() "); 1071 // qDebug("KABCore::setModifiedWOrefresh() ");
1072 mModified = true; 1072 mModified = true;
1073 mActionSave->setEnabled( mModified ); 1073 mActionSave->setEnabled( mModified );
1074#ifdef DESKTOP_VERSION 1074#ifdef DESKTOP_VERSION
1075 mDetails->refreshView(); 1075 mDetails->refreshView();
1076#endif 1076#endif
1077 1077
1078} 1078}
1079void KABCore::setModified( bool modified ) 1079void KABCore::setModified( bool modified )
1080{ 1080{
1081 mModified = modified; 1081 mModified = modified;
1082 mActionSave->setEnabled( mModified ); 1082 mActionSave->setEnabled( mModified );
1083 1083
1084 if ( modified ) 1084 if ( modified )
1085 mJumpButtonBar->recreateButtons(); 1085 mJumpButtonBar->recreateButtons();
1086 1086
1087 mViewManager->refreshView(); 1087 mViewManager->refreshView();
1088 mDetails->refreshView(); 1088 mDetails->refreshView();
1089 1089
1090} 1090}
1091 1091
1092bool KABCore::modified() const 1092bool KABCore::modified() const
1093{ 1093{
1094 return mModified; 1094 return mModified;
1095} 1095}
1096 1096
1097void KABCore::contactModified( const KABC::Addressee &addr ) 1097void KABCore::contactModified( const KABC::Addressee &addr )
1098{ 1098{
1099 1099
1100 Command *command = 0; 1100 Command *command = 0;
1101 QString uid; 1101 QString uid;
1102 1102
1103 // check if it exists already 1103 // check if it exists already
1104 KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() ); 1104 KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() );
1105 if ( origAddr.isEmpty() ) 1105 if ( origAddr.isEmpty() )
1106 command = new PwNewCommand( mAddressBook, addr ); 1106 command = new PwNewCommand( mAddressBook, addr );
1107 else { 1107 else {
1108 command = new PwEditCommand( mAddressBook, origAddr, addr ); 1108 command = new PwEditCommand( mAddressBook, origAddr, addr );
1109 uid = addr.uid(); 1109 uid = addr.uid();
1110 } 1110 }
1111 1111
1112 UndoStack::instance()->push( command ); 1112 UndoStack::instance()->push( command );
1113 RedoStack::instance()->clear(); 1113 RedoStack::instance()->clear();
1114 1114
1115 setModified( true ); 1115 setModified( true );
1116} 1116}
1117 1117
1118void KABCore::newContact() 1118void KABCore::newContact()
1119{ 1119{
1120 1120
1121 1121
1122 QPtrList<KABC::Resource> kabcResources = mAddressBook->resources(); 1122 QPtrList<KABC::Resource> kabcResources = mAddressBook->resources();
1123 1123
1124 QPtrList<KRES::Resource> kresResources; 1124 QPtrList<KRES::Resource> kresResources;
1125 QPtrListIterator<KABC::Resource> it( kabcResources ); 1125 QPtrListIterator<KABC::Resource> it( kabcResources );
1126 KABC::Resource *resource; 1126 KABC::Resource *resource;
1127 while ( ( resource = it.current() ) != 0 ) { 1127 while ( ( resource = it.current() ) != 0 ) {
1128 ++it; 1128 ++it;
1129 if ( !resource->readOnly() ) { 1129 if ( !resource->readOnly() ) {
1130 KRES::Resource *res = static_cast<KRES::Resource*>( resource ); 1130 KRES::Resource *res = static_cast<KRES::Resource*>( resource );
1131 if ( res ) 1131 if ( res )
1132 kresResources.append( res ); 1132 kresResources.append( res );
1133 } 1133 }
1134 } 1134 }
1135 1135
1136 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this ); 1136 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this );
1137 resource = static_cast<KABC::Resource*>( res ); 1137 resource = static_cast<KABC::Resource*>( res );
1138 1138
1139 if ( resource ) { 1139 if ( resource ) {
1140 KABC::Addressee addr; 1140 KABC::Addressee addr;
1141 addr.setResource( resource ); 1141 addr.setResource( resource );
1142 mEditorDialog->setAddressee( addr ); 1142 mEditorDialog->setAddressee( addr );
1143 KApplication::execDialog ( mEditorDialog ); 1143 KApplication::execDialog ( mEditorDialog );
1144 1144
1145 } else 1145 } else
1146 return; 1146 return;
1147 1147
1148 // mEditorDict.insert( dialog->addressee().uid(), dialog ); 1148 // mEditorDict.insert( dialog->addressee().uid(), dialog );
1149 1149
1150 1150
1151} 1151}
1152 1152
1153void KABCore::addEmail( QString aStr ) 1153void KABCore::addEmail( QString aStr )
1154{ 1154{
1155#ifndef KAB_EMBEDDED 1155#ifndef KAB_EMBEDDED
1156 QString fullName, email; 1156 QString fullName, email;
1157 1157
1158 KABC::Addressee::parseEmailAddress( aStr, fullName, email ); 1158 KABC::Addressee::parseEmailAddress( aStr, fullName, email );
1159 1159
1160 // Try to lookup the addressee matching the email address 1160 // Try to lookup the addressee matching the email address
1161 bool found = false; 1161 bool found = false;
1162 QStringList emailList; 1162 QStringList emailList;
1163 KABC::AddressBook::Iterator it; 1163 KABC::AddressBook::Iterator it;
1164 for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) { 1164 for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) {
1165 emailList = (*it).emails(); 1165 emailList = (*it).emails();
1166 if ( emailList.contains( email ) > 0 ) { 1166 if ( emailList.contains( email ) > 0 ) {
1167 found = true; 1167 found = true;
1168 (*it).setNameFromString( fullName ); 1168 (*it).setNameFromString( fullName );
1169 editContact( (*it).uid() ); 1169 editContact( (*it).uid() );
1170 } 1170 }
1171 } 1171 }
1172 1172
1173 if ( !found ) { 1173 if ( !found ) {
1174 KABC::Addressee addr; 1174 KABC::Addressee addr;
1175 addr.setNameFromString( fullName ); 1175 addr.setNameFromString( fullName );
1176 addr.insertEmail( email, true ); 1176 addr.insertEmail( email, true );
1177 1177
1178 mAddressBook->insertAddressee( addr ); 1178 mAddressBook->insertAddressee( addr );
1179 mViewManager->refreshView( addr.uid() ); 1179 mViewManager->refreshView( addr.uid() );
1180 editContact( addr.uid() ); 1180 editContact( addr.uid() );
1181 } 1181 }
1182#else //KAB_EMBEDDED 1182#else //KAB_EMBEDDED
1183 qDebug("KABCore::addEmail finsih method"); 1183 qDebug("KABCore::addEmail finsih method");
1184#endif //KAB_EMBEDDED 1184#endif //KAB_EMBEDDED
1185} 1185}
1186 1186
1187void KABCore::importVCard( const KURL &url, bool showPreview ) 1187void KABCore::importVCard( const KURL &url, bool showPreview )
1188{ 1188{
1189 mXXPortManager->importVCard( url, showPreview ); 1189 mXXPortManager->importVCard( url, showPreview );
1190} 1190}
1191void KABCore::importFromOL() 1191void KABCore::importFromOL()
1192{ 1192{
1193#ifdef _WIN32_ 1193#ifdef _WIN32_
1194 KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this ); 1194 KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this );
1195 idgl->exec(); 1195 idgl->exec();
1196 KABC::Addressee::List list = idgl->getAddressList(); 1196 KABC::Addressee::List list = idgl->getAddressList();
1197 if ( list.count() > 0 ) { 1197 if ( list.count() > 0 ) {
1198 KABC::Addressee::List listNew; 1198 KABC::Addressee::List listNew;
1199 KABC::Addressee::List listExisting; 1199 KABC::Addressee::List listExisting;
1200 KABC::Addressee::List::Iterator it; 1200 KABC::Addressee::List::Iterator it;
1201 KABC::AddressBook::Iterator iter; 1201 KABC::AddressBook::Iterator iter;
1202 for ( it = list.begin(); it != list.end(); ++it ) { 1202 for ( it = list.begin(); it != list.end(); ++it ) {
1203 if ( mAddressBook->findByUid((*it).uid() ).isEmpty()) 1203 if ( mAddressBook->findByUid((*it).uid() ).isEmpty())
1204 listNew.append( (*it) ); 1204 listNew.append( (*it) );
1205 else 1205 else
1206 listExisting.append( (*it) ); 1206 listExisting.append( (*it) );
1207 } 1207 }
1208 if ( listExisting.count() > 0 ) 1208 if ( listExisting.count() > 0 )
1209 KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() )); 1209 KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() ));
1210 if ( listNew.count() > 0 ) { 1210 if ( listNew.count() > 0 ) {
1211 pasteWithNewUid = false; 1211 pasteWithNewUid = false;
1212 pasteContacts( listNew ); 1212 pasteContacts( listNew );
1213 pasteWithNewUid = true; 1213 pasteWithNewUid = true;
1214 } 1214 }
1215 } 1215 }
1216 delete idgl; 1216 delete idgl;
1217#endif 1217#endif
1218} 1218}
1219 1219
1220void KABCore::importVCard( const QString &vCard, bool showPreview ) 1220void KABCore::importVCard( const QString &vCard, bool showPreview )
1221{ 1221{
1222 mXXPortManager->importVCard( vCard, showPreview ); 1222 mXXPortManager->importVCard( vCard, showPreview );
1223} 1223}
1224 1224
1225//US added a second method without defaultparameter 1225//US added a second method without defaultparameter
1226void KABCore::editContact2() { 1226void KABCore::editContact2() {
1227 editContact( QString::null ); 1227 editContact( QString::null );
1228} 1228}
1229 1229
1230void KABCore::editContact( const QString &uid ) 1230void KABCore::editContact( const QString &uid )
1231{ 1231{
1232 1232
1233 if ( mExtensionManager->isQuickEditVisible() ) 1233 if ( mExtensionManager->isQuickEditVisible() )
1234 return; 1234 return;
1235 1235
1236 // First, locate the contact entry 1236 // First, locate the contact entry
1237 QString localUID = uid; 1237 QString localUID = uid;
1238 if ( localUID.isNull() ) { 1238 if ( localUID.isNull() ) {
1239 QStringList uidList = mViewManager->selectedUids(); 1239 QStringList uidList = mViewManager->selectedUids();
1240 if ( uidList.count() > 0 ) 1240 if ( uidList.count() > 0 )
1241 localUID = *( uidList.at( 0 ) ); 1241 localUID = *( uidList.at( 0 ) );
1242 } 1242 }
1243 1243
1244 KABC::Addressee addr = mAddressBook->findByUid( localUID ); 1244 KABC::Addressee addr = mAddressBook->findByUid( localUID );
1245 if ( !addr.isEmpty() ) { 1245 if ( !addr.isEmpty() ) {
1246 mEditorDialog->setAddressee( addr ); 1246 mEditorDialog->setAddressee( addr );
1247 KApplication::execDialog ( mEditorDialog ); 1247 KApplication::execDialog ( mEditorDialog );
1248 } 1248 }
1249} 1249}
1250 1250
1251/** 1251/**
1252 Shows or edits the detail view for the given uid. If the uid is QString::null, 1252 Shows or edits the detail view for the given uid. If the uid is QString::null,
1253 the method will try to find a selected addressee in the view. 1253 the method will try to find a selected addressee in the view.
1254 */ 1254 */
1255void KABCore::executeContact( const QString &uid /*US = QString::null*/ ) 1255void KABCore::executeContact( const QString &uid /*US = QString::null*/ )
1256{ 1256{
1257 if ( mMultipleViewsAtOnce ) 1257 if ( mMultipleViewsAtOnce )
1258 { 1258 {
1259 editContact( uid ); 1259 editContact( uid );
1260 } 1260 }
1261 else 1261 else
1262 { 1262 {
1263 setDetailsVisible( true ); 1263 setDetailsVisible( true );
1264 mActionDetails->setChecked(true); 1264 mActionDetails->setChecked(true);
1265 } 1265 }
1266 1266
1267} 1267}
1268 1268
1269void KABCore::save() 1269void KABCore::save()
1270{ 1270{
1271 if (syncManager->blockSave()) 1271 if (syncManager->blockSave())
1272 return; 1272 return;
1273 if ( !mModified ) 1273 if ( !mModified )
1274 return; 1274 return;
1275 1275
1276 syncManager->setBlockSave(true); 1276 syncManager->setBlockSave(true);
1277 QString text = i18n( "There was an error while attempting to save\n the " 1277 QString text = i18n( "There was an error while attempting to save\n the "
1278 "address book. Please check that some \nother application is " 1278 "address book. Please check that some \nother application is "
1279 "not using it. " ); 1279 "not using it. " );
1280 message(i18n("Saving addressbook ... ")); 1280 message(i18n("Saving addressbook ... "));
1281#ifndef KAB_EMBEDDED 1281#ifndef KAB_EMBEDDED
1282 KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook ); 1282 KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook );
1283 if ( !b || !b->save() ) { 1283 if ( !b || !b->save() ) {
1284 KMessageBox::error( this, text, i18n( "Unable to Save" ) ); 1284 KMessageBox::error( this, text, i18n( "Unable to Save" ) );
1285 } 1285 }
1286#else //KAB_EMBEDDED 1286#else //KAB_EMBEDDED
1287 KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook ); 1287 KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook );
1288 if ( !b || !b->save() ) { 1288 if ( !b || !b->save() ) {
1289 QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok")); 1289 QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok"));
1290 } 1290 }
1291#endif //KAB_EMBEDDED 1291#endif //KAB_EMBEDDED
1292 1292
1293 message(i18n("Addressbook saved!")); 1293 message(i18n("Addressbook saved!"));
1294 setModified( false ); 1294 setModified( false );
1295 syncManager->setBlockSave(false); 1295 syncManager->setBlockSave(false);
1296} 1296}
1297 1297
1298 1298
1299void KABCore::undo() 1299void KABCore::undo()
1300{ 1300{
1301 UndoStack::instance()->undo(); 1301 UndoStack::instance()->undo();
1302 1302
1303 // Refresh the view 1303 // Refresh the view
1304 mViewManager->refreshView(); 1304 mViewManager->refreshView();
1305} 1305}
1306 1306
1307void KABCore::redo() 1307void KABCore::redo()
1308{ 1308{
1309 RedoStack::instance()->redo(); 1309 RedoStack::instance()->redo();
1310 1310
1311 // Refresh the view 1311 // Refresh the view
1312 mViewManager->refreshView(); 1312 mViewManager->refreshView();
1313} 1313}
1314 1314
1315void KABCore::setJumpButtonBarVisible( bool visible ) 1315void KABCore::setJumpButtonBarVisible( bool visible )
1316{ 1316{
1317 if (mMultipleViewsAtOnce) 1317 if (mMultipleViewsAtOnce)
1318 { 1318 {
1319 if ( visible ) 1319 if ( visible )
1320 mJumpButtonBar->show(); 1320 mJumpButtonBar->show();
1321 else 1321 else
1322 mJumpButtonBar->hide(); 1322 mJumpButtonBar->hide();
1323 } 1323 }
1324 else 1324 else
1325 { 1325 {
1326 // show the jumpbar only if "the details are hidden" == "viewmanager are shown" 1326 // show the jumpbar only if "the details are hidden" == "viewmanager are shown"
1327 if (mViewManager->isVisible()) 1327 if (mViewManager->isVisible())
1328 { 1328 {
1329 if ( visible ) 1329 if ( visible )
1330 mJumpButtonBar->show(); 1330 mJumpButtonBar->show();
1331 else 1331 else
1332 mJumpButtonBar->hide(); 1332 mJumpButtonBar->hide();
1333 } 1333 }
1334 else 1334 else
1335 { 1335 {
1336 mJumpButtonBar->hide(); 1336 mJumpButtonBar->hide();
1337 } 1337 }
1338 } 1338 }
1339} 1339}
1340 1340
1341 1341
1342void KABCore::setDetailsToState() 1342void KABCore::setDetailsToState()
1343{ 1343{
1344 setDetailsVisible( mActionDetails->isChecked() ); 1344 setDetailsVisible( mActionDetails->isChecked() );
1345} 1345}
1346void KABCore::setDetailsToggle() 1346void KABCore::setDetailsToggle()
1347{ 1347{
1348 mActionDetails->setChecked( !mActionDetails->isChecked() ); 1348 mActionDetails->setChecked( !mActionDetails->isChecked() );
1349 setDetailsToState(); 1349 setDetailsToState();
1350} 1350}
1351 1351
1352 1352
1353 1353
1354void KABCore::setDetailsVisible( bool visible ) 1354void KABCore::setDetailsVisible( bool visible )
1355{ 1355{
1356 if (visible && mDetails->isHidden()) 1356 if (visible && mDetails->isHidden())
1357 { 1357 {
1358 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 1358 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
1359 if ( addrList.count() > 0 ) 1359 if ( addrList.count() > 0 )
1360 mDetails->setAddressee( addrList[ 0 ] ); 1360 mDetails->setAddressee( addrList[ 0 ] );
1361 } 1361 }
1362 1362
1363 // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between 1363 // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between
1364 // the listview and the detailview. We do that by changing the splitbar size. 1364 // the listview and the detailview. We do that by changing the splitbar size.
1365 if (mMultipleViewsAtOnce) 1365 if (mMultipleViewsAtOnce)
1366 { 1366 {
1367 if ( visible ) 1367 if ( visible )
1368 mDetails->show(); 1368 mDetails->show();
1369 else 1369 else
1370 mDetails->hide(); 1370 mDetails->hide();
1371 } 1371 }
1372 else 1372 else
1373 { 1373 {
1374 if ( visible ) { 1374 if ( visible ) {
1375 mViewManager->hide(); 1375 mViewManager->hide();
1376 mDetails->show(); 1376 mDetails->show();
1377 mIncSearchWidget->setFocus(); 1377 mIncSearchWidget->setFocus();
1378 } 1378 }
1379 else { 1379 else {
1380 mViewManager->show(); 1380 mViewManager->show();
1381 mDetails->hide(); 1381 mDetails->hide();
1382 mViewManager->setFocusAV(); 1382 mViewManager->setFocusAV();
1383 } 1383 }
1384 setJumpButtonBarVisible( !visible ); 1384 setJumpButtonBarVisible( !visible );
1385 } 1385 }
1386 1386
1387} 1387}
1388 1388
1389void KABCore::extensionChanged( int id ) 1389void KABCore::extensionChanged( int id )
1390{ 1390{
1391 //change the details view only for non desktop systems 1391 //change the details view only for non desktop systems
1392#ifndef DESKTOP_VERSION 1392#ifndef DESKTOP_VERSION
1393 1393
1394 if (id == 0) 1394 if (id == 0)
1395 { 1395 {
1396 //the user disabled the extension. 1396 //the user disabled the extension.
1397 1397
1398 if (mMultipleViewsAtOnce) 1398 if (mMultipleViewsAtOnce)
1399 { // enable detailsview again 1399 { // enable detailsview again
1400 setDetailsVisible( true ); 1400 setDetailsVisible( true );
1401 mActionDetails->setChecked( true ); 1401 mActionDetails->setChecked( true );
1402 } 1402 }
1403 else 1403 else
1404 { //go back to the listview 1404 { //go back to the listview
1405 setDetailsVisible( false ); 1405 setDetailsVisible( false );
1406 mActionDetails->setChecked( false ); 1406 mActionDetails->setChecked( false );
1407 mActionDetails->setEnabled(true); 1407 mActionDetails->setEnabled(true);
1408 } 1408 }
1409 1409
1410 } 1410 }
1411 else 1411 else
1412 { 1412 {
1413 //the user enabled the extension. 1413 //the user enabled the extension.
1414 setDetailsVisible( false ); 1414 setDetailsVisible( false );
1415 mActionDetails->setChecked( false ); 1415 mActionDetails->setChecked( false );
1416 1416
1417 if (!mMultipleViewsAtOnce) 1417 if (!mMultipleViewsAtOnce)
1418 { 1418 {
1419 mActionDetails->setEnabled(false); 1419 mActionDetails->setEnabled(false);
1420 } 1420 }
1421 1421
1422 mExtensionManager->setSelectionChanged(); 1422 mExtensionManager->setSelectionChanged();
1423 1423
1424 } 1424 }
1425 1425
1426#endif// DESKTOP_VERSION 1426#endif// DESKTOP_VERSION
1427 1427
1428} 1428}
1429 1429
1430 1430
1431void KABCore::extensionModified( const KABC::Addressee::List &list ) 1431void KABCore::extensionModified( const KABC::Addressee::List &list )
1432{ 1432{
1433 1433
1434 if ( list.count() != 0 ) { 1434 if ( list.count() != 0 ) {
1435 KABC::Addressee::List::ConstIterator it; 1435 KABC::Addressee::List::ConstIterator it;
1436 for ( it = list.begin(); it != list.end(); ++it ) 1436 for ( it = list.begin(); it != list.end(); ++it )
1437 mAddressBook->insertAddressee( *it ); 1437 mAddressBook->insertAddressee( *it );
1438 if ( list.count() > 1 ) 1438 if ( list.count() > 1 )
1439 setModified(); 1439 setModified();
1440 else 1440 else
1441 setModifiedWOrefresh(); 1441 setModifiedWOrefresh();
1442 } 1442 }
1443 if ( list.count() == 0 ) 1443 if ( list.count() == 0 )
1444 mViewManager->refreshView(); 1444 mViewManager->refreshView();
1445 else 1445 else
1446 mViewManager->refreshView( list[ 0 ].uid() ); 1446 mViewManager->refreshView( list[ 0 ].uid() );
1447 1447
1448 1448
1449 1449
1450} 1450}
1451 1451
1452QString KABCore::getNameByPhone( const QString &phone ) 1452QString KABCore::getNameByPhone( const QString &phone )
1453{ 1453{
1454#ifndef KAB_EMBEDDED 1454#ifndef KAB_EMBEDDED
1455 QRegExp r( "[/*/-/ ]" ); 1455 QRegExp r( "[/*/-/ ]" );
1456 QString localPhone( phone ); 1456 QString localPhone( phone );
1457 1457
1458 bool found = false; 1458 bool found = false;
1459 QString ownerName = ""; 1459 QString ownerName = "";
1460 KABC::AddressBook::Iterator iter; 1460 KABC::AddressBook::Iterator iter;
1461 KABC::PhoneNumber::List::Iterator phoneIter; 1461 KABC::PhoneNumber::List::Iterator phoneIter;
1462 KABC::PhoneNumber::List phoneList; 1462 KABC::PhoneNumber::List phoneList;
1463 for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) { 1463 for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) {
1464 phoneList = (*iter).phoneNumbers(); 1464 phoneList = (*iter).phoneNumbers();
1465 for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() ); 1465 for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() );
1466 ++phoneIter) { 1466 ++phoneIter) {
1467 // Get rid of separator chars so just the numbers are compared. 1467 // Get rid of separator chars so just the numbers are compared.
1468 if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) { 1468 if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) {
1469 ownerName = (*iter).formattedName(); 1469 ownerName = (*iter).formattedName();
1470 found = true; 1470 found = true;
1471 } 1471 }
1472 } 1472 }
1473 } 1473 }
1474 1474
1475 return ownerName; 1475 return ownerName;
1476#else //KAB_EMBEDDED 1476#else //KAB_EMBEDDED
1477 qDebug("KABCore::getNameByPhone finsih method"); 1477 qDebug("KABCore::getNameByPhone finsih method");
1478 return ""; 1478 return "";
1479#endif //KAB_EMBEDDED 1479#endif //KAB_EMBEDDED
1480 1480
1481} 1481}
1482 1482
1483void KABCore::openConfigDialog() 1483void KABCore::openConfigDialog()
1484{ 1484{
1485 KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true ); 1485 KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true );
1486 KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" ); 1486 KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" );
1487 ConfigureDialog->addModule(kabcfg ); 1487 ConfigureDialog->addModule(kabcfg );
1488 KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" ); 1488 KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" );
1489 ConfigureDialog->addModule(kdelibcfg ); 1489 ConfigureDialog->addModule(kdelibcfg );
1490 1490
1491 connect( ConfigureDialog, SIGNAL( applyClicked() ), 1491 connect( ConfigureDialog, SIGNAL( applyClicked() ),
1492 this, SLOT( configurationChanged() ) ); 1492 this, SLOT( configurationChanged() ) );
1493 connect( ConfigureDialog, SIGNAL( okClicked() ), 1493 connect( ConfigureDialog, SIGNAL( okClicked() ),
1494 this, SLOT( configurationChanged() ) ); 1494 this, SLOT( configurationChanged() ) );
1495 saveSettings(); 1495 saveSettings();
1496#ifndef DESKTOP_VERSION 1496#ifndef DESKTOP_VERSION
1497 ConfigureDialog->showMaximized(); 1497 ConfigureDialog->showMaximized();
1498#endif 1498#endif
1499 if ( ConfigureDialog->exec() ) 1499 if ( ConfigureDialog->exec() )
1500 KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") ); 1500 KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") );
1501 delete ConfigureDialog; 1501 delete ConfigureDialog;
1502} 1502}
1503 1503
1504void KABCore::openLDAPDialog() 1504void KABCore::openLDAPDialog()
1505{ 1505{
1506#ifndef KAB_EMBEDDED 1506#ifndef KAB_EMBEDDED
1507 if ( !mLdapSearchDialog ) { 1507 if ( !mLdapSearchDialog ) {
1508 mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this ); 1508 mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this );
1509 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager, 1509 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager,
1510 SLOT( refreshView() ) ); 1510 SLOT( refreshView() ) );
1511 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this, 1511 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this,
1512 SLOT( setModified() ) ); 1512 SLOT( setModified() ) );
1513 } else 1513 } else
1514 mLdapSearchDialog->restoreSettings(); 1514 mLdapSearchDialog->restoreSettings();
1515 1515
1516 if ( mLdapSearchDialog->isOK() ) 1516 if ( mLdapSearchDialog->isOK() )
1517 mLdapSearchDialog->exec(); 1517 mLdapSearchDialog->exec();
1518#else //KAB_EMBEDDED 1518#else //KAB_EMBEDDED
1519 qDebug("KABCore::openLDAPDialog() finsih method"); 1519 qDebug("KABCore::openLDAPDialog() finsih method");
1520#endif //KAB_EMBEDDED 1520#endif //KAB_EMBEDDED
1521} 1521}
1522 1522
1523void KABCore::print() 1523void KABCore::print()
1524{ 1524{
1525#ifndef KAB_EMBEDDED 1525#ifndef KAB_EMBEDDED
1526 KPrinter printer; 1526 KPrinter printer;
1527 if ( !printer.setup( this ) ) 1527 if ( !printer.setup( this ) )
1528 return; 1528 return;
1529 1529
1530 KABPrinting::PrintingWizard wizard( &printer, mAddressBook, 1530 KABPrinting::PrintingWizard wizard( &printer, mAddressBook,
1531 mViewManager->selectedUids(), this ); 1531 mViewManager->selectedUids(), this );
1532 1532
1533 wizard.exec(); 1533 wizard.exec();
1534#else //KAB_EMBEDDED 1534#else //KAB_EMBEDDED
1535 qDebug("KABCore::print() finsih method"); 1535 qDebug("KABCore::print() finsih method");
1536#endif //KAB_EMBEDDED 1536#endif //KAB_EMBEDDED
1537 1537
1538} 1538}
1539 1539
1540 1540
1541void KABCore::addGUIClient( KXMLGUIClient *client ) 1541void KABCore::addGUIClient( KXMLGUIClient *client )
1542{ 1542{
1543 if ( mGUIClient ) 1543 if ( mGUIClient )
1544 mGUIClient->insertChildClient( client ); 1544 mGUIClient->insertChildClient( client );
1545 else 1545 else
1546 KMessageBox::error( this, "no KXMLGUICLient"); 1546 KMessageBox::error( this, "no KXMLGUICLient");
1547} 1547}
1548 1548
1549 1549
1550void KABCore::configurationChanged() 1550void KABCore::configurationChanged()
1551{ 1551{
1552 mExtensionManager->reconfigure(); 1552 mExtensionManager->reconfigure();
1553} 1553}
1554 1554
1555void KABCore::addressBookChanged() 1555void KABCore::addressBookChanged()
1556{ 1556{
1557/*US 1557/*US
1558 QDictIterator<AddresseeEditorDialog> it( mEditorDict ); 1558 QDictIterator<AddresseeEditorDialog> it( mEditorDict );
1559 while ( it.current() ) { 1559 while ( it.current() ) {
1560 if ( it.current()->dirty() ) { 1560 if ( it.current()->dirty() ) {
1561 QString text = i18n( "Data has been changed externally. Unsaved " 1561 QString text = i18n( "Data has been changed externally. Unsaved "
1562 "changes will be lost." ); 1562 "changes will be lost." );
1563 KMessageBox::information( this, text ); 1563 KMessageBox::information( this, text );
1564 } 1564 }
1565 it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) ); 1565 it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) );
1566 ++it; 1566 ++it;
1567 } 1567 }
1568*/ 1568*/
1569 if (mEditorDialog) 1569 if (mEditorDialog)
1570 { 1570 {
1571 if (mEditorDialog->dirty()) 1571 if (mEditorDialog->dirty())
1572 { 1572 {
1573 QString text = i18n( "Data has been changed externally. Unsaved " 1573 QString text = i18n( "Data has been changed externally. Unsaved "
1574 "changes will be lost." ); 1574 "changes will be lost." );
1575 KMessageBox::information( this, text ); 1575 KMessageBox::information( this, text );
1576 } 1576 }
1577 QString currentuid = mEditorDialog->addressee().uid(); 1577 QString currentuid = mEditorDialog->addressee().uid();
1578 mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) ); 1578 mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) );
1579 } 1579 }
1580 mViewManager->refreshView(); 1580 mViewManager->refreshView();
1581// mDetails->refreshView(); 1581// mDetails->refreshView();
1582 1582
1583 1583
1584} 1584}
1585 1585
1586AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent, 1586AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent,
1587 const char *name ) 1587 const char *name )
1588{ 1588{
1589 1589
1590 if ( mEditorDialog == 0 ) { 1590 if ( mEditorDialog == 0 ) {
1591 mEditorDialog = new AddresseeEditorDialog( this, parent, 1591 mEditorDialog = new AddresseeEditorDialog( this, parent,
1592 name ? name : "editorDialog" ); 1592 name ? name : "editorDialog" );
1593 1593
1594 1594
1595 connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ), 1595 connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ),
1596 SLOT( contactModified( const KABC::Addressee& ) ) ); 1596 SLOT( contactModified( const KABC::Addressee& ) ) );
1597 //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ), 1597 //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ),
1598 // SLOT( slotEditorDestroyed( const QString& ) ) ; 1598 // SLOT( slotEditorDestroyed( const QString& ) ) ;
1599 } 1599 }
1600 1600
1601 return mEditorDialog; 1601 return mEditorDialog;
1602} 1602}
1603 1603
1604void KABCore::slotEditorDestroyed( const QString &uid ) 1604void KABCore::slotEditorDestroyed( const QString &uid )
1605{ 1605{
1606 //mEditorDict.remove( uid ); 1606 //mEditorDict.remove( uid );
1607} 1607}
1608 1608
1609void KABCore::initGUI() 1609void KABCore::initGUI()
1610{ 1610{
1611#ifndef KAB_EMBEDDED 1611#ifndef KAB_EMBEDDED
1612 QHBoxLayout *topLayout = new QHBoxLayout( this ); 1612 QHBoxLayout *topLayout = new QHBoxLayout( this );
1613 topLayout->setSpacing( KDialogBase::spacingHint() ); 1613 topLayout->setSpacing( KDialogBase::spacingHint() );
1614 1614
1615 mExtensionBarSplitter = new QSplitter( this ); 1615 mExtensionBarSplitter = new QSplitter( this );
1616 mExtensionBarSplitter->setOrientation( Qt::Vertical ); 1616 mExtensionBarSplitter->setOrientation( Qt::Vertical );
1617 1617
1618 mDetailsSplitter = new QSplitter( mExtensionBarSplitter ); 1618 mDetailsSplitter = new QSplitter( mExtensionBarSplitter );
1619 1619
1620 QVBox *viewSpace = new QVBox( mDetailsSplitter ); 1620 QVBox *viewSpace = new QVBox( mDetailsSplitter );
1621 mIncSearchWidget = new IncSearchWidget( viewSpace ); 1621 mIncSearchWidget = new IncSearchWidget( viewSpace );
1622 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), 1622 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ),
1623 SLOT( incrementalSearch( const QString& ) ) ); 1623 SLOT( incrementalSearch( const QString& ) ) );
1624 1624
1625 mViewManager = new ViewManager( this, viewSpace ); 1625 mViewManager = new ViewManager( this, viewSpace );
1626 viewSpace->setStretchFactor( mViewManager, 1 ); 1626 viewSpace->setStretchFactor( mViewManager, 1 );
1627 1627
1628 mDetails = new ViewContainer( mDetailsSplitter ); 1628 mDetails = new ViewContainer( mDetailsSplitter );
1629 1629
1630 mJumpButtonBar = new JumpButtonBar( this, this ); 1630 mJumpButtonBar = new JumpButtonBar( this, this );
1631 1631
1632 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); 1632 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter );
1633 1633
1634 topLayout->addWidget( mExtensionBarSplitter ); 1634 topLayout->addWidget( mExtensionBarSplitter );
1635 topLayout->setStretchFactor( mExtensionBarSplitter, 100 ); 1635 topLayout->setStretchFactor( mExtensionBarSplitter, 100 );
1636 topLayout->addWidget( mJumpButtonBar ); 1636 topLayout->addWidget( mJumpButtonBar );
1637 topLayout->setStretchFactor( mJumpButtonBar, 1 ); 1637 topLayout->setStretchFactor( mJumpButtonBar, 1 );
1638 1638
1639 mXXPortManager = new XXPortManager( this, this ); 1639 mXXPortManager = new XXPortManager( this, this );
1640 1640
1641#else //KAB_EMBEDDED 1641#else //KAB_EMBEDDED
1642 //US initialize viewMenu before settingup viewmanager. 1642 //US initialize viewMenu before settingup viewmanager.
1643 // Viewmanager needs this menu to plugin submenues. 1643 // Viewmanager needs this menu to plugin submenues.
1644 viewMenu = new QPopupMenu( this ); 1644 viewMenu = new QPopupMenu( this );
1645 settingsMenu = new QPopupMenu( this ); 1645 settingsMenu = new QPopupMenu( this );
1646 //filterMenu = new QPopupMenu( this ); 1646 //filterMenu = new QPopupMenu( this );
1647 ImportMenu = new QPopupMenu( this ); 1647 ImportMenu = new QPopupMenu( this );
1648 ExportMenu = new QPopupMenu( this ); 1648 ExportMenu = new QPopupMenu( this );
1649 syncMenu = new QPopupMenu( this ); 1649 syncMenu = new QPopupMenu( this );
1650 changeMenu= new QPopupMenu( this ); 1650 changeMenu= new QPopupMenu( this );
1651 1651
1652//US since we have no splitter for the embedded system, setup 1652//US since we have no splitter for the embedded system, setup
1653// a layout with two frames. One left and one right. 1653// a layout with two frames. One left and one right.
1654 1654
1655 QBoxLayout *topLayout; 1655 QBoxLayout *topLayout;
1656 1656
1657 // = new QHBoxLayout( this ); 1657 // = new QHBoxLayout( this );
1658// QBoxLayout *topLayout = (QBoxLayout*)layout(); 1658// QBoxLayout *topLayout = (QBoxLayout*)layout();
1659 1659
1660// QWidget *mainBox = new QWidget( this ); 1660// QWidget *mainBox = new QWidget( this );
1661// QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox); 1661// QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox);
1662 1662
1663#ifdef DESKTOP_VERSION 1663#ifdef DESKTOP_VERSION
1664 topLayout = new QHBoxLayout( this ); 1664 topLayout = new QHBoxLayout( this );
1665 1665
1666 1666
1667 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); 1667 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this);
1668 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); 1668 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right );
1669 1669
1670 topLayout->addWidget(mMiniSplitter ); 1670 topLayout->addWidget(mMiniSplitter );
1671 1671
1672 mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter ); 1672 mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter );
1673 mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); 1673 mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down );
1674 mViewManager = new ViewManager( this, mExtensionBarSplitter ); 1674 mViewManager = new ViewManager( this, mExtensionBarSplitter );
1675 mDetails = new ViewContainer( mMiniSplitter ); 1675 mDetails = new ViewContainer( mMiniSplitter );
1676 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); 1676 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter );
1677#else 1677#else
1678 if ( QApplication::desktop()->width() > 480 ) { 1678 if ( QApplication::desktop()->width() > 480 ) {
1679 topLayout = new QHBoxLayout( this ); 1679 topLayout = new QHBoxLayout( this );
1680 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); 1680 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this);
1681 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); 1681 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right );
1682 } else { 1682 } else {
1683 1683
1684 topLayout = new QHBoxLayout( this ); 1684 topLayout = new QHBoxLayout( this );
1685 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this); 1685 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this);
1686 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); 1686 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down );
1687 } 1687 }
1688 1688
1689 topLayout->addWidget(mMiniSplitter ); 1689 topLayout->addWidget(mMiniSplitter );
1690 mViewManager = new ViewManager( this, mMiniSplitter ); 1690 mViewManager = new ViewManager( this, mMiniSplitter );
1691 mDetails = new ViewContainer( mMiniSplitter ); 1691 mDetails = new ViewContainer( mMiniSplitter );
1692 1692
1693 1693
1694 mExtensionManager = new ExtensionManager( this, mMiniSplitter ); 1694 mExtensionManager = new ExtensionManager( this, mMiniSplitter );
1695#endif 1695#endif
1696 //eh->hide(); 1696 //eh->hide();
1697 // topLayout->addWidget(mExtensionManager ); 1697 // topLayout->addWidget(mExtensionManager );
1698 1698
1699 1699
1700/*US 1700/*US
1701#ifndef KAB_NOSPLITTER 1701#ifndef KAB_NOSPLITTER
1702 QHBoxLayout *topLayout = new QHBoxLayout( this ); 1702 QHBoxLayout *topLayout = new QHBoxLayout( this );
1703//US topLayout->setSpacing( KDialogBase::spacingHint() ); 1703//US topLayout->setSpacing( KDialogBase::spacingHint() );
1704 topLayout->setSpacing( 10 ); 1704 topLayout->setSpacing( 10 );
1705 1705
1706 mDetailsSplitter = new QSplitter( this ); 1706 mDetailsSplitter = new QSplitter( this );
1707 1707
1708 QVBox *viewSpace = new QVBox( mDetailsSplitter ); 1708 QVBox *viewSpace = new QVBox( mDetailsSplitter );
1709 1709
1710 mViewManager = new ViewManager( this, viewSpace ); 1710 mViewManager = new ViewManager( this, viewSpace );
1711 viewSpace->setStretchFactor( mViewManager, 1 ); 1711 viewSpace->setStretchFactor( mViewManager, 1 );
1712 1712
1713 mDetails = new ViewContainer( mDetailsSplitter ); 1713 mDetails = new ViewContainer( mDetailsSplitter );
1714 1714
1715 topLayout->addWidget( mDetailsSplitter ); 1715 topLayout->addWidget( mDetailsSplitter );
1716 topLayout->setStretchFactor( mDetailsSplitter, 100 ); 1716 topLayout->setStretchFactor( mDetailsSplitter, 100 );
1717#else //KAB_NOSPLITTER 1717#else //KAB_NOSPLITTER
1718 QHBoxLayout *topLayout = new QHBoxLayout( this ); 1718 QHBoxLayout *topLayout = new QHBoxLayout( this );
1719//US topLayout->setSpacing( KDialogBase::spacingHint() ); 1719//US topLayout->setSpacing( KDialogBase::spacingHint() );
1720 topLayout->setSpacing( 10 ); 1720 topLayout->setSpacing( 10 );
1721 1721
1722// mDetailsSplitter = new QSplitter( this ); 1722// mDetailsSplitter = new QSplitter( this );
1723 1723
1724 QVBox *viewSpace = new QVBox( this ); 1724 QVBox *viewSpace = new QVBox( this );
1725 1725
1726 mViewManager = new ViewManager( this, viewSpace ); 1726 mViewManager = new ViewManager( this, viewSpace );
1727 viewSpace->setStretchFactor( mViewManager, 1 ); 1727 viewSpace->setStretchFactor( mViewManager, 1 );
1728 1728
1729 mDetails = new ViewContainer( this ); 1729 mDetails = new ViewContainer( this );
1730 1730
1731 topLayout->addWidget( viewSpace ); 1731 topLayout->addWidget( viewSpace );
1732// topLayout->setStretchFactor( mDetailsSplitter, 100 ); 1732// topLayout->setStretchFactor( mDetailsSplitter, 100 );
1733 topLayout->addWidget( mDetails ); 1733 topLayout->addWidget( mDetails );
1734#endif //KAB_NOSPLITTER 1734#endif //KAB_NOSPLITTER
1735*/ 1735*/
1736 1736
1737 syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); 1737 syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu);
1738 syncManager->setBlockSave(false); 1738 syncManager->setBlockSave(false);
1739 1739
1740 connect(syncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); 1740 connect(syncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) );
1741 connect(syncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); 1741 connect(syncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) );
1742 syncManager->setDefaultFileName( sentSyncFile()); 1742 syncManager->setDefaultFileName( sentSyncFile());
1743 //connect(syncManager , SIGNAL( ), this, SLOT( ) ); 1743 //connect(syncManager , SIGNAL( ), this, SLOT( ) );
1744 1744
1745#endif //KAB_EMBEDDED 1745#endif //KAB_EMBEDDED
1746 initActions(); 1746 initActions();
1747 1747
1748#ifdef KAB_EMBEDDED 1748#ifdef KAB_EMBEDDED
1749 addActionsManually(); 1749 addActionsManually();
1750 //US make sure the export and import menues are initialized before creating the xxPortManager. 1750 //US make sure the export and import menues are initialized before creating the xxPortManager.
1751 mXXPortManager = new XXPortManager( this, this ); 1751 mXXPortManager = new XXPortManager( this, this );
1752 1752
1753 // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() ); 1753 // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() );
1754 //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget); 1754 //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget);
1755 // mActionQuit->plug ( mMainWindow->toolBar()); 1755 // mActionQuit->plug ( mMainWindow->toolBar());
1756 //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() ); 1756 //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() );
1757 //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget); 1757 //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget);
1758 // mIncSearchWidget->hide(); 1758 // mIncSearchWidget->hide();
1759 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), 1759 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ),
1760 SLOT( incrementalSearch( const QString& ) ) ); 1760 SLOT( incrementalSearch( const QString& ) ) );
1761 connect( mIncSearchWidget, SIGNAL( scrollUP() ),mViewManager, SLOT( scrollUP() ) ); 1761 connect( mIncSearchWidget, SIGNAL( scrollUP() ),mViewManager, SLOT( scrollUP() ) );
1762 connect( mIncSearchWidget, SIGNAL( scrollDOWN() ),mViewManager, SLOT( scrollDOWN() ) ); 1762 connect( mIncSearchWidget, SIGNAL( scrollDOWN() ),mViewManager, SLOT( scrollDOWN() ) );
1763 1763
1764 mJumpButtonBar = new JumpButtonBar( this, this ); 1764 mJumpButtonBar = new JumpButtonBar( this, this );
1765 1765
1766 topLayout->addWidget( mJumpButtonBar ); 1766 topLayout->addWidget( mJumpButtonBar );
1767//US topLayout->setStretchFactor( mJumpButtonBar, 10 ); 1767//US topLayout->setStretchFactor( mJumpButtonBar, 10 );
1768 1768
1769// mMainWindow->getIconToolBar()->raise(); 1769// mMainWindow->getIconToolBar()->raise();
1770 1770
1771#endif //KAB_EMBEDDED 1771#endif //KAB_EMBEDDED
1772 1772
1773} 1773}
1774void KABCore::initActions() 1774void KABCore::initActions()
1775{ 1775{
1776//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); 1776//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart);
1777 1777
1778#ifndef KAB_EMBEDDED 1778#ifndef KAB_EMBEDDED
1779 connect( QApplication::clipboard(), SIGNAL( dataChanged() ), 1779 connect( QApplication::clipboard(), SIGNAL( dataChanged() ),
1780 SLOT( clipboardDataChanged() ) ); 1780 SLOT( clipboardDataChanged() ) );
1781#endif //KAB_EMBEDDED 1781#endif //KAB_EMBEDDED
1782 1782
1783 // file menu 1783 // file menu
1784 if ( mIsPart ) { 1784 if ( mIsPart ) {
1785 mActionMail = new KAction( i18n( "&Mail" ), "mail_generic", 0, this, 1785 mActionMail = new KAction( i18n( "&Mail" ), "mail_generic", 0, this,
1786 SLOT( sendMail() ), actionCollection(), 1786 SLOT( sendMail() ), actionCollection(),
1787 "kaddressbook_mail" ); 1787 "kaddressbook_mail" );
1788 mActionPrint = new KAction( i18n( "&Print" ), "fileprint", CTRL + Key_P, this, 1788 mActionPrint = new KAction( i18n( "&Print" ), "fileprint", CTRL + Key_P, this,
1789 SLOT( print() ), actionCollection(), "kaddressbook_print" ); 1789 SLOT( print() ), actionCollection(), "kaddressbook_print" );
1790 1790
1791 } else { 1791 } else {
1792 mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() ); 1792 mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() );
1793 mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() ); 1793 mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() );
1794 } 1794 }
1795 1795
1796 1796
1797 mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this, 1797 mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this,
1798 SLOT( save() ), actionCollection(), "file_sync" ); 1798 SLOT( save() ), actionCollection(), "file_sync" );
1799 1799
1800 mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this, 1800 mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this,
1801 SLOT( newContact() ), actionCollection(), "file_new_contact" ); 1801 SLOT( newContact() ), actionCollection(), "file_new_contact" );
1802 1802
1803 mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0, 1803 mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0,
1804 this, SLOT( mailVCard() ), 1804 this, SLOT( mailVCard() ),
1805 actionCollection(), "file_mail_vcard"); 1805 actionCollection(), "file_mail_vcard");
1806 1806
1807 mActionExport2phone = new KAction( i18n( "Export to phone" ), "ex2phone", 0, this, 1807 mActionExport2phone = new KAction( i18n( "Export to phone" ), "ex2phone", 0, this,
1808 SLOT( export2phone() ), actionCollection(), 1808 SLOT( export2phone() ), actionCollection(),
1809 "kaddressbook_ex2phone" ); 1809 "kaddressbook_ex2phone" );
1810 1810
1811 mActionBeamVCard = 0; 1811 mActionBeamVCard = 0;
1812 mActionBeam = 0; 1812 mActionBeam = 0;
1813 1813
1814#ifndef DESKTOP_VERSION 1814#ifndef DESKTOP_VERSION
1815 if ( Ir::supported() ) { 1815 if ( Ir::supported() ) {
1816 mActionBeamVCard = new KAction( i18n( "Beam selected v&Card(s)" ), "beam", 0, this, 1816 mActionBeamVCard = new KAction( i18n( "Beam selected v&Card(s)" ), "beam", 0, this,
1817 SLOT( beamVCard() ), actionCollection(), 1817 SLOT( beamVCard() ), actionCollection(),
1818 "kaddressbook_beam_vcard" ); 1818 "kaddressbook_beam_vcard" );
1819 1819
1820 mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this, 1820 mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this,
1821 SLOT( beamMySelf() ), actionCollection(), 1821 SLOT( beamMySelf() ), actionCollection(),
1822 "kaddressbook_beam_myself" ); 1822 "kaddressbook_beam_myself" );
1823 } 1823 }
1824#endif 1824#endif
1825 1825
1826 mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0, 1826 mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0,
1827 this, SLOT( editContact2() ), 1827 this, SLOT( editContact2() ),
1828 actionCollection(), "file_properties" ); 1828 actionCollection(), "file_properties" );
1829 1829
1830#ifdef KAB_EMBEDDED 1830#ifdef KAB_EMBEDDED
1831 // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() ); 1831 // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() );
1832 mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0, 1832 mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0,
1833 mMainWindow, SLOT( exit() ), 1833 mMainWindow, SLOT( exit() ),
1834 actionCollection(), "quit" ); 1834 actionCollection(), "quit" );
1835#endif //KAB_EMBEDDED 1835#endif //KAB_EMBEDDED
1836 1836
1837 // edit menu 1837 // edit menu
1838 if ( mIsPart ) { 1838 if ( mIsPart ) {
1839 mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this, 1839 mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this,
1840 SLOT( copyContacts() ), actionCollection(), 1840 SLOT( copyContacts() ), actionCollection(),
1841 "kaddressbook_copy" ); 1841 "kaddressbook_copy" );
1842 mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this, 1842 mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this,
1843 SLOT( cutContacts() ), actionCollection(), 1843 SLOT( cutContacts() ), actionCollection(),
1844 "kaddressbook_cut" ); 1844 "kaddressbook_cut" );
1845 mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this, 1845 mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this,
1846 SLOT( pasteContacts() ), actionCollection(), 1846 SLOT( pasteContacts() ), actionCollection(),
1847 "kaddressbook_paste" ); 1847 "kaddressbook_paste" );
1848 mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this, 1848 mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this,
1849 SLOT( selectAllContacts() ), actionCollection(), 1849 SLOT( selectAllContacts() ), actionCollection(),
1850 "kaddressbook_select_all" ); 1850 "kaddressbook_select_all" );
1851 mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this, 1851 mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this,
1852 SLOT( undo() ), actionCollection(), 1852 SLOT( undo() ), actionCollection(),
1853 "kaddressbook_undo" ); 1853 "kaddressbook_undo" );
1854 mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z, 1854 mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z,
1855 this, SLOT( redo() ), actionCollection(), 1855 this, SLOT( redo() ), actionCollection(),
1856 "kaddressbook_redo" ); 1856 "kaddressbook_redo" );
1857 } else { 1857 } else {
1858 mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() ); 1858 mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() );
1859 mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() ); 1859 mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() );
1860 mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() ); 1860 mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() );
1861 mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() ); 1861 mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() );
1862 mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() ); 1862 mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() );
1863 mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() ); 1863 mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() );
1864 } 1864 }
1865 1865
1866 mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete", 1866 mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete",
1867 Key_Delete, this, SLOT( deleteContacts() ), 1867 Key_Delete, this, SLOT( deleteContacts() ),
1868 actionCollection(), "edit_delete" ); 1868 actionCollection(), "edit_delete" );
1869 1869
1870 mActionUndo->setEnabled( false ); 1870 mActionUndo->setEnabled( false );
1871 mActionRedo->setEnabled( false ); 1871 mActionRedo->setEnabled( false );
1872 1872
1873 // settings menu 1873 // settings menu
1874#ifdef KAB_EMBEDDED 1874#ifdef KAB_EMBEDDED
1875//US special menuentry to configure the addressbook resources. On KDE 1875//US special menuentry to configure the addressbook resources. On KDE
1876// you do that through the control center !!! 1876// you do that through the control center !!!
1877 mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this, 1877 mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this,
1878 SLOT( configureResources() ), actionCollection(), 1878 SLOT( configureResources() ), actionCollection(),
1879 "kaddressbook_configure_resources" ); 1879 "kaddressbook_configure_resources" );
1880#endif //KAB_EMBEDDED 1880#endif //KAB_EMBEDDED
1881 1881
1882 if ( mIsPart ) { 1882 if ( mIsPart ) {
1883 mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this, 1883 mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this,
1884 SLOT( openConfigDialog() ), actionCollection(), 1884 SLOT( openConfigDialog() ), actionCollection(),
1885 "kaddressbook_configure" ); 1885 "kaddressbook_configure" );
1886 1886
1887 //US not implemented yet 1887 //US not implemented yet
1888 //mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0, 1888 //mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0,
1889 // this, SLOT( configureKeyBindings() ), actionCollection(), 1889 // this, SLOT( configureKeyBindings() ), actionCollection(),
1890 // "kaddressbook_configure_shortcuts" ); 1890 // "kaddressbook_configure_shortcuts" );
1891#ifdef KAB_EMBEDDED 1891#ifdef KAB_EMBEDDED
1892 mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() ); 1892 mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() );
1893 mActionConfigureToolbars->setEnabled( false ); 1893 mActionConfigureToolbars->setEnabled( false );
1894#endif //KAB_EMBEDDED 1894#endif //KAB_EMBEDDED
1895 1895
1896 } else { 1896 } else {
1897 mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() ); 1897 mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() );
1898 1898
1899 //US not implemented yet 1899 //US not implemented yet
1900 //mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() ); 1900 //mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() );
1901 } 1901 }
1902 1902
1903 mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0, 1903 mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0,
1904 actionCollection(), "options_show_jump_bar" ); 1904 actionCollection(), "options_show_jump_bar" );
1905 connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBarVisible( bool ) ) ); 1905 connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBarVisible( bool ) ) );
1906 1906
1907 mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0, 1907 mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0,
1908 actionCollection(), "options_show_details" ); 1908 actionCollection(), "options_show_details" );
1909 connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) ); 1909 connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) );
1910 1910
1911 1911
1912 mActionBR = new KToggleAction( i18n( "Beam receive enabled" ), "beam", 0, this, 1912 mActionBR = new KToggleAction( i18n( "Beam receive enabled" ), "beam", 0, this,
1913 SLOT( toggleBeamReceive() ), actionCollection(), 1913 SLOT( toggleBeamReceive() ), actionCollection(),
1914 "kaddressbook_beam_rec" ); 1914 "kaddressbook_beam_rec" );
1915 1915
1916 1916
1917 // misc 1917 // misc
1918 // only enable LDAP lookup if we can handle the protocol 1918 // only enable LDAP lookup if we can handle the protocol
1919#ifndef KAB_EMBEDDED 1919#ifndef KAB_EMBEDDED
1920 if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) { 1920 if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) {
1921 new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0, 1921 new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0,
1922 this, SLOT( openLDAPDialog() ), actionCollection(), 1922 this, SLOT( openLDAPDialog() ), actionCollection(),
1923 "ldap_lookup" ); 1923 "ldap_lookup" );
1924 } 1924 }
1925#else //KAB_EMBEDDED 1925#else //KAB_EMBEDDED
1926 //qDebug("KABCore::initActions() LDAP has to be implemented"); 1926 //qDebug("KABCore::initActions() LDAP has to be implemented");
1927#endif //KAB_EMBEDDED 1927#endif //KAB_EMBEDDED
1928 1928
1929 1929
1930 mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this, 1930 mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this,
1931 SLOT( setWhoAmI() ), actionCollection(), 1931 SLOT( setWhoAmI() ), actionCollection(),
1932 "set_personal" ); 1932 "set_personal" );
1933 1933
1934 1934
1935 mActionCategories = new KAction( i18n( "Set Categories" ), 0, this, 1935 mActionCategories = new KAction( i18n( "Set Categories" ), 0, this,
1936 SLOT( setCategories() ), actionCollection(), 1936 SLOT( setCategories() ), actionCollection(),
1937 "edit_set_categories" ); 1937 "edit_set_categories" );
1938 mActionEditCategories = new KAction( i18n( "Edit Categories" ), 0, this, 1938 mActionEditCategories = new KAction( i18n( "Edit Categories" ), 0, this,
1939 SLOT( editCategories() ), actionCollection(), 1939 SLOT( editCategories() ), actionCollection(),
1940 "edit__categories" ); 1940 "edit__categories" );
1941 1941
1942 mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this, 1942 mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this,
1943 SLOT( removeVoice() ), actionCollection(), 1943 SLOT( removeVoice() ), actionCollection(),
1944 "remove_voice" ); 1944 "remove_voice" );
1945 1945
1946 mActionManageCategories= new KAction( i18n( "Manage new categories..." ), 0, this, 1946 mActionManageCategories= new KAction( i18n( "Manage new categories..." ), 0, this,
1947 SLOT( manageCategories() ), actionCollection(), 1947 SLOT( manageCategories() ), actionCollection(),
1948 "remove_voice" ); 1948 "remove_voice" );
1949 1949
1950 1950
1951 mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this, 1951 mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this,
1952 SLOT( importFromOL() ), actionCollection(), 1952 SLOT( importFromOL() ), actionCollection(),
1953 "import_OL" ); 1953 "import_OL" );
1954#ifdef KAB_EMBEDDED 1954#ifdef KAB_EMBEDDED
1955 mActionLicence = new KAction( i18n( "Licence" ), 0, 1955 mActionLicence = new KAction( i18n( "Licence" ), 0,
1956 this, SLOT( showLicence() ), actionCollection(), 1956 this, SLOT( showLicence() ), actionCollection(),
1957 "licence_about_data" ); 1957 "licence_about_data" );
1958 mActionFaq = new KAction( i18n( "Faq" ), 0, 1958 mActionFaq = new KAction( i18n( "Faq" ), 0,
1959 this, SLOT( faq() ), actionCollection(), 1959 this, SLOT( faq() ), actionCollection(),
1960 "faq_about_data" ); 1960 "faq_about_data" );
1961 mActionWN = new KAction( i18n( "What's New?" ), 0, 1961 mActionWN = new KAction( i18n( "What's New?" ), 0,
1962 this, SLOT( whatsnew() ), actionCollection(), 1962 this, SLOT( whatsnew() ), actionCollection(),
1963 "wn" ); 1963 "wn" );
1964 mActionSyncHowto = new KAction( i18n( "Sync HowTo" ), 0, 1964 mActionSyncHowto = new KAction( i18n( "Sync HowTo" ), 0,
1965 this, SLOT( synchowto() ), actionCollection(), 1965 this, SLOT( synchowto() ), actionCollection(),
1966 "sync" ); 1966 "sync" );
1967 mActionKdeSyncHowto = new KAction( i18n( "Kde Sync HowTo" ), 0, 1967 mActionKdeSyncHowto = new KAction( i18n( "Kde Sync HowTo" ), 0,
1968 this, SLOT( kdesynchowto() ), actionCollection(), 1968 this, SLOT( kdesynchowto() ), actionCollection(),
1969 "kdesync" ); 1969 "kdesync" );
1970 mActionMultiSyncHowto = new KAction( i18n( "Multi Sync HowTo" ), 0, 1970 mActionMultiSyncHowto = new KAction( i18n( "Multi Sync HowTo" ), 0,
1971 this, SLOT( multisynchowto() ), actionCollection(), 1971 this, SLOT( multisynchowto() ), actionCollection(),
1972 "multisync" ); 1972 "multisync" );
1973 1973
1974 mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0, 1974 mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0,
1975 this, SLOT( createAboutData() ), actionCollection(), 1975 this, SLOT( createAboutData() ), actionCollection(),
1976 "kaddressbook_about_data" ); 1976 "kaddressbook_about_data" );
1977#endif //KAB_EMBEDDED 1977#endif //KAB_EMBEDDED
1978 1978
1979 clipboardDataChanged(); 1979 clipboardDataChanged();
1980 connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); 1980 connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) );
1981 connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); 1981 connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) );
1982} 1982}
1983 1983
1984//US we need this function, to plug all actions into the correct menues. 1984//US we need this function, to plug all actions into the correct menues.
1985// KDE uses a XML format to plug the actions, but we work her without this overhead. 1985// KDE uses a XML format to plug the actions, but we work her without this overhead.
1986void KABCore::addActionsManually() 1986void KABCore::addActionsManually()
1987{ 1987{
1988//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); 1988//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart);
1989 1989
1990#ifdef KAB_EMBEDDED 1990#ifdef KAB_EMBEDDED
1991 QPopupMenu *fileMenu = new QPopupMenu( this ); 1991 QPopupMenu *fileMenu = new QPopupMenu( this );
1992 QPopupMenu *editMenu = new QPopupMenu( this ); 1992 QPopupMenu *editMenu = new QPopupMenu( this );
1993 QPopupMenu *helpMenu = new QPopupMenu( this ); 1993 QPopupMenu *helpMenu = new QPopupMenu( this );
1994 1994
1995 KToolBar* tb = mMainWindow->toolBar(); 1995 KToolBar* tb = mMainWindow->toolBar();
1996 1996
1997#ifndef DESKTOP_VERSION 1997#ifndef DESKTOP_VERSION
1998 if ( KABPrefs::instance()->mFullMenuBarVisible ) { 1998 if ( KABPrefs::instance()->mFullMenuBarVisible ) {
1999#endif 1999#endif
2000 QMenuBar* mb = mMainWindow->menuBar(); 2000 QMenuBar* mb = mMainWindow->menuBar();
2001 2001
2002 //US setup menubar. 2002 //US setup menubar.
2003 //Disable the following block if you do not want to have a menubar. 2003 //Disable the following block if you do not want to have a menubar.
2004 mb->insertItem( i18n("&File"), fileMenu ); 2004 mb->insertItem( i18n("&File"), fileMenu );
2005 mb->insertItem( i18n("&Edit"), editMenu ); 2005 mb->insertItem( i18n("&Edit"), editMenu );
2006 mb->insertItem( i18n("&View"), viewMenu ); 2006 mb->insertItem( i18n("&View"), viewMenu );
2007 mb->insertItem( i18n("&Settings"), settingsMenu ); 2007 mb->insertItem( i18n("&Settings"), settingsMenu );
2008 mb->insertItem( i18n("Synchronize"), syncMenu ); 2008 mb->insertItem( i18n("Synchronize"), syncMenu );
2009 mb->insertItem( i18n("&Change selected"), changeMenu ); 2009 //mb->insertItem( i18n("&Change"), changeMenu );
2010 mb->insertItem( i18n("&Help"), helpMenu ); 2010 mb->insertItem( i18n("&Help"), helpMenu );
2011 mIncSearchWidget = new IncSearchWidget( tb ); 2011 mIncSearchWidget = new IncSearchWidget( tb );
2012 // tb->insertWidget(-1, 0, mIncSearchWidget); 2012 // tb->insertWidget(-1, 0, mIncSearchWidget);
2013#ifndef DESKTOP_VERSION 2013#ifndef DESKTOP_VERSION
2014 } else { 2014 } else {
2015 //US setup toolbar 2015 //US setup toolbar
2016 QPEMenuBar *menuBarTB = new QPEMenuBar( tb ); 2016 QPEMenuBar *menuBarTB = new QPEMenuBar( tb );
2017 QPopupMenu *popupBarTB = new QPopupMenu( this ); 2017 QPopupMenu *popupBarTB = new QPopupMenu( this );
2018 menuBarTB->insertItem( "ME", popupBarTB); 2018 menuBarTB->insertItem( "ME", popupBarTB);
2019 tb->insertWidget(-1, 0, menuBarTB); 2019 tb->insertWidget(-1, 0, menuBarTB);
2020 mIncSearchWidget = new IncSearchWidget( tb ); 2020 mIncSearchWidget = new IncSearchWidget( tb );
2021 2021
2022 tb->enableMoving(false); 2022 tb->enableMoving(false);
2023 popupBarTB->insertItem( i18n("&File"), fileMenu ); 2023 popupBarTB->insertItem( i18n("&File"), fileMenu );
2024 popupBarTB->insertItem( i18n("&Edit"), editMenu ); 2024 popupBarTB->insertItem( i18n("&Edit"), editMenu );
2025 popupBarTB->insertItem( i18n("&View"), viewMenu ); 2025 popupBarTB->insertItem( i18n("&View"), viewMenu );
2026 popupBarTB->insertItem( i18n("&Settings"), settingsMenu ); 2026 popupBarTB->insertItem( i18n("&Settings"), settingsMenu );
2027 popupBarTB->insertItem( i18n("Synchronize"), syncMenu ); 2027 popupBarTB->insertItem( i18n("Synchronize"), syncMenu );
2028 mViewManager->getFilterAction()->plug ( popupBarTB); 2028 mViewManager->getFilterAction()->plug ( popupBarTB);
2029 popupBarTB->insertItem( i18n("&Change selected"), changeMenu ); 2029 //popupBarTB->insertItem( i18n("&Change selected"), changeMenu );
2030 popupBarTB->insertItem( i18n("&Help"), helpMenu ); 2030 popupBarTB->insertItem( i18n("&Help"), helpMenu );
2031 if (QApplication::desktop()->width() > 320 ) { 2031 if (QApplication::desktop()->width() > 320 ) {
2032 // mViewManager->getFilterAction()->plug ( tb); 2032 // mViewManager->getFilterAction()->plug ( tb);
2033 } 2033 }
2034 } 2034 }
2035#endif 2035#endif
2036 // mActionQuit->plug ( mMainWindow->toolBar()); 2036 // mActionQuit->plug ( mMainWindow->toolBar());
2037 2037
2038 2038
2039 2039
2040 //US Now connect the actions with the menue entries. 2040 //US Now connect the actions with the menue entries.
2041 mActionPrint->plug( fileMenu ); 2041 mActionPrint->plug( fileMenu );
2042 mActionMail->plug( fileMenu ); 2042 mActionMail->plug( fileMenu );
2043 fileMenu->insertSeparator(); 2043 fileMenu->insertSeparator();
2044 2044
2045 mActionNewContact->plug( fileMenu ); 2045 mActionNewContact->plug( fileMenu );
2046 mActionNewContact->plug( tb ); 2046 mActionNewContact->plug( tb );
2047 2047
2048 mActionEditAddressee->plug( fileMenu ); 2048 mActionEditAddressee->plug( fileMenu );
2049 // if ((KGlobal::getDesktopSize() > KGlobal::Small ) || 2049 // if ((KGlobal::getDesktopSize() > KGlobal::Small ) ||
2050 // (!KABPrefs::instance()->mMultipleViewsAtOnce )) 2050 // (!KABPrefs::instance()->mMultipleViewsAtOnce ))
2051 mActionEditAddressee->plug( tb ); 2051 mActionEditAddressee->plug( tb );
2052 2052
2053 fileMenu->insertSeparator(); 2053 fileMenu->insertSeparator();
2054 mActionSave->plug( fileMenu ); 2054 mActionSave->plug( fileMenu );
2055 fileMenu->insertItem( "&Import", ImportMenu ); 2055 fileMenu->insertItem( "&Import", ImportMenu );
2056 fileMenu->insertItem( "&Export", ExportMenu ); 2056 fileMenu->insertItem( "&Export", ExportMenu );
2057 fileMenu->insertItem( i18n("&Change"), changeMenu );
2057 fileMenu->insertSeparator(); 2058 fileMenu->insertSeparator();
2058 mActionMailVCard->plug( fileMenu ); 2059 mActionMailVCard->plug( fileMenu );
2059#ifndef DESKTOP_VERSION 2060#ifndef DESKTOP_VERSION
2060 if ( Ir::supported() ) mActionBeamVCard->plug( fileMenu ); 2061 if ( Ir::supported() ) mActionBeamVCard->plug( fileMenu );
2061 if ( Ir::supported() ) mActionBeam->plug(fileMenu ); 2062 if ( Ir::supported() ) mActionBeam->plug(fileMenu );
2062#endif 2063#endif
2063 fileMenu->insertSeparator(); 2064 fileMenu->insertSeparator();
2064 mActionQuit->plug( fileMenu ); 2065 mActionQuit->plug( fileMenu );
2065#ifdef _WIN32_ 2066#ifdef _WIN32_
2066 mActionImportOL->plug( ImportMenu ); 2067 mActionImportOL->plug( ImportMenu );
2067#endif 2068#endif
2068 // edit menu 2069 // edit menu
2069 mActionUndo->plug( editMenu ); 2070 mActionUndo->plug( editMenu );
2070 mActionRedo->plug( editMenu ); 2071 mActionRedo->plug( editMenu );
2071 editMenu->insertSeparator(); 2072 editMenu->insertSeparator();
2072 mActionCut->plug( editMenu ); 2073 mActionCut->plug( editMenu );
2073 mActionCopy->plug( editMenu ); 2074 mActionCopy->plug( editMenu );
2074 mActionPaste->plug( editMenu ); 2075 mActionPaste->plug( editMenu );
2075 mActionDelete->plug( editMenu ); 2076 mActionDelete->plug( editMenu );
2076 editMenu->insertSeparator(); 2077 editMenu->insertSeparator();
2077 mActionSelectAll->plug( editMenu ); 2078 mActionSelectAll->plug( editMenu );
2078 2079
2079 mActionRemoveVoice->plug( changeMenu ); 2080 mActionRemoveVoice->plug( changeMenu );
2080 // settings menu 2081 // settings menu
2081//US special menuentry to configure the addressbook resources. On KDE 2082//US special menuentry to configure the addressbook resources. On KDE
2082// you do that through the control center !!! 2083// you do that through the control center !!!
2083 mActionConfigResources->plug( settingsMenu ); 2084 mActionConfigResources->plug( settingsMenu );
2084 settingsMenu->insertSeparator(); 2085 settingsMenu->insertSeparator();
2085 2086
2086 mActionConfigKAddressbook->plug( settingsMenu ); 2087 mActionConfigKAddressbook->plug( settingsMenu );
2087 2088
2088 if ( mIsPart ) { 2089 if ( mIsPart ) {
2089 //US not implemented yet 2090 //US not implemented yet
2090 //mActionConfigShortcuts->plug( settingsMenu ); 2091 //mActionConfigShortcuts->plug( settingsMenu );
2091 //mActionConfigureToolbars->plug( settingsMenu ); 2092 //mActionConfigureToolbars->plug( settingsMenu );
2092 2093
2093 } else { 2094 } else {
2094 //US not implemented yet 2095 //US not implemented yet
2095 //mActionKeyBindings->plug( settingsMenu ); 2096 //mActionKeyBindings->plug( settingsMenu );
2096 } 2097 }
2097 2098
2098 settingsMenu->insertSeparator(); 2099 settingsMenu->insertSeparator();
2099 2100
2100 mActionJumpBar->plug( settingsMenu ); 2101 mActionJumpBar->plug( settingsMenu );
2101 mActionDetails->plug( settingsMenu ); 2102 mActionDetails->plug( settingsMenu );
2102 //if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop ) 2103 //if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop )
2103 mActionDetails->plug( tb ); 2104 mActionDetails->plug( tb );
2104 settingsMenu->insertSeparator(); 2105 settingsMenu->insertSeparator();
2105 mActionBR->plug(settingsMenu ); 2106 mActionBR->plug(settingsMenu );
2106 settingsMenu->insertSeparator(); 2107 settingsMenu->insertSeparator();
2107 2108
2108 mActionWhoAmI->plug( settingsMenu ); 2109 mActionWhoAmI->plug( settingsMenu );
2109 mActionEditCategories->plug( settingsMenu ); 2110 mActionEditCategories->plug( settingsMenu );
2110 mActionCategories->plug( settingsMenu ); 2111 mActionCategories->plug( settingsMenu );
2111 mActionManageCategories->plug( settingsMenu ); 2112 mActionManageCategories->plug( settingsMenu );
2112 2113
2113 2114
2114 mActionWN->plug( helpMenu ); 2115 mActionWN->plug( helpMenu );
2115 mActionSyncHowto->plug( helpMenu ); 2116 mActionSyncHowto->plug( helpMenu );
2116 mActionKdeSyncHowto->plug( helpMenu ); 2117 mActionKdeSyncHowto->plug( helpMenu );
2117 mActionMultiSyncHowto->plug( helpMenu ); 2118 mActionMultiSyncHowto->plug( helpMenu );
2118 mActionFaq->plug( helpMenu ); 2119 mActionFaq->plug( helpMenu );
2119 mActionLicence->plug( helpMenu ); 2120 mActionLicence->plug( helpMenu );
2120 mActionAboutKAddressbook->plug( helpMenu ); 2121 mActionAboutKAddressbook->plug( helpMenu );
2121 2122
2122 if (KGlobal::getDesktopSize() > KGlobal::Small ) { 2123 if (KGlobal::getDesktopSize() > KGlobal::Small ) {
2123 2124
2124 mActionSave->plug( tb ); 2125 mActionSave->plug( tb );
2125 mViewManager->getFilterAction()->plug ( tb); 2126 mViewManager->getFilterAction()->plug ( tb);
2126 if (KGlobal::getDesktopSize() == KGlobal::Desktop ) { 2127 if (KGlobal::getDesktopSize() == KGlobal::Desktop ) {
2127 mActionUndo->plug( tb ); 2128 mActionUndo->plug( tb );
2128 mActionDelete->plug( tb ); 2129 mActionDelete->plug( tb );
2129 mActionRedo->plug( tb ); 2130 mActionRedo->plug( tb );
2130 } 2131 }
2131 } else { 2132 } else {
2132 mActionSave->plug( tb ); 2133 mActionSave->plug( tb );
2133 tb->enableMoving(false); 2134 tb->enableMoving(false);
2134 } 2135 }
2135 //mActionQuit->plug ( tb ); 2136 //mActionQuit->plug ( tb );
2136 // tb->insertWidget(-1, 0, mIncSearchWidget, 6); 2137 // tb->insertWidget(-1, 0, mIncSearchWidget, 6);
2137 2138
2138 //US link the searchwidget first to this. 2139 //US link the searchwidget first to this.
2139 // The real linkage to the toolbar happens later. 2140 // The real linkage to the toolbar happens later.
2140//US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE); 2141//US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE);
2141//US tb->insertItem( mIncSearchWidget ); 2142//US tb->insertItem( mIncSearchWidget );
2142/*US 2143/*US
2143 mIncSearchWidget = new IncSearchWidget( tb ); 2144 mIncSearchWidget = new IncSearchWidget( tb );
2144 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), 2145 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ),
2145 SLOT( incrementalSearch( const QString& ) ) ); 2146 SLOT( incrementalSearch( const QString& ) ) );
2146 2147
2147 mJumpButtonBar = new JumpButtonBar( this, this ); 2148 mJumpButtonBar = new JumpButtonBar( this, this );
2148 2149
2149//US topLayout->addWidget( mJumpButtonBar ); 2150//US topLayout->addWidget( mJumpButtonBar );
2150 this->layout()->add( mJumpButtonBar ); 2151 this->layout()->add( mJumpButtonBar );
2151*/ 2152*/
2152 2153
2153#endif //KAB_EMBEDDED 2154#endif //KAB_EMBEDDED
2154 2155
2155 mActionExport2phone->plug( ExportMenu ); 2156 mActionExport2phone->plug( ExportMenu );
2156 connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) ); 2157 connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) );
2157 syncManager->fillSyncMenu(); 2158 syncManager->fillSyncMenu();
2158 2159
2159} 2160}
2160void KABCore::showLicence() 2161void KABCore::showLicence()
2161{ 2162{
2162 KApplication::showLicence(); 2163 KApplication::showLicence();
2163} 2164}
2164 2165
2165void KABCore::manageCategories( ) 2166void KABCore::manageCategories( )
2166{ 2167{
2167 KABCatPrefs* cp = new KABCatPrefs(); 2168 KABCatPrefs* cp = new KABCatPrefs();
2168 cp->show(); 2169 cp->show();
2169 int w =cp->sizeHint().width() ; 2170 int w =cp->sizeHint().width() ;
2170 int h = cp->sizeHint().height() ; 2171 int h = cp->sizeHint().height() ;
2171 int dw = QApplication::desktop()->width(); 2172 int dw = QApplication::desktop()->width();
2172 int dh = QApplication::desktop()->height(); 2173 int dh = QApplication::desktop()->height();
2173 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2174 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2174 if ( !cp->exec() ) { 2175 if ( !cp->exec() ) {
2175 delete cp; 2176 delete cp;
2176 return; 2177 return;
2177 } 2178 }
2178 int count = 0; 2179 int count = 0;
2179 message( i18n("Please wait, processing categories...")); 2180 message( i18n("Please wait, processing categories..."));
2180 if ( cp->addCat() ) { 2181 if ( cp->addCat() ) {
2181 KABC::AddressBook::Iterator it; 2182 KABC::AddressBook::Iterator it;
2182 QStringList catList = KABPrefs::instance()->mCustomCategories; 2183 QStringList catList = KABPrefs::instance()->mCustomCategories;
2183 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { 2184 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) {
2184 QStringList catIncList = (*it).categories(); 2185 QStringList catIncList = (*it).categories();
2185 int i; 2186 int i;
2186 for( i = 0; i< catIncList.count(); ++i ) { 2187 for( i = 0; i< catIncList.count(); ++i ) {
2187 if ( !catList.contains (catIncList[i])) { 2188 if ( !catList.contains (catIncList[i])) {
2188 catList.append( catIncList[i] ); 2189 catList.append( catIncList[i] );
2189 //qDebug("add cat %s ", catIncList[i].latin1()); 2190 //qDebug("add cat %s ", catIncList[i].latin1());
2190 ++count; 2191 ++count;
2191 } 2192 }
2192 } 2193 }
2193 } 2194 }
2194 catList.sort(); 2195 catList.sort();
2195 KABPrefs::instance()->mCustomCategories = catList; 2196 KABPrefs::instance()->mCustomCategories = catList;
2196 KABPrefs::instance()->writeConfig(); 2197 KABPrefs::instance()->writeConfig();
2197 message(QString::number( count )+ i18n(" categories added to list! ")); 2198 message(QString::number( count )+ i18n(" categories added to list! "));
2198 } else { 2199 } else {
2199 QStringList catList = KABPrefs::instance()->mCustomCategories; 2200 QStringList catList = KABPrefs::instance()->mCustomCategories;
2200 QStringList catIncList; 2201 QStringList catIncList;
2201 QStringList newCatList; 2202 QStringList newCatList;
2202 KABC::AddressBook::Iterator it; 2203 KABC::AddressBook::Iterator it;
2203 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { 2204 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) {
2204 QStringList catIncList = (*it).categories(); 2205 QStringList catIncList = (*it).categories();
2205 int i; 2206 int i;
2206 if ( catIncList.count() ) { 2207 if ( catIncList.count() ) {
2207 newCatList.clear(); 2208 newCatList.clear();
2208 for( i = 0; i< catIncList.count(); ++i ) { 2209 for( i = 0; i< catIncList.count(); ++i ) {
2209 if ( catList.contains (catIncList[i])) { 2210 if ( catList.contains (catIncList[i])) {
2210 newCatList.append( catIncList[i] ); 2211 newCatList.append( catIncList[i] );
2211 } 2212 }
2212 } 2213 }
2213 newCatList.sort(); 2214 newCatList.sort();
2214 (*it).setCategories( newCatList ); 2215 (*it).setCategories( newCatList );
2215 mAddressBook->insertAddressee( (*it) ); 2216 mAddressBook->insertAddressee( (*it) );
2216 } 2217 }
2217 } 2218 }
2218 setModified( true ); 2219 setModified( true );
2219 mViewManager->refreshView(); 2220 mViewManager->refreshView();
2220 mDetails->refreshView(); 2221 mDetails->refreshView();
2221 message( i18n("Removing categories done!")); 2222 message( i18n("Removing categories done!"));
2222 } 2223 }
2223 delete cp; 2224 delete cp;
2224} 2225}
2225void KABCore::removeVoice() 2226void KABCore::removeVoice()
2226{ 2227{
2227 if ( KMessageBox::questionYesNo( this, i18n("After importing, phone numbers\nmay have two or more types.\n(E.g. work+voice)\nThese numbers are shown as \"other\".\nClick Yes to remove the voice type\nfrom numbers with more than one type.\n\nRemove voice type?") ) == KMessageBox::No ) 2228 if ( KMessageBox::questionYesNo( this, i18n("After importing, phone numbers\nmay have two or more types.\n(E.g. work+voice)\nThese numbers are shown as \"other\".\nClick Yes to remove the voice type\nfrom numbers with more than one type.\n\nRemove voice type?") ) == KMessageBox::No )
2228 return; 2229 return;
2229 KABC::Addressee::List list = mViewManager->selectedAddressees(); 2230 KABC::Addressee::List list;
2231 XXPortSelectDialog dlg( this, false, this );
2232 if ( dlg.exec() )
2233 list = dlg.contacts();
2234 else
2235 return;
2230 KABC::Addressee::List::Iterator it; 2236 KABC::Addressee::List::Iterator it;
2231 for ( it = list.begin(); it != list.end(); ++it ) { 2237 for ( it = list.begin(); it != list.end(); ++it ) {
2232
2233 if ( (*it).removeVoice() ) 2238 if ( (*it).removeVoice() )
2234 contactModified((*it) ); 2239 contactModified((*it) );
2235 } 2240 }
2236} 2241}
2237 2242
2238 2243
2239 2244
2240void KABCore::clipboardDataChanged() 2245void KABCore::clipboardDataChanged()
2241{ 2246{
2242 2247
2243 if ( mReadWrite ) 2248 if ( mReadWrite )
2244 mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() ); 2249 mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() );
2245 2250
2246} 2251}
2247 2252
2248void KABCore::updateActionMenu() 2253void KABCore::updateActionMenu()
2249{ 2254{
2250 UndoStack *undo = UndoStack::instance(); 2255 UndoStack *undo = UndoStack::instance();
2251 RedoStack *redo = RedoStack::instance(); 2256 RedoStack *redo = RedoStack::instance();
2252 2257
2253 if ( undo->isEmpty() ) 2258 if ( undo->isEmpty() )
2254 mActionUndo->setText( i18n( "Undo" ) ); 2259 mActionUndo->setText( i18n( "Undo" ) );
2255 else 2260 else
2256 mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) ); 2261 mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) );
2257 2262
2258 mActionUndo->setEnabled( !undo->isEmpty() ); 2263 mActionUndo->setEnabled( !undo->isEmpty() );
2259 2264
2260 if ( !redo->top() ) 2265 if ( !redo->top() )
2261 mActionRedo->setText( i18n( "Redo" ) ); 2266 mActionRedo->setText( i18n( "Redo" ) );
2262 else 2267 else
2263 mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) ); 2268 mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) );
2264 2269
2265 mActionRedo->setEnabled( !redo->isEmpty() ); 2270 mActionRedo->setEnabled( !redo->isEmpty() );
2266} 2271}
2267 2272
2268void KABCore::configureKeyBindings() 2273void KABCore::configureKeyBindings()
2269{ 2274{
2270#ifndef KAB_EMBEDDED 2275#ifndef KAB_EMBEDDED
2271 KKeyDialog::configure( actionCollection(), true ); 2276 KKeyDialog::configure( actionCollection(), true );
2272#else //KAB_EMBEDDED 2277#else //KAB_EMBEDDED
2273 qDebug("KABCore::configureKeyBindings() not implemented"); 2278 qDebug("KABCore::configureKeyBindings() not implemented");
2274#endif //KAB_EMBEDDED 2279#endif //KAB_EMBEDDED
2275} 2280}
2276 2281
2277#ifdef KAB_EMBEDDED 2282#ifdef KAB_EMBEDDED
2278void KABCore::configureResources() 2283void KABCore::configureResources()
2279{ 2284{
2280 KRES::KCMKResources dlg( this, "" , 0 ); 2285 KRES::KCMKResources dlg( this, "" , 0 );
2281 2286
2282 if ( !dlg.exec() ) 2287 if ( !dlg.exec() )
2283 return; 2288 return;
2284 KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") ); 2289 KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") );
2285} 2290}
2286#endif //KAB_EMBEDDED 2291#endif //KAB_EMBEDDED
2287 2292
2288 2293
2289/* this method will be called through the QCop interface from Ko/Pi to select addresses 2294/* this method will be called through the QCop interface from Ko/Pi to select addresses
2290 * for the attendees list of an event. 2295 * for the attendees list of an event.
2291 */ 2296 */
2292void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid) 2297void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid)
2293{ 2298{
2294 QStringList nameList; 2299 QStringList nameList;
2295 QStringList emailList; 2300 QStringList emailList;
2296 QStringList uidList; 2301 QStringList uidList;
2297 2302
2298 KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); 2303 KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this);
2299 uint i=0; 2304 uint i=0;
2300 for (i=0; i < list.count(); i++) 2305 for (i=0; i < list.count(); i++)
2301 { 2306 {
2302 nameList.append(list[i].realName()); 2307 nameList.append(list[i].realName());
2303 emailList.append(list[i].preferredEmail()); 2308 emailList.append(list[i].preferredEmail());
2304 uidList.append(list[i].uid()); 2309 uidList.append(list[i].uid());
2305 } 2310 }
2306 2311
2307 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(sourceChannel, uid, nameList, emailList, uidList); 2312 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(sourceChannel, uid, nameList, emailList, uidList);
2308 2313
2309} 2314}
2310 2315
2311/* this method will be called through the QCop interface from Ko/Pi to select birthdays 2316/* this method will be called through the QCop interface from Ko/Pi to select birthdays
2312 * to put them into the calendar. 2317 * to put them into the calendar.
2313 */ 2318 */
2314void KABCore::requestForBirthdayList(const QString& sourceChannel, const QString& uid) 2319void KABCore::requestForBirthdayList(const QString& sourceChannel, const QString& uid)
2315{ 2320{
2316 // qDebug("KABCore::requestForBirthdayList"); 2321 // qDebug("KABCore::requestForBirthdayList");
2317 QStringList birthdayList; 2322 QStringList birthdayList;
2318 QStringList anniversaryList; 2323 QStringList anniversaryList;
2319 QStringList realNameList; 2324 QStringList realNameList;
2320 QStringList preferredEmailList; 2325 QStringList preferredEmailList;
2321 QStringList assembledNameList; 2326 QStringList assembledNameList;
2322 QStringList uidList; 2327 QStringList uidList;
2323 2328
2324 KABC::AddressBook::Iterator it; 2329 KABC::AddressBook::Iterator it;
2325 2330
2326 int count = 0; 2331 int count = 0;
2327 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { 2332 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) {
2328 ++count; 2333 ++count;
2329 } 2334 }
2330 QProgressBar bar(count,0 ); 2335 QProgressBar bar(count,0 );
2331 int w = 300; 2336 int w = 300;
2332 if ( QApplication::desktop()->width() < 320 ) 2337 if ( QApplication::desktop()->width() < 320 )
2333 w = 220; 2338 w = 220;
2334 int h = bar.sizeHint().height() ; 2339 int h = bar.sizeHint().height() ;
2335 int dw = QApplication::desktop()->width(); 2340 int dw = QApplication::desktop()->width();
2336 int dh = QApplication::desktop()->height(); 2341 int dh = QApplication::desktop()->height();
2337 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2342 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2338 bar.show(); 2343 bar.show();
2339 bar.setCaption (i18n("Collecting birthdays - close to abort!") ); 2344 bar.setCaption (i18n("Collecting birthdays - close to abort!") );
2340 qApp->processEvents(); 2345 qApp->processEvents();
2341 2346
2342 QDate bday; 2347 QDate bday;
2343 QString anni; 2348 QString anni;
2344 QString formattedbday; 2349 QString formattedbday;
2345 2350
2346 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) 2351 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it )
2347 { 2352 {
2348 if ( ! bar.isVisible() ) 2353 if ( ! bar.isVisible() )
2349 return; 2354 return;
2350 bar.setProgress( count++ ); 2355 bar.setProgress( count++ );
2351 qApp->processEvents(); 2356 qApp->processEvents();
2352 bday = (*it).birthday().date(); 2357 bday = (*it).birthday().date();
2353 anni = (*it).custom("KADDRESSBOOK", "X-Anniversary" ); 2358 anni = (*it).custom("KADDRESSBOOK", "X-Anniversary" );
2354 2359
2355 if ( bday.isValid() || !anni.isEmpty()) 2360 if ( bday.isValid() || !anni.isEmpty())
2356 { 2361 {
2357 if (bday.isValid()) 2362 if (bday.isValid())
2358 formattedbday = KGlobal::locale()->formatDate(bday, true, KLocale::ISODate); 2363 formattedbday = KGlobal::locale()->formatDate(bday, true, KLocale::ISODate);
2359 else 2364 else
2360 formattedbday = "NOTVALID"; 2365 formattedbday = "NOTVALID";
2361 if (anni.isEmpty()) 2366 if (anni.isEmpty())
2362 anni = "INVALID"; 2367 anni = "INVALID";
2363 2368
2364 birthdayList.append(formattedbday); 2369 birthdayList.append(formattedbday);
2365 anniversaryList.append(anni); //should be ISODate 2370 anniversaryList.append(anni); //should be ISODate
2366 realNameList.append((*it).realName()); 2371 realNameList.append((*it).realName());
2367 preferredEmailList.append((*it).preferredEmail()); 2372 preferredEmailList.append((*it).preferredEmail());
2368 assembledNameList.append((*it).assembledName()); 2373 assembledNameList.append((*it).assembledName());
2369 uidList.append((*it).uid()); 2374 uidList.append((*it).uid());
2370 2375
2371 //qDebug("found birthday in KA/Pi: %s,%s,%s,%s: %s, %s", (*it).realName().latin1(), (*it).preferredEmail().latin1(), (*it).assembledName().latin1(), (*it).uid().latin1(), formattedbday.latin1(), anni.latin1() ); 2376 //qDebug("found birthday in KA/Pi: %s,%s,%s,%s: %s, %s", (*it).realName().latin1(), (*it).preferredEmail().latin1(), (*it).assembledName().latin1(), (*it).uid().latin1(), formattedbday.latin1(), anni.latin1() );
2372 } 2377 }
2373 } 2378 }
2374 2379
2375 bool res = ExternalAppHandler::instance()->returnBirthdayListFromKAPI(sourceChannel, uid, birthdayList, anniversaryList, realNameList, preferredEmailList, assembledNameList, uidList); 2380 bool res = ExternalAppHandler::instance()->returnBirthdayListFromKAPI(sourceChannel, uid, birthdayList, anniversaryList, realNameList, preferredEmailList, assembledNameList, uidList);
2376 2381
2377} 2382}
2378 2383
2379/* this method will be called through the QCop interface from other apps to show details of a contact. 2384/* this method will be called through the QCop interface from other apps to show details of a contact.
2380 */ 2385 */
2381void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid) 2386void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid)
2382{ 2387{
2383 //qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1()); 2388 //qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1());
2384 2389
2385 QString foundUid = QString::null; 2390 QString foundUid = QString::null;
2386 if ( ! uid.isEmpty() ) { 2391 if ( ! uid.isEmpty() ) {
2387 Addressee adrr = mAddressBook->findByUid( uid ); 2392 Addressee adrr = mAddressBook->findByUid( uid );
2388 if ( !adrr.isEmpty() ) { 2393 if ( !adrr.isEmpty() ) {
2389 foundUid = uid; 2394 foundUid = uid;
2390 } 2395 }
2391 if ( email == "sendbacklist" ) { 2396 if ( email == "sendbacklist" ) {
2392 //qDebug("ssssssssssssssssssssssend "); 2397 //qDebug("ssssssssssssssssssssssend ");
2393 QStringList nameList; 2398 QStringList nameList;
2394 QStringList emailList; 2399 QStringList emailList;
2395 QStringList uidList; 2400 QStringList uidList;
2396 nameList.append(adrr.realName()); 2401 nameList.append(adrr.realName());
2397 emailList = adrr.emails(); 2402 emailList = adrr.emails();
2398 uidList.append( adrr.preferredEmail()); 2403 uidList.append( adrr.preferredEmail());
2399 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList); 2404 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList);
2400 return; 2405 return;
2401 } 2406 }
2402 2407
2403 } 2408 }
2404 2409
2405 if ( email == "sendbacklist" ) 2410 if ( email == "sendbacklist" )
2406 return; 2411 return;
2407 if (foundUid.isEmpty()) 2412 if (foundUid.isEmpty())
2408 { 2413 {
2409 //find the uid of the person first 2414 //find the uid of the person first
2410 Addressee::List namelist; 2415 Addressee::List namelist;
2411 Addressee::List emaillist; 2416 Addressee::List emaillist;
2412 2417
2413 if (!name.isEmpty()) 2418 if (!name.isEmpty())
2414 namelist = mAddressBook->findByName( name ); 2419 namelist = mAddressBook->findByName( name );
2415 2420
2416 if (!email.isEmpty()) 2421 if (!email.isEmpty())
2417 emaillist = mAddressBook->findByEmail( email ); 2422 emaillist = mAddressBook->findByEmail( email );
2418 //qDebug("count %d %d ", namelist.count(),emaillist.count() ); 2423 //qDebug("count %d %d ", namelist.count(),emaillist.count() );
2419 //check if we have a match in Namelist and Emaillist 2424 //check if we have a match in Namelist and Emaillist
2420 if ((namelist.count() == 0) && (emaillist.count() > 0)) { 2425 if ((namelist.count() == 0) && (emaillist.count() > 0)) {
2421 foundUid = emaillist[0].uid(); 2426 foundUid = emaillist[0].uid();
2422 } 2427 }
2423 else if ((namelist.count() > 0) && (emaillist.count() == 0)) 2428 else if ((namelist.count() > 0) && (emaillist.count() == 0))
2424 foundUid = namelist[0].uid(); 2429 foundUid = namelist[0].uid();
2425 else 2430 else
2426 { 2431 {
2427 for (int i = 0; i < namelist.count(); i++) 2432 for (int i = 0; i < namelist.count(); i++)
2428 { 2433 {
2429 for (int j = 0; j < emaillist.count(); j++) 2434 for (int j = 0; j < emaillist.count(); j++)
2430 { 2435 {
2431 if (namelist[i] == emaillist[j]) 2436 if (namelist[i] == emaillist[j])
2432 { 2437 {
2433 foundUid = namelist[i].uid(); 2438 foundUid = namelist[i].uid();
2434 } 2439 }
2435 } 2440 }
2436 } 2441 }
2437 } 2442 }
2438 } 2443 }
2439 else 2444 else
2440 { 2445 {
2441 foundUid = uid; 2446 foundUid = uid;
2442 } 2447 }
2443 2448
2444 if (!foundUid.isEmpty()) 2449 if (!foundUid.isEmpty())
2445 { 2450 {
2446 2451
2447 // raise Ka/Pi if it is in the background 2452 // raise Ka/Pi if it is in the background
2448#ifndef DESKTOP_VERSION 2453#ifndef DESKTOP_VERSION
2449#ifndef KORG_NODCOP 2454#ifndef KORG_NODCOP
2450 //QCopEnvelope e("QPE/Application/kapi", "raise()"); 2455 //QCopEnvelope e("QPE/Application/kapi", "raise()");
2451#endif 2456#endif
2452#endif 2457#endif
2453 2458
2454 mMainWindow->showMaximized(); 2459 mMainWindow->showMaximized();
2455 mMainWindow-> raise(); 2460 mMainWindow-> raise();
2456 2461
2457 mViewManager->setSelected( "", false); 2462 mViewManager->setSelected( "", false);
2458 mViewManager->refreshView( "" ); 2463 mViewManager->refreshView( "" );
2459 mViewManager->setSelected( foundUid, true ); 2464 mViewManager->setSelected( foundUid, true );
2460 mViewManager->refreshView( foundUid ); 2465 mViewManager->refreshView( foundUid );
2461 2466
2462 if ( !mMultipleViewsAtOnce ) 2467 if ( !mMultipleViewsAtOnce )
2463 { 2468 {
2464 setDetailsVisible( true ); 2469 setDetailsVisible( true );
2465 mActionDetails->setChecked(true); 2470 mActionDetails->setChecked(true);
2466 } 2471 }
2467 } 2472 }
2468} 2473}
2469 2474
2470void KABCore::whatsnew() 2475void KABCore::whatsnew()
2471{ 2476{
2472 KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" ); 2477 KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" );
2473} 2478}
2474void KABCore::synchowto() 2479void KABCore::synchowto()
2475{ 2480{
2476 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" ); 2481 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" );
2477} 2482}
2478void KABCore::kdesynchowto() 2483void KABCore::kdesynchowto()
2479{ 2484{
2480 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/Zaurus-KDE_syncHowTo.txt" ); 2485 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/Zaurus-KDE_syncHowTo.txt" );
2481} 2486}
2482void KABCore::multisynchowto() 2487void KABCore::multisynchowto()
2483{ 2488{
2484 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/MultiSyncHowTo.txt" ); 2489 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/MultiSyncHowTo.txt" );
2485} 2490}
2486void KABCore::faq() 2491void KABCore::faq()
2487{ 2492{
2488 KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" ); 2493 KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" );
2489} 2494}
2490 2495
2491#include <libkcal/syncdefines.h> 2496#include <libkcal/syncdefines.h>
2492 2497
2493KABC::Addressee KABCore::getLastSyncAddressee() 2498KABC::Addressee KABCore::getLastSyncAddressee()
2494{ 2499{
2495 Addressee lse; 2500 Addressee lse;
2496 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); 2501 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
2497 2502
2498 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); 2503 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() );
2499 lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); 2504 lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice );
2500 if (lse.isEmpty()) { 2505 if (lse.isEmpty()) {
2501 qDebug("Creating new last-syncAddressee "); 2506 qDebug("Creating new last-syncAddressee ");
2502 lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice ); 2507 lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice );
2503 QString sum = ""; 2508 QString sum = "";
2504 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) 2509 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL )
2505 sum = "E: "; 2510 sum = "E: ";
2506 lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event")); 2511 lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event"));
2507 lse.setRevision( mLastAddressbookSync ); 2512 lse.setRevision( mLastAddressbookSync );
2508 lse.setCategories( i18n("SyncEvent") ); 2513 lse.setCategories( i18n("SyncEvent") );
2509 mAddressBook->insertAddressee( lse ); 2514 mAddressBook->insertAddressee( lse );
2510 } 2515 }
2511 return lse; 2516 return lse;
2512} 2517}
2513int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ) 2518int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full )
2514{ 2519{
2515 2520
2516 //void setZaurusId(int id); 2521 //void setZaurusId(int id);
2517 // int zaurusId() const; 2522 // int zaurusId() const;
2518 // void setZaurusUid(int id); 2523 // void setZaurusUid(int id);
2519 // int zaurusUid() const; 2524 // int zaurusUid() const;
2520 // void setZaurusStat(int id); 2525 // void setZaurusStat(int id);
2521 // int zaurusStat() const; 2526 // int zaurusStat() const;
2522 // 0 equal 2527 // 0 equal
2523 // 1 take local 2528 // 1 take local
2524 // 2 take remote 2529 // 2 take remote
2525 // 3 cancel 2530 // 3 cancel
2526 QDateTime lastSync = mLastAddressbookSync; 2531 QDateTime lastSync = mLastAddressbookSync;
2527 QDateTime localMod = local->revision(); 2532 QDateTime localMod = local->revision();
2528 QDateTime remoteMod = remote->revision(); 2533 QDateTime remoteMod = remote->revision();
2529 2534
2530 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); 2535 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
2531 2536
2532 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2537 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2533 bool remCh, locCh; 2538 bool remCh, locCh;
2534 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); 2539 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) );
2535 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); 2540 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() );
2536 locCh = ( localMod > mLastAddressbookSync ); 2541 locCh = ( localMod > mLastAddressbookSync );
2537 if ( !remCh && ! locCh ) { 2542 if ( !remCh && ! locCh ) {
2538 //qDebug("both not changed "); 2543 //qDebug("both not changed ");
2539 lastSync = localMod.addDays(1); 2544 lastSync = localMod.addDays(1);
2540 if ( mode <= SYNC_PREF_ASK ) 2545 if ( mode <= SYNC_PREF_ASK )
2541 return 0; 2546 return 0;
2542 } else { 2547 } else {
2543 if ( locCh ) { 2548 if ( locCh ) {
2544 //qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1()); 2549 //qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1());
2545 lastSync = localMod.addDays( -1 ); 2550 lastSync = localMod.addDays( -1 );
2546 if ( !remCh ) 2551 if ( !remCh )
2547 remoteMod =( lastSync.addDays( -1 ) ); 2552 remoteMod =( lastSync.addDays( -1 ) );
2548 } else { 2553 } else {
2549 //qDebug(" not loc changed "); 2554 //qDebug(" not loc changed ");
2550 lastSync = localMod.addDays( 1 ); 2555 lastSync = localMod.addDays( 1 );
2551 if ( remCh ) { 2556 if ( remCh ) {
2552 //qDebug("rem changed "); 2557 //qDebug("rem changed ");
2553 remoteMod =( lastSync.addDays( 1 ) ); 2558 remoteMod =( lastSync.addDays( 1 ) );
2554 } 2559 }
2555 2560
2556 } 2561 }
2557 } 2562 }
2558 full = true; 2563 full = true;
2559 if ( mode < SYNC_PREF_ASK ) 2564 if ( mode < SYNC_PREF_ASK )
2560 mode = SYNC_PREF_ASK; 2565 mode = SYNC_PREF_ASK;
2561 } else { 2566 } else {
2562 if ( localMod == remoteMod ) 2567 if ( localMod == remoteMod )
2563 return 0; 2568 return 0;
2564 2569
2565 } 2570 }
2566 //qDebug("%s %s --- %d %d", localMod.toString().latin1() , remoteMod.toString().latin1(), localMod.time().msec(), remoteMod.time().msec()); 2571 //qDebug("%s %s --- %d %d", localMod.toString().latin1() , remoteMod.toString().latin1(), localMod.time().msec(), remoteMod.time().msec());
2567 //qDebug("lastsync %s ", lastSync.toString().latin1() ); 2572 //qDebug("lastsync %s ", lastSync.toString().latin1() );
2568 //full = true; //debug only 2573 //full = true; //debug only
2569 if ( full ) { 2574 if ( full ) {
2570 bool equ = ( (*local) == (*remote) ); 2575 bool equ = ( (*local) == (*remote) );
2571 if ( equ ) { 2576 if ( equ ) {
2572 //qDebug("equal "); 2577 //qDebug("equal ");
2573 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2578 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2574 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); 2579 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) );
2575 } 2580 }
2576 if ( mode < SYNC_PREF_FORCE_LOCAL ) 2581 if ( mode < SYNC_PREF_FORCE_LOCAL )
2577 return 0; 2582 return 0;
2578 2583
2579 }//else //debug only 2584 }//else //debug only
2580 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); 2585 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1());
2581 } 2586 }
2582 int result; 2587 int result;
2583 bool localIsNew; 2588 bool localIsNew;
2584 //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , local->lastModified().toString().latin1() , remote->lastModified().toString().latin1() ); 2589 //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , local->lastModified().toString().latin1() , remote->lastModified().toString().latin1() );
2585 2590
2586 if ( full && mode < SYNC_PREF_NEWEST ) 2591 if ( full && mode < SYNC_PREF_NEWEST )
2587 mode = SYNC_PREF_ASK; 2592 mode = SYNC_PREF_ASK;
2588 2593
2589 switch( mode ) { 2594 switch( mode ) {
2590 case SYNC_PREF_LOCAL: 2595 case SYNC_PREF_LOCAL:
2591 if ( lastSync > remoteMod ) 2596 if ( lastSync > remoteMod )
2592 return 1; 2597 return 1;
2593 if ( lastSync > localMod ) 2598 if ( lastSync > localMod )
2594 return 2; 2599 return 2;
2595 return 1; 2600 return 1;
2596 break; 2601 break;
2597 case SYNC_PREF_REMOTE: 2602 case SYNC_PREF_REMOTE:
2598 if ( lastSync > remoteMod ) 2603 if ( lastSync > remoteMod )
2599 return 1; 2604 return 1;
2600 if ( lastSync > localMod ) 2605 if ( lastSync > localMod )
2601 return 2; 2606 return 2;
2602 return 2; 2607 return 2;
2603 break; 2608 break;
2604 case SYNC_PREF_NEWEST: 2609 case SYNC_PREF_NEWEST:
2605 if ( localMod > remoteMod ) 2610 if ( localMod > remoteMod )
2606 return 1; 2611 return 1;
2607 else 2612 else
2608 return 2; 2613 return 2;
2609 break; 2614 break;
2610 case SYNC_PREF_ASK: 2615 case SYNC_PREF_ASK:
2611 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); 2616 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
2612 if ( lastSync > remoteMod ) 2617 if ( lastSync > remoteMod )
2613 return 1; 2618 return 1;
2614 if ( lastSync > localMod ) 2619 if ( lastSync > localMod )
2615 return 2; 2620 return 2;
2616 localIsNew = localMod >= remoteMod; 2621 localIsNew = localMod >= remoteMod;
2617 //qDebug("conflict! ************************************** "); 2622 //qDebug("conflict! ************************************** ");
2618 { 2623 {
2619 KPIM::AddresseeChooser acd ( *local,*remote, localIsNew , this ); 2624 KPIM::AddresseeChooser acd ( *local,*remote, localIsNew , this );
2620 result = acd.executeD(localIsNew); 2625 result = acd.executeD(localIsNew);
2621 return result; 2626 return result;
2622 } 2627 }
2623 break; 2628 break;
2624 case SYNC_PREF_FORCE_LOCAL: 2629 case SYNC_PREF_FORCE_LOCAL:
2625 return 1; 2630 return 1;
2626 break; 2631 break;
2627 case SYNC_PREF_FORCE_REMOTE: 2632 case SYNC_PREF_FORCE_REMOTE:
2628 return 2; 2633 return 2;
2629 break; 2634 break;
2630 2635
2631 default: 2636 default:
2632 // SYNC_PREF_TAKE_BOTH not implemented 2637 // SYNC_PREF_TAKE_BOTH not implemented
2633 break; 2638 break;
2634 } 2639 }
2635 return 0; 2640 return 0;
2636} 2641}
2637 2642
2638 2643
2639bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode) 2644bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode)
2640{ 2645{
2641 bool syncOK = true; 2646 bool syncOK = true;
2642 int addedAddressee = 0; 2647 int addedAddressee = 0;
2643 int addedAddresseeR = 0; 2648 int addedAddresseeR = 0;
2644 int deletedAddresseeR = 0; 2649 int deletedAddresseeR = 0;
2645 int deletedAddresseeL = 0; 2650 int deletedAddresseeL = 0;
2646 int changedLocal = 0; 2651 int changedLocal = 0;
2647 int changedRemote = 0; 2652 int changedRemote = 0;
2648 2653
2649 QString mCurrentSyncName = syncManager->getCurrentSyncName(); 2654 QString mCurrentSyncName = syncManager->getCurrentSyncName();
2650 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); 2655 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
2651 2656
2652 //QPtrList<Addressee> el = local->rawAddressees(); 2657 //QPtrList<Addressee> el = local->rawAddressees();
2653 Addressee addresseeR; 2658 Addressee addresseeR;
2654 QString uid; 2659 QString uid;
2655 int take; 2660 int take;
2656 Addressee addresseeL; 2661 Addressee addresseeL;
2657 Addressee addresseeRSync; 2662 Addressee addresseeRSync;
2658 Addressee addresseeLSync; 2663 Addressee addresseeLSync;
2659 // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees(); 2664 // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees();
2660 //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees(); 2665 //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees();
2661 bool fullDateRange = false; 2666 bool fullDateRange = false;
2662 local->resetTempSyncStat(); 2667 local->resetTempSyncStat();
2663 mLastAddressbookSync = QDateTime::currentDateTime(); 2668 mLastAddressbookSync = QDateTime::currentDateTime();
2664 if ( syncManager->syncWithDesktop() ) { 2669 if ( syncManager->syncWithDesktop() ) {
2665 // remote->removeSyncInfo( QString());//remove all info 2670 // remote->removeSyncInfo( QString());//remove all info
2666 if ( KSyncManager::mRequestedSyncEvent.isValid() ) { 2671 if ( KSyncManager::mRequestedSyncEvent.isValid() ) {
2667 mLastAddressbookSync = KSyncManager::mRequestedSyncEvent; 2672 mLastAddressbookSync = KSyncManager::mRequestedSyncEvent;
2668 qDebug("using extern time for calendar sync: %s ", mLastAddressbookSync.toString().latin1() ); 2673 qDebug("using extern time for calendar sync: %s ", mLastAddressbookSync.toString().latin1() );
2669 } else { 2674 } else {
2670 qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); 2675 qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime ");
2671 } 2676 }
2672 } 2677 }
2673 QDateTime modifiedCalendar = mLastAddressbookSync; 2678 QDateTime modifiedCalendar = mLastAddressbookSync;
2674 addresseeLSync = getLastSyncAddressee(); 2679 addresseeLSync = getLastSyncAddressee();
2675 qDebug("Last Sync %s ", addresseeLSync.revision().toString().latin1()); 2680 qDebug("Last Sync %s ", addresseeLSync.revision().toString().latin1());
2676 addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName ); 2681 addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName );
2677 if ( !addresseeR.isEmpty() ) { 2682 if ( !addresseeR.isEmpty() ) {
2678 addresseeRSync = addresseeR; 2683 addresseeRSync = addresseeR;
2679 remote->removeAddressee(addresseeR ); 2684 remote->removeAddressee(addresseeR );
2680 2685
2681 } else { 2686 } else {
2682 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2687 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2683 addresseeRSync = addresseeLSync ; 2688 addresseeRSync = addresseeLSync ;
2684 } else { 2689 } else {
2685 //qDebug("FULLDATE 1"); 2690 //qDebug("FULLDATE 1");
2686 fullDateRange = true; 2691 fullDateRange = true;
2687 Addressee newAdd; 2692 Addressee newAdd;
2688 addresseeRSync = newAdd; 2693 addresseeRSync = newAdd;
2689 addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee")); 2694 addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee"));
2690 addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName ); 2695 addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName );
2691 addresseeRSync.setRevision( mLastAddressbookSync ); 2696 addresseeRSync.setRevision( mLastAddressbookSync );
2692 addresseeRSync.setCategories( i18n("SyncAddressee") ); 2697 addresseeRSync.setCategories( i18n("SyncAddressee") );
2693 } 2698 }
2694 } 2699 }
2695 if ( addresseeLSync.revision() == mLastAddressbookSync ) { 2700 if ( addresseeLSync.revision() == mLastAddressbookSync ) {
2696 // qDebug("FULLDATE 2"); 2701 // qDebug("FULLDATE 2");
2697 fullDateRange = true; 2702 fullDateRange = true;
2698 } 2703 }
2699 if ( ! fullDateRange ) { 2704 if ( ! fullDateRange ) {
2700 if ( addresseeLSync.revision() != addresseeRSync.revision() ) { 2705 if ( addresseeLSync.revision() != addresseeRSync.revision() ) {
2701 2706
2702 // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() ); 2707 // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() );
2703 //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec()); 2708 //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec());
2704 fullDateRange = true; 2709 fullDateRange = true;
2705 //qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() ); 2710 //qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() );
2706 } 2711 }
2707 } 2712 }
2708 // fullDateRange = true; // debug only! 2713 // fullDateRange = true; // debug only!
2709 if ( fullDateRange ) 2714 if ( fullDateRange )
2710 mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365); 2715 mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365);
2711 else 2716 else
2712 mLastAddressbookSync = addresseeLSync.revision(); 2717 mLastAddressbookSync = addresseeLSync.revision();
2713 // for resyncing if own file has changed 2718 // for resyncing if own file has changed
2714 // PENDING fixme later when implemented 2719 // PENDING fixme later when implemented
2715#if 0 2720#if 0
2716 if ( mCurrentSyncDevice == "deleteaftersync" ) { 2721 if ( mCurrentSyncDevice == "deleteaftersync" ) {
2717 mLastAddressbookSync = loadedFileVersion; 2722 mLastAddressbookSync = loadedFileVersion;
2718 qDebug("setting mLastAddressbookSync "); 2723 qDebug("setting mLastAddressbookSync ");
2719 } 2724 }
2720#endif 2725#endif
2721 2726
2722 //qDebug("*************************** "); 2727 //qDebug("*************************** ");
2723 // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() ); 2728 // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() );
2724 QStringList er = remote->uidList(); 2729 QStringList er = remote->uidList();
2725 Addressee inR ;//= er.first(); 2730 Addressee inR ;//= er.first();
2726 Addressee inL; 2731 Addressee inL;
2727 2732
2728 syncManager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count()); 2733 syncManager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count());
2729 2734
2730 int modulo = (er.count()/10)+1; 2735 int modulo = (er.count()/10)+1;
2731 int incCounter = 0; 2736 int incCounter = 0;
2732 while ( incCounter < er.count()) { 2737 while ( incCounter < er.count()) {
2733 if (syncManager->isProgressBarCanceled()) 2738 if (syncManager->isProgressBarCanceled())
2734 return false; 2739 return false;
2735 if ( incCounter % modulo == 0 ) 2740 if ( incCounter % modulo == 0 )
2736 syncManager->showProgressBar(incCounter); 2741 syncManager->showProgressBar(incCounter);
2737 2742
2738 uid = er[ incCounter ]; 2743 uid = er[ incCounter ];
2739 bool skipIncidence = false; 2744 bool skipIncidence = false;
2740 if ( uid.left(19) == QString("last-syncAddressee-") ) 2745 if ( uid.left(19) == QString("last-syncAddressee-") )
2741 skipIncidence = true; 2746 skipIncidence = true;
2742 QString idS,OidS; 2747 QString idS,OidS;
2743 qApp->processEvents(); 2748 qApp->processEvents();
2744 if ( !skipIncidence ) { 2749 if ( !skipIncidence ) {
2745 inL = local->findByUid( uid ); 2750 inL = local->findByUid( uid );
2746 inR = remote->findByUid( uid ); 2751 inR = remote->findByUid( uid );
2747 //inL.setResource( 0 ); 2752 //inL.setResource( 0 );
2748 //inR.setResource( 0 ); 2753 //inR.setResource( 0 );
2749 if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars 2754 if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars
2750 if ( !inL.resource() || inL.resource()->includeInSync() ) { 2755 if ( !inL.resource() || inL.resource()->includeInSync() ) {
2751 if ( (take = takeAddressee( &inL, &inR, mode, fullDateRange )) ) { 2756 if ( (take = takeAddressee( &inL, &inR, mode, fullDateRange )) ) {
2752 //qDebug("take %d %s ", take, inL.summary().latin1()); 2757 //qDebug("take %d %s ", take, inL.summary().latin1());
2753 if ( take == 3 ) 2758 if ( take == 3 )
2754 return false; 2759 return false;
2755 if ( take == 1 ) {// take local ********************** 2760 if ( take == 1 ) {// take local **********************
2756 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2761 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2757 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); 2762 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) );
2758 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); 2763 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) );
2759 local->insertAddressee( inL, false ); 2764 local->insertAddressee( inL, false );
2760 idS = inR.externalUID(); 2765 idS = inR.externalUID();
2761 OidS = inR.originalExternalUID(); 2766 OidS = inR.originalExternalUID();
2762 } 2767 }
2763 else 2768 else
2764 idS = inR.IDStr(); 2769 idS = inR.IDStr();
2765 remote->removeAddressee( inR ); 2770 remote->removeAddressee( inR );
2766 inR = inL; 2771 inR = inL;
2767 inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 2772 inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
2768 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2773 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2769 inR.setOriginalExternalUID( OidS ); 2774 inR.setOriginalExternalUID( OidS );
2770 inR.setExternalUID( idS ); 2775 inR.setExternalUID( idS );
2771 if ( syncManager->syncWithDesktop() ) { 2776 if ( syncManager->syncWithDesktop() ) {
2772 inR.setIDStr("changed" ); 2777 inR.setIDStr("changed" );
2773 } 2778 }
2774 //inR.insertCustom( "KADDRESSBOOK", "X-KDESYNC","changed" ); 2779 //inR.insertCustom( "KADDRESSBOOK", "X-KDESYNC","changed" );
2775 } else { 2780 } else {
2776 inR.setIDStr( idS ); 2781 inR.setIDStr( idS );
2777 } 2782 }
2778 inR.setResource( 0 ); 2783 inR.setResource( 0 );
2779 remote->insertAddressee( inR , false); 2784 remote->insertAddressee( inR , false);
2780 ++changedRemote; 2785 ++changedRemote;
2781 } else { // take == 2 take remote ********************** 2786 } else { // take == 2 take remote **********************
2782 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2787 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2783 if ( inR.revision().date().year() < 2004 ) 2788 if ( inR.revision().date().year() < 2004 )
2784 inR.setRevision( modifiedCalendar ); 2789 inR.setRevision( modifiedCalendar );
2785 } 2790 }
2786 idS = inL.IDStr(); 2791 idS = inL.IDStr();
2787 local->removeAddressee( inL ); 2792 local->removeAddressee( inL );
2788 inL = inR; 2793 inL = inR;
2789 inL.setIDStr( idS ); 2794 inL.setIDStr( idS );
2790 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2795 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2791 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); 2796 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) );
2792 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); 2797 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) );
2793 } 2798 }
2794 inL.setResource( 0 ); 2799 inL.setResource( 0 );
2795 local->insertAddressee( inL , false ); 2800 local->insertAddressee( inL , false );
2796 ++changedLocal; 2801 ++changedLocal;
2797 } 2802 }
2798 } 2803 }
2799 } 2804 }
2800 } else { // no conflict ********** add or delete remote 2805 } else { // no conflict ********** add or delete remote
2801 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2806 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2802 QString des = addresseeLSync.note(); 2807 QString des = addresseeLSync.note();
2803 if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it 2808 if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it
2804 inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE ); 2809 inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE );
2805 remote->insertAddressee( inR, false ); 2810 remote->insertAddressee( inR, false );
2806 ++deletedAddresseeR; 2811 ++deletedAddresseeR;
2807 } else { 2812 } else {
2808 inR.setRevision( modifiedCalendar ); 2813 inR.setRevision( modifiedCalendar );
2809 remote->insertAddressee( inR, false ); 2814 remote->insertAddressee( inR, false );
2810 inL = inR; 2815 inL = inR;
2811 inL.setIDStr( ":" ); 2816 inL.setIDStr( ":" );
2812 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); 2817 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) );
2813 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); 2818 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) );
2814 inL.setResource( 0 ); 2819 inL.setResource( 0 );
2815 local->insertAddressee( inL , false); 2820 local->insertAddressee( inL , false);
2816 ++addedAddressee; 2821 ++addedAddressee;
2817 } 2822 }
2818 } else { 2823 } else {
2819 if ( inR.revision() > mLastAddressbookSync || mode == 5 ) { 2824 if ( inR.revision() > mLastAddressbookSync || mode == 5 ) {
2820 inR.setRevision( modifiedCalendar ); 2825 inR.setRevision( modifiedCalendar );
2821 remote->insertAddressee( inR, false ); 2826 remote->insertAddressee( inR, false );
2822 inR.setResource( 0 ); 2827 inR.setResource( 0 );
2823 local->insertAddressee( inR, false ); 2828 local->insertAddressee( inR, false );
2824 ++addedAddressee; 2829 ++addedAddressee;
2825 } else { 2830 } else {
2826 // pending checkExternSyncAddressee(addresseeRSyncSharp, inR); 2831 // pending checkExternSyncAddressee(addresseeRSyncSharp, inR);
2827 remote->removeAddressee( inR ); 2832 remote->removeAddressee( inR );
2828 ++deletedAddresseeR; 2833 ++deletedAddresseeR;
2829 } 2834 }
2830 } 2835 }
2831 } 2836 }
2832 } 2837 }
2833 ++incCounter; 2838 ++incCounter;
2834 } 2839 }
2835 er.clear(); 2840 er.clear();
2836 QStringList el = local->uidList(); 2841 QStringList el = local->uidList();
2837 modulo = (el.count()/10)+1; 2842 modulo = (el.count()/10)+1;
2838 2843
2839 syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count()); 2844 syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count());
2840 incCounter = 0; 2845 incCounter = 0;
2841 while ( incCounter < el.count()) { 2846 while ( incCounter < el.count()) {
2842 qApp->processEvents(); 2847 qApp->processEvents();
2843 if (syncManager->isProgressBarCanceled()) 2848 if (syncManager->isProgressBarCanceled())
2844 return false; 2849 return false;
2845 if ( incCounter % modulo == 0 ) 2850 if ( incCounter % modulo == 0 )
2846 syncManager->showProgressBar(incCounter); 2851 syncManager->showProgressBar(incCounter);
2847 uid = el[ incCounter ]; 2852 uid = el[ incCounter ];
2848 bool skipIncidence = false; 2853 bool skipIncidence = false;
2849 if ( uid.left(19) == QString("last-syncAddressee-") ) 2854 if ( uid.left(19) == QString("last-syncAddressee-") )
2850 skipIncidence = true; 2855 skipIncidence = true;
2851 if ( !skipIncidence ) { 2856 if ( !skipIncidence ) {
2852 inL = local->findByUid( uid ); 2857 inL = local->findByUid( uid );
2853 if ( !inL.resource() || inL.resource()->includeInSync() ) { 2858 if ( !inL.resource() || inL.resource()->includeInSync() ) {
2854 inR = remote->findByUid( uid ); 2859 inR = remote->findByUid( uid );
2855 if ( inR.isEmpty() ) { // no conflict ********** add or delete local 2860 if ( inR.isEmpty() ) { // no conflict ********** add or delete local
2856 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2861 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2857 if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { 2862 if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) {
2858 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); 2863 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL);
2859 local->removeAddressee( inL ); 2864 local->removeAddressee( inL );
2860 ++deletedAddresseeL; 2865 ++deletedAddresseeL;
2861 } else { 2866 } else {
2862 if ( ! syncManager->mWriteBackExistingOnly ) { 2867 if ( ! syncManager->mWriteBackExistingOnly ) {
2863 inL.removeID(mCurrentSyncDevice ); 2868 inL.removeID(mCurrentSyncDevice );
2864 ++addedAddresseeR; 2869 ++addedAddresseeR;
2865 inL.setRevision( modifiedCalendar ); 2870 inL.setRevision( modifiedCalendar );
2866 local->insertAddressee( inL, false ); 2871 local->insertAddressee( inL, false );
2867 inR = inL; 2872 inR = inL;
2868 inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL ); 2873 inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL );
2869 inR.setResource( 0 ); 2874 inR.setResource( 0 );
2870 remote->insertAddressee( inR, false ); 2875 remote->insertAddressee( inR, false );
2871 } 2876 }
2872 } 2877 }
2873 } else { 2878 } else {
2874 if ( inL.revision() < mLastAddressbookSync && mode != 4 ) { 2879 if ( inL.revision() < mLastAddressbookSync && mode != 4 ) {
2875 //qDebug("data %s ", inL.revision().toString().latin1()); 2880 //qDebug("data %s ", inL.revision().toString().latin1());
2876 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); 2881 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL);
2877 local->removeAddressee( inL ); 2882 local->removeAddressee( inL );
2878 ++deletedAddresseeL; 2883 ++deletedAddresseeL;
2879 } else { 2884 } else {
2880 if ( ! syncManager->mWriteBackExistingOnly ) { 2885 if ( ! syncManager->mWriteBackExistingOnly ) {
2881 ++addedAddresseeR; 2886 ++addedAddresseeR;
2882 inL.setRevision( modifiedCalendar ); 2887 inL.setRevision( modifiedCalendar );
2883 local->insertAddressee( inL, false ); 2888 local->insertAddressee( inL, false );
2884 inR = inL; 2889 inR = inL;
2885 inR.setIDStr( ":" ); 2890 inR.setIDStr( ":" );
2886 inR.setResource( 0 ); 2891 inR.setResource( 0 );
2887 remote->insertAddressee( inR, false ); 2892 remote->insertAddressee( inR, false );
2888 } 2893 }
2889 } 2894 }
2890 } 2895 }
2891 } 2896 }
2892 } 2897 }
2893 } 2898 }
2894 ++incCounter; 2899 ++incCounter;
2895 } 2900 }
2896 el.clear(); 2901 el.clear();
2897 syncManager->hideProgressBar(); 2902 syncManager->hideProgressBar();
2898 mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); 2903 mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 );
2899 // get rid of micro seconds 2904 // get rid of micro seconds
2900 QTime t = mLastAddressbookSync.time(); 2905 QTime t = mLastAddressbookSync.time();
2901 mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); 2906 mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) );
2902 addresseeLSync.setRevision( mLastAddressbookSync ); 2907 addresseeLSync.setRevision( mLastAddressbookSync );
2903 addresseeRSync.setRevision( mLastAddressbookSync ); 2908 addresseeRSync.setRevision( mLastAddressbookSync );
2904 addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ; 2909 addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ;
2905 addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName ); 2910 addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName );
2906 addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ; 2911 addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ;
2907 addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") ); 2912 addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") );
2908 addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ; 2913 addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ;
2909 addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() ); 2914 addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() );
2910 addresseeRSync.setNote( "" ) ; 2915 addresseeRSync.setNote( "" ) ;
2911 addresseeLSync.setNote( "" ); 2916 addresseeLSync.setNote( "" );
2912 2917
2913 if ( mGlobalSyncMode == SYNC_MODE_NORMAL) 2918 if ( mGlobalSyncMode == SYNC_MODE_NORMAL)
2914 remote->insertAddressee( addresseeRSync, false ); 2919 remote->insertAddressee( addresseeRSync, false );
2915 local->insertAddressee( addresseeLSync, false ); 2920 local->insertAddressee( addresseeLSync, false );
2916 QString mes; 2921 QString mes;
2917 mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n"),addedAddressee, addedAddresseeR, changedLocal, changedRemote, deletedAddresseeL, deletedAddresseeR ); 2922 mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n"),addedAddressee, addedAddresseeR, changedLocal, changedRemote, deletedAddresseeL, deletedAddresseeR );
2918 qDebug( mes ); 2923 qDebug( mes );
2919 mes = i18n("Local addressbook changed!\n") +mes; 2924 mes = i18n("Local addressbook changed!\n") +mes;
2920 if ( syncManager->mShowSyncSummary ) { 2925 if ( syncManager->mShowSyncSummary ) {
2921 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, 2926 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes,
2922 i18n("KA/Pi Synchronization"),i18n("Write back"))) { 2927 i18n("KA/Pi Synchronization"),i18n("Write back"))) {
2923 qDebug("cancelled "); 2928 qDebug("cancelled ");
2924 return false; 2929 return false;
2925 } 2930 }
2926 } 2931 }
2927 return syncOK; 2932 return syncOK;
2928} 2933}
2929 2934
2930 2935
2931//this is a overwritten callbackmethods from the syncinterface 2936//this is a overwritten callbackmethods from the syncinterface
2932bool KABCore::sync(KSyncManager* manager, QString filename, int mode) 2937bool KABCore::sync(KSyncManager* manager, QString filename, int mode)
2933{ 2938{
2934 2939
2935 //pending prepare addresseeview for output 2940 //pending prepare addresseeview for output
2936 //pending detect, if remote file has REV field. if not switch to external sync 2941 //pending detect, if remote file has REV field. if not switch to external sync
2937 mGlobalSyncMode = SYNC_MODE_NORMAL; 2942 mGlobalSyncMode = SYNC_MODE_NORMAL;
2938 QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); 2943 QString mCurrentSyncDevice = manager->getCurrentSyncDevice();
2939 2944
2940 AddressBook abLocal(filename,"syncContact"); 2945 AddressBook abLocal(filename,"syncContact");
2941 bool syncOK = false; 2946 bool syncOK = false;
2942 if ( abLocal.load() ) { 2947 if ( abLocal.load() ) {
2943 qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode ); 2948 qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode );
2944 bool external = false; 2949 bool external = false;
2945 bool isXML = false; 2950 bool isXML = false;
2946 if ( filename.right(4) == ".xml") { 2951 if ( filename.right(4) == ".xml") {
2947 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 2952 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
2948 isXML = true; 2953 isXML = true;
2949 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); 2954 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true );
2950 } else { 2955 } else {
2951 external = !manager->mIsKapiFile; 2956 external = !manager->mIsKapiFile;
2952 if ( external ) { 2957 if ( external ) {
2953 qDebug("Setting vcf mode to external "); 2958 qDebug("Setting vcf mode to external ");
2954 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 2959 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
2955 AddressBook::Iterator it; 2960 AddressBook::Iterator it;
2956 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { 2961 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) {
2957 (*it).setID( mCurrentSyncDevice, (*it).uid() ); 2962 (*it).setID( mCurrentSyncDevice, (*it).uid() );
2958 (*it).computeCsum( mCurrentSyncDevice ); 2963 (*it).computeCsum( mCurrentSyncDevice );
2959 } 2964 }
2960 } 2965 }
2961 } 2966 }
2962 //AddressBook::Iterator it; 2967 //AddressBook::Iterator it;
2963 //QStringList vcards; 2968 //QStringList vcards;
2964 //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { 2969 //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) {
2965 // qDebug("Name %s ", (*it).familyName().latin1()); 2970 // qDebug("Name %s ", (*it).familyName().latin1());
2966 //} 2971 //}
2967 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); 2972 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode );
2968 if ( syncOK ) { 2973 if ( syncOK ) {
2969 if ( syncManager->mWriteBackFile ) 2974 if ( syncManager->mWriteBackFile )
2970 { 2975 {
2971 if ( external ) 2976 if ( external )
2972 abLocal.removeSyncAddressees( !isXML); 2977 abLocal.removeSyncAddressees( !isXML);
2973 qDebug("Saving remote AB "); 2978 qDebug("Saving remote AB ");
2974 if ( ! abLocal.saveAB()) 2979 if ( ! abLocal.saveAB())
2975 qDebug("Error writing back AB to file "); 2980 qDebug("Error writing back AB to file ");
2976 if ( external ) { 2981 if ( external ) {
2977 // afterwrite processing 2982 // afterwrite processing
2978 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ,isXML); 2983 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ,isXML);
2979 } 2984 }
2980 } 2985 }
2981 } 2986 }
2982 setModified(); 2987 setModified();
2983 2988
2984 } 2989 }
2985 abLocal.removeResources(); 2990 abLocal.removeResources();
2986 if ( syncOK ) 2991 if ( syncOK )
2987 mViewManager->refreshView(); 2992 mViewManager->refreshView();
2988 return syncOK; 2993 return syncOK;
2989 2994
2990} 2995}
2991void KABCore::removeSyncInfo( QString syncProfile) 2996void KABCore::removeSyncInfo( QString syncProfile)
2992{ 2997{
2993 qDebug("AB:removeSyncInfo for profile %s ", syncProfile.latin1()); 2998 qDebug("AB:removeSyncInfo for profile %s ", syncProfile.latin1());
2994 mAddressBook->removeSyncInfo( syncProfile ); 2999 mAddressBook->removeSyncInfo( syncProfile );
2995 setModified(); 3000 setModified();
2996} 3001}
2997 3002
2998 3003
2999//this is a overwritten callbackmethods from the syncinterface 3004//this is a overwritten callbackmethods from the syncinterface
3000bool KABCore::syncExternal(KSyncManager* manager, QString resource) 3005bool KABCore::syncExternal(KSyncManager* manager, QString resource)
3001{ 3006{
3002 if ( resource == "phone" ) 3007 if ( resource == "phone" )
3003 return syncPhone(); 3008 return syncPhone();
3004 disableBR( true ); 3009 disableBR( true );
3005 QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); 3010 QString mCurrentSyncDevice = manager->getCurrentSyncDevice();
3006 3011
3007 AddressBook abLocal( resource,"syncContact"); 3012 AddressBook abLocal( resource,"syncContact");
3008 bool syncOK = false; 3013 bool syncOK = false;
3009 if ( abLocal.load() ) { 3014 if ( abLocal.load() ) {
3010 qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1()); 3015 qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1());
3011 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 3016 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
3012 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, false ); 3017 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, false );
3013 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); 3018 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs );
3014 if ( syncOK ) { 3019 if ( syncOK ) {
3015 if ( syncManager->mWriteBackFile ) { 3020 if ( syncManager->mWriteBackFile ) {
3016 abLocal.removeSyncAddressees( false ); 3021 abLocal.removeSyncAddressees( false );
3017 abLocal.saveAB(); 3022 abLocal.saveAB();
3018 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true ); 3023 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true );
3019 } 3024 }
3020 } else 3025 } else
3021 message( i18n("Sync cancelled or failed.") ); 3026 message( i18n("Sync cancelled or failed.") );
3022 setModified(); 3027 setModified();
3023 } 3028 }
3024 abLocal.removeResources(); 3029 abLocal.removeResources();
3025 if ( syncOK ) 3030 if ( syncOK )
3026 mViewManager->refreshView(); 3031 mViewManager->refreshView();
3027 disableBR( false ); 3032 disableBR( false );
3028 return syncOK; 3033 return syncOK;
3029 3034
3030} 3035}
3031void KABCore::message( QString m ) 3036void KABCore::message( QString m )
3032{ 3037{
3033 topLevelWidget()->setCaption( m ); 3038 topLevelWidget()->setCaption( m );
3034 mMessageTimer->start( 15000, true ); 3039 mMessageTimer->start( 15000, true );
3035} 3040}
3036bool KABCore::syncPhone() 3041bool KABCore::syncPhone()
3037{ 3042{
3038 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); 3043 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
3039 QString fileName = getPhoneFile(); 3044 QString fileName = getPhoneFile();
3040 if ( !PhoneAccess::readFromPhone( fileName) ) { 3045 if ( !PhoneAccess::readFromPhone( fileName) ) {
3041 message(i18n("Phone access failed!")); 3046 message(i18n("Phone access failed!"));
3042 return false; 3047 return false;
3043 } 3048 }
3044 AddressBook abLocal( fileName,"syncContact"); 3049 AddressBook abLocal( fileName,"syncContact");
3045 bool syncOK = false; 3050 bool syncOK = false;
3046 { 3051 {
3047 abLocal.importFromFile( fileName ); 3052 abLocal.importFromFile( fileName );
3048 qDebug("AB phone loaded ,sync device %s",mCurrentSyncDevice.latin1()); 3053 qDebug("AB phone loaded ,sync device %s",mCurrentSyncDevice.latin1());
3049 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 3054 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
3050 abLocal.preparePhoneSync( mCurrentSyncDevice, true ); 3055 abLocal.preparePhoneSync( mCurrentSyncDevice, true );
3051 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); 3056 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true );
3052 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); 3057 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs );
3053 if ( syncOK ) { 3058 if ( syncOK ) {
3054 if ( syncManager->mWriteBackFile ) { 3059 if ( syncManager->mWriteBackFile ) {
3055 abLocal.removeSyncAddressees( true ); 3060 abLocal.removeSyncAddressees( true );
3056 abLocal.saveABphone( fileName ); 3061 abLocal.saveABphone( fileName );
3057 abLocal.findNewExtIds( fileName, mCurrentSyncDevice ); 3062 abLocal.findNewExtIds( fileName, mCurrentSyncDevice );
3058 //abLocal.preparePhoneSync( mCurrentSyncDevice, false ); 3063 //abLocal.preparePhoneSync( mCurrentSyncDevice, false );
3059 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true ); 3064 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true );
3060 } 3065 }
3061 } 3066 }
3062 setModified(); 3067 setModified();
3063 } 3068 }
3064 abLocal.removeResources(); 3069 abLocal.removeResources();
3065 if ( syncOK ) 3070 if ( syncOK )
3066 mViewManager->refreshView(); 3071 mViewManager->refreshView();
3067 return syncOK; 3072 return syncOK;
3068} 3073}
3069void KABCore::getFile( bool success ) 3074void KABCore::getFile( bool success )
3070{ 3075{
3071 if ( ! success ) { 3076 if ( ! success ) {
3072 message( i18n("Error receiving file. Nothing changed!") ); 3077 message( i18n("Error receiving file. Nothing changed!") );
3073 return; 3078 return;
3074 } 3079 }
3075 int count = mAddressBook->importFromFile( sentSyncFile() , false, true ); 3080 int count = mAddressBook->importFromFile( sentSyncFile() , false, true );
3076 if ( count ) 3081 if ( count )
3077 setModified( true ); 3082 setModified( true );
3078 message( i18n("Pi-Sync successful!") ); 3083 message( i18n("Pi-Sync successful!") );
3079 mViewManager->refreshView(); 3084 mViewManager->refreshView();
3080} 3085}
3081void KABCore::syncFileRequest() 3086void KABCore::syncFileRequest()
3082{ 3087{
3083 if ( KABPrefs::instance()->mPassiveSyncWithDesktop ) { 3088 if ( KABPrefs::instance()->mPassiveSyncWithDesktop ) {
3084 syncManager->slotSyncMenu( 999 ); 3089 syncManager->slotSyncMenu( 999 );
3085 } 3090 }
3086 mAddressBook->export2File( sentSyncFile() ); 3091 mAddressBook->export2File( sentSyncFile() );
3087} 3092}
3088QString KABCore::sentSyncFile() 3093QString KABCore::sentSyncFile()
3089{ 3094{
3090#ifdef DESKTOP_VERSION 3095#ifdef DESKTOP_VERSION
3091 return locateLocal( "tmp", "copysyncab.vcf" ); 3096 return locateLocal( "tmp", "copysyncab.vcf" );
3092#else 3097#else
3093 return QString( "/tmp/copysyncab.vcf" ); 3098 return QString( "/tmp/copysyncab.vcf" );
3094#endif 3099#endif
3095} 3100}
3096 3101
3097void KABCore::setCaptionBack() 3102void KABCore::setCaptionBack()
3098{ 3103{
3099 mMessageTimer->stop(); 3104 mMessageTimer->stop();
3100 topLevelWidget()->setCaption( i18n("KAddressbook/Pi") ); 3105 topLevelWidget()->setCaption( i18n("KAddressbook/Pi") );
3101} 3106}