summaryrefslogtreecommitdiffabout
path: root/kaddressbook
Unidiff
Diffstat (limited to 'kaddressbook') (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/kabcore.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index 5cd9649..6538295 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -448,385 +448,385 @@ void KABCore::setContactSelected( const QString &uid )
448 mDetails->setAddressee( addr ); 448 mDetails->setAddressee( addr );
449 449
450 if ( !addr.isEmpty() ) { 450 if ( !addr.isEmpty() ) {
451 emit contactSelected( addr.formattedName() ); 451 emit contactSelected( addr.formattedName() );
452 KABC::Picture pic = addr.photo(); 452 KABC::Picture pic = addr.photo();
453 if ( pic.isIntern() ) { 453 if ( pic.isIntern() ) {
454//US emit contactSelected( pic.data() ); 454//US emit contactSelected( pic.data() );
455//US instead use: 455//US instead use:
456 QPixmap px; 456 QPixmap px;
457 if (pic.data().isNull() != true) 457 if (pic.data().isNull() != true)
458 { 458 {
459 px.convertFromImage(pic.data()); 459 px.convertFromImage(pic.data());
460 } 460 }
461 461
462 emit contactSelected( px ); 462 emit contactSelected( px );
463 } 463 }
464 } 464 }
465 465
466 466
467 mExtensionManager->setSelectionChanged(); 467 mExtensionManager->setSelectionChanged();
468 468
469 // update the actions 469 // update the actions
470 bool selected = !uid.isEmpty(); 470 bool selected = !uid.isEmpty();
471 471
472 if ( mReadWrite ) { 472 if ( mReadWrite ) {
473 mActionCut->setEnabled( selected ); 473 mActionCut->setEnabled( selected );
474 mActionPaste->setEnabled( selected ); 474 mActionPaste->setEnabled( selected );
475 } 475 }
476 476
477 mActionCopy->setEnabled( selected ); 477 mActionCopy->setEnabled( selected );
478 mActionDelete->setEnabled( selected ); 478 mActionDelete->setEnabled( selected );
479 mActionEditAddressee->setEnabled( selected ); 479 mActionEditAddressee->setEnabled( selected );
480 mActionMail->setEnabled( selected ); 480 mActionMail->setEnabled( selected );
481 mActionMailVCard->setEnabled( selected ); 481 mActionMailVCard->setEnabled( selected );
482 //if (mActionBeam) 482 //if (mActionBeam)
483 //mActionBeam->setEnabled( selected ); 483 //mActionBeam->setEnabled( selected );
484 484
485 if (mActionBeamVCard) 485 if (mActionBeamVCard)
486 mActionBeamVCard->setEnabled( selected ); 486 mActionBeamVCard->setEnabled( selected );
487 487
488 mActionWhoAmI->setEnabled( selected ); 488 mActionWhoAmI->setEnabled( selected );
489 mActionCategories->setEnabled( selected ); 489 mActionCategories->setEnabled( selected );
490} 490}
491 491
492void KABCore::sendMail() 492void KABCore::sendMail()
493{ 493{
494 sendMail( mViewManager->selectedEmails().join( ", " ) ); 494 sendMail( mViewManager->selectedEmails().join( ", " ) );
495} 495}
496 496
497void KABCore::sendMail( const QString& emaillist ) 497void KABCore::sendMail( const QString& emaillist )
498{ 498{
499 // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... " 499 // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... "
500 if (emaillist.contains(",") > 0) 500 if (emaillist.contains(",") > 0)
501 ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null ); 501 ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null );
502 else 502 else
503 ExternalAppHandler::instance()->mailToOneContact( emaillist ); 503 ExternalAppHandler::instance()->mailToOneContact( emaillist );
504} 504}
505 505
506 506
507 507
508void KABCore::mailVCard() 508void KABCore::mailVCard()
509{ 509{
510 QStringList uids = mViewManager->selectedUids(); 510 QStringList uids = mViewManager->selectedUids();
511 if ( !uids.isEmpty() ) 511 if ( !uids.isEmpty() )
512 mailVCard( uids ); 512 mailVCard( uids );
513} 513}
514 514
515void KABCore::mailVCard( const QStringList& uids ) 515void KABCore::mailVCard( const QStringList& uids )
516{ 516{
517 QStringList urls; 517 QStringList urls;
518 518
519// QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); 519// QString tmpdir = locateLocal("tmp", KGlobal::getAppName());
520 520
521 QString dirName = "/tmp/" + KApplication::randomString( 8 ); 521 QString dirName = "/tmp/" + KApplication::randomString( 8 );
522 522
523 523
524 524
525 QDir().mkdir( dirName, true ); 525 QDir().mkdir( dirName, true );
526 526
527 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { 527 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) {
528 KABC::Addressee a = mAddressBook->findByUid( *it ); 528 KABC::Addressee a = mAddressBook->findByUid( *it );
529 529
530 if ( a.isEmpty() ) 530 if ( a.isEmpty() )
531 continue; 531 continue;
532 532
533 QString name = a.givenName() + "_" + a.familyName() + ".vcf"; 533 QString name = a.givenName() + "_" + a.familyName() + ".vcf";
534 534
535 QString fileName = dirName + "/" + name; 535 QString fileName = dirName + "/" + name;
536 536
537 QFile outFile(fileName); 537 QFile outFile(fileName);
538 538
539 if ( outFile.open(IO_WriteOnly) ) { // file opened successfully 539 if ( outFile.open(IO_WriteOnly) ) { // file opened successfully
540 KABC::VCardConverter converter; 540 KABC::VCardConverter converter;
541 QString vcard; 541 QString vcard;
542 542
543 converter.addresseeToVCard( a, vcard ); 543 converter.addresseeToVCard( a, vcard );
544 544
545 QTextStream t( &outFile ); // use a text stream 545 QTextStream t( &outFile ); // use a text stream
546 t.setEncoding( QTextStream::UnicodeUTF8 ); 546 t.setEncoding( QTextStream::UnicodeUTF8 );
547 t << vcard; 547 t << vcard;
548 548
549 outFile.close(); 549 outFile.close();
550 550
551 urls.append( fileName ); 551 urls.append( fileName );
552 } 552 }
553 } 553 }
554 554
555 bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") ); 555 bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") );
556 556
557 557
558/*US 558/*US
559 kapp->invokeMailer( QString::null, QString::null, QString::null, 559 kapp->invokeMailer( QString::null, QString::null, QString::null,
560 QString::null, // subject 560 QString::null, // subject
561 QString::null, // body 561 QString::null, // body
562 QString::null, 562 QString::null,
563 urls ); // attachments 563 urls ); // attachments
564*/ 564*/
565 565
566} 566}
567 567
568/** 568/**
569 Beams the "WhoAmI contact. 569 Beams the "WhoAmI contact.
570*/ 570*/
571void KABCore::beamMySelf() 571void KABCore::beamMySelf()
572{ 572{
573 KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI(); 573 KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI();
574 if (!a.isEmpty()) 574 if (!a.isEmpty())
575 { 575 {
576 QStringList uids; 576 QStringList uids;
577 uids << a.uid(); 577 uids << a.uid();
578 578
579 beamVCard(uids); 579 beamVCard(uids);
580 } else { 580 } else {
581 KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) ); 581 KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) );
582 582
583 583
584 } 584 }
585} 585}
586 586
587void KABCore::beamVCard() 587void KABCore::beamVCard()
588{ 588{
589 QStringList uids = mViewManager->selectedUids(); 589 QStringList uids = mViewManager->selectedUids();
590 if ( !uids.isEmpty() ) 590 if ( !uids.isEmpty() )
591 beamVCard( uids ); 591 beamVCard( uids );
592} 592}
593 593
594 594
595void KABCore::beamVCard(const QStringList& uids) 595void KABCore::beamVCard(const QStringList& uids)
596{ 596{
597/*US 597/*US
598 QString beamFilename; 598 QString beamFilename;
599 Opie::OPimContact c; 599 Opie::OPimContact c;
600 if ( actionPersonal->isOn() ) { 600 if ( actionPersonal->isOn() ) {
601 beamFilename = addressbookPersonalVCardName(); 601 beamFilename = addressbookPersonalVCardName();
602 if ( !QFile::exists( beamFilename ) ) 602 if ( !QFile::exists( beamFilename ) )
603 return; // can't beam a non-existent file 603 return; // can't beam a non-existent file
604 Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, 604 Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null,
605 beamFilename ); 605 beamFilename );
606 Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); 606 Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true );
607 Opie::OPimContactAccess::List allList = access->allRecords(); 607 Opie::OPimContactAccess::List allList = access->allRecords();
608 Opie::OPimContactAccess::List::Iterator it = allList.begin(); // Just take first 608 Opie::OPimContactAccess::List::Iterator it = allList.begin(); // Just take first
609 c = *it; 609 c = *it;
610 610
611 delete access; 611 delete access;
612 } else { 612 } else {
613 unlink( beamfile ); // delete if exists 613 unlink( beamfile ); // delete if exists
614 mkdir("/tmp/obex/", 0755); 614 mkdir("/tmp/obex/", 0755);
615 c = m_abView -> currentEntry(); 615 c = m_abView -> currentEntry();
616 Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, 616 Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null,
617 beamfile ); 617 beamfile );
618 Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); 618 Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true );
619 access->add( c ); 619 access->add( c );
620 access->save(); 620 access->save();
621 delete access; 621 delete access;
622 622
623 beamFilename = beamfile; 623 beamFilename = beamfile;
624 } 624 }
625 625
626 owarn << "Beaming: " << beamFilename << oendl; 626 owarn << "Beaming: " << beamFilename << oendl;
627*/ 627*/
628 628
629#if 0 629#if 0
630 QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); 630 QString tmpdir = locateLocal("tmp", KGlobal::getAppName());
631 631
632 QString dirName = tmpdir + "/" + KApplication::randomString( 8 ); 632 QString dirName = tmpdir + "/" + KApplication::randomString( 8 );
633 633
634 QString name = "contact.vcf"; 634 QString name = "contact.vcf";
635 635
636 QString fileName = dirName + "/" + name; 636 QString fileName = dirName + "/" + name;
637#endif 637#endif
638 // LR: we should use the /tmp dir, because: /tmp = RAM, (HOME)/kdepim = flash memory 638 // LR: we should use the /tmp dir, because: /tmp = RAM, (HOME)/kdepim = flash memory
639 // 639 //
640 QString fileName = "/tmp/kdepimbeamfile"; 640 QString fileName = "/tmp/kapibeamfile.vcf";
641 641
642 642
643 //QDir().mkdir( dirName, true ); 643 //QDir().mkdir( dirName, true );
644 644
645 QFile outFile(fileName); 645 QFile outFile(fileName);
646 KABC::VCardConverter converter; 646 KABC::VCardConverter converter;
647 QString description; 647 QString description;
648 648
649 if ( outFile.open(IO_WriteOnly) ) { // file opened successfully 649 if ( outFile.open(IO_WriteOnly) ) { // file opened successfully
650 650
651 QTextStream t( &outFile ); // use a text stream 651 QTextStream t( &outFile ); // use a text stream
652 t.setEncoding( QTextStream::UnicodeUTF8 ); 652 t.setEncoding( QTextStream::UnicodeUTF8 );
653 653
654 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { 654 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) {
655 KABC::Addressee a = mAddressBook->findByUid( *it ); 655 KABC::Addressee a = mAddressBook->findByUid( *it );
656 656
657 if ( a.isEmpty() ) 657 if ( a.isEmpty() )
658 continue; 658 continue;
659 659
660 if (description.isEmpty()) 660 if (description.isEmpty())
661 description = a.formattedName(); 661 description = a.formattedName();
662 662
663 QString vcard; 663 QString vcard;
664 converter.addresseeToVCard( a, vcard ); 664 converter.addresseeToVCard( a, vcard );
665 t << vcard; 665 t << vcard;
666 666
667 } 667 }
668 } else { 668 } else {
669 qDebug("Error open temp beam file "); 669 qDebug("Error open temp beam file ");
670 return; 670 return;
671 } 671 }
672 672
673 outFile.close(); 673 outFile.close();
674 674
675#ifndef DESKTOP_VERSION 675#ifndef DESKTOP_VERSION
676 Ir *ir = new Ir( this ); 676 Ir *ir = new Ir( this );
677 connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); 677 connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) );
678 ir->send( fileName, description, "text/x-vCard" ); 678 ir->send( fileName, description, "text/x-vCard" );
679#endif 679#endif
680 680
681} 681}
682 682
683void KABCore::beamDone( Ir *ir ) 683void KABCore::beamDone( Ir *ir )
684{ 684{
685#ifndef DESKTOP_VERSION 685#ifndef DESKTOP_VERSION
686 delete ir; 686 delete ir;
687#endif 687#endif
688} 688}
689 689
690 690
691void KABCore::browse( const QString& url ) 691void KABCore::browse( const QString& url )
692{ 692{
693#ifndef KAB_EMBEDDED 693#ifndef KAB_EMBEDDED
694 kapp->invokeBrowser( url ); 694 kapp->invokeBrowser( url );
695#else //KAB_EMBEDDED 695#else //KAB_EMBEDDED
696 qDebug("KABCore::browse must be fixed"); 696 qDebug("KABCore::browse must be fixed");
697#endif //KAB_EMBEDDED 697#endif //KAB_EMBEDDED
698} 698}
699 699
700void KABCore::selectAllContacts() 700void KABCore::selectAllContacts()
701{ 701{
702 mViewManager->setSelected( QString::null, true ); 702 mViewManager->setSelected( QString::null, true );
703} 703}
704 704
705void KABCore::deleteContacts() 705void KABCore::deleteContacts()
706{ 706{
707 QStringList uidList = mViewManager->selectedUids(); 707 QStringList uidList = mViewManager->selectedUids();
708 deleteContacts( uidList ); 708 deleteContacts( uidList );
709} 709}
710 710
711void KABCore::deleteContacts( const QStringList &uids ) 711void KABCore::deleteContacts( const QStringList &uids )
712{ 712{
713 if ( uids.count() > 0 ) { 713 if ( uids.count() > 0 ) {
714 PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids ); 714 PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids );
715 UndoStack::instance()->push( command ); 715 UndoStack::instance()->push( command );
716 RedoStack::instance()->clear(); 716 RedoStack::instance()->clear();
717 717
718 // now if we deleted anything, refresh 718 // now if we deleted anything, refresh
719 setContactSelected( QString::null ); 719 setContactSelected( QString::null );
720 setModified( true ); 720 setModified( true );
721 } 721 }
722} 722}
723 723
724void KABCore::copyContacts() 724void KABCore::copyContacts()
725{ 725{
726 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 726 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
727 727
728 QString clipText = AddresseeUtil::addresseesToClipboard( addrList ); 728 QString clipText = AddresseeUtil::addresseesToClipboard( addrList );
729 729
730 kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl; 730 kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl;
731 731
732 QClipboard *cb = QApplication::clipboard(); 732 QClipboard *cb = QApplication::clipboard();
733 cb->setText( clipText ); 733 cb->setText( clipText );
734} 734}
735 735
736void KABCore::cutContacts() 736void KABCore::cutContacts()
737{ 737{
738 QStringList uidList = mViewManager->selectedUids(); 738 QStringList uidList = mViewManager->selectedUids();
739 739
740//US if ( uidList.size() > 0 ) { 740//US if ( uidList.size() > 0 ) {
741 if ( uidList.count() > 0 ) { 741 if ( uidList.count() > 0 ) {
742 PwCutCommand *command = new PwCutCommand( mAddressBook, uidList ); 742 PwCutCommand *command = new PwCutCommand( mAddressBook, uidList );
743 UndoStack::instance()->push( command ); 743 UndoStack::instance()->push( command );
744 RedoStack::instance()->clear(); 744 RedoStack::instance()->clear();
745 745
746 setModified( true ); 746 setModified( true );
747 } 747 }
748} 748}
749 749
750void KABCore::pasteContacts() 750void KABCore::pasteContacts()
751{ 751{
752 QClipboard *cb = QApplication::clipboard(); 752 QClipboard *cb = QApplication::clipboard();
753 753
754 KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() ); 754 KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() );
755 755
756 pasteContacts( list ); 756 pasteContacts( list );
757} 757}
758 758
759void KABCore::pasteContacts( KABC::Addressee::List &list ) 759void KABCore::pasteContacts( KABC::Addressee::List &list )
760{ 760{
761 KABC::Resource *resource = requestResource( this ); 761 KABC::Resource *resource = requestResource( this );
762 KABC::Addressee::List::Iterator it; 762 KABC::Addressee::List::Iterator it;
763 for ( it = list.begin(); it != list.end(); ++it ) 763 for ( it = list.begin(); it != list.end(); ++it )
764 (*it).setResource( resource ); 764 (*it).setResource( resource );
765 765
766 PwPasteCommand *command = new PwPasteCommand( this, list ); 766 PwPasteCommand *command = new PwPasteCommand( this, list );
767 UndoStack::instance()->push( command ); 767 UndoStack::instance()->push( command );
768 RedoStack::instance()->clear(); 768 RedoStack::instance()->clear();
769 769
770 setModified( true ); 770 setModified( true );
771} 771}
772 772
773void KABCore::setWhoAmI() 773void KABCore::setWhoAmI()
774{ 774{
775 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 775 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
776 776
777 if ( addrList.count() > 1 ) { 777 if ( addrList.count() > 1 ) {
778 KMessageBox::sorry( this, i18n( "Please select only one contact." ) ); 778 KMessageBox::sorry( this, i18n( "Please select only one contact." ) );
779 return; 779 return;
780 } 780 }
781 781
782 QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) ); 782 QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) );
783 if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes ) 783 if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes )
784 static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] ); 784 static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] );
785} 785}
786 786
787void KABCore::setCategories() 787void KABCore::setCategories()
788{ 788{
789 KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true ); 789 KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true );
790 if ( !dlg.exec() ) 790 if ( !dlg.exec() )
791 return; 791 return;
792 792
793 bool merge = false; 793 bool merge = false;
794 QString msg = i18n( "Merge with existing categories?" ); 794 QString msg = i18n( "Merge with existing categories?" );
795 if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes ) 795 if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes )
796 merge = true; 796 merge = true;
797 797
798 QStringList categories = dlg.selectedCategories(); 798 QStringList categories = dlg.selectedCategories();
799 799
800 QStringList uids = mViewManager->selectedUids(); 800 QStringList uids = mViewManager->selectedUids();
801 QStringList::Iterator it; 801 QStringList::Iterator it;
802 for ( it = uids.begin(); it != uids.end(); ++it ) { 802 for ( it = uids.begin(); it != uids.end(); ++it ) {
803 KABC::Addressee addr = mAddressBook->findByUid( *it ); 803 KABC::Addressee addr = mAddressBook->findByUid( *it );
804 if ( !addr.isEmpty() ) { 804 if ( !addr.isEmpty() ) {
805 if ( !merge ) 805 if ( !merge )
806 addr.setCategories( categories ); 806 addr.setCategories( categories );
807 else { 807 else {
808 QStringList addrCategories = addr.categories(); 808 QStringList addrCategories = addr.categories();
809 QStringList::Iterator catIt; 809 QStringList::Iterator catIt;
810 for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) { 810 for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) {
811 if ( !addrCategories.contains( *catIt ) ) 811 if ( !addrCategories.contains( *catIt ) )
812 addrCategories.append( *catIt ); 812 addrCategories.append( *catIt );
813 } 813 }
814 addr.setCategories( addrCategories ); 814 addr.setCategories( addrCategories );
815 } 815 }
816 816
817 mAddressBook->insertAddressee( addr ); 817 mAddressBook->insertAddressee( addr );
818 } 818 }
819 } 819 }
820 820
821 if ( uids.count() > 0 ) 821 if ( uids.count() > 0 )
822 setModified( true ); 822 setModified( true );
823} 823}
824 824
825void KABCore::setSearchFields( const KABC::Field::List &fields ) 825void KABCore::setSearchFields( const KABC::Field::List &fields )
826{ 826{
827 mIncSearchWidget->setFields( fields ); 827 mIncSearchWidget->setFields( fields );
828} 828}
829 829
830void KABCore::incrementalSearch( const QString& text ) 830void KABCore::incrementalSearch( const QString& text )
831{ 831{
832 mViewManager->setSelected( QString::null, false ); 832 mViewManager->setSelected( QString::null, false );