author | zautrix <zautrix> | 2005-10-22 14:12:43 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-10-22 14:12:43 (UTC) |
commit | a72d70beb381b9cd6f2af301b52ca82cdcafb299 (patch) (unidiff) | |
tree | f5b068e80395821abb5717fb07757a17d805f770 /kaddressbook | |
parent | a72f3f3acfac791715a1c512fc4cc4c3facdbb62 (diff) | |
download | kdepimpi-a72d70beb381b9cd6f2af301b52ca82cdcafb299.zip kdepimpi-a72d70beb381b9cd6f2af301b52ca82cdcafb299.tar.gz kdepimpi-a72d70beb381b9cd6f2af301b52ca82cdcafb299.tar.bz2 |
fix
-rw-r--r-- | kaddressbook/kabcore.cpp | 6 |
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 | |||
@@ -659,432 +659,436 @@ KABC::Resource *KABCore::requestResource( QWidget *parent ) | |||
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 |
671 | KAboutData *KABCore::createAboutData() | 671 | KAboutData *KABCore::createAboutData() |
672 | #else //KAB_EMBEDDED | 672 | #else //KAB_EMBEDDED |
673 | void KABCore::createAboutData() | 673 | void 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 | ||
707 | void KABCore::setContactSelected( const QString &uid ) | 707 | void 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 | ||
750 | void KABCore::sendMail() | 750 | void KABCore::sendMail() |
751 | { | 751 | { |
752 | sendMail( mViewManager->selectedEmails().join( ", " ) ); | 752 | sendMail( mViewManager->selectedEmails().join( ", " ) ); |
753 | } | 753 | } |
754 | 754 | ||
755 | void KABCore::sendMail( const QString& emaillist ) | 755 | void 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 | ||
766 | void KABCore::mailVCard() | 766 | void 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 | ||
773 | void KABCore::mailVCard( const QStringList& uids ) | 773 | void 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 | */ |
829 | void KABCore::beamMySelf() | 829 | void 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 | } |
844 | void KABCore::updateMainWindow() | 844 | void KABCore::updateMainWindow() |
845 | { | 845 | { |
846 | mMainWindow->showMaximized(); | 846 | mMainWindow->showMaximized(); |
847 | //mMainWindow->repaint(); | 847 | //mMainWindow->repaint(); |
848 | } | 848 | } |
849 | void KABCore::resizeEvent(QResizeEvent* e ) | 849 | void 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 | } |
902 | void KABCore::export2phone() | 906 | void 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 | } |
940 | QString KABCore::getPhoneFile() | 944 | QString 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 | } |
949 | void KABCore::writeToPhone( ) | 953 | void 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 | } |
956 | void KABCore::beamVCard() | 960 | void 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 | ||
970 | void KABCore::beamVCard(const QStringList& uids) | 974 | void 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 | ||
1032 | void KABCore::beamDone( Ir *ir ) | 1036 | void 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 | ||
1042 | void KABCore::browse( const QString& url ) | 1046 | void 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 | ||
1051 | void KABCore::selectAllContacts() | 1055 | void KABCore::selectAllContacts() |
1052 | { | 1056 | { |
1053 | mViewManager->setSelected( QString::null, true ); | 1057 | mViewManager->setSelected( QString::null, true ); |
1054 | } | 1058 | } |
1055 | 1059 | ||
1056 | void KABCore::deleteContacts() | 1060 | void KABCore::deleteContacts() |
1057 | { | 1061 | { |
1058 | QStringList uidList = mViewManager->selectedUids(); | 1062 | QStringList uidList = mViewManager->selectedUids(); |
1059 | deleteContacts( uidList ); | 1063 | deleteContacts( uidList ); |
1060 | } | 1064 | } |
1061 | 1065 | ||
1062 | void KABCore::deleteContacts( const QStringList &uids ) | 1066 | void 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 | ||