-rw-r--r-- | kaddressbook/kabcore.cpp | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index d5de9cb..b9830b1 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp | |||
@@ -1007,49 +1007,65 @@ void KABCore::beamDone( Ir *ir ) | |||
1007 | 1007 | ||
1008 | 1008 | ||
1009 | void KABCore::browse( const QString& url ) | 1009 | void KABCore::browse( const QString& url ) |
1010 | { | 1010 | { |
1011 | #ifndef KAB_EMBEDDED | 1011 | #ifndef KAB_EMBEDDED |
1012 | kapp->invokeBrowser( url ); | 1012 | kapp->invokeBrowser( url ); |
1013 | #else //KAB_EMBEDDED | 1013 | #else //KAB_EMBEDDED |
1014 | qDebug("KABCore::browse must be fixed"); | 1014 | qDebug("KABCore::browse must be fixed"); |
1015 | #endif //KAB_EMBEDDED | 1015 | #endif //KAB_EMBEDDED |
1016 | } | 1016 | } |
1017 | 1017 | ||
1018 | void KABCore::selectAllContacts() | 1018 | void KABCore::selectAllContacts() |
1019 | { | 1019 | { |
1020 | mViewManager->setSelected( QString::null, true ); | 1020 | mViewManager->setSelected( QString::null, true ); |
1021 | } | 1021 | } |
1022 | 1022 | ||
1023 | void KABCore::deleteContacts() | 1023 | void KABCore::deleteContacts() |
1024 | { | 1024 | { |
1025 | QStringList uidList = mViewManager->selectedUids(); | 1025 | QStringList uidList = mViewManager->selectedUids(); |
1026 | deleteContacts( uidList ); | 1026 | deleteContacts( uidList ); |
1027 | } | 1027 | } |
1028 | 1028 | ||
1029 | void KABCore::deleteContacts( const QStringList &uids ) | 1029 | void KABCore::deleteContacts( const QStringList &uids ) |
1030 | { | 1030 | { |
1031 | |||
1031 | if ( uids.count() > 0 ) { | 1032 | if ( uids.count() > 0 ) { |
1033 | |||
1034 | if ( KABPrefs::instance()->mAskForDelete ) { | ||
1035 | int count = uids.count(); | ||
1036 | if ( count > 5 ) count = 5; | ||
1037 | QString cNames; | ||
1038 | int i; | ||
1039 | for ( i = 0; i < count ; ++i ) { | ||
1040 | cNames += KGlobal::formatMessage( mAddressBook->findByUid( uids[i] ).realName() ,0) + "\n"; | ||
1041 | } | ||
1042 | if ( uids.count() > 5 ) | ||
1043 | cNames += i18n("...and %1 more\ncontact(s) selected").arg( uids.count() - 5 ); | ||
1044 | QString text = i18n( "Do you really\nwant to delete the\nsetected contact(s)?\n\n" ) + cNames ; | ||
1045 | if ( KMessageBox::questionYesNo( this, text ) != KMessageBox::Yes ) | ||
1046 | return; | ||
1047 | } | ||
1032 | PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids ); | 1048 | PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids ); |
1033 | UndoStack::instance()->push( command ); | 1049 | UndoStack::instance()->push( command ); |
1034 | RedoStack::instance()->clear(); | 1050 | RedoStack::instance()->clear(); |
1035 | 1051 | ||
1036 | // now if we deleted anything, refresh | 1052 | // now if we deleted anything, refresh |
1037 | setContactSelected( QString::null ); | 1053 | setContactSelected( QString::null ); |
1038 | setModified( true ); | 1054 | setModified( true ); |
1039 | } | 1055 | } |
1040 | } | 1056 | } |
1041 | 1057 | ||
1042 | void KABCore::copyContacts() | 1058 | void KABCore::copyContacts() |
1043 | { | 1059 | { |
1044 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); | 1060 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); |
1045 | 1061 | ||
1046 | QString clipText = AddresseeUtil::addresseesToClipboard( addrList ); | 1062 | QString clipText = AddresseeUtil::addresseesToClipboard( addrList ); |
1047 | 1063 | ||
1048 | kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl; | 1064 | kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl; |
1049 | 1065 | ||
1050 | QClipboard *cb = QApplication::clipboard(); | 1066 | QClipboard *cb = QApplication::clipboard(); |
1051 | cb->setText( clipText ); | 1067 | cb->setText( clipText ); |
1052 | } | 1068 | } |
1053 | 1069 | ||
1054 | void KABCore::cutContacts() | 1070 | void KABCore::cutContacts() |
1055 | { | 1071 | { |
@@ -1077,49 +1093,49 @@ void KABCore::pasteContacts() | |||
1077 | void KABCore::pasteContacts( KABC::Addressee::List &list ) | 1093 | void KABCore::pasteContacts( KABC::Addressee::List &list ) |
1078 | { | 1094 | { |
1079 | KABC::Resource *resource = requestResource( this ); | 1095 | KABC::Resource *resource = requestResource( this ); |
1080 | KABC::Addressee::List::Iterator it; | 1096 | KABC::Addressee::List::Iterator it; |
1081 | for ( it = list.begin(); it != list.end(); ++it ) | 1097 | for ( it = list.begin(); it != list.end(); ++it ) |
1082 | (*it).setResource( resource ); | 1098 | (*it).setResource( resource ); |
1083 | 1099 | ||
1084 | PwPasteCommand *command = new PwPasteCommand( this, list ); | 1100 | PwPasteCommand *command = new PwPasteCommand( this, list ); |
1085 | UndoStack::instance()->push( command ); | 1101 | UndoStack::instance()->push( command ); |
1086 | RedoStack::instance()->clear(); | 1102 | RedoStack::instance()->clear(); |
1087 | 1103 | ||
1088 | setModified( true ); | 1104 | setModified( true ); |
1089 | } | 1105 | } |
1090 | 1106 | ||
1091 | void KABCore::setWhoAmI() | 1107 | void KABCore::setWhoAmI() |
1092 | { | 1108 | { |
1093 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); | 1109 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); |
1094 | 1110 | ||
1095 | if ( addrList.count() > 1 ) { | 1111 | if ( addrList.count() > 1 ) { |
1096 | KMessageBox::sorry( this, i18n( "Please select only one contact." ) ); | 1112 | KMessageBox::sorry( this, i18n( "Please select only one contact." ) ); |
1097 | return; | 1113 | return; |
1098 | } | 1114 | } |
1099 | 1115 | ||
1100 | QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) ); | 1116 | QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) ); |
1101 | if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes ) | 1117 | if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].realName() ) ) == KMessageBox::Yes ) |
1102 | static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] ); | 1118 | static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] ); |
1103 | } | 1119 | } |
1104 | void KABCore::editCategories() | 1120 | void KABCore::editCategories() |
1105 | { | 1121 | { |
1106 | KPIM::CategoryEditDialog dlg ( KABPrefs::instance(), this, "", true ); | 1122 | KPIM::CategoryEditDialog dlg ( KABPrefs::instance(), this, "", true ); |
1107 | dlg.exec(); | 1123 | dlg.exec(); |
1108 | } | 1124 | } |
1109 | void KABCore::setCategories() | 1125 | void KABCore::setCategories() |
1110 | { | 1126 | { |
1111 | 1127 | ||
1112 | QStringList uids; | 1128 | QStringList uids; |
1113 | XXPortSelectDialog dlgx( this, false, this ); | 1129 | XXPortSelectDialog dlgx( this, false, this ); |
1114 | if ( dlgx.exec() ) | 1130 | if ( dlgx.exec() ) |
1115 | uids = dlgx.uids(); | 1131 | uids = dlgx.uids(); |
1116 | else | 1132 | else |
1117 | return; | 1133 | return; |
1118 | if ( uids.isEmpty() ) | 1134 | if ( uids.isEmpty() ) |
1119 | return; | 1135 | return; |
1120 | // qDebug("count %d ", uids.count()); | 1136 | // qDebug("count %d ", uids.count()); |
1121 | 1137 | ||
1122 | 1138 | ||
1123 | KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true ); | 1139 | KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true ); |
1124 | if ( !dlg.exec() ) { | 1140 | if ( !dlg.exec() ) { |
1125 | message( i18n("Setting categories cancelled") ); | 1141 | message( i18n("Setting categories cancelled") ); |
@@ -2645,49 +2661,49 @@ void KABCore::requestForBirthdayList(const QString& sourceChannel, const QString | |||
2645 | QString formattedbday; | 2661 | QString formattedbday; |
2646 | 2662 | ||
2647 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) | 2663 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) |
2648 | { | 2664 | { |
2649 | if ( ! bar.isVisible() ) | 2665 | if ( ! bar.isVisible() ) |
2650 | return; | 2666 | return; |
2651 | bar.setProgress( count++ ); | 2667 | bar.setProgress( count++ ); |
2652 | qApp->processEvents(); | 2668 | qApp->processEvents(); |
2653 | bday = (*it).birthday().date(); | 2669 | bday = (*it).birthday().date(); |
2654 | anni = (*it).custom("KADDRESSBOOK", "X-Anniversary" ); | 2670 | anni = (*it).custom("KADDRESSBOOK", "X-Anniversary" ); |
2655 | 2671 | ||
2656 | if ( bday.isValid() || !anni.isEmpty()) | 2672 | if ( bday.isValid() || !anni.isEmpty()) |
2657 | { | 2673 | { |
2658 | if (bday.isValid()) | 2674 | if (bday.isValid()) |
2659 | formattedbday = KGlobal::locale()->formatDate(bday, true, KLocale::ISODate); | 2675 | formattedbday = KGlobal::locale()->formatDate(bday, true, KLocale::ISODate); |
2660 | else | 2676 | else |
2661 | formattedbday = "NOTVALID"; | 2677 | formattedbday = "NOTVALID"; |
2662 | if (anni.isEmpty()) | 2678 | if (anni.isEmpty()) |
2663 | anni = "INVALID"; | 2679 | anni = "INVALID"; |
2664 | 2680 | ||
2665 | birthdayList.append(formattedbday); | 2681 | birthdayList.append(formattedbday); |
2666 | anniversaryList.append(anni); //should be ISODate | 2682 | anniversaryList.append(anni); //should be ISODate |
2667 | realNameList.append((*it).realName()); | 2683 | realNameList.append((*it).realName()); |
2668 | preferredEmailList.append((*it).preferredEmail()); | 2684 | preferredEmailList.append((*it).preferredEmail()); |
2669 | assembledNameList.append((*it).assembledName()); | 2685 | assembledNameList.append((*it).realName()); |
2670 | uidList.append((*it).uid()); | 2686 | uidList.append((*it).uid()); |
2671 | 2687 | ||
2672 | //qDebug("found birthday in KA/Pi: %s,%s,%s,%s: %s, %s", (*it).realName().latin1(), (*it).preferredEmail().latin1(), (*it).assembledName().latin1(), (*it).uid().latin1(), formattedbday.latin1(), anni.latin1() ); | 2688 | //qDebug("found birthday in KA/Pi: %s,%s,%s,%s: %s, %s", (*it).realName().latin1(), (*it).preferredEmail().latin1(), (*it).assembledName().latin1(), (*it).uid().latin1(), formattedbday.latin1(), anni.latin1() ); |
2673 | } | 2689 | } |
2674 | } | 2690 | } |
2675 | 2691 | ||
2676 | bool res = ExternalAppHandler::instance()->returnBirthdayListFromKAPI(sourceChannel, uid, birthdayList, anniversaryList, realNameList, preferredEmailList, assembledNameList, uidList); | 2692 | bool res = ExternalAppHandler::instance()->returnBirthdayListFromKAPI(sourceChannel, uid, birthdayList, anniversaryList, realNameList, preferredEmailList, assembledNameList, uidList); |
2677 | 2693 | ||
2678 | } | 2694 | } |
2679 | 2695 | ||
2680 | /* this method will be called through the QCop interface from other apps to show details of a contact. | 2696 | /* this method will be called through the QCop interface from other apps to show details of a contact. |
2681 | */ | 2697 | */ |
2682 | void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid) | 2698 | void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid) |
2683 | { | 2699 | { |
2684 | //qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1()); | 2700 | //qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1()); |
2685 | 2701 | ||
2686 | QString foundUid = QString::null; | 2702 | QString foundUid = QString::null; |
2687 | if ( ! uid.isEmpty() ) { | 2703 | if ( ! uid.isEmpty() ) { |
2688 | Addressee adrr = mAddressBook->findByUid( uid ); | 2704 | Addressee adrr = mAddressBook->findByUid( uid ); |
2689 | if ( !adrr.isEmpty() ) { | 2705 | if ( !adrr.isEmpty() ) { |
2690 | foundUid = uid; | 2706 | foundUid = uid; |
2691 | } | 2707 | } |
2692 | if ( email == "sendbacklist" ) { | 2708 | if ( email == "sendbacklist" ) { |
2693 | //qDebug("ssssssssssssssssssssssend "); | 2709 | //qDebug("ssssssssssssssssssssssend "); |