author | zautrix <zautrix> | 2004-12-13 12:35:00 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-12-13 12:35:00 (UTC) |
commit | 7ac6c21e832b7d16bd0888d0b66252b6e152005a (patch) (unidiff) | |
tree | c7610e0e25020f19af82ac6257c2debab2638316 /kaddressbook | |
parent | 17b25691f0332e648dd1d800e89ccf4e1da8955d (diff) | |
download | kdepimpi-7ac6c21e832b7d16bd0888d0b66252b6e152005a.zip kdepimpi-7ac6c21e832b7d16bd0888d0b66252b6e152005a.tar.gz kdepimpi-7ac6c21e832b7d16bd0888d0b66252b6e152005a.tar.bz2 |
many bugfixes
-rw-r--r-- | kaddressbook/kabcore.cpp | 11 | ||||
-rw-r--r-- | kaddressbook/viewmanager.cpp | 11 |
2 files changed, 16 insertions, 6 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index b7edccd..f6bdda4 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp | |||
@@ -662,256 +662,257 @@ void KABCore::setContactSelected( const QString &uid ) | |||
662 | } | 662 | } |
663 | } | 663 | } |
664 | 664 | ||
665 | 665 | ||
666 | mExtensionManager->setSelectionChanged(); | 666 | mExtensionManager->setSelectionChanged(); |
667 | 667 | ||
668 | // update the actions | 668 | // update the actions |
669 | bool selected = !uid.isEmpty(); | 669 | bool selected = !uid.isEmpty(); |
670 | 670 | ||
671 | if ( mReadWrite ) { | 671 | if ( mReadWrite ) { |
672 | mActionCut->setEnabled( selected ); | 672 | mActionCut->setEnabled( selected ); |
673 | mActionPaste->setEnabled( selected ); | 673 | mActionPaste->setEnabled( selected ); |
674 | } | 674 | } |
675 | 675 | ||
676 | mActionCopy->setEnabled( selected ); | 676 | mActionCopy->setEnabled( selected ); |
677 | mActionDelete->setEnabled( selected ); | 677 | mActionDelete->setEnabled( selected ); |
678 | mActionEditAddressee->setEnabled( selected ); | 678 | mActionEditAddressee->setEnabled( selected ); |
679 | mActionMail->setEnabled( selected ); | 679 | mActionMail->setEnabled( selected ); |
680 | mActionMailVCard->setEnabled( selected ); | 680 | mActionMailVCard->setEnabled( selected ); |
681 | //if (mActionBeam) | 681 | //if (mActionBeam) |
682 | //mActionBeam->setEnabled( selected ); | 682 | //mActionBeam->setEnabled( selected ); |
683 | mActionWhoAmI->setEnabled( selected ); | 683 | mActionWhoAmI->setEnabled( selected ); |
684 | } | 684 | } |
685 | 685 | ||
686 | void KABCore::sendMail() | 686 | void KABCore::sendMail() |
687 | { | 687 | { |
688 | sendMail( mViewManager->selectedEmails().join( ", " ) ); | 688 | sendMail( mViewManager->selectedEmails().join( ", " ) ); |
689 | } | 689 | } |
690 | 690 | ||
691 | void KABCore::sendMail( const QString& emaillist ) | 691 | void KABCore::sendMail( const QString& emaillist ) |
692 | { | 692 | { |
693 | // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... " | 693 | // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... " |
694 | if (emaillist.contains(",") > 0) | 694 | if (emaillist.contains(",") > 0) |
695 | ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null ); | 695 | ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null ); |
696 | else | 696 | else |
697 | ExternalAppHandler::instance()->mailToOneContact( emaillist ); | 697 | ExternalAppHandler::instance()->mailToOneContact( emaillist ); |
698 | } | 698 | } |
699 | 699 | ||
700 | 700 | ||
701 | 701 | ||
702 | void KABCore::mailVCard() | 702 | void KABCore::mailVCard() |
703 | { | 703 | { |
704 | QStringList uids = mViewManager->selectedUids(); | 704 | QStringList uids = mViewManager->selectedUids(); |
705 | if ( !uids.isEmpty() ) | 705 | if ( !uids.isEmpty() ) |
706 | mailVCard( uids ); | 706 | mailVCard( uids ); |
707 | } | 707 | } |
708 | 708 | ||
709 | void KABCore::mailVCard( const QStringList& uids ) | 709 | void KABCore::mailVCard( const QStringList& uids ) |
710 | { | 710 | { |
711 | QStringList urls; | 711 | QStringList urls; |
712 | 712 | ||
713 | // QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); | 713 | // QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); |
714 | 714 | ||
715 | QString dirName = "/tmp/" + KApplication::randomString( 8 ); | 715 | QString dirName = "/tmp/" + KApplication::randomString( 8 ); |
716 | 716 | ||
717 | 717 | ||
718 | 718 | ||
719 | QDir().mkdir( dirName, true ); | 719 | QDir().mkdir( dirName, true ); |
720 | 720 | ||
721 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { | 721 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { |
722 | KABC::Addressee a = mAddressBook->findByUid( *it ); | 722 | KABC::Addressee a = mAddressBook->findByUid( *it ); |
723 | 723 | ||
724 | if ( a.isEmpty() ) | 724 | if ( a.isEmpty() ) |
725 | continue; | 725 | continue; |
726 | 726 | ||
727 | QString name = a.givenName() + "_" + a.familyName() + ".vcf"; | 727 | QString name = a.givenName() + "_" + a.familyName() + ".vcf"; |
728 | 728 | ||
729 | QString fileName = dirName + "/" + name; | 729 | QString fileName = dirName + "/" + name; |
730 | 730 | ||
731 | QFile outFile(fileName); | 731 | QFile outFile(fileName); |
732 | 732 | ||
733 | if ( outFile.open(IO_WriteOnly) ) { // file opened successfully | 733 | if ( outFile.open(IO_WriteOnly) ) { // file opened successfully |
734 | KABC::VCardConverter converter; | 734 | KABC::VCardConverter converter; |
735 | QString vcard; | 735 | QString vcard; |
736 | 736 | ||
737 | converter.addresseeToVCard( a, vcard ); | 737 | converter.addresseeToVCard( a, vcard ); |
738 | 738 | ||
739 | QTextStream t( &outFile ); // use a text stream | 739 | QTextStream t( &outFile ); // use a text stream |
740 | t.setEncoding( QTextStream::UnicodeUTF8 ); | 740 | t.setEncoding( QTextStream::UnicodeUTF8 ); |
741 | t << vcard; | 741 | t << vcard; |
742 | 742 | ||
743 | outFile.close(); | 743 | outFile.close(); |
744 | 744 | ||
745 | urls.append( fileName ); | 745 | urls.append( fileName ); |
746 | } | 746 | } |
747 | } | 747 | } |
748 | 748 | ||
749 | bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") ); | 749 | bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") ); |
750 | 750 | ||
751 | 751 | ||
752 | /*US | 752 | /*US |
753 | kapp->invokeMailer( QString::null, QString::null, QString::null, | 753 | kapp->invokeMailer( QString::null, QString::null, QString::null, |
754 | QString::null, // subject | 754 | QString::null, // subject |
755 | QString::null, // body | 755 | QString::null, // body |
756 | QString::null, | 756 | QString::null, |
757 | urls ); // attachments | 757 | urls ); // attachments |
758 | */ | 758 | */ |
759 | 759 | ||
760 | } | 760 | } |
761 | 761 | ||
762 | /** | 762 | /** |
763 | Beams the "WhoAmI contact. | 763 | Beams the "WhoAmI contact. |
764 | */ | 764 | */ |
765 | void KABCore::beamMySelf() | 765 | void KABCore::beamMySelf() |
766 | { | 766 | { |
767 | KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI(); | 767 | KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI(); |
768 | if (!a.isEmpty()) | 768 | if (!a.isEmpty()) |
769 | { | 769 | { |
770 | QStringList uids; | 770 | QStringList uids; |
771 | uids << a.uid(); | 771 | uids << a.uid(); |
772 | 772 | ||
773 | beamVCard(uids); | 773 | beamVCard(uids); |
774 | } else { | 774 | } else { |
775 | KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) ); | 775 | KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) ); |
776 | 776 | ||
777 | 777 | ||
778 | } | 778 | } |
779 | } | 779 | } |
780 | void KABCore::updateMainWindow() | 780 | void KABCore::updateMainWindow() |
781 | { | 781 | { |
782 | 782 | ||
783 | mMainWindow->showMaximized(); | 783 | mMainWindow->showMaximized(); |
784 | mMainWindow->update(); | 784 | mMainWindow->update(); |
785 | } | 785 | } |
786 | void KABCore::resizeEvent(QResizeEvent* e ) | 786 | void KABCore::resizeEvent(QResizeEvent* e ) |
787 | { | 787 | { |
788 | if ( !mMiniSplitter ) | 788 | if ( !mMiniSplitter ) |
789 | return; | 789 | return; |
790 | //qDebug("KABCore::resizeEvent(QResizeEvent* e ) "); | ||
790 | if ( QApplication::desktop()->width() >= 480 ) { | 791 | if ( QApplication::desktop()->width() >= 480 ) { |
791 | if (QApplication::desktop()->width() == 640 ) { // e.g. 640x480 | 792 | if (QApplication::desktop()->width() == 640 ) { // e.g. 640x480 |
792 | if ( mMiniSplitter->orientation() == Qt::Vertical ) { | 793 | if ( mMiniSplitter->orientation() == Qt::Vertical ) { |
793 | mMiniSplitter->setOrientation( Qt::Horizontal); | 794 | mMiniSplitter->setOrientation( Qt::Horizontal); |
794 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); | 795 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); |
795 | if ( QApplication::desktop()->width() <= 640 ) { | 796 | if ( QApplication::desktop()->width() <= 640 ) { |
796 | //mMainWindow->setMaximumSize( QApplication::desktop()->size() ); | 797 | //mMainWindow->setMaximumSize( QApplication::desktop()->size() ); |
797 | mViewManager->getFilterAction()->setComboWidth( 150 ); | 798 | mViewManager->getFilterAction()->setComboWidth( 150 ); |
798 | QTimer::singleShot( 1, this , SLOT ( updateMainWindow())); | 799 | QTimer::singleShot( 1, this , SLOT ( updateMainWindow())); |
799 | } | 800 | } |
800 | } | 801 | } |
801 | } else if (QApplication::desktop()->width() == 480 ){// e.g. 480x640 | 802 | } else if (QApplication::desktop()->width() == 480 ){// e.g. 480x640 |
802 | if ( mMiniSplitter->orientation() == Qt::Horizontal ) { | 803 | if ( mMiniSplitter->orientation() == Qt::Horizontal ) { |
803 | mMiniSplitter->setOrientation( Qt::Vertical ); | 804 | mMiniSplitter->setOrientation( Qt::Vertical ); |
804 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); | 805 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); |
805 | if ( QApplication::desktop()->width() <= 640 ) { | 806 | if ( QApplication::desktop()->width() <= 640 ) { |
806 | //mMainWindow->setMaximumSize( QApplication::desktop()->size() ); | 807 | //mMainWindow->setMaximumSize( QApplication::desktop()->size() ); |
807 | mMainWindow->showMinimized(); | 808 | mMainWindow->showMinimized(); |
808 | mViewManager->getFilterAction()->setComboWidth( 0 ); | 809 | mViewManager->getFilterAction()->setComboWidth( 0 ); |
809 | QTimer::singleShot( 1, this , SLOT ( updateMainWindow())); | 810 | QTimer::singleShot( 1, this , SLOT ( updateMainWindow())); |
810 | } | 811 | } |
811 | } | 812 | } |
812 | } | 813 | } |
813 | } | 814 | } |
814 | 815 | ||
815 | } | 816 | } |
816 | void KABCore::export2phone() | 817 | void KABCore::export2phone() |
817 | { | 818 | { |
818 | 819 | ||
819 | QStringList uids; | 820 | QStringList uids; |
820 | XXPortSelectDialog dlg( this, false, this ); | 821 | XXPortSelectDialog dlg( this, false, this ); |
821 | if ( dlg.exec() ) | 822 | if ( dlg.exec() ) |
822 | uids = dlg.uids(); | 823 | uids = dlg.uids(); |
823 | else | 824 | else |
824 | return; | 825 | return; |
825 | if ( uids.isEmpty() ) | 826 | if ( uids.isEmpty() ) |
826 | return; | 827 | return; |
827 | // qDebug("count %d ", uids.count()); | 828 | // qDebug("count %d ", uids.count()); |
828 | 829 | ||
829 | KAex2phonePrefs ex2phone; | 830 | KAex2phonePrefs ex2phone; |
830 | ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); | 831 | ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); |
831 | ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); | 832 | ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); |
832 | ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); | 833 | ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); |
833 | 834 | ||
834 | if ( !ex2phone.exec() ) { | 835 | if ( !ex2phone.exec() ) { |
835 | return; | 836 | return; |
836 | } | 837 | } |
837 | KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); | 838 | KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); |
838 | KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); | 839 | KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); |
839 | KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); | 840 | KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); |
840 | 841 | ||
841 | 842 | ||
842 | PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, | 843 | PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, |
843 | KPimGlobalPrefs::instance()->mEx2PhoneConnection, | 844 | KPimGlobalPrefs::instance()->mEx2PhoneConnection, |
844 | KPimGlobalPrefs::instance()->mEx2PhoneModel ); | 845 | KPimGlobalPrefs::instance()->mEx2PhoneModel ); |
845 | 846 | ||
846 | QString fileName = getPhoneFile(); | 847 | QString fileName = getPhoneFile(); |
847 | if ( ! mAddressBook->export2PhoneFormat( uids ,fileName ) ) | 848 | if ( ! mAddressBook->export2PhoneFormat( uids ,fileName ) ) |
848 | return; | 849 | return; |
849 | 850 | ||
850 | message(i18n("Exporting to phone...")); | 851 | message(i18n("Exporting to phone...")); |
851 | QTimer::singleShot( 1, this , SLOT ( writeToPhone())); | 852 | QTimer::singleShot( 1, this , SLOT ( writeToPhone())); |
852 | 853 | ||
853 | } | 854 | } |
854 | QString KABCore::getPhoneFile() | 855 | QString KABCore::getPhoneFile() |
855 | { | 856 | { |
856 | #ifdef DESKTOP_VERSION | 857 | #ifdef DESKTOP_VERSION |
857 | return locateLocal("tmp", "phonefile.vcf"); | 858 | return locateLocal("tmp", "phonefile.vcf"); |
858 | #else | 859 | #else |
859 | return "/tmp/phonefile.vcf"; | 860 | return "/tmp/phonefile.vcf"; |
860 | #endif | 861 | #endif |
861 | 862 | ||
862 | } | 863 | } |
863 | void KABCore::writeToPhone( ) | 864 | void KABCore::writeToPhone( ) |
864 | { | 865 | { |
865 | if ( PhoneAccess::writeToPhone( getPhoneFile() ) ) | 866 | if ( PhoneAccess::writeToPhone( getPhoneFile() ) ) |
866 | message(i18n("Export to phone finished!")); | 867 | message(i18n("Export to phone finished!")); |
867 | else | 868 | else |
868 | qDebug(i18n("Error exporting to phone")); | 869 | qDebug(i18n("Error exporting to phone")); |
869 | } | 870 | } |
870 | void KABCore::beamVCard() | 871 | void KABCore::beamVCard() |
871 | { | 872 | { |
872 | QStringList uids; | 873 | QStringList uids; |
873 | XXPortSelectDialog dlg( this, false, this ); | 874 | XXPortSelectDialog dlg( this, false, this ); |
874 | if ( dlg.exec() ) | 875 | if ( dlg.exec() ) |
875 | uids = dlg.uids(); | 876 | uids = dlg.uids(); |
876 | else | 877 | else |
877 | return; | 878 | return; |
878 | if ( uids.isEmpty() ) | 879 | if ( uids.isEmpty() ) |
879 | return; | 880 | return; |
880 | beamVCard( uids ); | 881 | beamVCard( uids ); |
881 | } | 882 | } |
882 | 883 | ||
883 | 884 | ||
884 | void KABCore::beamVCard(const QStringList& uids) | 885 | void KABCore::beamVCard(const QStringList& uids) |
885 | { | 886 | { |
886 | 887 | ||
887 | // LR: we should use the /tmp dir on the Zaurus, | 888 | // LR: we should use the /tmp dir on the Zaurus, |
888 | // because: /tmp = RAM, (HOME)/kdepim = flash memory | 889 | // because: /tmp = RAM, (HOME)/kdepim = flash memory |
889 | 890 | ||
890 | #ifdef DESKTOP_VERSION | 891 | #ifdef DESKTOP_VERSION |
891 | QString fileName = locateLocal("tmp", "kapibeamfile.vcf"); | 892 | QString fileName = locateLocal("tmp", "kapibeamfile.vcf"); |
892 | #else | 893 | #else |
893 | QString fileName = "/tmp/kapibeamfile.vcf"; | 894 | QString fileName = "/tmp/kapibeamfile.vcf"; |
894 | #endif | 895 | #endif |
895 | 896 | ||
896 | KABC::VCardConverter converter; | 897 | KABC::VCardConverter converter; |
897 | QString description; | 898 | QString description; |
898 | QString datastream; | 899 | QString datastream; |
899 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { | 900 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { |
900 | KABC::Addressee a = mAddressBook->findByUid( *it ); | 901 | KABC::Addressee a = mAddressBook->findByUid( *it ); |
901 | 902 | ||
902 | if ( a.isEmpty() ) | 903 | if ( a.isEmpty() ) |
903 | continue; | 904 | continue; |
904 | 905 | ||
905 | if (description.isEmpty()) | 906 | if (description.isEmpty()) |
906 | description = a.formattedName(); | 907 | description = a.formattedName(); |
907 | 908 | ||
908 | QString vcard; | 909 | QString vcard; |
909 | converter.addresseeToVCard( a, vcard ); | 910 | converter.addresseeToVCard( a, vcard ); |
910 | int start = 0; | 911 | int start = 0; |
911 | int next; | 912 | int next; |
912 | while ( (next = vcard.find("TYPE=", start) )>= 0 ) { | 913 | while ( (next = vcard.find("TYPE=", start) )>= 0 ) { |
913 | int semi = vcard.find(";", next); | 914 | int semi = vcard.find(";", next); |
914 | int dopp = vcard.find(":", next); | 915 | int dopp = vcard.find(":", next); |
915 | int sep; | 916 | int sep; |
916 | if ( semi < dopp && semi >= 0 ) | 917 | if ( semi < dopp && semi >= 0 ) |
917 | sep = semi ; | 918 | sep = semi ; |
@@ -2067,261 +2068,263 @@ void KABCore::addActionsManually() | |||
2067 | mb->insertItem( i18n("&Help"), helpMenu ); | 2068 | mb->insertItem( i18n("&Help"), helpMenu ); |
2068 | mIncSearchWidget = new IncSearchWidget( tb ); | 2069 | mIncSearchWidget = new IncSearchWidget( tb ); |
2069 | // tb->insertWidget(-1, 0, mIncSearchWidget); | 2070 | // tb->insertWidget(-1, 0, mIncSearchWidget); |
2070 | #ifndef DESKTOP_VERSION | 2071 | #ifndef DESKTOP_VERSION |
2071 | } else { | 2072 | } else { |
2072 | //US setup toolbar | 2073 | //US setup toolbar |
2073 | QPEMenuBar *menuBarTB = new QPEMenuBar( tb ); | 2074 | QPEMenuBar *menuBarTB = new QPEMenuBar( tb ); |
2074 | QPopupMenu *popupBarTB = new QPopupMenu( this ); | 2075 | QPopupMenu *popupBarTB = new QPopupMenu( this ); |
2075 | menuBarTB->insertItem( "ME", popupBarTB); | 2076 | menuBarTB->insertItem( "ME", popupBarTB); |
2076 | tb->insertWidget(-1, 0, menuBarTB); | 2077 | tb->insertWidget(-1, 0, menuBarTB); |
2077 | mIncSearchWidget = new IncSearchWidget( tb ); | 2078 | mIncSearchWidget = new IncSearchWidget( tb ); |
2078 | 2079 | ||
2079 | tb->enableMoving(false); | 2080 | tb->enableMoving(false); |
2080 | popupBarTB->insertItem( i18n("&File"), fileMenu ); | 2081 | popupBarTB->insertItem( i18n("&File"), fileMenu ); |
2081 | popupBarTB->insertItem( i18n("&Edit"), editMenu ); | 2082 | popupBarTB->insertItem( i18n("&Edit"), editMenu ); |
2082 | popupBarTB->insertItem( i18n("&View"), viewMenu ); | 2083 | popupBarTB->insertItem( i18n("&View"), viewMenu ); |
2083 | popupBarTB->insertItem( i18n("&Settings"), settingsMenu ); | 2084 | popupBarTB->insertItem( i18n("&Settings"), settingsMenu ); |
2084 | popupBarTB->insertItem( i18n("Synchronize"), syncMenu ); | 2085 | popupBarTB->insertItem( i18n("Synchronize"), syncMenu ); |
2085 | mViewManager->getFilterAction()->plug ( popupBarTB); | 2086 | mViewManager->getFilterAction()->plug ( popupBarTB); |
2086 | //popupBarTB->insertItem( i18n("&Change selected"), changeMenu ); | 2087 | //popupBarTB->insertItem( i18n("&Change selected"), changeMenu ); |
2087 | popupBarTB->insertItem( i18n("&Help"), helpMenu ); | 2088 | popupBarTB->insertItem( i18n("&Help"), helpMenu ); |
2088 | if (QApplication::desktop()->width() > 320 ) { | 2089 | if (QApplication::desktop()->width() > 320 ) { |
2089 | // mViewManager->getFilterAction()->plug ( tb); | 2090 | // mViewManager->getFilterAction()->plug ( tb); |
2090 | } | 2091 | } |
2091 | } | 2092 | } |
2092 | #endif | 2093 | #endif |
2093 | // mActionQuit->plug ( mMainWindow->toolBar()); | 2094 | // mActionQuit->plug ( mMainWindow->toolBar()); |
2094 | 2095 | ||
2095 | 2096 | ||
2096 | 2097 | ||
2097 | //US Now connect the actions with the menue entries. | 2098 | //US Now connect the actions with the menue entries. |
2098 | mActionPrint->plug( fileMenu ); | 2099 | mActionPrint->plug( fileMenu ); |
2099 | mActionMail->plug( fileMenu ); | 2100 | mActionMail->plug( fileMenu ); |
2100 | fileMenu->insertSeparator(); | 2101 | fileMenu->insertSeparator(); |
2101 | 2102 | ||
2102 | mActionNewContact->plug( fileMenu ); | 2103 | mActionNewContact->plug( fileMenu ); |
2103 | mActionNewContact->plug( tb ); | 2104 | mActionNewContact->plug( tb ); |
2104 | 2105 | ||
2105 | mActionEditAddressee->plug( fileMenu ); | 2106 | mActionEditAddressee->plug( fileMenu ); |
2106 | // if ((KGlobal::getDesktopSize() > KGlobal::Small ) || | 2107 | // if ((KGlobal::getDesktopSize() > KGlobal::Small ) || |
2107 | // (!KABPrefs::instance()->mMultipleViewsAtOnce )) | 2108 | // (!KABPrefs::instance()->mMultipleViewsAtOnce )) |
2108 | mActionEditAddressee->plug( tb ); | 2109 | mActionEditAddressee->plug( tb ); |
2109 | 2110 | ||
2110 | fileMenu->insertSeparator(); | 2111 | fileMenu->insertSeparator(); |
2111 | mActionSave->plug( fileMenu ); | 2112 | mActionSave->plug( fileMenu ); |
2112 | fileMenu->insertItem( "&Import", ImportMenu ); | 2113 | fileMenu->insertItem( "&Import", ImportMenu ); |
2113 | fileMenu->insertItem( "&Export", ExportMenu ); | 2114 | fileMenu->insertItem( "&Export", ExportMenu ); |
2114 | fileMenu->insertItem( i18n("&Change"), changeMenu ); | 2115 | fileMenu->insertItem( i18n("&Change"), changeMenu ); |
2115 | #ifndef DESKTOP_VERSION | 2116 | #ifndef DESKTOP_VERSION |
2116 | if ( Ir::supported() ) fileMenu->insertItem( i18n("&Beam"), beamMenu ); | 2117 | if ( Ir::supported() ) fileMenu->insertItem( i18n("&Beam"), beamMenu ); |
2117 | #endif | 2118 | #endif |
2118 | 2119 | ||
2119 | fileMenu->insertSeparator(); | 2120 | fileMenu->insertSeparator(); |
2120 | mActionMailVCard->plug( fileMenu ); | 2121 | mActionMailVCard->plug( fileMenu ); |
2121 | #ifndef DESKTOP_VERSION | 2122 | #ifndef DESKTOP_VERSION |
2122 | if ( Ir::supported() ) mActionBR->plug( beamMenu ); | 2123 | if ( Ir::supported() ) mActionBR->plug( beamMenu ); |
2123 | if ( Ir::supported() ) mActionBeamVCard->plug( beamMenu ); | 2124 | if ( Ir::supported() ) mActionBeamVCard->plug( beamMenu ); |
2124 | if ( Ir::supported() ) mActionBeam->plug( beamMenu ); | 2125 | if ( Ir::supported() ) mActionBeam->plug( beamMenu ); |
2125 | #endif | 2126 | #endif |
2126 | fileMenu->insertSeparator(); | 2127 | fileMenu->insertSeparator(); |
2127 | mActionQuit->plug( fileMenu ); | 2128 | mActionQuit->plug( fileMenu ); |
2128 | #ifdef _WIN32_ | 2129 | #ifdef _WIN32_ |
2129 | mActionImportOL->plug( ImportMenu ); | 2130 | mActionImportOL->plug( ImportMenu ); |
2130 | #endif | 2131 | #endif |
2131 | // edit menu | 2132 | // edit menu |
2132 | mActionUndo->plug( editMenu ); | 2133 | mActionUndo->plug( editMenu ); |
2133 | mActionRedo->plug( editMenu ); | 2134 | mActionRedo->plug( editMenu ); |
2134 | editMenu->insertSeparator(); | 2135 | editMenu->insertSeparator(); |
2135 | mActionCut->plug( editMenu ); | 2136 | mActionCut->plug( editMenu ); |
2136 | mActionCopy->plug( editMenu ); | 2137 | mActionCopy->plug( editMenu ); |
2137 | mActionPaste->plug( editMenu ); | 2138 | mActionPaste->plug( editMenu ); |
2138 | mActionDelete->plug( editMenu ); | 2139 | mActionDelete->plug( editMenu ); |
2139 | editMenu->insertSeparator(); | 2140 | editMenu->insertSeparator(); |
2140 | mActionSelectAll->plug( editMenu ); | 2141 | mActionSelectAll->plug( editMenu ); |
2141 | 2142 | ||
2142 | mActionRemoveVoice->plug( changeMenu ); | 2143 | mActionRemoveVoice->plug( changeMenu ); |
2143 | // settings menu | 2144 | // settings menu |
2144 | //US special menuentry to configure the addressbook resources. On KDE | 2145 | //US special menuentry to configure the addressbook resources. On KDE |
2145 | // you do that through the control center !!! | 2146 | // you do that through the control center !!! |
2146 | mActionConfigResources->plug( settingsMenu ); | 2147 | mActionConfigResources->plug( settingsMenu ); |
2147 | settingsMenu->insertSeparator(); | 2148 | settingsMenu->insertSeparator(); |
2148 | 2149 | ||
2149 | mActionConfigKAddressbook->plug( settingsMenu ); | 2150 | mActionConfigKAddressbook->plug( settingsMenu ); |
2150 | 2151 | ||
2151 | if ( mIsPart ) { | 2152 | if ( mIsPart ) { |
2152 | //US not implemented yet | 2153 | //US not implemented yet |
2153 | //mActionConfigShortcuts->plug( settingsMenu ); | 2154 | //mActionConfigShortcuts->plug( settingsMenu ); |
2154 | //mActionConfigureToolbars->plug( settingsMenu ); | 2155 | //mActionConfigureToolbars->plug( settingsMenu ); |
2155 | 2156 | ||
2156 | } else { | 2157 | } else { |
2157 | //US not implemented yet | 2158 | //US not implemented yet |
2158 | //mActionKeyBindings->plug( settingsMenu ); | 2159 | //mActionKeyBindings->plug( settingsMenu ); |
2159 | } | 2160 | } |
2160 | 2161 | ||
2161 | settingsMenu->insertSeparator(); | 2162 | settingsMenu->insertSeparator(); |
2162 | 2163 | ||
2163 | mActionJumpBar->plug( settingsMenu ); | 2164 | mActionJumpBar->plug( settingsMenu ); |
2164 | mActionDetails->plug( settingsMenu ); | 2165 | mActionDetails->plug( settingsMenu ); |
2165 | //if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop ) | 2166 | //if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop ) |
2166 | mActionDetails->plug( tb ); | 2167 | mActionDetails->plug( tb ); |
2167 | settingsMenu->insertSeparator(); | 2168 | settingsMenu->insertSeparator(); |
2168 | #ifndef DESKTOP_VERSION | 2169 | #ifndef DESKTOP_VERSION |
2169 | if ( Ir::supported() ) mActionBR->plug(settingsMenu ); | 2170 | if ( Ir::supported() ) mActionBR->plug(settingsMenu ); |
2170 | #endif | 2171 | #endif |
2171 | settingsMenu->insertSeparator(); | 2172 | settingsMenu->insertSeparator(); |
2172 | 2173 | ||
2173 | mActionWhoAmI->plug( settingsMenu ); | 2174 | mActionWhoAmI->plug( settingsMenu ); |
2174 | mActionEditCategories->plug( settingsMenu ); | 2175 | mActionEditCategories->plug( settingsMenu ); |
2175 | mActionEditCategories->plug( changeMenu ); | 2176 | mActionEditCategories->plug( changeMenu ); |
2176 | mActionCategories->plug( changeMenu ); | 2177 | mActionCategories->plug( changeMenu ); |
2177 | mActionManageCategories->plug( changeMenu ); | 2178 | mActionManageCategories->plug( changeMenu ); |
2178 | 2179 | ||
2179 | mActionCategories->plug( settingsMenu ); | 2180 | mActionCategories->plug( settingsMenu ); |
2180 | mActionManageCategories->plug( settingsMenu ); | 2181 | mActionManageCategories->plug( settingsMenu ); |
2181 | 2182 | ||
2182 | 2183 | ||
2183 | mActionWN->plug( helpMenu ); | 2184 | mActionWN->plug( helpMenu ); |
2184 | mActionSyncHowto->plug( helpMenu ); | 2185 | mActionSyncHowto->plug( helpMenu ); |
2185 | mActionKdeSyncHowto->plug( helpMenu ); | 2186 | mActionKdeSyncHowto->plug( helpMenu ); |
2186 | mActionMultiSyncHowto->plug( helpMenu ); | 2187 | mActionMultiSyncHowto->plug( helpMenu ); |
2187 | mActionFaq->plug( helpMenu ); | 2188 | mActionFaq->plug( helpMenu ); |
2188 | mActionLicence->plug( helpMenu ); | 2189 | mActionLicence->plug( helpMenu ); |
2189 | mActionAboutKAddressbook->plug( helpMenu ); | 2190 | mActionAboutKAddressbook->plug( helpMenu ); |
2190 | 2191 | ||
2191 | if (KGlobal::getDesktopSize() > KGlobal::Small ) { | 2192 | if (KGlobal::getDesktopSize() > KGlobal::Small ) { |
2192 | 2193 | ||
2193 | mActionSave->plug( tb ); | 2194 | mActionSave->plug( tb ); |
2194 | mViewManager->getFilterAction()->plug ( tb); | 2195 | mViewManager->getFilterAction()->plug ( tb); |
2195 | if (KGlobal::getDesktopSize() == KGlobal::Desktop ) { | 2196 | //LR hide filteraction on started in 480x640 |
2196 | mActionUndo->plug( tb ); | 2197 | if (QApplication::desktop()->width() == 480 ) { |
2197 | mActionDelete->plug( tb ); | 2198 | mViewManager->getFilterAction()->setComboWidth( 0 ); |
2198 | mActionRedo->plug( tb ); | ||
2199 | } | 2199 | } |
2200 | mActionUndo->plug( tb ); | ||
2201 | mActionDelete->plug( tb ); | ||
2202 | mActionRedo->plug( tb ); | ||
2200 | } else { | 2203 | } else { |
2201 | mActionSave->plug( tb ); | 2204 | mActionSave->plug( tb ); |
2202 | tb->enableMoving(false); | 2205 | tb->enableMoving(false); |
2203 | } | 2206 | } |
2204 | //mActionQuit->plug ( tb ); | 2207 | //mActionQuit->plug ( tb ); |
2205 | // tb->insertWidget(-1, 0, mIncSearchWidget, 6); | 2208 | // tb->insertWidget(-1, 0, mIncSearchWidget, 6); |
2206 | 2209 | ||
2207 | //US link the searchwidget first to this. | 2210 | //US link the searchwidget first to this. |
2208 | // The real linkage to the toolbar happens later. | 2211 | // The real linkage to the toolbar happens later. |
2209 | //US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE); | 2212 | //US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE); |
2210 | //US tb->insertItem( mIncSearchWidget ); | 2213 | //US tb->insertItem( mIncSearchWidget ); |
2211 | /*US | 2214 | /*US |
2212 | mIncSearchWidget = new IncSearchWidget( tb ); | 2215 | mIncSearchWidget = new IncSearchWidget( tb ); |
2213 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), | 2216 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), |
2214 | SLOT( incrementalSearch( const QString& ) ) ); | 2217 | SLOT( incrementalSearch( const QString& ) ) ); |
2215 | 2218 | ||
2216 | mJumpButtonBar = new JumpButtonBar( this, this ); | 2219 | mJumpButtonBar = new JumpButtonBar( this, this ); |
2217 | 2220 | ||
2218 | //US topLayout->addWidget( mJumpButtonBar ); | 2221 | //US topLayout->addWidget( mJumpButtonBar ); |
2219 | this->layout()->add( mJumpButtonBar ); | 2222 | this->layout()->add( mJumpButtonBar ); |
2220 | */ | 2223 | */ |
2221 | 2224 | ||
2222 | #endif //KAB_EMBEDDED | 2225 | #endif //KAB_EMBEDDED |
2223 | 2226 | ||
2224 | mActionExport2phone->plug( ExportMenu ); | 2227 | mActionExport2phone->plug( ExportMenu ); |
2225 | connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) ); | 2228 | connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) ); |
2226 | syncManager->fillSyncMenu(); | 2229 | syncManager->fillSyncMenu(); |
2227 | 2230 | ||
2228 | } | 2231 | } |
2229 | void KABCore::showLicence() | 2232 | void KABCore::showLicence() |
2230 | { | 2233 | { |
2231 | KApplication::showLicence(); | 2234 | KApplication::showLicence(); |
2232 | } | 2235 | } |
2233 | 2236 | ||
2234 | void KABCore::manageCategories( ) | 2237 | void KABCore::manageCategories( ) |
2235 | { | 2238 | { |
2236 | KABCatPrefs* cp = new KABCatPrefs(); | 2239 | KABCatPrefs* cp = new KABCatPrefs(); |
2237 | cp->show(); | 2240 | cp->show(); |
2238 | int w =cp->sizeHint().width() ; | 2241 | int w =cp->sizeHint().width() ; |
2239 | int h = cp->sizeHint().height() ; | 2242 | int h = cp->sizeHint().height() ; |
2240 | int dw = QApplication::desktop()->width(); | 2243 | int dw = QApplication::desktop()->width(); |
2241 | int dh = QApplication::desktop()->height(); | 2244 | int dh = QApplication::desktop()->height(); |
2242 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2245 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2243 | if ( !cp->exec() ) { | 2246 | if ( !cp->exec() ) { |
2244 | delete cp; | 2247 | delete cp; |
2245 | return; | 2248 | return; |
2246 | } | 2249 | } |
2247 | int count = 0; | 2250 | int count = 0; |
2248 | message( i18n("Please wait, processing categories...")); | 2251 | message( i18n("Please wait, processing categories...")); |
2249 | if ( cp->addCat() ) { | 2252 | if ( cp->addCat() ) { |
2250 | KABC::AddressBook::Iterator it; | 2253 | KABC::AddressBook::Iterator it; |
2251 | QStringList catList = KABPrefs::instance()->mCustomCategories; | 2254 | QStringList catList = KABPrefs::instance()->mCustomCategories; |
2252 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { | 2255 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { |
2253 | QStringList catIncList = (*it).categories(); | 2256 | QStringList catIncList = (*it).categories(); |
2254 | int i; | 2257 | int i; |
2255 | for( i = 0; i< catIncList.count(); ++i ) { | 2258 | for( i = 0; i< catIncList.count(); ++i ) { |
2256 | if ( !catList.contains (catIncList[i])) { | 2259 | if ( !catList.contains (catIncList[i])) { |
2257 | catList.append( catIncList[i] ); | 2260 | catList.append( catIncList[i] ); |
2258 | //qDebug("add cat %s ", catIncList[i].latin1()); | 2261 | //qDebug("add cat %s ", catIncList[i].latin1()); |
2259 | ++count; | 2262 | ++count; |
2260 | } | 2263 | } |
2261 | } | 2264 | } |
2262 | } | 2265 | } |
2263 | catList.sort(); | 2266 | catList.sort(); |
2264 | KABPrefs::instance()->mCustomCategories = catList; | 2267 | KABPrefs::instance()->mCustomCategories = catList; |
2265 | KABPrefs::instance()->writeConfig(); | 2268 | KABPrefs::instance()->writeConfig(); |
2266 | message(QString::number( count )+ i18n(" categories added to list! ")); | 2269 | message(QString::number( count )+ i18n(" categories added to list! ")); |
2267 | } else { | 2270 | } else { |
2268 | QStringList catList = KABPrefs::instance()->mCustomCategories; | 2271 | QStringList catList = KABPrefs::instance()->mCustomCategories; |
2269 | QStringList catIncList; | 2272 | QStringList catIncList; |
2270 | QStringList newCatList; | 2273 | QStringList newCatList; |
2271 | KABC::AddressBook::Iterator it; | 2274 | KABC::AddressBook::Iterator it; |
2272 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { | 2275 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { |
2273 | QStringList catIncList = (*it).categories(); | 2276 | QStringList catIncList = (*it).categories(); |
2274 | int i; | 2277 | int i; |
2275 | if ( catIncList.count() ) { | 2278 | if ( catIncList.count() ) { |
2276 | newCatList.clear(); | 2279 | newCatList.clear(); |
2277 | for( i = 0; i< catIncList.count(); ++i ) { | 2280 | for( i = 0; i< catIncList.count(); ++i ) { |
2278 | if ( catList.contains (catIncList[i])) { | 2281 | if ( catList.contains (catIncList[i])) { |
2279 | newCatList.append( catIncList[i] ); | 2282 | newCatList.append( catIncList[i] ); |
2280 | } | 2283 | } |
2281 | } | 2284 | } |
2282 | newCatList.sort(); | 2285 | newCatList.sort(); |
2283 | (*it).setCategories( newCatList ); | 2286 | (*it).setCategories( newCatList ); |
2284 | mAddressBook->insertAddressee( (*it) ); | 2287 | mAddressBook->insertAddressee( (*it) ); |
2285 | } | 2288 | } |
2286 | } | 2289 | } |
2287 | setModified( true ); | 2290 | setModified( true ); |
2288 | mViewManager->refreshView(); | 2291 | mViewManager->refreshView(); |
2289 | mDetails->refreshView(); | 2292 | mDetails->refreshView(); |
2290 | message( i18n("Removing categories done!")); | 2293 | message( i18n("Removing categories done!")); |
2291 | } | 2294 | } |
2292 | delete cp; | 2295 | delete cp; |
2293 | } | 2296 | } |
2294 | void KABCore::removeVoice() | 2297 | void KABCore::removeVoice() |
2295 | { | 2298 | { |
2296 | if ( KMessageBox::questionYesNo( this, i18n("After importing, phone numbers\nmay have two or more types.\n(E.g. work+voice)\nThese numbers are shown as \"other\".\nClick Yes to remove the voice type\nfrom numbers with more than one type.\n\nRemove voice type?") ) == KMessageBox::No ) | 2299 | if ( KMessageBox::questionYesNo( this, i18n("After importing, phone numbers\nmay have two or more types.\n(E.g. work+voice)\nThese numbers are shown as \"other\".\nClick Yes to remove the voice type\nfrom numbers with more than one type.\n\nRemove voice type?") ) == KMessageBox::No ) |
2297 | return; | 2300 | return; |
2298 | KABC::Addressee::List list; | 2301 | KABC::Addressee::List list; |
2299 | XXPortSelectDialog dlg( this, false, this ); | 2302 | XXPortSelectDialog dlg( this, false, this ); |
2300 | if ( dlg.exec() ) | 2303 | if ( dlg.exec() ) |
2301 | list = dlg.contacts(); | 2304 | list = dlg.contacts(); |
2302 | else | 2305 | else |
2303 | return; | 2306 | return; |
2304 | KABC::Addressee::List::Iterator it; | 2307 | KABC::Addressee::List::Iterator it; |
2305 | for ( it = list.begin(); it != list.end(); ++it ) { | 2308 | for ( it = list.begin(); it != list.end(); ++it ) { |
2306 | if ( (*it).removeVoice() ) | 2309 | if ( (*it).removeVoice() ) |
2307 | contactModified((*it) ); | 2310 | contactModified((*it) ); |
2308 | } | 2311 | } |
2309 | } | 2312 | } |
2310 | 2313 | ||
2311 | 2314 | ||
2312 | 2315 | ||
2313 | void KABCore::clipboardDataChanged() | 2316 | void KABCore::clipboardDataChanged() |
2314 | { | 2317 | { |
2315 | 2318 | ||
2316 | if ( mReadWrite ) | 2319 | if ( mReadWrite ) |
2317 | mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() ); | 2320 | mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() ); |
2318 | 2321 | ||
2319 | } | 2322 | } |
2320 | 2323 | ||
2321 | void KABCore::updateActionMenu() | 2324 | void KABCore::updateActionMenu() |
2322 | { | 2325 | { |
2323 | UndoStack *undo = UndoStack::instance(); | 2326 | UndoStack *undo = UndoStack::instance(); |
2324 | RedoStack *redo = RedoStack::instance(); | 2327 | RedoStack *redo = RedoStack::instance(); |
2325 | 2328 | ||
2326 | if ( undo->isEmpty() ) | 2329 | if ( undo->isEmpty() ) |
2327 | mActionUndo->setText( i18n( "Undo" ) ); | 2330 | mActionUndo->setText( i18n( "Undo" ) ); |
diff --git a/kaddressbook/viewmanager.cpp b/kaddressbook/viewmanager.cpp index 0d91c12..33bef5a 100644 --- a/kaddressbook/viewmanager.cpp +++ b/kaddressbook/viewmanager.cpp | |||
@@ -1,237 +1,241 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KAddressBook. | 2 | This file is part of KAddressBook. |
3 | Copyright (c) 2002 Mike Pilone <mpilone@slac.com> | 3 | Copyright (c) 2002 Mike Pilone <mpilone@slac.com> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | /* | 24 | /* |
25 | Enhanced Version of the file for platform independent KDE tools. | 25 | Enhanced Version of the file for platform independent KDE tools. |
26 | Copyright (c) 2004 Ulf Schenk | 26 | Copyright (c) 2004 Ulf Schenk |
27 | 27 | ||
28 | $Id$ | 28 | $Id$ |
29 | */ | 29 | */ |
30 | 30 | ||
31 | 31 | ||
32 | #ifndef KAB_EMBEDDED | 32 | #ifndef KAB_EMBEDDED |
33 | #include <libkdepim/kvcarddrag.h> | 33 | #include <libkdepim/kvcarddrag.h> |
34 | #include <kabc/vcardconverter.h> | 34 | #include <kabc/vcardconverter.h> |
35 | #include <kconfig.h> | 35 | #include <kconfig.h> |
36 | #include <kdeversion.h> | 36 | #include <kdeversion.h> |
37 | #include <kiconloader.h> | 37 | #include <kiconloader.h> |
38 | #include <klocale.h> | 38 | #include <klocale.h> |
39 | #include <kmessagebox.h> | 39 | #include <kmessagebox.h> |
40 | #include <kmultipledrag.h> | 40 | #include <kmultipledrag.h> |
41 | #include <ktrader.h> | 41 | #include <ktrader.h> |
42 | #include <kurldrag.h> | 42 | #include <kurldrag.h> |
43 | 43 | ||
44 | #include "addresseeutil.h" | 44 | #include "addresseeutil.h" |
45 | #else //KAB_EMBEDDED | 45 | #else //KAB_EMBEDDED |
46 | #include "views/kaddressbookiconview.h" | 46 | #include "views/kaddressbookiconview.h" |
47 | #include "views/kaddressbooktableview.h" | 47 | #include "views/kaddressbooktableview.h" |
48 | #include "views/kaddressbookcardview.h" | 48 | #include "views/kaddressbookcardview.h" |
49 | #include "kaddressbookview.h" | 49 | #include "kaddressbookview.h" |
50 | 50 | ||
51 | #include <qaction.h> | 51 | #include <qaction.h> |
52 | #include <qmessagebox.h> | 52 | #include <qmessagebox.h> |
53 | #include <qpopupmenu.h> | 53 | #include <qpopupmenu.h> |
54 | #include <kconfigbase.h> | 54 | #include <kconfigbase.h> |
55 | 55 | ||
56 | #endif //KAB_EMBEDDED | 56 | #endif //KAB_EMBEDDED |
57 | 57 | ||
58 | 58 | ||
59 | #include <kdebug.h> | 59 | #include <kdebug.h> |
60 | #include <kactionclasses.h> | 60 | #include <kactionclasses.h> |
61 | 61 | ||
62 | #include <qlayout.h> | 62 | #include <qlayout.h> |
63 | #include <qapplication.h> | ||
63 | #include <qwidgetstack.h> | 64 | #include <qwidgetstack.h> |
64 | 65 | ||
65 | #include <kabc/addressbook.h> | 66 | #include <kabc/addressbook.h> |
66 | #include "filtereditdialog.h" | 67 | #include "filtereditdialog.h" |
67 | #include "addviewdialog.h" | 68 | #include "addviewdialog.h" |
68 | #include "kabcore.h" | 69 | #include "kabcore.h" |
69 | #include "kabprefs.h" | 70 | #include "kabprefs.h" |
70 | #include "viewmanager.h" | 71 | #include "viewmanager.h" |
71 | 72 | ||
72 | ViewManager::ViewManager( KABCore *core, QWidget *parent, const char *name ) | 73 | ViewManager::ViewManager( KABCore *core, QWidget *parent, const char *name ) |
73 | : QWidget( parent, name ), mCore( core ), mActiveView( 0 ) | 74 | : QWidget( parent, name ), mCore( core ), mActiveView( 0 ) |
74 | { | 75 | { |
75 | initGUI(); | 76 | initGUI(); |
76 | initActions(); | 77 | initActions(); |
77 | 78 | ||
78 | mViewDict.setAutoDelete( true ); | 79 | mViewDict.setAutoDelete( true ); |
79 | 80 | ||
80 | createViewFactories(); | 81 | createViewFactories(); |
81 | } | 82 | } |
82 | 83 | ||
83 | ViewManager::~ViewManager() | 84 | ViewManager::~ViewManager() |
84 | { | 85 | { |
85 | unloadViews(); | 86 | unloadViews(); |
86 | mViewFactoryDict.clear(); | 87 | mViewFactoryDict.clear(); |
87 | } | 88 | } |
88 | void ViewManager::scrollUP() | 89 | void ViewManager::scrollUP() |
89 | { | 90 | { |
90 | if ( mActiveView ) | 91 | if ( mActiveView ) |
91 | mActiveView->scrollUP(); | 92 | mActiveView->scrollUP(); |
92 | } | 93 | } |
93 | void ViewManager::scrollDOWN() | 94 | void ViewManager::scrollDOWN() |
94 | { | 95 | { |
95 | if ( mActiveView ) | 96 | if ( mActiveView ) |
96 | mActiveView->scrollDOWN(); | 97 | mActiveView->scrollDOWN(); |
97 | } | 98 | } |
98 | void ViewManager::restoreSettings() | 99 | void ViewManager::restoreSettings() |
99 | { | 100 | { |
100 | mViewNameList = KABPrefs::instance()->mViewNames; | 101 | mViewNameList = KABPrefs::instance()->mViewNames; |
101 | QString activeViewName = KABPrefs::instance()->mCurrentView; | 102 | QString activeViewName = KABPrefs::instance()->mCurrentView; |
102 | 103 | ||
103 | mActionSelectView->setItems( mViewNameList ); | 104 | mActionSelectView->setItems( mViewNameList ); |
104 | 105 | ||
105 | // Filter | 106 | // Filter |
106 | mFilterList = Filter::restore( mCore->config(), "Filter" ); | 107 | mFilterList = Filter::restore( mCore->config(), "Filter" ); |
107 | mActionSelectFilter->setItems( filterNames() ); | 108 | mActionSelectFilter->setItems( filterNames() ); |
108 | mActionSelectFilter->setCurrentItem( KABPrefs::instance()->mCurrentFilter ); | 109 | mActionSelectFilter->setCurrentItem( KABPrefs::instance()->mCurrentFilter ); |
109 | mActionSelectFilter->setComboWidth( 150 ); | 110 | int cw = 150; |
111 | if (QApplication::desktop()->width() == 480 ) | ||
112 | cw = 0; | ||
113 | mActionSelectFilter->setComboWidth( cw ); | ||
110 | // Tell the views to reread their config, since they may have | 114 | // Tell the views to reread their config, since they may have |
111 | // been modified by global settings | 115 | // been modified by global settings |
112 | QString _oldgroup = mCore->config()->group(); | 116 | QString _oldgroup = mCore->config()->group(); |
113 | 117 | ||
114 | QDictIterator<KAddressBookView> it( mViewDict ); | 118 | QDictIterator<KAddressBookView> it( mViewDict ); |
115 | for ( it.toFirst(); it.current(); ++it ) { | 119 | for ( it.toFirst(); it.current(); ++it ) { |
116 | KConfigGroupSaver saver( mCore->config(), it.currentKey() ); | 120 | KConfigGroupSaver saver( mCore->config(), it.currentKey() ); |
117 | it.current()->readConfig( mCore->config() ); | 121 | it.current()->readConfig( mCore->config() ); |
118 | } | 122 | } |
119 | setActiveView( activeViewName ); | 123 | setActiveView( activeViewName ); |
120 | 124 | ||
121 | mActionDeleteView->setEnabled( mViewNameList.count() > 1 ); | 125 | mActionDeleteView->setEnabled( mViewNameList.count() > 1 ); |
122 | } | 126 | } |
123 | 127 | ||
124 | void ViewManager::saveSettings() | 128 | void ViewManager::saveSettings() |
125 | { | 129 | { |
126 | QString _oldgroup = mCore->config()->group(); | 130 | QString _oldgroup = mCore->config()->group(); |
127 | 131 | ||
128 | QDictIterator<KAddressBookView> it( mViewDict ); | 132 | QDictIterator<KAddressBookView> it( mViewDict ); |
129 | for ( it.toFirst(); it.current(); ++it ) { | 133 | for ( it.toFirst(); it.current(); ++it ) { |
130 | KConfigGroupSaver saver( mCore->config(), it.currentKey() ); | 134 | KConfigGroupSaver saver( mCore->config(), it.currentKey() ); |
131 | #ifdef DESKTOP_VERSION | 135 | #ifdef DESKTOP_VERSION |
132 | (*it)->writeConfig( mCore->config() ); | 136 | (*it)->writeConfig( mCore->config() ); |
133 | #else | 137 | #else |
134 | (*it).writeConfig( mCore->config() ); | 138 | (*it).writeConfig( mCore->config() ); |
135 | #endif | 139 | #endif |
136 | } | 140 | } |
137 | 141 | ||
138 | Filter::save( mCore->config(), "Filter", mFilterList ); | 142 | Filter::save( mCore->config(), "Filter", mFilterList ); |
139 | KABPrefs::instance()->mCurrentFilter = mActionSelectFilter->currentItem(); | 143 | KABPrefs::instance()->mCurrentFilter = mActionSelectFilter->currentItem(); |
140 | 144 | ||
141 | // write the view name list | 145 | // write the view name list |
142 | KABPrefs::instance()->mViewNames = mViewNameList; | 146 | KABPrefs::instance()->mViewNames = mViewNameList; |
143 | KABPrefs::instance()->mCurrentView = mActiveView->caption(); | 147 | KABPrefs::instance()->mCurrentView = mActiveView->caption(); |
144 | 148 | ||
145 | } | 149 | } |
146 | 150 | ||
147 | QStringList ViewManager::selectedUids() const | 151 | QStringList ViewManager::selectedUids() const |
148 | { | 152 | { |
149 | if ( mActiveView ) | 153 | if ( mActiveView ) |
150 | return mActiveView->selectedUids(); | 154 | return mActiveView->selectedUids(); |
151 | else | 155 | else |
152 | return QStringList(); | 156 | return QStringList(); |
153 | } | 157 | } |
154 | 158 | ||
155 | QStringList ViewManager::selectedEmails() const | 159 | QStringList ViewManager::selectedEmails() const |
156 | { | 160 | { |
157 | if ( mActiveView ) | 161 | if ( mActiveView ) |
158 | return mActiveView->selectedEmails(); | 162 | return mActiveView->selectedEmails(); |
159 | else | 163 | else |
160 | return QStringList(); | 164 | return QStringList(); |
161 | } | 165 | } |
162 | 166 | ||
163 | KABC::Addressee::List ViewManager::selectedAddressees() const | 167 | KABC::Addressee::List ViewManager::selectedAddressees() const |
164 | { | 168 | { |
165 | KABC::Addressee::List list; | 169 | KABC::Addressee::List list; |
166 | if ( mActiveView ) { | 170 | if ( mActiveView ) { |
167 | QStringList uids = mActiveView->selectedUids(); | 171 | QStringList uids = mActiveView->selectedUids(); |
168 | QStringList::Iterator it; | 172 | QStringList::Iterator it; |
169 | for ( it = uids.begin(); it != uids.end(); ++it ) { | 173 | for ( it = uids.begin(); it != uids.end(); ++it ) { |
170 | KABC::Addressee addr = mCore->addressBook()->findByUid( *it ); | 174 | KABC::Addressee addr = mCore->addressBook()->findByUid( *it ); |
171 | if ( !addr.isEmpty() ) | 175 | if ( !addr.isEmpty() ) |
172 | list.append( addr ); | 176 | list.append( addr ); |
173 | } | 177 | } |
174 | } | 178 | } |
175 | 179 | ||
176 | return list; | 180 | return list; |
177 | } | 181 | } |
178 | //US added another method with no parameter, since my moc compiler does not support default parameters. | 182 | //US added another method with no parameter, since my moc compiler does not support default parameters. |
179 | void ViewManager::setSelected() | 183 | void ViewManager::setSelected() |
180 | { | 184 | { |
181 | setSelected( QString::null, true ); | 185 | setSelected( QString::null, true ); |
182 | } | 186 | } |
183 | 187 | ||
184 | void ViewManager::setSelected( const QString &uid, bool selected ) | 188 | void ViewManager::setSelected( const QString &uid, bool selected ) |
185 | { | 189 | { |
186 | if ( mActiveView ) | 190 | if ( mActiveView ) |
187 | mActiveView->setSelected( uid, selected ); | 191 | mActiveView->setSelected( uid, selected ); |
188 | } | 192 | } |
189 | 193 | ||
190 | void ViewManager::setListSelected(QStringList list) | 194 | void ViewManager::setListSelected(QStringList list) |
191 | { | 195 | { |
192 | int i, count = list.count(); | 196 | int i, count = list.count(); |
193 | for ( i = 0; i < count;++i ) | 197 | for ( i = 0; i < count;++i ) |
194 | setSelected( list[i], true ); | 198 | setSelected( list[i], true ); |
195 | 199 | ||
196 | } | 200 | } |
197 | void ViewManager::unloadViews() | 201 | void ViewManager::unloadViews() |
198 | { | 202 | { |
199 | mViewDict.clear(); | 203 | mViewDict.clear(); |
200 | mActiveView = 0; | 204 | mActiveView = 0; |
201 | } | 205 | } |
202 | 206 | ||
203 | void ViewManager::setActiveView( const QString &name ) | 207 | void ViewManager::setActiveView( const QString &name ) |
204 | { | 208 | { |
205 | KAddressBookView *view = 0; | 209 | KAddressBookView *view = 0; |
206 | 210 | ||
207 | // Check that this isn't the same as the current active view | 211 | // Check that this isn't the same as the current active view |
208 | if ( mActiveView && ( mActiveView->caption() == name ) ) | 212 | if ( mActiveView && ( mActiveView->caption() == name ) ) |
209 | return; | 213 | return; |
210 | 214 | ||
211 | // At this point we know the view that should be active is not | 215 | // At this point we know the view that should be active is not |
212 | // currently active. We will try to find the new on in the list. If | 216 | // currently active. We will try to find the new on in the list. If |
213 | // we can't find it, it means it hasn't been instantiated, so we will | 217 | // we can't find it, it means it hasn't been instantiated, so we will |
214 | // create it on demand. | 218 | // create it on demand. |
215 | 219 | ||
216 | view = mViewDict.find( name ); | 220 | view = mViewDict.find( name ); |
217 | 221 | ||
218 | // Check if we found the view. If we didn't, then we need to create it | 222 | // Check if we found the view. If we didn't, then we need to create it |
219 | if ( view == 0 ) { | 223 | if ( view == 0 ) { |
220 | KConfig *config = mCore->config(); | 224 | KConfig *config = mCore->config(); |
221 | 225 | ||
222 | KConfigGroupSaver saver( config, name ); | 226 | KConfigGroupSaver saver( config, name ); |
223 | 227 | ||
224 | QString type = config->readEntry( "Type", "Table" ); | 228 | QString type = config->readEntry( "Type", "Table" ); |
225 | 229 | ||
226 | kdDebug(5720) << "ViewManager::setActiveView: creating view - " << name << endl; | 230 | kdDebug(5720) << "ViewManager::setActiveView: creating view - " << name << endl; |
227 | 231 | ||
228 | ViewFactory *factory = mViewFactoryDict.find( type ); | 232 | ViewFactory *factory = mViewFactoryDict.find( type ); |
229 | if ( factory ) | 233 | if ( factory ) |
230 | view = factory->view( mCore->addressBook(), mViewWidgetStack ); | 234 | view = factory->view( mCore->addressBook(), mViewWidgetStack ); |
231 | 235 | ||
232 | if ( view ) { | 236 | if ( view ) { |
233 | view->setCaption( name ); | 237 | view->setCaption( name ); |
234 | mViewDict.insert( name, view ); | 238 | mViewDict.insert( name, view ); |
235 | //US my version needs an int as second parameter to addWidget | 239 | //US my version needs an int as second parameter to addWidget |
236 | mViewWidgetStack->addWidget( view, -1 ); | 240 | mViewWidgetStack->addWidget( view, -1 ); |
237 | view->readConfig( config ); | 241 | view->readConfig( config ); |
@@ -472,247 +476,250 @@ void ViewManager::createViewFactories() | |||
472 | mViewFactoryDict.insert( viewFactory->type(), viewFactory ); | 476 | mViewFactoryDict.insert( viewFactory->type(), viewFactory ); |
473 | // qDebug("ViewManager::createViewFactories() Loading factory: %s", viewFactory->type().latin1()); | 477 | // qDebug("ViewManager::createViewFactories() Loading factory: %s", viewFactory->type().latin1()); |
474 | 478 | ||
475 | viewFactory = new TableViewFactory(); | 479 | viewFactory = new TableViewFactory(); |
476 | mViewFactoryDict.insert( viewFactory->type(), viewFactory ); | 480 | mViewFactoryDict.insert( viewFactory->type(), viewFactory ); |
477 | // qDebug("ViewManager::createViewFactories() Loading factory: %s", viewFactory->type().latin1()); | 481 | // qDebug("ViewManager::createViewFactories() Loading factory: %s", viewFactory->type().latin1()); |
478 | 482 | ||
479 | viewFactory = new CardViewFactory(); | 483 | viewFactory = new CardViewFactory(); |
480 | mViewFactoryDict.insert( viewFactory->type(), viewFactory ); | 484 | mViewFactoryDict.insert( viewFactory->type(), viewFactory ); |
481 | // qDebug("ViewManager::createViewFactories() Loading factory: %s", viewFactory->type().latin1()); | 485 | // qDebug("ViewManager::createViewFactories() Loading factory: %s", viewFactory->type().latin1()); |
482 | 486 | ||
483 | #endif //KAB_EMBEDDED | 487 | #endif //KAB_EMBEDDED |
484 | 488 | ||
485 | } | 489 | } |
486 | 490 | ||
487 | void ViewManager::dropped( QDropEvent *e ) | 491 | void ViewManager::dropped( QDropEvent *e ) |
488 | { | 492 | { |
489 | kdDebug(5720) << "ViewManager::dropped: got a drop event" << endl; | 493 | kdDebug(5720) << "ViewManager::dropped: got a drop event" << endl; |
490 | 494 | ||
491 | #ifndef KAB_EMBEDDED | 495 | #ifndef KAB_EMBEDDED |
492 | 496 | ||
493 | QString clipText, vcards; | 497 | QString clipText, vcards; |
494 | KURL::List urls; | 498 | KURL::List urls; |
495 | 499 | ||
496 | if ( KURLDrag::decode( e, urls) ) { | 500 | if ( KURLDrag::decode( e, urls) ) { |
497 | KURL::List::Iterator it = urls.begin(); | 501 | KURL::List::Iterator it = urls.begin(); |
498 | int c = urls.count(); | 502 | int c = urls.count(); |
499 | if ( c > 1 ) { | 503 | if ( c > 1 ) { |
500 | QString questionString = i18n( "Import one contact into your addressbook?", "Import %n contacts into your addressbook?", c ); | 504 | QString questionString = i18n( "Import one contact into your addressbook?", "Import %n contacts into your addressbook?", c ); |
501 | if ( KMessageBox::questionYesNo( this, questionString, i18n( "Import Contacts?" ) ) == KMessageBox::Yes ) { | 505 | if ( KMessageBox::questionYesNo( this, questionString, i18n( "Import Contacts?" ) ) == KMessageBox::Yes ) { |
502 | for ( ; it != urls.end(); ++it ) | 506 | for ( ; it != urls.end(); ++it ) |
503 | emit urlDropped( *it ); | 507 | emit urlDropped( *it ); |
504 | } | 508 | } |
505 | } else if ( c == 1 ) | 509 | } else if ( c == 1 ) |
506 | emit urlDropped( *it ); | 510 | emit urlDropped( *it ); |
507 | } else if ( KVCardDrag::decode( e, vcards ) ) { | 511 | } else if ( KVCardDrag::decode( e, vcards ) ) { |
508 | KABC::Addressee addr; | 512 | KABC::Addressee addr; |
509 | KABC::VCardConverter converter; | 513 | KABC::VCardConverter converter; |
510 | QStringList list = QStringList::split( "\r\n\r\n", vcards ); | 514 | QStringList list = QStringList::split( "\r\n\r\n", vcards ); |
511 | QStringList::Iterator it; | 515 | QStringList::Iterator it; |
512 | for ( it = list.begin(); it != list.end(); ++it ) { | 516 | for ( it = list.begin(); it != list.end(); ++it ) { |
513 | if ( converter.vCardToAddressee( (*it).stripWhiteSpace(), addr ) ) { | 517 | if ( converter.vCardToAddressee( (*it).stripWhiteSpace(), addr ) ) { |
514 | KABC::Addressee a = mCore->addressBook()->findByUid( addr.uid() ); | 518 | KABC::Addressee a = mCore->addressBook()->findByUid( addr.uid() ); |
515 | if ( a.isEmpty() ) { | 519 | if ( a.isEmpty() ) { |
516 | mCore->addressBook()->insertAddressee( addr ); | 520 | mCore->addressBook()->insertAddressee( addr ); |
517 | emit modified(); | 521 | emit modified(); |
518 | } | 522 | } |
519 | } | 523 | } |
520 | } | 524 | } |
521 | 525 | ||
522 | mActiveView->refresh(); | 526 | mActiveView->refresh(); |
523 | } | 527 | } |
524 | #else //KAB_EMBEDDED | 528 | #else //KAB_EMBEDDED |
525 | qDebug("ViewManager::dropped() has to be changed!!" ); | 529 | qDebug("ViewManager::dropped() has to be changed!!" ); |
526 | #endif //KAB_EMBEDDED | 530 | #endif //KAB_EMBEDDED |
527 | 531 | ||
528 | } | 532 | } |
529 | 533 | ||
530 | void ViewManager::startDrag() | 534 | void ViewManager::startDrag() |
531 | { | 535 | { |
532 | kdDebug(5720) << "ViewManager::startDrag: starting to drag" << endl; | 536 | kdDebug(5720) << "ViewManager::startDrag: starting to drag" << endl; |
533 | 537 | ||
534 | #ifndef KAB_EMBEDDED | 538 | #ifndef KAB_EMBEDDED |
535 | 539 | ||
536 | // Get the list of all the selected addressees | 540 | // Get the list of all the selected addressees |
537 | KABC::Addressee::List addrList; | 541 | KABC::Addressee::List addrList; |
538 | QStringList uidList = selectedUids(); | 542 | QStringList uidList = selectedUids(); |
539 | QStringList::Iterator iter; | 543 | QStringList::Iterator iter; |
540 | for ( iter = uidList.begin(); iter != uidList.end(); ++iter ) | 544 | for ( iter = uidList.begin(); iter != uidList.end(); ++iter ) |
541 | addrList.append( mCore->addressBook()->findByUid( *iter ) ); | 545 | addrList.append( mCore->addressBook()->findByUid( *iter ) ); |
542 | 546 | ||
543 | KMultipleDrag *drag = new KMultipleDrag( this ); | 547 | KMultipleDrag *drag = new KMultipleDrag( this ); |
544 | drag->addDragObject( new QTextDrag( AddresseeUtil::addresseesToClipboard(addrList), this ) ); | 548 | drag->addDragObject( new QTextDrag( AddresseeUtil::addresseesToClipboard(addrList), this ) ); |
545 | KABC::Addressee::List::Iterator it; | 549 | KABC::Addressee::List::Iterator it; |
546 | QStringList vcards; | 550 | QStringList vcards; |
547 | for ( it = addrList.begin(); it != addrList.end(); ++it ) { | 551 | for ( it = addrList.begin(); it != addrList.end(); ++it ) { |
548 | QString vcard = QString::null; | 552 | QString vcard = QString::null; |
549 | KABC::VCardConverter converter; | 553 | KABC::VCardConverter converter; |
550 | if ( converter.addresseeToVCard( *it, vcard ) ) | 554 | if ( converter.addresseeToVCard( *it, vcard ) ) |
551 | vcards.append( vcard ); | 555 | vcards.append( vcard ); |
552 | } | 556 | } |
553 | drag->addDragObject( new KVCardDrag( vcards.join( "\r\n" ), this ) ); | 557 | drag->addDragObject( new KVCardDrag( vcards.join( "\r\n" ), this ) ); |
554 | 558 | ||
555 | drag->setPixmap( KGlobal::iconLoader()->loadIcon( "vcard", KIcon::Desktop ) ); | 559 | drag->setPixmap( KGlobal::iconLoader()->loadIcon( "vcard", KIcon::Desktop ) ); |
556 | drag->dragCopy(); | 560 | drag->dragCopy(); |
557 | 561 | ||
558 | #else //KAB_EMBEDDED | 562 | #else //KAB_EMBEDDED |
559 | qDebug("ViewManager::startDrag() has to be changed!!" ); | 563 | qDebug("ViewManager::startDrag() has to be changed!!" ); |
560 | #endif //KAB_EMBEDDED | 564 | #endif //KAB_EMBEDDED |
561 | 565 | ||
562 | } | 566 | } |
563 | void ViewManager::doSearch( const QString& s,KABC::Field *field ) | 567 | void ViewManager::doSearch( const QString& s,KABC::Field *field ) |
564 | { | 568 | { |
565 | if ( mActiveView ) | 569 | if ( mActiveView ) |
566 | mActiveView->doSearch( s, field ); | 570 | mActiveView->doSearch( s, field ); |
567 | 571 | ||
568 | } | 572 | } |
569 | void ViewManager::setActiveFilter( int index ) | 573 | void ViewManager::setActiveFilter( int index ) |
570 | { | 574 | { |
571 | Filter currentFilter; | 575 | Filter currentFilter; |
572 | 576 | ||
573 | if ( ( index - 1 ) < 0 ) | 577 | if ( ( index - 1 ) < 0 ) |
574 | currentFilter = Filter(); | 578 | currentFilter = Filter(); |
575 | else | 579 | else |
576 | currentFilter = mFilterList[ index - 1 ]; | 580 | currentFilter = mFilterList[ index - 1 ]; |
577 | 581 | ||
578 | // Check if we have a view. Since the filter combo is created before | 582 | // Check if we have a view. Since the filter combo is created before |
579 | // the view, this slot could be called before there is a valid view. | 583 | // the view, this slot could be called before there is a valid view. |
580 | if ( mActiveView ) { | 584 | if ( mActiveView ) { |
581 | mActiveView->setFilter( currentFilter ); | 585 | mActiveView->setFilter( currentFilter ); |
582 | mActiveView->refresh(); | 586 | mActiveView->refresh(); |
583 | emit selected( QString::null ); | 587 | emit selected( QString::null ); |
584 | } | 588 | } |
585 | } | 589 | } |
586 | 590 | ||
587 | void ViewManager::configureFilters() | 591 | void ViewManager::configureFilters() |
588 | { | 592 | { |
589 | FilterDialog dlg( this ); | 593 | FilterDialog dlg( this ); |
590 | 594 | ||
591 | dlg.setFilters( mFilterList ); | 595 | dlg.setFilters( mFilterList ); |
592 | 596 | ||
593 | if ( dlg.exec() ) | 597 | if ( dlg.exec() ) |
594 | mFilterList = dlg.filters(); | 598 | mFilterList = dlg.filters(); |
595 | 599 | ||
596 | uint pos = mActionSelectFilter->currentItem(); | 600 | uint pos = mActionSelectFilter->currentItem(); |
597 | mActionSelectFilter->setItems( filterNames() ); | 601 | mActionSelectFilter->setItems( filterNames() ); |
598 | mActionSelectFilter->setCurrentItem( pos ); | 602 | mActionSelectFilter->setCurrentItem( pos ); |
599 | setActiveFilter( pos ); | 603 | setActiveFilter( pos ); |
600 | mActionSelectFilter->setComboWidth( 150 ); | 604 | int cw = 150; |
605 | if (QApplication::desktop()->width() == 480 ) | ||
606 | cw = 0; | ||
607 | mActionSelectFilter->setComboWidth( cw ); | ||
601 | } | 608 | } |
602 | 609 | ||
603 | QStringList ViewManager::filterNames() const | 610 | QStringList ViewManager::filterNames() const |
604 | { | 611 | { |
605 | QStringList names( i18n( "No Filter" ) ); | 612 | QStringList names( i18n( "No Filter" ) ); |
606 | 613 | ||
607 | Filter::List::ConstIterator it; | 614 | Filter::List::ConstIterator it; |
608 | for ( it = mFilterList.begin(); it != mFilterList.end(); ++it ) | 615 | for ( it = mFilterList.begin(); it != mFilterList.end(); ++it ) |
609 | names.append( (*it).name() ); | 616 | names.append( (*it).name() ); |
610 | 617 | ||
611 | return names; | 618 | return names; |
612 | } | 619 | } |
613 | 620 | ||
614 | int ViewManager::filterPosition( const QString &name ) const | 621 | int ViewManager::filterPosition( const QString &name ) const |
615 | { | 622 | { |
616 | int pos = 0; | 623 | int pos = 0; |
617 | 624 | ||
618 | Filter::List::ConstIterator it; | 625 | Filter::List::ConstIterator it; |
619 | for ( it = mFilterList.begin(); it != mFilterList.end(); ++it, ++pos ) | 626 | for ( it = mFilterList.begin(); it != mFilterList.end(); ++it, ++pos ) |
620 | if ( name == (*it).name() ) | 627 | if ( name == (*it).name() ) |
621 | return pos + 1; | 628 | return pos + 1; |
622 | 629 | ||
623 | return 0; | 630 | return 0; |
624 | } | 631 | } |
625 | 632 | ||
626 | void ViewManager::initActions() | 633 | void ViewManager::initActions() |
627 | { | 634 | { |
628 | //US <ActionList name="view_loadedviews"/> | 635 | //US <ActionList name="view_loadedviews"/> |
629 | //US <Separator/> | 636 | //US <Separator/> |
630 | 637 | ||
631 | #ifdef KAB_EMBEDDED | 638 | #ifdef KAB_EMBEDDED |
632 | QPopupMenu *viewmenu = (QPopupMenu*)mCore->getViewMenu(); | 639 | QPopupMenu *viewmenu = (QPopupMenu*)mCore->getViewMenu(); |
633 | QPopupMenu *settingsmenu = (QPopupMenu*)mCore->getSettingsMenu(); | 640 | QPopupMenu *settingsmenu = (QPopupMenu*)mCore->getSettingsMenu(); |
634 | QPopupMenu *filtermenu = (QPopupMenu*)mCore->getFilterMenu(); | 641 | QPopupMenu *filtermenu = (QPopupMenu*)mCore->getFilterMenu(); |
635 | #endif //KAB_EMBEDDED | 642 | #endif //KAB_EMBEDDED |
636 | 643 | ||
637 | mActionSelectView = new KSelectAction( i18n( "Select View" ), 0, mCore->actionCollection(), "select_view" ); | 644 | mActionSelectView = new KSelectAction( i18n( "Select View" ), 0, mCore->actionCollection(), "select_view" ); |
638 | #if KDE_VERSION >= 309 | 645 | #if KDE_VERSION >= 309 |
639 | mActionSelectView->setMenuAccelsEnabled( false ); | 646 | mActionSelectView->setMenuAccelsEnabled( false ); |
640 | #endif | 647 | #endif |
641 | connect( mActionSelectView, SIGNAL( activated( const QString& ) ), | 648 | connect( mActionSelectView, SIGNAL( activated( const QString& ) ), |
642 | SLOT( setActiveView( const QString& ) ) ); | 649 | SLOT( setActiveView( const QString& ) ) ); |
643 | 650 | ||
644 | 651 | ||
645 | #ifdef KAB_EMBEDDED | 652 | #ifdef KAB_EMBEDDED |
646 | mActionSelectView->plug(viewmenu); | 653 | mActionSelectView->plug(viewmenu); |
647 | viewmenu->insertSeparator(); | 654 | viewmenu->insertSeparator(); |
648 | #endif //KAB_EMBEDDED | 655 | #endif //KAB_EMBEDDED |
649 | 656 | ||
650 | KAction *action; | 657 | KAction *action; |
651 | 658 | ||
652 | action = new KAction( i18n( "Modify View..." ), "configure", 0, this, | 659 | action = new KAction( i18n( "Modify View..." ), "configure", 0, this, |
653 | SLOT( editView() ), mCore->actionCollection(), "view_modify" ); | 660 | SLOT( editView() ), mCore->actionCollection(), "view_modify" ); |
654 | #ifndef KAB_EMBEDDED | 661 | #ifndef KAB_EMBEDDED |
655 | action->setWhatsThis( i18n( "By pressing this button a dialog opens that allows you to modify the view of the addressbook. There you can add or remove fields that you want to be shown or hidden in the addressbook like the name for example." ) ); | 662 | action->setWhatsThis( i18n( "By pressing this button a dialog opens that allows you to modify the view of the addressbook. There you can add or remove fields that you want to be shown or hidden in the addressbook like the name for example." ) ); |
656 | #else //KAB_EMBEDDED | 663 | #else //KAB_EMBEDDED |
657 | action->plug(viewmenu); | 664 | action->plug(viewmenu); |
658 | #endif //KAB_EMBEDDED | 665 | #endif //KAB_EMBEDDED |
659 | 666 | ||
660 | action = new KAction( i18n( "Add View..." ), "window_new", 0, this, | 667 | action = new KAction( i18n( "Add View..." ), "window_new", 0, this, |
661 | SLOT( addView() ), mCore->actionCollection(), "view_add" ); | 668 | SLOT( addView() ), mCore->actionCollection(), "view_add" ); |
662 | #ifndef KAB_EMBEDDED | 669 | #ifndef KAB_EMBEDDED |
663 | action->setWhatsThis( i18n( "You can add a new view by choosing one of the dialog that appears after pressing the button. You have to give the view a name, so that you can distinguish between the different views." ) ); | 670 | action->setWhatsThis( i18n( "You can add a new view by choosing one of the dialog that appears after pressing the button. You have to give the view a name, so that you can distinguish between the different views." ) ); |
664 | #else //KAB_EMBEDDED | 671 | #else //KAB_EMBEDDED |
665 | action->plug(viewmenu); | 672 | action->plug(viewmenu); |
666 | #endif //KAB_EMBEDDED | 673 | #endif //KAB_EMBEDDED |
667 | 674 | ||
668 | mActionDeleteView = new KAction( i18n( "Delete View" ), "view_remove", 0, | 675 | mActionDeleteView = new KAction( i18n( "Delete View" ), "view_remove", 0, |
669 | this, SLOT( deleteView() ), | 676 | this, SLOT( deleteView() ), |
670 | mCore->actionCollection(), "view_delete" ); | 677 | mCore->actionCollection(), "view_delete" ); |
671 | #ifndef KAB_EMBEDDED | 678 | #ifndef KAB_EMBEDDED |
672 | mActionDeleteView->setWhatsThis( i18n( "By pressing this button you can delete the actual view, which you have added before." ) ); | 679 | mActionDeleteView->setWhatsThis( i18n( "By pressing this button you can delete the actual view, which you have added before." ) ); |
673 | #else //KAB_EMBEDDED | 680 | #else //KAB_EMBEDDED |
674 | mActionDeleteView->plug(viewmenu); | 681 | mActionDeleteView->plug(viewmenu); |
675 | viewmenu->insertSeparator(); | 682 | viewmenu->insertSeparator(); |
676 | #endif //KAB_EMBEDDED | 683 | #endif //KAB_EMBEDDED |
677 | 684 | ||
678 | #ifndef KAB_EMBEDDED | 685 | #ifndef KAB_EMBEDDED |
679 | action = new KAction( i18n( "Refresh View" ), "reload", 0, this, | 686 | action = new KAction( i18n( "Refresh View" ), "reload", 0, this, |
680 | SLOT( refreshView(const QString &) ), mCore->actionCollection(), | 687 | SLOT( refreshView(const QString &) ), mCore->actionCollection(), |
681 | "view_refresh" ); | 688 | "view_refresh" ); |
682 | action->setWhatsThis( i18n( "The view will be refreshed by pressing this button." ) ); | 689 | action->setWhatsThis( i18n( "The view will be refreshed by pressing this button." ) ); |
683 | #else //KAB_EMBEDDED | 690 | #else //KAB_EMBEDDED |
684 | action = new KAction( i18n( "Refresh View" ), "reload", 0, this, | 691 | action = new KAction( i18n( "Refresh View" ), "reload", 0, this, |
685 | SLOT( refreshView()), mCore->actionCollection(), | 692 | SLOT( refreshView()), mCore->actionCollection(), |
686 | "view_refresh" ); | 693 | "view_refresh" ); |
687 | action->plug(viewmenu); | 694 | action->plug(viewmenu); |
688 | viewmenu->insertSeparator(); | 695 | viewmenu->insertSeparator(); |
689 | #endif //KAB_EMBEDDED | 696 | #endif //KAB_EMBEDDED |
690 | 697 | ||
691 | action = new KAction( i18n( "Edit &Filters..." ), "filter", 0, this, | 698 | action = new KAction( i18n( "Edit &Filters..." ), "filter", 0, this, |
692 | SLOT( configureFilters() ), mCore->actionCollection(), | 699 | SLOT( configureFilters() ), mCore->actionCollection(), |
693 | "options_edit_filters" ); | 700 | "options_edit_filters" ); |
694 | 701 | ||
695 | mActionSelectFilter = new KSelectAction( i18n( "Select Filter" ), "filter", mCore->actionCollection(), "select_filter" ); | 702 | mActionSelectFilter = new KSelectAction( i18n( "Select Filter" ), "filter", mCore->actionCollection(), "select_filter" ); |
696 | #if KDE_VERSION >= 309 | 703 | #if KDE_VERSION >= 309 |
697 | mActionSelectFilter->setMenuAccelsEnabled( false ); | 704 | mActionSelectFilter->setMenuAccelsEnabled( false ); |
698 | #endif | 705 | #endif |
699 | connect( mActionSelectFilter, SIGNAL( activated( int ) ), | 706 | connect( mActionSelectFilter, SIGNAL( activated( int ) ), |
700 | SLOT( setActiveFilter( int ) ) ); | 707 | SLOT( setActiveFilter( int ) ) ); |
701 | 708 | ||
702 | #ifdef KAB_EMBEDDED | 709 | #ifdef KAB_EMBEDDED |
703 | action->plug(settingsmenu); | 710 | action->plug(settingsmenu); |
704 | mActionSelectFilter->plug(viewmenu); | 711 | mActionSelectFilter->plug(viewmenu); |
705 | #endif //KAB_EMBEDDED | 712 | #endif //KAB_EMBEDDED |
706 | 713 | ||
707 | } | 714 | } |
708 | 715 | ||
709 | void ViewManager::initGUI() | 716 | void ViewManager::initGUI() |
710 | { | 717 | { |
711 | QHBoxLayout *layout = new QHBoxLayout( this, 0, 0 ); | 718 | QHBoxLayout *layout = new QHBoxLayout( this, 0, 0 ); |
712 | mViewWidgetStack = new QWidgetStack( this ); | 719 | mViewWidgetStack = new QWidgetStack( this ); |
713 | layout->addWidget( mViewWidgetStack ); | 720 | layout->addWidget( mViewWidgetStack ); |
714 | } | 721 | } |
715 | 722 | ||
716 | #ifndef KAB_EMBEDDED | 723 | #ifndef KAB_EMBEDDED |
717 | #include "viewmanager.moc" | 724 | #include "viewmanager.moc" |
718 | #endif //KAB_EMBEDDED | 725 | #endif //KAB_EMBEDDED |