-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 | |||
@@ -755,240 +755,244 @@ void KABCore::sendMail() | |||
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; |