Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
openSUSE:Evergreen:11.1:kernel-2.6.32
kdepim4
r890865.diff
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File r890865.diff of Package kdepim4
Subject: kmail: don't force duplicate add to addressbook From: wstephenson@suse.de Bug: kde#174332 Patch-upstream: 890865 --- kmail/kmreadermainwin.cpp (revision 890864) +++ kmail/kmreadermainwin.cpp (revision 890865) @@ -51,6 +51,9 @@ #include "kmreadermainwin.h" +#include <kabc/stdaddressbook.h> +#include <kpimutils/email.h> + KMReaderMainWin::KMReaderMainWin( bool htmlOverride, bool htmlLoadExtOverride, char *name ) : KMail::SecondaryWindow( name ? name : "readerwindow#" ), @@ -380,16 +383,15 @@ void KMReaderMainWin::updateMessageMenu( //----------------------------------------------------------------------------- -void KMReaderMainWin::slotMsgPopup(KMMessage &aMsg, const KUrl &aUrl, const QPoint& aPoint) +void KMReaderMainWin::slotMsgPopup( KMMessage &aMsg, const KUrl &aUrl, const QPoint &aPoint ) { - KMenu * menu = new KMenu; + KMenu *menu = new KMenu; mUrl = aUrl; mMsg = &aMsg; - bool urlMenuAdded=false; + bool urlMenuAdded = false; - if (!aUrl.isEmpty()) - { - if (aUrl.protocol() == "mailto") { + if ( !aUrl.isEmpty() ) { + if ( aUrl.protocol() == "mailto" ) { // popup on a mailto URL menu->addAction( mReaderWin->mailToComposeAction() ); if ( mMsg ) { @@ -397,8 +399,15 @@ void KMReaderMainWin::slotMsgPopup(KMMes menu->addAction( mReaderWin->mailToForwardAction() ); menu->addSeparator(); } - menu->addAction( mReaderWin->addAddrBookAction() ); - menu->addAction( mReaderWin->openAddrBookAction() ); + QString email = KPIMUtils::firstEmailAddress( aUrl.path() ); + KABC::AddressBook *addressBook = KABC::StdAddressBook::self( true ); + KABC::Addressee::List addresseeList = addressBook->findByEmail( email ); + + if ( addresseeList.count() == 0 ) { + menu->addAction( mReaderWin->addAddrBookAction() ); + } else { + menu->addAction( mReaderWin->openAddrBookAction() ); + } menu->addAction( mReaderWin->copyAction() ); } else { // popup on a not-mailto URL @@ -407,22 +416,22 @@ void KMReaderMainWin::slotMsgPopup(KMMes menu->addAction( mReaderWin->urlSaveAsAction() ); menu->addAction( mReaderWin->copyURLAction() ); } - urlMenuAdded=true; + urlMenuAdded = true; } - if(!mReaderWin->copyText().isEmpty()) { - if ( urlMenuAdded ) + if ( !mReaderWin->copyText().isEmpty() ) { + if ( urlMenuAdded ) { menu->addSeparator(); + } menu->addAction( mMsgActions->replyMenu() ); menu->addSeparator(); menu->addAction( mReaderWin->copyAction() ); menu->addAction( mReaderWin->selectAllAction() ); - } else if ( !urlMenuAdded ) - { + } else if ( !urlMenuAdded ) { // popup somewhere else (i.e., not a URL) on the message - if (!mMsg) // no message - { + if (!mMsg) { + // no message delete menu; return; } @@ -452,7 +461,7 @@ void KMReaderMainWin::slotMsgPopup(KMMes menu->addAction( mSaveAtmAction ); menu->addAction( mMsgActions->createTodoAction() ); } - menu->exec(aPoint, 0); + menu->exec( aPoint, 0 ); delete menu; } --- kmail/kmmainwidget.cpp (revision 890864) +++ kmail/kmmainwidget.cpp (revision 890865) @@ -147,6 +147,9 @@ using KMail::TemplateParser; #include "managesievescriptsdialog.h" #include "customtemplatesmenu.h" +#include <kabc/stdaddressbook.h> +#include <kpimutils/email.h> + #include "kmmainwidget.moc" K_GLOBAL_STATIC( KMMainWidget::PtrList, theMainWidgetList ) @@ -2478,24 +2481,30 @@ void KMMainWidget::slotMarkAll() //----------------------------------------------------------------------------- void KMMainWidget::slotMsgPopup(KMMessage&, const KUrl &aUrl, const QPoint& aPoint) { - KMenu * menu = new KMenu; + KMenu *menu = new KMenu; updateMessageMenu(); mUrlCurrent = aUrl; bool urlMenuAdded = false; - if (!aUrl.isEmpty()) - { - if (aUrl.protocol() == "mailto") - { + if ( !aUrl.isEmpty() ) { + if ( aUrl.protocol() == "mailto" ) { // popup on a mailto URL menu->addAction( mMsgView->mailToComposeAction() ); menu->addAction( mMsgView->mailToReplyAction() ); menu->addAction( mMsgView->mailToForwardAction() ); menu->addSeparator(); - menu->addAction( mMsgView->addAddrBookAction() ); - menu->addAction( mMsgView->openAddrBookAction() ); + + QString email = KPIMUtils::firstEmailAddress( aUrl.path() ); + KABC::AddressBook *addressBook = KABC::StdAddressBook::self( true ); + KABC::Addressee::List addresseeList = addressBook->findByEmail( email ); + + if ( addresseeList.count() == 0 ) { + menu->addAction( mMsgView->addAddrBookAction() ); + } else { + menu->addAction( mMsgView->openAddrBookAction() ); + } menu->addAction( mMsgView->copyURLAction() ); } else { // popup on a not-mailto URL @@ -2505,21 +2514,20 @@ void KMMainWidget::slotMsgPopup(KMMessag menu->addAction( mMsgView->copyURLAction() ); } - urlMenuAdded=true; - kDebug( 0 ) <<" URL is:" << aUrl; + urlMenuAdded = true; + kDebug() <<" URL is:" << aUrl; } - - if(mMsgView && !mMsgView->copyText().isEmpty()) { - if ( urlMenuAdded ) + if ( mMsgView && !mMsgView->copyText().isEmpty() ) { + if ( urlMenuAdded ) { menu->addSeparator(); + } menu->addAction( mMsgActions->replyMenu() ); menu->addSeparator(); menu->addAction( mMsgView->copyAction() ); menu->addAction( mMsgView->selectAllAction() ); - } else if ( !urlMenuAdded ) - { + } else if ( !urlMenuAdded ) { // popup somewhere else (i.e., not a URL) on the message if (!mHeaders->currentMsg()) // no messages @@ -2532,8 +2540,9 @@ void KMMainWidget::slotMsgPopup(KMMessag menu->addAction( mUseAction ); } else { - if ( !mFolder->isSent() ) + if ( !mFolder->isSent() ) { menu->addAction( mMsgActions->replyMenu() ); + } menu->addAction( mForwardActionMenu ); } menu->addAction(editAction()); @@ -2548,7 +2557,7 @@ void KMMainWidget::slotMsgPopup(KMMessag menu->addSeparator(); menu->addAction( viewSourceAction() ); - if(mMsgView) { + if ( mMsgView ) { menu->addAction( mMsgView->toggleFixFontAction() ); } menu->addSeparator(); @@ -2557,16 +2566,17 @@ void KMMainWidget::slotMsgPopup(KMMessag menu->addAction( mSaveAttachmentsAction ); menu->addSeparator(); - if( mFolder->isTrash() ) + if ( mFolder->isTrash() ) { menu->addAction( mDeleteAction ); - else + } else { menu->addAction( mTrashAction ); + } menu->addSeparator(); menu->addAction( mMsgActions->createTodoAction() ); } KAcceleratorManager::manage(menu); - menu->exec(aPoint, 0); + menu->exec( aPoint, 0 ); delete menu; } Index: kmail/kmreadermainwin.cpp =================================================================== Index: kmail/kmmainwidget.cpp ===================================================================
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor