From 08d9e5880cb6a9f2f2e27d387b0b16bf99f2c813 Mon Sep 17 00:00:00 2001 From: Allen Winter Date: Wed, 17 May 2006 02:26:59 +0000 Subject: [PATCH] forward port SVN commit 541603 by wstephens: Fix Novell bug:159533 Save the address book after adding things to it, and fix bug where the addressee's name was used in place of their email address. svn path=/trunk/KDE/kdepim/; revision=541705 --- distributionlistdialog.cpp | 38 +++++++++++++++++++++++++------------- 1 file changed, 25 insertions(+), 13 deletions(-) diff --git a/distributionlistdialog.cpp b/distributionlistdialog.cpp index e9aecf114..16e4bb998 100644 --- a/distributionlistdialog.cpp +++ b/distributionlistdialog.cpp @@ -7,12 +7,12 @@ modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. - + This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. - + You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, @@ -24,6 +24,7 @@ #include "distributionlistdialog.h" #include +#include #include #include @@ -73,17 +74,17 @@ class DistributionListItem : public Q3CheckListItem { return mAddressee; } - + QString email() const { return mEmail; } - + bool isTransient() const { return mIsTransient; } - + private: KABC::Addressee mAddressee; QString mEmail; @@ -96,20 +97,20 @@ DistributionListDialog::DistributionListDialog( QWidget *parent ) User1, parent, 0, false, false, i18n("Save List") ) { QFrame *topFrame = plainPage(); - + QBoxLayout *topLayout = new QVBoxLayout( topFrame ); topLayout->setSpacing( spacingHint() ); - + QBoxLayout *titleLayout = new QHBoxLayout(); topLayout->addItem( titleLayout ); - + QLabel *label = new QLabel( i18n("Name:"), topFrame ); titleLayout->addWidget( label ); - + mTitleEdit = new QLineEdit( topFrame ); titleLayout->addWidget( mTitleEdit ); mTitleEdit->setFocus(); - + mRecipientsList = new K3ListView( topFrame ); mRecipientsList->addColumn( QString() ); mRecipientsList->addColumn( i18n("Name") ); @@ -134,7 +135,7 @@ void DistributionListDialog::setRecipients( const Recipient::List &recipients ) if ( addressees.isEmpty() ) { KABC::Addressee a; a.setNameFromString( name ); - a.insertEmail( name ); + a.insertEmail( email ); item->setTransientAddressee( a, email ); item->setOn( true ); } else { @@ -153,7 +154,7 @@ void DistributionListDialog::slotUser1() { bool isEmpty = true; - KABC::StdAddressBook *ab = KABC::StdAddressBook::self( true ); + KABC::AddressBook *ab = KABC::StdAddressBook::self( true ); Q3ListViewItem *i = mRecipientsList->firstChild(); while( i ) { @@ -200,7 +201,6 @@ void DistributionListDialog::slotUser1() if ( item->isOn() ) { kDebug() << " " << item->addressee().fullEmail() << endl; if ( item->isTransient() ) { - // FIXME: Adding to the address book doesn't seem to work. ab->insertAddressee( item->addressee() ); } if ( item->email() == item->addressee().preferredEmail() ) { @@ -212,6 +212,18 @@ void DistributionListDialog::slotUser1() i = i->nextSibling(); } + // FIXME: Ask the user which resource to save to instead of the default + bool saveError = true; + KABC::Ticket *ticket = ab->requestSaveTicket( 0 /*default resource */ ); + if ( ticket ) + if ( ab->save( ticket ) ) + saveError = false; + else + ab->releaseSaveTicket( ticket ); + + if ( saveError ) + kWarning(5006) << k_funcinfo << " Couldn't save new addresses in the distribution list just created to the address book" << endl; + manager.save(); close();