summaryrefslogtreecommitdiffabout
path: root/kaddressbook/kabcore.cpp
Unidiff
Diffstat (limited to 'kaddressbook/kabcore.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/kabcore.cpp19
1 files changed, 17 insertions, 2 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index d99a9cd..7be5db8 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -635,97 +635,96 @@ void KABCore::createAboutData()
635 ); 635 );
636} 636}
637 637
638void KABCore::setContactSelected( const QString &uid ) 638void KABCore::setContactSelected( const QString &uid )
639{ 639{
640 KABC::Addressee addr = mAddressBook->findByUid( uid ); 640 KABC::Addressee addr = mAddressBook->findByUid( uid );
641 if ( !mDetails->isHidden() ) 641 if ( !mDetails->isHidden() )
642 mDetails->setAddressee( addr ); 642 mDetails->setAddressee( addr );
643 643
644 if ( !addr.isEmpty() ) { 644 if ( !addr.isEmpty() ) {
645 emit contactSelected( addr.formattedName() ); 645 emit contactSelected( addr.formattedName() );
646 KABC::Picture pic = addr.photo(); 646 KABC::Picture pic = addr.photo();
647 if ( pic.isIntern() ) { 647 if ( pic.isIntern() ) {
648//US emit contactSelected( pic.data() ); 648//US emit contactSelected( pic.data() );
649//US instead use: 649//US instead use:
650 QPixmap px; 650 QPixmap px;
651 if (pic.data().isNull() != true) 651 if (pic.data().isNull() != true)
652 { 652 {
653 px.convertFromImage(pic.data()); 653 px.convertFromImage(pic.data());
654 } 654 }
655 655
656 emit contactSelected( px ); 656 emit contactSelected( px );
657 } 657 }
658 } 658 }
659 659
660 660
661 mExtensionManager->setSelectionChanged(); 661 mExtensionManager->setSelectionChanged();
662 662
663 // update the actions 663 // update the actions
664 bool selected = !uid.isEmpty(); 664 bool selected = !uid.isEmpty();
665 665
666 if ( mReadWrite ) { 666 if ( mReadWrite ) {
667 mActionCut->setEnabled( selected ); 667 mActionCut->setEnabled( selected );
668 mActionPaste->setEnabled( selected ); 668 mActionPaste->setEnabled( selected );
669 } 669 }
670 670
671 mActionCopy->setEnabled( selected ); 671 mActionCopy->setEnabled( selected );
672 mActionDelete->setEnabled( selected ); 672 mActionDelete->setEnabled( selected );
673 mActionEditAddressee->setEnabled( selected ); 673 mActionEditAddressee->setEnabled( selected );
674 mActionMail->setEnabled( selected ); 674 mActionMail->setEnabled( selected );
675 mActionMailVCard->setEnabled( selected ); 675 mActionMailVCard->setEnabled( selected );
676 //if (mActionBeam) 676 //if (mActionBeam)
677 //mActionBeam->setEnabled( selected ); 677 //mActionBeam->setEnabled( selected );
678 678
679 if (mActionBeamVCard) 679 if (mActionBeamVCard)
680 mActionBeamVCard->setEnabled( selected ); 680 mActionBeamVCard->setEnabled( selected );
681 681
682 mActionWhoAmI->setEnabled( selected ); 682 mActionWhoAmI->setEnabled( selected );
683 mActionCategories->setEnabled( selected );
684} 683}
685 684
686void KABCore::sendMail() 685void KABCore::sendMail()
687{ 686{
688 sendMail( mViewManager->selectedEmails().join( ", " ) ); 687 sendMail( mViewManager->selectedEmails().join( ", " ) );
689} 688}
690 689
691void KABCore::sendMail( const QString& emaillist ) 690void KABCore::sendMail( const QString& emaillist )
692{ 691{
693 // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... " 692 // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... "
694 if (emaillist.contains(",") > 0) 693 if (emaillist.contains(",") > 0)
695 ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null ); 694 ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null );
696 else 695 else
697 ExternalAppHandler::instance()->mailToOneContact( emaillist ); 696 ExternalAppHandler::instance()->mailToOneContact( emaillist );
698} 697}
699 698
700 699
701 700
702void KABCore::mailVCard() 701void KABCore::mailVCard()
703{ 702{
704 QStringList uids = mViewManager->selectedUids(); 703 QStringList uids = mViewManager->selectedUids();
705 if ( !uids.isEmpty() ) 704 if ( !uids.isEmpty() )
706 mailVCard( uids ); 705 mailVCard( uids );
707} 706}
708 707
709void KABCore::mailVCard( const QStringList& uids ) 708void KABCore::mailVCard( const QStringList& uids )
710{ 709{
711 QStringList urls; 710 QStringList urls;
712 711
713// QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); 712// QString tmpdir = locateLocal("tmp", KGlobal::getAppName());
714 713
715 QString dirName = "/tmp/" + KApplication::randomString( 8 ); 714 QString dirName = "/tmp/" + KApplication::randomString( 8 );
716 715
717 716
718 717
719 QDir().mkdir( dirName, true ); 718 QDir().mkdir( dirName, true );
720 719
721 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { 720 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) {
722 KABC::Addressee a = mAddressBook->findByUid( *it ); 721 KABC::Addressee a = mAddressBook->findByUid( *it );
723 722
724 if ( a.isEmpty() ) 723 if ( a.isEmpty() )
725 continue; 724 continue;
726 725
727 QString name = a.givenName() + "_" + a.familyName() + ".vcf"; 726 QString name = a.givenName() + "_" + a.familyName() + ".vcf";
728 727
729 QString fileName = dirName + "/" + name; 728 QString fileName = dirName + "/" + name;
730 729
731 QFile outFile(fileName); 730 QFile outFile(fileName);
@@ -968,110 +967,122 @@ void KABCore::cutContacts()
968 967
969 setModified( true ); 968 setModified( true );
970 } 969 }
971} 970}
972 971
973void KABCore::pasteContacts() 972void KABCore::pasteContacts()
974{ 973{
975 QClipboard *cb = QApplication::clipboard(); 974 QClipboard *cb = QApplication::clipboard();
976 975
977 KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() ); 976 KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() );
978 977
979 pasteContacts( list ); 978 pasteContacts( list );
980} 979}
981 980
982void KABCore::pasteContacts( KABC::Addressee::List &list ) 981void KABCore::pasteContacts( KABC::Addressee::List &list )
983{ 982{
984 KABC::Resource *resource = requestResource( this ); 983 KABC::Resource *resource = requestResource( this );
985 KABC::Addressee::List::Iterator it; 984 KABC::Addressee::List::Iterator it;
986 for ( it = list.begin(); it != list.end(); ++it ) 985 for ( it = list.begin(); it != list.end(); ++it )
987 (*it).setResource( resource ); 986 (*it).setResource( resource );
988 987
989 PwPasteCommand *command = new PwPasteCommand( this, list ); 988 PwPasteCommand *command = new PwPasteCommand( this, list );
990 UndoStack::instance()->push( command ); 989 UndoStack::instance()->push( command );
991 RedoStack::instance()->clear(); 990 RedoStack::instance()->clear();
992 991
993 setModified( true ); 992 setModified( true );
994} 993}
995 994
996void KABCore::setWhoAmI() 995void KABCore::setWhoAmI()
997{ 996{
998 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 997 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
999 998
1000 if ( addrList.count() > 1 ) { 999 if ( addrList.count() > 1 ) {
1001 KMessageBox::sorry( this, i18n( "Please select only one contact." ) ); 1000 KMessageBox::sorry( this, i18n( "Please select only one contact." ) );
1002 return; 1001 return;
1003 } 1002 }
1004 1003
1005 QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) ); 1004 QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) );
1006 if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes ) 1005 if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes )
1007 static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] ); 1006 static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] );
1008} 1007}
1009void KABCore::editCategories() 1008void KABCore::editCategories()
1010{ 1009{
1011 KPIM::CategoryEditDialog dlg ( KABPrefs::instance(), this, "", true ); 1010 KPIM::CategoryEditDialog dlg ( KABPrefs::instance(), this, "", true );
1012 dlg.exec(); 1011 dlg.exec();
1013} 1012}
1014void KABCore::setCategories() 1013void KABCore::setCategories()
1015{ 1014{
1015
1016 QStringList uids;
1017 XXPortSelectDialog dlgx( this, false, this );
1018 if ( dlgx.exec() )
1019 uids = dlgx.uids();
1020 else
1021 return;
1022 if ( uids.isEmpty() )
1023 return;
1024 // qDebug("count %d ", uids.count());
1025
1026
1016 KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true ); 1027 KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true );
1017 if ( !dlg.exec() ) { 1028 if ( !dlg.exec() ) {
1018 message( i18n("Setting categories cancelled") ); 1029 message( i18n("Setting categories cancelled") );
1019 return; 1030 return;
1020 } 1031 }
1021 bool merge = false; 1032 bool merge = false;
1022 QString msg = i18n( "Merge with existing categories?" ); 1033 QString msg = i18n( "Merge with existing categories?" );
1023 if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes ) 1034 if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes )
1024 merge = true; 1035 merge = true;
1025 1036
1026 message( i18n("Setting categories ... please wait!") ); 1037 message( i18n("Setting categories ... please wait!") );
1027 QStringList categories = dlg.selectedCategories(); 1038 QStringList categories = dlg.selectedCategories();
1028 1039
1029 QStringList uids = mViewManager->selectedUids(); 1040 //QStringList uids = mViewManager->selectedUids();
1030 QStringList::Iterator it; 1041 QStringList::Iterator it;
1031 for ( it = uids.begin(); it != uids.end(); ++it ) { 1042 for ( it = uids.begin(); it != uids.end(); ++it ) {
1032 KABC::Addressee addr = mAddressBook->findByUid( *it ); 1043 KABC::Addressee addr = mAddressBook->findByUid( *it );
1033 if ( !addr.isEmpty() ) { 1044 if ( !addr.isEmpty() ) {
1034 if ( !merge ) 1045 if ( !merge )
1035 addr.setCategories( categories ); 1046 addr.setCategories( categories );
1036 else { 1047 else {
1037 QStringList addrCategories = addr.categories(); 1048 QStringList addrCategories = addr.categories();
1038 QStringList::Iterator catIt; 1049 QStringList::Iterator catIt;
1039 for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) { 1050 for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) {
1040 if ( !addrCategories.contains( *catIt ) ) 1051 if ( !addrCategories.contains( *catIt ) )
1041 addrCategories.append( *catIt ); 1052 addrCategories.append( *catIt );
1042 } 1053 }
1043 addr.setCategories( addrCategories ); 1054 addr.setCategories( addrCategories );
1044 } 1055 }
1045 mAddressBook->insertAddressee( addr ); 1056 mAddressBook->insertAddressee( addr );
1046 } 1057 }
1047 } 1058 }
1048 1059
1049 if ( uids.count() > 0 ) 1060 if ( uids.count() > 0 )
1050 setModified( true ); 1061 setModified( true );
1051 message( i18n("Setting categories completed!") ); 1062 message( i18n("Setting categories completed!") );
1052} 1063}
1053 1064
1054void KABCore::setSearchFields( const KABC::Field::List &fields ) 1065void KABCore::setSearchFields( const KABC::Field::List &fields )
1055{ 1066{
1056 mIncSearchWidget->setFields( fields ); 1067 mIncSearchWidget->setFields( fields );
1057} 1068}
1058 1069
1059void KABCore::incrementalSearch( const QString& text ) 1070void KABCore::incrementalSearch( const QString& text )
1060{ 1071{
1061 mViewManager->doSearch( text, mIncSearchWidget->currentField() ); 1072 mViewManager->doSearch( text, mIncSearchWidget->currentField() );
1062} 1073}
1063 1074
1064void KABCore::setModified() 1075void KABCore::setModified()
1065{ 1076{
1066 setModified( true ); 1077 setModified( true );
1067} 1078}
1068 1079
1069void KABCore::setModifiedWOrefresh() 1080void KABCore::setModifiedWOrefresh()
1070{ 1081{
1071 // qDebug("KABCore::setModifiedWOrefresh() "); 1082 // qDebug("KABCore::setModifiedWOrefresh() ");
1072 mModified = true; 1083 mModified = true;
1073 mActionSave->setEnabled( mModified ); 1084 mActionSave->setEnabled( mModified );
1074#ifdef DESKTOP_VERSION 1085#ifdef DESKTOP_VERSION
1075 mDetails->refreshView(); 1086 mDetails->refreshView();
1076#endif 1087#endif
1077 1088
@@ -2063,96 +2074,100 @@ void KABCore::addActionsManually()
2063#endif 2074#endif
2064 fileMenu->insertSeparator(); 2075 fileMenu->insertSeparator();
2065 mActionQuit->plug( fileMenu ); 2076 mActionQuit->plug( fileMenu );
2066#ifdef _WIN32_ 2077#ifdef _WIN32_
2067 mActionImportOL->plug( ImportMenu ); 2078 mActionImportOL->plug( ImportMenu );
2068#endif 2079#endif
2069 // edit menu 2080 // edit menu
2070 mActionUndo->plug( editMenu ); 2081 mActionUndo->plug( editMenu );
2071 mActionRedo->plug( editMenu ); 2082 mActionRedo->plug( editMenu );
2072 editMenu->insertSeparator(); 2083 editMenu->insertSeparator();
2073 mActionCut->plug( editMenu ); 2084 mActionCut->plug( editMenu );
2074 mActionCopy->plug( editMenu ); 2085 mActionCopy->plug( editMenu );
2075 mActionPaste->plug( editMenu ); 2086 mActionPaste->plug( editMenu );
2076 mActionDelete->plug( editMenu ); 2087 mActionDelete->plug( editMenu );
2077 editMenu->insertSeparator(); 2088 editMenu->insertSeparator();
2078 mActionSelectAll->plug( editMenu ); 2089 mActionSelectAll->plug( editMenu );
2079 2090
2080 mActionRemoveVoice->plug( changeMenu ); 2091 mActionRemoveVoice->plug( changeMenu );
2081 // settings menu 2092 // settings menu
2082//US special menuentry to configure the addressbook resources. On KDE 2093//US special menuentry to configure the addressbook resources. On KDE
2083// you do that through the control center !!! 2094// you do that through the control center !!!
2084 mActionConfigResources->plug( settingsMenu ); 2095 mActionConfigResources->plug( settingsMenu );
2085 settingsMenu->insertSeparator(); 2096 settingsMenu->insertSeparator();
2086 2097
2087 mActionConfigKAddressbook->plug( settingsMenu ); 2098 mActionConfigKAddressbook->plug( settingsMenu );
2088 2099
2089 if ( mIsPart ) { 2100 if ( mIsPart ) {
2090 //US not implemented yet 2101 //US not implemented yet
2091 //mActionConfigShortcuts->plug( settingsMenu ); 2102 //mActionConfigShortcuts->plug( settingsMenu );
2092 //mActionConfigureToolbars->plug( settingsMenu ); 2103 //mActionConfigureToolbars->plug( settingsMenu );
2093 2104
2094 } else { 2105 } else {
2095 //US not implemented yet 2106 //US not implemented yet
2096 //mActionKeyBindings->plug( settingsMenu ); 2107 //mActionKeyBindings->plug( settingsMenu );
2097 } 2108 }
2098 2109
2099 settingsMenu->insertSeparator(); 2110 settingsMenu->insertSeparator();
2100 2111
2101 mActionJumpBar->plug( settingsMenu ); 2112 mActionJumpBar->plug( settingsMenu );
2102 mActionDetails->plug( settingsMenu ); 2113 mActionDetails->plug( settingsMenu );
2103 //if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop ) 2114 //if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop )
2104 mActionDetails->plug( tb ); 2115 mActionDetails->plug( tb );
2105 settingsMenu->insertSeparator(); 2116 settingsMenu->insertSeparator();
2106 mActionBR->plug(settingsMenu ); 2117 mActionBR->plug(settingsMenu );
2107 settingsMenu->insertSeparator(); 2118 settingsMenu->insertSeparator();
2108 2119
2109 mActionWhoAmI->plug( settingsMenu ); 2120 mActionWhoAmI->plug( settingsMenu );
2110 mActionEditCategories->plug( settingsMenu ); 2121 mActionEditCategories->plug( settingsMenu );
2122 mActionEditCategories->plug( changeMenu );
2123 mActionCategories->plug( changeMenu );
2124 mActionManageCategories->plug( changeMenu );
2125
2111 mActionCategories->plug( settingsMenu ); 2126 mActionCategories->plug( settingsMenu );
2112 mActionManageCategories->plug( settingsMenu ); 2127 mActionManageCategories->plug( settingsMenu );
2113 2128
2114 2129
2115 mActionWN->plug( helpMenu ); 2130 mActionWN->plug( helpMenu );
2116 mActionSyncHowto->plug( helpMenu ); 2131 mActionSyncHowto->plug( helpMenu );
2117 mActionKdeSyncHowto->plug( helpMenu ); 2132 mActionKdeSyncHowto->plug( helpMenu );
2118 mActionMultiSyncHowto->plug( helpMenu ); 2133 mActionMultiSyncHowto->plug( helpMenu );
2119 mActionFaq->plug( helpMenu ); 2134 mActionFaq->plug( helpMenu );
2120 mActionLicence->plug( helpMenu ); 2135 mActionLicence->plug( helpMenu );
2121 mActionAboutKAddressbook->plug( helpMenu ); 2136 mActionAboutKAddressbook->plug( helpMenu );
2122 2137
2123 if (KGlobal::getDesktopSize() > KGlobal::Small ) { 2138 if (KGlobal::getDesktopSize() > KGlobal::Small ) {
2124 2139
2125 mActionSave->plug( tb ); 2140 mActionSave->plug( tb );
2126 mViewManager->getFilterAction()->plug ( tb); 2141 mViewManager->getFilterAction()->plug ( tb);
2127 if (KGlobal::getDesktopSize() == KGlobal::Desktop ) { 2142 if (KGlobal::getDesktopSize() == KGlobal::Desktop ) {
2128 mActionUndo->plug( tb ); 2143 mActionUndo->plug( tb );
2129 mActionDelete->plug( tb ); 2144 mActionDelete->plug( tb );
2130 mActionRedo->plug( tb ); 2145 mActionRedo->plug( tb );
2131 } 2146 }
2132 } else { 2147 } else {
2133 mActionSave->plug( tb ); 2148 mActionSave->plug( tb );
2134 tb->enableMoving(false); 2149 tb->enableMoving(false);
2135 } 2150 }
2136 //mActionQuit->plug ( tb ); 2151 //mActionQuit->plug ( tb );
2137 // tb->insertWidget(-1, 0, mIncSearchWidget, 6); 2152 // tb->insertWidget(-1, 0, mIncSearchWidget, 6);
2138 2153
2139 //US link the searchwidget first to this. 2154 //US link the searchwidget first to this.
2140 // The real linkage to the toolbar happens later. 2155 // The real linkage to the toolbar happens later.
2141//US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE); 2156//US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE);
2142//US tb->insertItem( mIncSearchWidget ); 2157//US tb->insertItem( mIncSearchWidget );
2143/*US 2158/*US
2144 mIncSearchWidget = new IncSearchWidget( tb ); 2159 mIncSearchWidget = new IncSearchWidget( tb );
2145 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), 2160 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ),
2146 SLOT( incrementalSearch( const QString& ) ) ); 2161 SLOT( incrementalSearch( const QString& ) ) );
2147 2162
2148 mJumpButtonBar = new JumpButtonBar( this, this ); 2163 mJumpButtonBar = new JumpButtonBar( this, this );
2149 2164
2150//US topLayout->addWidget( mJumpButtonBar ); 2165//US topLayout->addWidget( mJumpButtonBar );
2151 this->layout()->add( mJumpButtonBar ); 2166 this->layout()->add( mJumpButtonBar );
2152*/ 2167*/
2153 2168
2154#endif //KAB_EMBEDDED 2169#endif //KAB_EMBEDDED
2155 2170
2156 mActionExport2phone->plug( ExportMenu ); 2171 mActionExport2phone->plug( ExportMenu );
2157 connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) ); 2172 connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) );
2158 syncManager->fillSyncMenu(); 2173 syncManager->fillSyncMenu();