summaryrefslogtreecommitdiffabout
path: root/kaddressbook
Unidiff
Diffstat (limited to 'kaddressbook') (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/kabcore.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index 4e2523e..033e537 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -467,816 +467,820 @@ void KABCore::toggleBeamReceive( )
467{ 467{
468 if ( mBRdisabled ) 468 if ( mBRdisabled )
469 return; 469 return;
470#ifndef DESKTOP_VERSION 470#ifndef DESKTOP_VERSION
471 if ( infrared ) { 471 if ( infrared ) {
472 qDebug("KA: AB disable BeamReceive "); 472 qDebug("KA: AB disable BeamReceive ");
473 delete infrared; 473 delete infrared;
474 infrared = 0; 474 infrared = 0;
475 mActionBR->setChecked(false); 475 mActionBR->setChecked(false);
476 return; 476 return;
477 } 477 }
478 qDebug("KA: AB enable BeamReceive "); 478 qDebug("KA: AB enable BeamReceive ");
479 mActionBR->setChecked(true); 479 mActionBR->setChecked(true);
480 480
481 infrared = new QCopChannel("QPE/Application/addressbook",this, "channelAB" ) ; 481 infrared = new QCopChannel("QPE/Application/addressbook",this, "channelAB" ) ;
482 QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(receive( const QCString&, const QByteArray& ))); 482 QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(receive( const QCString&, const QByteArray& )));
483#endif 483#endif
484} 484}
485 485
486 486
487void KABCore::disableBR(bool b) 487void KABCore::disableBR(bool b)
488{ 488{
489#ifndef DESKTOP_VERSION 489#ifndef DESKTOP_VERSION
490 if ( b ) { 490 if ( b ) {
491 if ( infrared ) { 491 if ( infrared ) {
492 toggleBeamReceive( ); 492 toggleBeamReceive( );
493 } 493 }
494 mBRdisabled = true; 494 mBRdisabled = true;
495 } else { 495 } else {
496 if ( mBRdisabled ) { 496 if ( mBRdisabled ) {
497 mBRdisabled = false; 497 mBRdisabled = false;
498 //toggleBeamReceive( ); 498 //toggleBeamReceive( );
499 } 499 }
500 } 500 }
501#endif 501#endif
502 502
503} 503}
504void KABCore::recieve( QString fn ) 504void KABCore::recieve( QString fn )
505{ 505{
506 //qDebug("KABCore::recieve "); 506 //qDebug("KABCore::recieve ");
507 int count = mAddressBook->importFromFile( fn, true ); 507 int count = mAddressBook->importFromFile( fn, true );
508 if ( count ) 508 if ( count )
509 setModified( true ); 509 setModified( true );
510 mViewManager->refreshView(); 510 mViewManager->refreshView();
511 message(i18n("%1 contact(s) received!").arg( count )); 511 message(i18n("%1 contact(s) received!").arg( count ));
512 topLevelWidget()->showMaximized(); 512 topLevelWidget()->showMaximized();
513 topLevelWidget()->raise(); 513 topLevelWidget()->raise();
514} 514}
515void KABCore::restoreSettings() 515void KABCore::restoreSettings()
516{ 516{
517 mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce; 517 mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce;
518 518
519 bool state; 519 bool state;
520 520
521 if (mMultipleViewsAtOnce) 521 if (mMultipleViewsAtOnce)
522 state = KABPrefs::instance()->mDetailsPageVisible; 522 state = KABPrefs::instance()->mDetailsPageVisible;
523 else 523 else
524 state = false; 524 state = false;
525 525
526 mActionDetails->setChecked( state ); 526 mActionDetails->setChecked( state );
527 setDetailsVisible( state ); 527 setDetailsVisible( state );
528 528
529 state = KABPrefs::instance()->mJumpButtonBarVisible; 529 state = KABPrefs::instance()->mJumpButtonBarVisible;
530 530
531 mActionJumpBar->setChecked( state ); 531 mActionJumpBar->setChecked( state );
532 setJumpButtonBarVisible( state ); 532 setJumpButtonBarVisible( state );
533/*US 533/*US
534 QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter; 534 QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter;
535 if ( splitterSize.count() == 0 ) { 535 if ( splitterSize.count() == 0 ) {
536 splitterSize.append( width() / 2 ); 536 splitterSize.append( width() / 2 );
537 splitterSize.append( width() / 2 ); 537 splitterSize.append( width() / 2 );
538 } 538 }
539 mMiniSplitter->setSizes( splitterSize ); 539 mMiniSplitter->setSizes( splitterSize );
540 if ( mExtensionBarSplitter ) { 540 if ( mExtensionBarSplitter ) {
541 splitterSize = KABPrefs::instance()->mExtensionsSplitter; 541 splitterSize = KABPrefs::instance()->mExtensionsSplitter;
542 if ( splitterSize.count() == 0 ) { 542 if ( splitterSize.count() == 0 ) {
543 splitterSize.append( width() / 2 ); 543 splitterSize.append( width() / 2 );
544 splitterSize.append( width() / 2 ); 544 splitterSize.append( width() / 2 );
545 } 545 }
546 mExtensionBarSplitter->setSizes( splitterSize ); 546 mExtensionBarSplitter->setSizes( splitterSize );
547 547
548 } 548 }
549*/ 549*/
550 mViewManager->restoreSettings(); 550 mViewManager->restoreSettings();
551 mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField ); 551 mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField );
552 mExtensionManager->restoreSettings(); 552 mExtensionManager->restoreSettings();
553#ifdef DESKTOP_VERSION 553#ifdef DESKTOP_VERSION
554 int wid = width(); 554 int wid = width();
555 if ( wid < 10 ) 555 if ( wid < 10 )
556 wid = 400; 556 wid = 400;
557#else 557#else
558 int wid = QApplication::desktop()->width(); 558 int wid = QApplication::desktop()->width();
559 if ( wid < 640 ) 559 if ( wid < 640 )
560 wid = QApplication::desktop()->height(); 560 wid = QApplication::desktop()->height();
561#endif 561#endif
562 QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter; 562 QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter;
563 if ( true /*splitterSize.count() == 0*/ ) { 563 if ( true /*splitterSize.count() == 0*/ ) {
564 splitterSize.append( wid / 2 ); 564 splitterSize.append( wid / 2 );
565 splitterSize.append( wid / 2 ); 565 splitterSize.append( wid / 2 );
566 } 566 }
567 mMiniSplitter->setSizes( splitterSize ); 567 mMiniSplitter->setSizes( splitterSize );
568 if ( mExtensionBarSplitter ) { 568 if ( mExtensionBarSplitter ) {
569 //splitterSize = KABPrefs::instance()->mExtensionsSplitter; 569 //splitterSize = KABPrefs::instance()->mExtensionsSplitter;
570 if ( true /*splitterSize.count() == 0*/ ) { 570 if ( true /*splitterSize.count() == 0*/ ) {
571 splitterSize.append( wid / 2 ); 571 splitterSize.append( wid / 2 );
572 splitterSize.append( wid / 2 ); 572 splitterSize.append( wid / 2 );
573 } 573 }
574 mExtensionBarSplitter->setSizes( splitterSize ); 574 mExtensionBarSplitter->setSizes( splitterSize );
575 575
576 } 576 }
577#ifdef DESKTOP_VERSION 577#ifdef DESKTOP_VERSION
578 KConfig *config = KABPrefs::instance()->getConfig(); 578 KConfig *config = KABPrefs::instance()->getConfig();
579 config->setGroup("WidgetLayout"); 579 config->setGroup("WidgetLayout");
580 QStringList list; 580 QStringList list;
581 list = config->readListEntry("MainLayout"); 581 list = config->readListEntry("MainLayout");
582 int x,y,w,h; 582 int x,y,w,h;
583 if ( ! list.isEmpty() ) { 583 if ( ! list.isEmpty() ) {
584 x = list[0].toInt(); 584 x = list[0].toInt();
585 y = list[1].toInt(); 585 y = list[1].toInt();
586 w = list[2].toInt(); 586 w = list[2].toInt();
587 h = list[3].toInt(); 587 h = list[3].toInt();
588 KApplication::testCoords( &x,&y,&w,&h ); 588 KApplication::testCoords( &x,&y,&w,&h );
589 topLevelWidget()->setGeometry(x,y,w,h); 589 topLevelWidget()->setGeometry(x,y,w,h);
590 590
591 } else { 591 } else {
592 topLevelWidget()->setGeometry( 40 ,40 , 640, 440); 592 topLevelWidget()->setGeometry( 40 ,40 , 640, 440);
593 } 593 }
594#endif 594#endif
595} 595}
596 596
597void KABCore::saveSettings() 597void KABCore::saveSettings()
598{ 598{
599 KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked(); 599 KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked();
600 if ( mExtensionBarSplitter ) 600 if ( mExtensionBarSplitter )
601 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); 601 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes();
602 KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked(); 602 KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked();
603 KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes(); 603 KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes();
604#ifndef KAB_EMBEDDED 604#ifndef KAB_EMBEDDED
605 605
606 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); 606 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes();
607 KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes(); 607 KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes();
608#endif //KAB_EMBEDDED 608#endif //KAB_EMBEDDED
609 mExtensionManager->saveSettings(); 609 mExtensionManager->saveSettings();
610 mViewManager->saveSettings(); 610 mViewManager->saveSettings();
611 611
612 KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem(); 612 KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem();
613 613
614 KABPrefs::instance()->writeConfig(); 614 KABPrefs::instance()->writeConfig();
615 //qDebug("KA: KABCore::saveSettings() "); 615 //qDebug("KA: KABCore::saveSettings() ");
616} 616}
617 617
618KABC::AddressBook *KABCore::addressBook() const 618KABC::AddressBook *KABCore::addressBook() const
619{ 619{
620 return mAddressBook; 620 return mAddressBook;
621} 621}
622 622
623KConfig *KABCore::config() 623KConfig *KABCore::config()
624{ 624{
625#ifndef KAB_EMBEDDED 625#ifndef KAB_EMBEDDED
626 return KABPrefs::instance()->config(); 626 return KABPrefs::instance()->config();
627#else //KAB_EMBEDDED 627#else //KAB_EMBEDDED
628 return KABPrefs::instance()->getConfig(); 628 return KABPrefs::instance()->getConfig();
629#endif //KAB_EMBEDDED 629#endif //KAB_EMBEDDED
630} 630}
631 631
632KActionCollection *KABCore::actionCollection() const 632KActionCollection *KABCore::actionCollection() const
633{ 633{
634 return mGUIClient->actionCollection(); 634 return mGUIClient->actionCollection();
635} 635}
636 636
637KABC::Field *KABCore::currentSearchField() const 637KABC::Field *KABCore::currentSearchField() const
638{ 638{
639 if (mIncSearchWidget) 639 if (mIncSearchWidget)
640 return mIncSearchWidget->currentField(); 640 return mIncSearchWidget->currentField();
641 else 641 else
642 return 0; 642 return 0;
643} 643}
644 644
645QStringList KABCore::selectedUIDs() const 645QStringList KABCore::selectedUIDs() const
646{ 646{
647 return mViewManager->selectedUids(); 647 return mViewManager->selectedUids();
648} 648}
649 649
650KABC::Resource *KABCore::requestResource( QWidget *parent ) 650KABC::Resource *KABCore::requestResource( QWidget *parent )
651{ 651{
652 QPtrList<KABC::Resource> kabcResources = addressBook()->resources(); 652 QPtrList<KABC::Resource> kabcResources = addressBook()->resources();
653 653
654 QPtrList<KRES::Resource> kresResources; 654 QPtrList<KRES::Resource> kresResources;
655 QPtrListIterator<KABC::Resource> resIt( kabcResources ); 655 QPtrListIterator<KABC::Resource> resIt( kabcResources );
656 KABC::Resource *resource; 656 KABC::Resource *resource;
657 while ( ( resource = resIt.current() ) != 0 ) { 657 while ( ( resource = resIt.current() ) != 0 ) {
658 ++resIt; 658 ++resIt;
659 if ( !resource->readOnly() ) { 659 if ( !resource->readOnly() ) {
660 KRES::Resource *res = static_cast<KRES::Resource*>( resource ); 660 KRES::Resource *res = static_cast<KRES::Resource*>( resource );
661 if ( res ) 661 if ( res )
662 kresResources.append( res ); 662 kresResources.append( res );
663 } 663 }
664 } 664 }
665 665
666 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent ); 666 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent );
667 return static_cast<KABC::Resource*>( res ); 667 return static_cast<KABC::Resource*>( res );
668} 668}
669 669
670#ifndef KAB_EMBEDDED 670#ifndef KAB_EMBEDDED
671KAboutData *KABCore::createAboutData() 671KAboutData *KABCore::createAboutData()
672#else //KAB_EMBEDDED 672#else //KAB_EMBEDDED
673void KABCore::createAboutData() 673void KABCore::createAboutData()
674#endif //KAB_EMBEDDED 674#endif //KAB_EMBEDDED
675{ 675{
676 676
677 677
678 QString version; 678 QString version;
679#include <../version> 679#include <../version>
680 QMessageBox::about( this, "About KAddressbook/Pi", 680 QMessageBox::about( this, "About KAddressbook/Pi",
681 "KAddressbook/Platform-independent\n" 681 "KAddressbook/Platform-independent\n"
682 "(KA/Pi) " +version + " - " + 682 "(KA/Pi) " +version + " - " +
683#ifdef DESKTOP_VERSION 683#ifdef DESKTOP_VERSION
684 "Desktop Edition\n" 684 "Desktop Edition\n"
685#else 685#else
686 "PDA-Edition\n" 686 "PDA-Edition\n"
687 "for: Zaurus 5500 / 7x0 / 8x0\n" 687 "for: Zaurus 5500 / 7x0 / 8x0\n"
688#endif 688#endif
689 689
690 "(c) 2004 Ulf Schenk\n" 690 "(c) 2004 Ulf Schenk\n"
691 "(c) 2004-2005 Lutz Rogowski\nrogowski@kde.org\n" 691 "(c) 2004-2005 Lutz Rogowski\nrogowski@kde.org\n"
692 "(c) 1997-2003, The KDE PIM Team\n" 692 "(c) 1997-2003, The KDE PIM Team\n"
693 "Tobias Koenig Maintainer\n" 693 "Tobias Koenig Maintainer\n"
694 "Don Sanders Original author\n" 694 "Don Sanders Original author\n"
695 "Cornelius Schumacher Co-maintainer\n" 695 "Cornelius Schumacher Co-maintainer\n"
696 "Mike Pilone GUI and framework redesign\n" 696 "Mike Pilone GUI and framework redesign\n"
697 "Greg Stern DCOP interface\n" 697 "Greg Stern DCOP interface\n"
698 "Mark Westcot Contact pinning\n" 698 "Mark Westcot Contact pinning\n"
699 "Michel Boyer de la Giroday LDAP Lookup\n" 699 "Michel Boyer de la Giroday LDAP Lookup\n"
700 "Steffen Hansen LDAP Lookup" 700 "Steffen Hansen LDAP Lookup"
701#ifdef _WIN32_ 701#ifdef _WIN32_
702 "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n" 702 "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n"
703#endif 703#endif
704 ); 704 );
705} 705}
706 706
707void KABCore::setContactSelected( const QString &uid ) 707void KABCore::setContactSelected( const QString &uid )
708{ 708{
709 KABC::Addressee addr = mAddressBook->findByUid( uid ); 709 KABC::Addressee addr = mAddressBook->findByUid( uid );
710 if ( !mDetails->isHidden() ) 710 if ( !mDetails->isHidden() )
711 mDetails->setAddressee( addr ); 711 mDetails->setAddressee( addr );
712 712
713 if ( !addr.isEmpty() ) { 713 if ( !addr.isEmpty() ) {
714 emit contactSelected( addr.formattedName() ); 714 emit contactSelected( addr.formattedName() );
715 KABC::Picture pic = addr.photo(); 715 KABC::Picture pic = addr.photo();
716 if ( pic.isIntern() ) { 716 if ( pic.isIntern() ) {
717//US emit contactSelected( pic.data() ); 717//US emit contactSelected( pic.data() );
718//US instead use: 718//US instead use:
719 QPixmap px; 719 QPixmap px;
720 if (pic.data().isNull() != true) 720 if (pic.data().isNull() != true)
721 { 721 {
722 px.convertFromImage(pic.data()); 722 px.convertFromImage(pic.data());
723 } 723 }
724 724
725 emit contactSelected( px ); 725 emit contactSelected( px );
726 } 726 }
727 } 727 }
728 728
729 729
730 mExtensionManager->setSelectionChanged(); 730 mExtensionManager->setSelectionChanged();
731 731
732 // update the actions 732 // update the actions
733 bool selected = !uid.isEmpty(); 733 bool selected = !uid.isEmpty();
734 734
735 if ( mReadWrite ) { 735 if ( mReadWrite ) {
736 mActionCut->setEnabled( selected ); 736 mActionCut->setEnabled( selected );
737 mActionPaste->setEnabled( selected ); 737 mActionPaste->setEnabled( selected );
738 } 738 }
739 739
740 mActionCopy->setEnabled( selected ); 740 mActionCopy->setEnabled( selected );
741 mActionDelete->setEnabled( selected ); 741 mActionDelete->setEnabled( selected );
742 mActionEditAddressee->setEnabled( selected ); 742 mActionEditAddressee->setEnabled( selected );
743 mActionMail->setEnabled( selected ); 743 mActionMail->setEnabled( selected );
744 mActionMailVCard->setEnabled( selected ); 744 mActionMailVCard->setEnabled( selected );
745 //if (mActionBeam) 745 //if (mActionBeam)
746 //mActionBeam->setEnabled( selected ); 746 //mActionBeam->setEnabled( selected );
747 mActionWhoAmI->setEnabled( selected ); 747 mActionWhoAmI->setEnabled( selected );
748} 748}
749 749
750void KABCore::sendMail() 750void KABCore::sendMail()
751{ 751{
752 sendMail( mViewManager->selectedEmails().join( ", " ) ); 752 sendMail( mViewManager->selectedEmails().join( ", " ) );
753} 753}
754 754
755void KABCore::sendMail( const QString& emaillist ) 755void KABCore::sendMail( const QString& emaillist )
756{ 756{
757 // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... " 757 // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... "
758 if (emaillist.contains(",") > 0) 758 if (emaillist.contains(",") > 0)
759 ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null ); 759 ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null );
760 else 760 else
761 ExternalAppHandler::instance()->mailToOneContact( emaillist ); 761 ExternalAppHandler::instance()->mailToOneContact( emaillist );
762} 762}
763 763
764 764
765 765
766void KABCore::mailVCard() 766void KABCore::mailVCard()
767{ 767{
768 QStringList uids = mViewManager->selectedUids(); 768 QStringList uids = mViewManager->selectedUids();
769 if ( !uids.isEmpty() ) 769 if ( !uids.isEmpty() )
770 mailVCard( uids ); 770 mailVCard( uids );
771} 771}
772 772
773void KABCore::mailVCard( const QStringList& uids ) 773void KABCore::mailVCard( const QStringList& uids )
774{ 774{
775 QStringList urls; 775 QStringList urls;
776 776
777// QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); 777// QString tmpdir = locateLocal("tmp", KGlobal::getAppName());
778 778
779 QString dirName = "/tmp/" + KApplication::randomString( 8 ); 779 QString dirName = "/tmp/" + KApplication::randomString( 8 );
780 780
781 781
782 782
783 QDir().mkdir( dirName, true ); 783 QDir().mkdir( dirName, true );
784 784
785 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { 785 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) {
786 KABC::Addressee a = mAddressBook->findByUid( *it ); 786 KABC::Addressee a = mAddressBook->findByUid( *it );
787 787
788 if ( a.isEmpty() ) 788 if ( a.isEmpty() )
789 continue; 789 continue;
790 790
791 QString name = a.givenName() + "_" + a.familyName() + ".vcf"; 791 QString name = a.givenName() + "_" + a.familyName() + ".vcf";
792 792
793 QString fileName = dirName + "/" + name; 793 QString fileName = dirName + "/" + name;
794 794
795 QFile outFile(fileName); 795 QFile outFile(fileName);
796 796
797 if ( outFile.open(IO_WriteOnly) ) { // file opened successfully 797 if ( outFile.open(IO_WriteOnly) ) { // file opened successfully
798 KABC::VCardConverter converter; 798 KABC::VCardConverter converter;
799 QString vcard; 799 QString vcard;
800 800
801 converter.addresseeToVCard( a, vcard ); 801 converter.addresseeToVCard( a, vcard );
802 802
803 QTextStream t( &outFile ); // use a text stream 803 QTextStream t( &outFile ); // use a text stream
804 t.setEncoding( QTextStream::UnicodeUTF8 ); 804 t.setEncoding( QTextStream::UnicodeUTF8 );
805 t << vcard; 805 t << vcard;
806 806
807 outFile.close(); 807 outFile.close();
808 808
809 urls.append( fileName ); 809 urls.append( fileName );
810 } 810 }
811 } 811 }
812 812
813 bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") ); 813 bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") );
814 814
815 815
816/*US 816/*US
817 kapp->invokeMailer( QString::null, QString::null, QString::null, 817 kapp->invokeMailer( QString::null, QString::null, QString::null,
818 QString::null, // subject 818 QString::null, // subject
819 QString::null, // body 819 QString::null, // body
820 QString::null, 820 QString::null,
821 urls ); // attachments 821 urls ); // attachments
822*/ 822*/
823 823
824} 824}
825 825
826/** 826/**
827 Beams the "WhoAmI contact. 827 Beams the "WhoAmI contact.
828*/ 828*/
829void KABCore::beamMySelf() 829void KABCore::beamMySelf()
830{ 830{
831 KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI(); 831 KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI();
832 if (!a.isEmpty()) 832 if (!a.isEmpty())
833 { 833 {
834 QStringList uids; 834 QStringList uids;
835 uids << a.uid(); 835 uids << a.uid();
836 836
837 beamVCard(uids); 837 beamVCard(uids);
838 } else { 838 } else {
839 KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) ); 839 KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) );
840 840
841 841
842 } 842 }
843} 843}
844void KABCore::updateMainWindow() 844void KABCore::updateMainWindow()
845{ 845{
846 mMainWindow->showMaximized(); 846 mMainWindow->showMaximized();
847 //mMainWindow->repaint(); 847 //mMainWindow->repaint();
848} 848}
849void KABCore::resizeEvent(QResizeEvent* e ) 849void KABCore::resizeEvent(QResizeEvent* e )
850{ 850{
851 if ( !mMiniSplitter ) 851 if ( !mMiniSplitter ) {
852 QWidget::resizeEvent( e );
852 return; 853 return;
854 }
855#ifndef DESKTOP_VERSION
853 static int desktop_width = 0; 856 static int desktop_width = 0;
854 //qDebug("KABCore::resizeEvent %d %d ",desktop_width,QApplication::desktop()->width() ); 857 //qDebug("KABCore::resizeEvent %d %d ",desktop_width,QApplication::desktop()->width() );
855 if ( desktop_width != QApplication::desktop()->width() ) 858 if ( desktop_width != QApplication::desktop()->width() )
856 if ( QApplication::desktop()->width() >= 480 ) { 859 if ( QApplication::desktop()->width() >= 480 ) {
857 if (QApplication::desktop()->width() == 640 ) { // e.g. 640x480 860 if (QApplication::desktop()->width() == 640 ) { // e.g. 640x480
858 //qDebug("640 "); 861 //qDebug("640 ");
859 if ( mMiniSplitter->orientation() == Qt::Vertical ) { 862 if ( mMiniSplitter->orientation() == Qt::Vertical ) {
860 //qDebug("switch V->H "); 863 //qDebug("switch V->H ");
861 mMiniSplitter->setOrientation( Qt::Horizontal); 864 mMiniSplitter->setOrientation( Qt::Horizontal);
862 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); 865 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right );
863 } 866 }
864 if ( QApplication::desktop()->width() <= 640 ) { 867 if ( QApplication::desktop()->width() <= 640 ) {
865 bool shot = mMainWindow->isVisible(); 868 bool shot = mMainWindow->isVisible();
866 mMainWindow->showMinimized(); 869 mMainWindow->showMinimized();
867 //mMainWindow->setMaximumSize( QApplication::desktop()->size() ); 870 //mMainWindow->setMaximumSize( QApplication::desktop()->size() );
868 mViewManager->getFilterAction()->setComboWidth( 150 ); 871 mViewManager->getFilterAction()->setComboWidth( 150 );
869 if ( mIncSearchWidget ) 872 if ( mIncSearchWidget )
870 mIncSearchWidget->setSize(); 873 mIncSearchWidget->setSize();
871 if ( shot ) 874 if ( shot )
872 QTimer::singleShot( 1, this , SLOT ( updateMainWindow())); 875 QTimer::singleShot( 1, this , SLOT ( updateMainWindow()));
873 } 876 }
874 877
875 } else if (QApplication::desktop()->width() == 480 ){// e.g. 480x640 878 } else if (QApplication::desktop()->width() == 480 ){// e.g. 480x640
876 //qDebug("480 "); 879 //qDebug("480 ");
877 if ( mMiniSplitter->orientation() == Qt::Horizontal ) { 880 if ( mMiniSplitter->orientation() == Qt::Horizontal ) {
878 //qDebug("switch H->V "); 881 //qDebug("switch H->V ");
879 mMiniSplitter->setOrientation( Qt::Vertical ); 882 mMiniSplitter->setOrientation( Qt::Vertical );
880 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); 883 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down );
881 } 884 }
882 if ( QApplication::desktop()->width() <= 640 ) { 885 if ( QApplication::desktop()->width() <= 640 ) {
883 //mMainWindow->setMaximumSize( QApplication::desktop()->size() ); 886 //mMainWindow->setMaximumSize( QApplication::desktop()->size() );
884 bool shot = mMainWindow->isVisible(); 887 bool shot = mMainWindow->isVisible();
885 mMainWindow->showMinimized(); 888 mMainWindow->showMinimized();
886 if ( KABPrefs::instance()->mHideSearchOnSwitch ) { 889 if ( KABPrefs::instance()->mHideSearchOnSwitch ) {
887 if ( mIncSearchWidget ) { 890 if ( mIncSearchWidget ) {
888 mIncSearchWidget->setSize(); 891 mIncSearchWidget->setSize();
889 } 892 }
890 } else { 893 } else {
891 mViewManager->getFilterAction()->setComboWidth( 0 ); 894 mViewManager->getFilterAction()->setComboWidth( 0 );
892 } 895 }
893 if ( shot ) 896 if ( shot )
894 QTimer::singleShot( 1, this , SLOT ( updateMainWindow())); 897 QTimer::singleShot( 1, this , SLOT ( updateMainWindow()));
895 } 898 }
896 } 899 }
897 } 900 }
898 desktop_width = QApplication::desktop()->width(); 901 desktop_width = QApplication::desktop()->width();
902#endif
899 QWidget::resizeEvent( e ); 903 QWidget::resizeEvent( e );
900 904
901} 905}
902void KABCore::export2phone() 906void KABCore::export2phone()
903{ 907{
904 908
905 QStringList uids; 909 QStringList uids;
906 XXPortSelectDialog dlg( this, false, this ); 910 XXPortSelectDialog dlg( this, false, this );
907 if ( dlg.exec() ) 911 if ( dlg.exec() )
908 uids = dlg.uids(); 912 uids = dlg.uids();
909 else 913 else
910 return; 914 return;
911 if ( uids.isEmpty() ) 915 if ( uids.isEmpty() )
912 return; 916 return;
913 // qDebug("count %d ", uids.count()); 917 // qDebug("count %d ", uids.count());
914 918
915 KAex2phonePrefs ex2phone; 919 KAex2phonePrefs ex2phone;
916 ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); 920 ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection );
917 ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); 921 ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice );
918 ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); 922 ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel );
919 923
920 if ( !ex2phone.exec() ) { 924 if ( !ex2phone.exec() ) {
921 return; 925 return;
922 } 926 }
923 KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); 927 KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text();
924 KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); 928 KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text();
925 KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); 929 KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text();
926 930
927 931
928 PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, 932 PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice,
929 KPimGlobalPrefs::instance()->mEx2PhoneConnection, 933 KPimGlobalPrefs::instance()->mEx2PhoneConnection,
930 KPimGlobalPrefs::instance()->mEx2PhoneModel ); 934 KPimGlobalPrefs::instance()->mEx2PhoneModel );
931 935
932 QString fileName = getPhoneFile(); 936 QString fileName = getPhoneFile();
933 if ( ! mAddressBook->export2PhoneFormat( uids ,fileName ) ) 937 if ( ! mAddressBook->export2PhoneFormat( uids ,fileName ) )
934 return; 938 return;
935 939
936 message(i18n("Exporting to phone...")); 940 message(i18n("Exporting to phone..."));
937 QTimer::singleShot( 1, this , SLOT ( writeToPhone())); 941 QTimer::singleShot( 1, this , SLOT ( writeToPhone()));
938 942
939} 943}
940QString KABCore::getPhoneFile() 944QString KABCore::getPhoneFile()
941{ 945{
942#ifdef DESKTOP_VERSION 946#ifdef DESKTOP_VERSION
943 return locateLocal("tmp", "phonefile.vcf"); 947 return locateLocal("tmp", "phonefile.vcf");
944#else 948#else
945 return "/tmp/phonefile.vcf"; 949 return "/tmp/phonefile.vcf";
946#endif 950#endif
947 951
948} 952}
949void KABCore::writeToPhone( ) 953void KABCore::writeToPhone( )
950{ 954{
951 if ( PhoneAccess::writeToPhone( getPhoneFile() ) ) 955 if ( PhoneAccess::writeToPhone( getPhoneFile() ) )
952 message(i18n("Export to phone finished!")); 956 message(i18n("Export to phone finished!"));
953 else 957 else
954 qDebug(i18n("KA: Error exporting to phone")); 958 qDebug(i18n("KA: Error exporting to phone"));
955} 959}
956void KABCore::beamVCard() 960void KABCore::beamVCard()
957{ 961{
958 QStringList uids; 962 QStringList uids;
959 XXPortSelectDialog dlg( this, false, this ); 963 XXPortSelectDialog dlg( this, false, this );
960 if ( dlg.exec() ) 964 if ( dlg.exec() )
961 uids = dlg.uids(); 965 uids = dlg.uids();
962 else 966 else
963 return; 967 return;
964 if ( uids.isEmpty() ) 968 if ( uids.isEmpty() )
965 return; 969 return;
966 beamVCard( uids ); 970 beamVCard( uids );
967} 971}
968 972
969 973
970void KABCore::beamVCard(const QStringList& uids) 974void KABCore::beamVCard(const QStringList& uids)
971{ 975{
972 976
973 // LR: we should use the /tmp dir on the Zaurus, 977 // LR: we should use the /tmp dir on the Zaurus,
974 // because: /tmp = RAM, (HOME)/kdepim = flash memory 978 // because: /tmp = RAM, (HOME)/kdepim = flash memory
975 979
976#ifdef DESKTOP_VERSION 980#ifdef DESKTOP_VERSION
977 QString fileName = locateLocal("tmp", "kapibeamfile.vcf"); 981 QString fileName = locateLocal("tmp", "kapibeamfile.vcf");
978#else 982#else
979 QString fileName = "/tmp/kapibeamfile.vcf"; 983 QString fileName = "/tmp/kapibeamfile.vcf";
980#endif 984#endif
981 985
982 KABC::VCardConverter converter; 986 KABC::VCardConverter converter;
983 QString description; 987 QString description;
984 QString datastream; 988 QString datastream;
985 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { 989 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) {
986 KABC::Addressee a = mAddressBook->findByUid( *it ); 990 KABC::Addressee a = mAddressBook->findByUid( *it );
987 991
988 if ( a.isEmpty() ) 992 if ( a.isEmpty() )
989 continue; 993 continue;
990 994
991 if (description.isEmpty()) 995 if (description.isEmpty())
992 description = a.formattedName(); 996 description = a.formattedName();
993 997
994 QString vcard; 998 QString vcard;
995 converter.addresseeToVCard( a, vcard ); 999 converter.addresseeToVCard( a, vcard );
996 int start = 0; 1000 int start = 0;
997 int next; 1001 int next;
998 while ( (next = vcard.find("TYPE=", start) )>= 0 ) { 1002 while ( (next = vcard.find("TYPE=", start) )>= 0 ) {
999 int semi = vcard.find(";", next); 1003 int semi = vcard.find(";", next);
1000 int dopp = vcard.find(":", next); 1004 int dopp = vcard.find(":", next);
1001 int sep; 1005 int sep;
1002 if ( semi < dopp && semi >= 0 ) 1006 if ( semi < dopp && semi >= 0 )
1003 sep = semi ; 1007 sep = semi ;
1004 else 1008 else
1005 sep = dopp; 1009 sep = dopp;
1006 datastream +=vcard.mid( start, next - start); 1010 datastream +=vcard.mid( start, next - start);
1007 datastream +=vcard.mid( next+5,sep -next -5 ).upper(); 1011 datastream +=vcard.mid( next+5,sep -next -5 ).upper();
1008 start = sep; 1012 start = sep;
1009 } 1013 }
1010 datastream += vcard.mid( start,vcard.length() ); 1014 datastream += vcard.mid( start,vcard.length() );
1011 } 1015 }
1012#ifndef DESKTOP_VERSION 1016#ifndef DESKTOP_VERSION
1013 QFile outFile(fileName); 1017 QFile outFile(fileName);
1014 if ( outFile.open(IO_WriteOnly) ) { 1018 if ( outFile.open(IO_WriteOnly) ) {
1015 datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); 1019 datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" );
1016 QTextStream t( &outFile ); // use a text stream 1020 QTextStream t( &outFile ); // use a text stream
1017 //t.setEncoding( QTextStream::UnicodeUTF8 ); 1021 //t.setEncoding( QTextStream::UnicodeUTF8 );
1018 t.setEncoding( QTextStream::Latin1 ); 1022 t.setEncoding( QTextStream::Latin1 );
1019 t <<datastream.latin1(); 1023 t <<datastream.latin1();
1020 outFile.close(); 1024 outFile.close();
1021 Ir *ir = new Ir( this ); 1025 Ir *ir = new Ir( this );
1022 connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); 1026 connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) );
1023 ir->send( fileName, description, "text/x-vCard" ); 1027 ir->send( fileName, description, "text/x-vCard" );
1024 } else { 1028 } else {
1025 qDebug("KA: Error open temp beam file "); 1029 qDebug("KA: Error open temp beam file ");
1026 return; 1030 return;
1027 } 1031 }
1028#endif 1032#endif
1029 1033
1030} 1034}
1031 1035
1032void KABCore::beamDone( Ir *ir ) 1036void KABCore::beamDone( Ir *ir )
1033{ 1037{
1034#ifndef DESKTOP_VERSION 1038#ifndef DESKTOP_VERSION
1035 delete ir; 1039 delete ir;
1036#endif 1040#endif
1037 topLevelWidget()->raise(); 1041 topLevelWidget()->raise();
1038 message( i18n("Beaming finished!") ); 1042 message( i18n("Beaming finished!") );
1039} 1043}
1040 1044
1041 1045
1042void KABCore::browse( const QString& url ) 1046void KABCore::browse( const QString& url )
1043{ 1047{
1044#ifndef KAB_EMBEDDED 1048#ifndef KAB_EMBEDDED
1045 kapp->invokeBrowser( url ); 1049 kapp->invokeBrowser( url );
1046#else //KAB_EMBEDDED 1050#else //KAB_EMBEDDED
1047 qDebug("KABCore::browse must be fixed"); 1051 qDebug("KABCore::browse must be fixed");
1048#endif //KAB_EMBEDDED 1052#endif //KAB_EMBEDDED
1049} 1053}
1050 1054
1051void KABCore::selectAllContacts() 1055void KABCore::selectAllContacts()
1052{ 1056{
1053 mViewManager->setSelected( QString::null, true ); 1057 mViewManager->setSelected( QString::null, true );
1054} 1058}
1055 1059
1056void KABCore::deleteContacts() 1060void KABCore::deleteContacts()
1057{ 1061{
1058 QStringList uidList = mViewManager->selectedUids(); 1062 QStringList uidList = mViewManager->selectedUids();
1059 deleteContacts( uidList ); 1063 deleteContacts( uidList );
1060} 1064}
1061 1065
1062void KABCore::deleteContacts( const QStringList &uids ) 1066void KABCore::deleteContacts( const QStringList &uids )
1063{ 1067{
1064 1068
1065 if ( uids.count() > 0 ) { 1069 if ( uids.count() > 0 ) {
1066 1070
1067 if ( KABPrefs::instance()->mAskForDelete ) { 1071 if ( KABPrefs::instance()->mAskForDelete ) {
1068 int count = uids.count(); 1072 int count = uids.count();
1069 if ( count > 5 ) count = 5; 1073 if ( count > 5 ) count = 5;
1070 QString cNames; 1074 QString cNames;
1071 int i; 1075 int i;
1072 for ( i = 0; i < count ; ++i ) { 1076 for ( i = 0; i < count ; ++i ) {
1073 cNames += KGlobal::formatMessage( mAddressBook->findByUid( uids[i] ).realName() ,0) + "\n"; 1077 cNames += KGlobal::formatMessage( mAddressBook->findByUid( uids[i] ).realName() ,0) + "\n";
1074 } 1078 }
1075 if ( uids.count() > 5 ) 1079 if ( uids.count() > 5 )
1076 cNames += i18n("...and %1 more\ncontact(s) selected").arg( uids.count() - 5 ); 1080 cNames += i18n("...and %1 more\ncontact(s) selected").arg( uids.count() - 5 );
1077 QString text = i18n( "Do you really\nwant to delete the\nsetected contact(s)?\n\n" ) + cNames ; 1081 QString text = i18n( "Do you really\nwant to delete the\nsetected contact(s)?\n\n" ) + cNames ;
1078 if ( KMessageBox::questionYesNo( this, text ) != KMessageBox::Yes ) 1082 if ( KMessageBox::questionYesNo( this, text ) != KMessageBox::Yes )
1079 return; 1083 return;
1080 } 1084 }
1081 PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids ); 1085 PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids );
1082 UndoStack::instance()->push( command ); 1086 UndoStack::instance()->push( command );
1083 RedoStack::instance()->clear(); 1087 RedoStack::instance()->clear();
1084 1088
1085 // now if we deleted anything, refresh 1089 // now if we deleted anything, refresh
1086 setContactSelected( QString::null ); 1090 setContactSelected( QString::null );
1087 setModified( true ); 1091 setModified( true );
1088 } 1092 }
1089} 1093}
1090 1094
1091void KABCore::copyContacts() 1095void KABCore::copyContacts()
1092{ 1096{
1093 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 1097 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
1094 1098
1095 QString clipText = AddresseeUtil::addresseesToClipboard( addrList ); 1099 QString clipText = AddresseeUtil::addresseesToClipboard( addrList );
1096 1100
1097 kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl; 1101 kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl;
1098 1102
1099 QClipboard *cb = QApplication::clipboard(); 1103 QClipboard *cb = QApplication::clipboard();
1100 cb->setText( clipText ); 1104 cb->setText( clipText );
1101} 1105}
1102 1106
1103void KABCore::cutContacts() 1107void KABCore::cutContacts()
1104{ 1108{
1105 QStringList uidList = mViewManager->selectedUids(); 1109 QStringList uidList = mViewManager->selectedUids();
1106 1110
1107//US if ( uidList.size() > 0 ) { 1111//US if ( uidList.size() > 0 ) {
1108 if ( uidList.count() > 0 ) { 1112 if ( uidList.count() > 0 ) {
1109 PwCutCommand *command = new PwCutCommand( mAddressBook, uidList ); 1113 PwCutCommand *command = new PwCutCommand( mAddressBook, uidList );
1110 UndoStack::instance()->push( command ); 1114 UndoStack::instance()->push( command );
1111 RedoStack::instance()->clear(); 1115 RedoStack::instance()->clear();
1112 1116
1113 setModified( true ); 1117 setModified( true );
1114 } 1118 }
1115} 1119}
1116 1120
1117void KABCore::pasteContacts() 1121void KABCore::pasteContacts()
1118{ 1122{
1119 QClipboard *cb = QApplication::clipboard(); 1123 QClipboard *cb = QApplication::clipboard();
1120 1124
1121 KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() ); 1125 KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() );
1122 1126
1123 pasteContacts( list ); 1127 pasteContacts( list );
1124} 1128}
1125 1129
1126void KABCore::pasteContacts( KABC::Addressee::List &list ) 1130void KABCore::pasteContacts( KABC::Addressee::List &list )
1127{ 1131{
1128 KABC::Resource *resource = requestResource( this ); 1132 KABC::Resource *resource = requestResource( this );
1129 KABC::Addressee::List::Iterator it; 1133 KABC::Addressee::List::Iterator it;
1130 for ( it = list.begin(); it != list.end(); ++it ) 1134 for ( it = list.begin(); it != list.end(); ++it )
1131 (*it).setResource( resource ); 1135 (*it).setResource( resource );
1132 1136
1133 PwPasteCommand *command = new PwPasteCommand( this, list ); 1137 PwPasteCommand *command = new PwPasteCommand( this, list );
1134 UndoStack::instance()->push( command ); 1138 UndoStack::instance()->push( command );
1135 RedoStack::instance()->clear(); 1139 RedoStack::instance()->clear();
1136 1140
1137 setModified( true ); 1141 setModified( true );
1138} 1142}
1139 1143
1140void KABCore::setWhoAmI() 1144void KABCore::setWhoAmI()
1141{ 1145{
1142 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 1146 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
1143 1147
1144 if ( addrList.count() > 1 ) { 1148 if ( addrList.count() > 1 ) {
1145 KMessageBox::sorry( this, i18n( "Please select only one contact." ) ); 1149 KMessageBox::sorry( this, i18n( "Please select only one contact." ) );
1146 return; 1150 return;
1147 } 1151 }
1148 1152
1149 QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) ); 1153 QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) );
1150 if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].realName() ) ) == KMessageBox::Yes ) 1154 if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].realName() ) ) == KMessageBox::Yes )
1151 static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] ); 1155 static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] );
1152} 1156}
1153void KABCore::editCategories() 1157void KABCore::editCategories()
1154{ 1158{
1155 KPIM::CategoryEditDialog dlg ( KABPrefs::instance(), this, "", true ); 1159 KPIM::CategoryEditDialog dlg ( KABPrefs::instance(), this, "", true );
1156 dlg.exec(); 1160 dlg.exec();
1157} 1161}
1158void KABCore::setCategories() 1162void KABCore::setCategories()
1159{ 1163{
1160 1164
1161 QStringList uids; 1165 QStringList uids;
1162 XXPortSelectDialog dlgx( this, false, this ); 1166 XXPortSelectDialog dlgx( this, false, this );
1163 if ( dlgx.exec() ) 1167 if ( dlgx.exec() )
1164 uids = dlgx.uids(); 1168 uids = dlgx.uids();
1165 else 1169 else
1166 return; 1170 return;
1167 if ( uids.isEmpty() ) 1171 if ( uids.isEmpty() )
1168 return; 1172 return;
1169 // qDebug("count %d ", uids.count()); 1173 // qDebug("count %d ", uids.count());
1170 1174
1171 1175
1172 KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true ); 1176 KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true );
1173 if ( !dlg.exec() ) { 1177 if ( !dlg.exec() ) {
1174 message( i18n("Setting categories cancelled") ); 1178 message( i18n("Setting categories cancelled") );
1175 return; 1179 return;
1176 } 1180 }
1177 bool merge = false; 1181 bool merge = false;
1178 QString msg = i18n( "Merge with existing categories?" ); 1182 QString msg = i18n( "Merge with existing categories?" );
1179 if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes ) 1183 if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes )
1180 merge = true; 1184 merge = true;
1181 1185
1182 message( i18n("Setting categories ... please wait!") ); 1186 message( i18n("Setting categories ... please wait!") );
1183 QStringList categories = dlg.selectedCategories(); 1187 QStringList categories = dlg.selectedCategories();
1184 1188
1185 //QStringList uids = mViewManager->selectedUids(); 1189 //QStringList uids = mViewManager->selectedUids();
1186 QStringList::Iterator it; 1190 QStringList::Iterator it;
1187 for ( it = uids.begin(); it != uids.end(); ++it ) { 1191 for ( it = uids.begin(); it != uids.end(); ++it ) {
1188 KABC::Addressee addr = mAddressBook->findByUid( *it ); 1192 KABC::Addressee addr = mAddressBook->findByUid( *it );
1189 if ( !addr.isEmpty() ) { 1193 if ( !addr.isEmpty() ) {
1190 if ( !merge ) 1194 if ( !merge )
1191 addr.setCategories( categories ); 1195 addr.setCategories( categories );
1192 else { 1196 else {
1193 QStringList addrCategories = addr.categories(); 1197 QStringList addrCategories = addr.categories();
1194 QStringList::Iterator catIt; 1198 QStringList::Iterator catIt;
1195 for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) { 1199 for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) {
1196 if ( !addrCategories.contains( *catIt ) ) 1200 if ( !addrCategories.contains( *catIt ) )
1197 addrCategories.append( *catIt ); 1201 addrCategories.append( *catIt );
1198 } 1202 }
1199 addr.setCategories( addrCategories ); 1203 addr.setCategories( addrCategories );
1200 } 1204 }
1201 mAddressBook->insertAddressee( addr ); 1205 mAddressBook->insertAddressee( addr );
1202 } 1206 }
1203 } 1207 }
1204 1208
1205 if ( uids.count() > 0 ) 1209 if ( uids.count() > 0 )
1206 setModified( true ); 1210 setModified( true );
1207 message( i18n("Setting categories completed!") ); 1211 message( i18n("Setting categories completed!") );
1208} 1212}
1209 1213
1210void KABCore::setSearchFields( const KABC::Field::List &fields ) 1214void KABCore::setSearchFields( const KABC::Field::List &fields )
1211{ 1215{
1212 mIncSearchWidget->setFields( fields ); 1216 mIncSearchWidget->setFields( fields );
1213} 1217}
1214 1218
1215void KABCore::incrementalSearch( const QString& text ) 1219void KABCore::incrementalSearch( const QString& text )
1216{ 1220{
1217 QString stext; 1221 QString stext;
1218 if ( KABPrefs::instance()->mAutoSearchWithWildcard ) { 1222 if ( KABPrefs::instance()->mAutoSearchWithWildcard ) {
1219 stext = "*" + text; 1223 stext = "*" + text;
1220 } else { 1224 } else {
1221 stext = text; 1225 stext = text;
1222 } 1226 }
1223 mViewManager->doSearch( stext, mIncSearchWidget->currentField() ); 1227 mViewManager->doSearch( stext, mIncSearchWidget->currentField() );
1224} 1228}
1225void KABCore::incrementalSearchJump( const QString& text ) 1229void KABCore::incrementalSearchJump( const QString& text )
1226{ 1230{
1227 mViewManager->doSearch( text, mIncSearchWidget->currentField() ); 1231 mViewManager->doSearch( text, mIncSearchWidget->currentField() );
1228} 1232}
1229 1233
1230void KABCore::setModified() 1234void KABCore::setModified()
1231{ 1235{
1232 setModified( true ); 1236 setModified( true );
1233} 1237}
1234 1238
1235void KABCore::setModifiedWOrefresh() 1239void KABCore::setModifiedWOrefresh()
1236{ 1240{
1237 // qDebug("KABCore::setModifiedWOrefresh() "); 1241 // qDebug("KABCore::setModifiedWOrefresh() ");
1238 mModified = true; 1242 mModified = true;
1239 mActionSave->setEnabled( mModified ); 1243 mActionSave->setEnabled( mModified );
1240 1244
1241 1245
1242} 1246}
1243void KABCore::setModified( bool modified ) 1247void KABCore::setModified( bool modified )
1244{ 1248{
1245 mModified = modified; 1249 mModified = modified;
1246 mActionSave->setEnabled( mModified ); 1250 mActionSave->setEnabled( mModified );
1247 1251
1248 if ( modified ) 1252 if ( modified )
1249 mJumpButtonBar->recreateButtons(); 1253 mJumpButtonBar->recreateButtons();
1250 1254
1251 mViewManager->refreshView(); 1255 mViewManager->refreshView();
1252 1256
1253} 1257}
1254 1258
1255bool KABCore::modified() const 1259bool KABCore::modified() const
1256{ 1260{
1257 return mModified; 1261 return mModified;
1258} 1262}
1259 1263
1260void KABCore::contactModified( const KABC::Addressee &addr ) 1264void KABCore::contactModified( const KABC::Addressee &addr )
1261{ 1265{
1262 addrModified( addr ); 1266 addrModified( addr );
1263#if 0 // debug only 1267#if 0 // debug only
1264 KABC::Addressee ad = addr; 1268 KABC::Addressee ad = addr;
1265 ad.computeCsum( "123"); 1269 ad.computeCsum( "123");
1266#endif 1270#endif
1267} 1271}
1268 1272
1269void KABCore::addrModified( const KABC::Addressee &addr ,bool updateDetails ) 1273void KABCore::addrModified( const KABC::Addressee &addr ,bool updateDetails )
1270{ 1274{
1271 1275
1272 Command *command = 0; 1276 Command *command = 0;
1273 QString uid; 1277 QString uid;
1274 1278
1275 // check if it exists already 1279 // check if it exists already
1276 KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() ); 1280 KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() );
1277 if ( origAddr.isEmpty() ) 1281 if ( origAddr.isEmpty() )
1278 command = new PwNewCommand( mAddressBook, addr ); 1282 command = new PwNewCommand( mAddressBook, addr );
1279 else { 1283 else {
1280 command = new PwEditCommand( mAddressBook, origAddr, addr ); 1284 command = new PwEditCommand( mAddressBook, origAddr, addr );
1281 uid = addr.uid(); 1285 uid = addr.uid();
1282 } 1286 }