From e8c3d343b53bbb3ccfa96c8d49d15f9d486ce843 Mon Sep 17 00:00:00 2001 From: Till Adam Date: Sun, 15 Aug 2004 17:28:37 +0000 Subject: [PATCH] Patch by Matt Douhan Don't overwrite bcc addresses the user already editted when changing to an identity with a bcc address. Also fixes several other corner cases in that area. Thanks, Matt. CCMAIL: 67115-done@bugs.kde.org svn path=/trunk/kdepim/; revision=338138 --- kmcomposewin.cpp | 52 ++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 42 insertions(+), 10 deletions(-) diff --git a/kmcomposewin.cpp b/kmcomposewin.cpp index 90238c497..44ea7960e 100644 --- a/kmcomposewin.cpp +++ b/kmcomposewin.cpp @@ -3346,34 +3346,66 @@ void KMComposeWin::focusNextPrevEdit(const QWidget* aCur, bool aNext) } //----------------------------------------------------------------------------- -void KMComposeWin::slotIdentityChanged(uint uoid) +void KMComposeWin::slotIdentityChanged( uint uoid ) { const KPIM::Identity & ident = kmkernel->identityManager()->identityForUoid( uoid ); - if ( ident.isNull() ) return; + if( ident.isNull() ) return; - if(!ident.fullEmailAddr().isNull()) + if( !ident.fullEmailAddr().isNull() ) mEdtFrom->setText(ident.fullEmailAddr()); // make sure the From field is shown if it's empty if ( from().isEmpty() ) mShowHeaders |= HDR_FROM; mEdtReplyTo->setText(ident.replyToAddr()); // don't overwrite the BCC field when the user has edited it and the - // BCC field of the new identity is empty - if( !mEdtBcc->edited() || !ident.bcc().isEmpty() ) - mEdtBcc->setText(ident.bcc()); + // BCC field of the new identity is not empty + if( !mEdtBcc->edited() && !ident.bcc().isEmpty() ) { + if( mEdtBcc->text().isEmpty() ) { + mEdtBcc->setText( ident.bcc() ); + } else { + // user type into the editbox an address that != to the preset bcc + // of the identity, we assume that since the user typed it + // they want to keep it + if ( mEdtBcc->text() != ident.bcc() ) { + QString temp_string( mEdtBcc->text() + QString::fromLatin1(",") + ident.bcc() ); + mEdtBcc->setText( temp_string ); + } else { + // if the user typed the same address as the preset BCC + // from the identity we will overwrite it to avoid duplicates. + mEdtBcc->setText( ident.bcc() ); + } + } + } + // user edited the bcc box and has a preset bcc in the identity + // we will append whatever the user typed to the preset address + // allowing the user to keep all addresses + if( mEdtBcc->edited() && !ident.bcc().isEmpty() ) { + if( !mEdtBcc->text().isEmpty() ) { + QString temp_string ( mEdtBcc->text() + QString::fromLatin1(",") + ident.bcc() ); + mEdtBcc->setText( temp_string ); + } else { + mEdtBcc->setText( ident.bcc() ); + } + } + // user typed nothing and the identity does not have a preset bcc + // we then reset the value to get rid of any previous + // values if the user changed identity mid way through. + if( !mEdtBcc->edited() && ident.bcc().isEmpty() ) { + mEdtBcc->setText( ident.bcc() ); + } // make sure the BCC field is shown because else it's ignored - if (! ident.bcc().isEmpty()) { + if ( !ident.bcc().isEmpty() ) { mShowHeaders |= HDR_BCC; } - if (ident.organization().isEmpty()) + if ( ident.organization().isEmpty() ) mMsg->removeHeaderField("Organization"); else mMsg->setHeaderField("Organization", ident.organization()); - if (!mBtnTransport->isChecked()) { + if ( !mBtnTransport->isChecked() ) { QString transp = ident.transport(); - if (transp.isEmpty()) + if ( transp.isEmpty() ) { mMsg->removeHeaderField("X-KMail-Transport"); transp = mTransport->text(0);